예제 #1
0
        public async Task <IActionResult> PutSModule([FromRoute] int id, [FromBody] SModule sModule)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sModule.ModuleCode)
            {
                return(BadRequest());
            }

            _context.Entry(sModule).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SModuleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PostSModule([FromBody] SModule sModule)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SModule.Add(sModule);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSModule", new { id = sModule.ModuleCode }, sModule));
        }
예제 #3
0
        public async Task <SSymbolNameAndDisplacement> LookupSymbolName(ulong pointer)
        {
            try {
                SModule module = await this.debuggerEngine.GetModuleForAddress(pointer);

                Dia2Lib.IDiaSession session = await this.debuggerEngine.DiaLoader.LoadDiaSession(module.Name);

                if (session != null)
                {
                    // We have a DIA session; use it.
                    Dia2Lib.IDiaSymbol symbol;
                    ulong rva = pointer - module.BaseAddress;
                    session.findSymbolByRVA((uint)rva, Dia2Lib.SymTagEnum.SymTagNull, out symbol);

                    // Blocks don't have names.  Walk up to the nearest non-block parent.
                    while ((Dia2Lib.SymTagEnum)symbol.symTag == Dia2Lib.SymTagEnum.SymTagBlock)
                    {
                        symbol = symbol.lexicalParent;
                    }

                    SymTagEnum symTag = (SymTagEnum)symbol.symTag;
                    string     name;
                    if (symTag == SymTagEnum.SymTagPublicSymbol || symTag == SymTagEnum.SymTagThunk)
                    {
                        // Public symbols have decorated names that need to be undecorated (see dbghelp!diaFillSymbolInfo).
                        symbol.get_undecoratedNameEx(0x1000, out name);
                    }
                    else
                    {
                        name = symbol.name;
                    }

                    return(new SSymbolNameAndDisplacement()
                    {
                        Module = module.Name,
                        Name = name,
                        Displacement = (ulong)(rva - symbol.relativeVirtualAddress)
                    });
                }
                else
                {
                    return(await this.debuggerEngine.LookupSymbolName(pointer));
                }
            } catch {
                throw new DebuggerException(String.Format("Invalid symbol address: 0x{0:x8}", pointer));
            }
        }
예제 #4
0
        public async Task <SModule> GetModuleForName(string module)
        {
            string pythonResult = await this.QueryDebuggerPython(String.Format("GetModuleForName(\"{0}\")", module));

            if (pythonResult == "None")
            {
                throw new DebuggerException(String.Format("No module {0}", module));
            }

            Debug.Assert(pythonResult[0] == '{');
            int    fieldEndIndex = pythonResult.IndexOf('}');
            string fieldString   = pythonResult.Substring(1, fieldEndIndex - 1);

            string[] properties = fieldString.Split("#");
            SModule  result     = new SModule();

            result.Name        = properties[0];
            result.BaseAddress = UInt64.Parse(properties[1]);
            return(result);
        }
예제 #5
0
        public static List<SModule> GetModuleList()
        {
            var list = new List<SModule>();
            var module = new SModule();
            module.ModuleId = "1";
            module.ParentId = "0";
            module.ModuleName = "Mock Up Test Data";
            module.LinkUrl = "";
            module.OrderNo = 1;
            module.Icon = "icon-users";
            list.Add(module);

            module = new SModule();
            module.ModuleId = "001";
            module.ParentId = "1";
            module.ModuleName = "Realtime Review List";
            module.LinkUrl = "/RealtimeReview";
            module.OrderNo = 2;
            module.Icon = "icon-users";
            list.Add(module);

            return list;
        }
예제 #6
0
        public async Task <IEnumerable <SNamedSymbol> > GetSymbolsInStackFrame(ulong instructionAddress, ulong stackAddress, ulong frameAddress)
        {
            List <SNamedSymbol> results = new List <SNamedSymbol>();
            SModule             module  = await this.debuggerEngine.GetModuleForAddress(instructionAddress);

            Dia2Lib.IDiaSession session = await this.debuggerEngine.DiaLoader.LoadDiaSession(module.Name);

            if (session == null)
            {
                throw new DebuggerException("Loading stack frame symbols directly from the debugger is not supported.");
            }

            Dia2Lib.IDiaSymbol symbol;
            uint rva = (uint)(instructionAddress - module.BaseAddress);

            try {
                session.findSymbolByRVA(rva, Dia2Lib.SymTagEnum.SymTagNull, out symbol);
            } catch {
                throw new DebuggerException(string.Format("Invalid symbol address: 0x:{0:x8}", instructionAddress));
            }

            if ((SymTagEnum)symbol.symTag == SymTagEnum.SymTagFunction || (SymTagEnum)symbol.symTag == SymTagEnum.SymTagBlock)
            {
                do
                {
                    IDiaEnumSymbols symbols = null;
                    symbol.findChildrenExByRVA(SymTagEnum.SymTagData, null, (uint)DiaHelpers.NameSearchOptions.nsNone, rva, out symbols);

                    foreach (IDiaSymbol localSymbol in symbols)
                    {
                        DiaHelpers.LocationType location = (DiaHelpers.LocationType)localSymbol.locationType;
                        if (location == DiaHelpers.LocationType.LocIsRegRel)
                        {
                            // Check if the offset is from the stack address or frame address.
                            DiaHelpers.CV_HREG_e register = (DiaHelpers.CV_HREG_e)localSymbol.registerId;
                            ulong relativeAddress         = 0;
                            switch (register)
                            {
                            case DiaHelpers.CV_HREG_e.CV_AMD64_RSP:
                            case DiaHelpers.CV_HREG_e.CV_AMD64_ESP: // Also CV_REG_ESP
                                relativeAddress = stackAddress;
                                break;

                            case DiaHelpers.CV_HREG_e.CV_AMD64_RBP:
                            case DiaHelpers.CV_HREG_e.CV_AMD64_EBP: // Also CV_REG_EBP
                            case DiaHelpers.CV_HREG_e.CV_ALLREG_VFRAME:
                                relativeAddress = frameAddress;
                                break;

                            default:
                                // Relative to a register that's not the frame pointer or stack pointer.  We don't have support for this yet.
                                continue;
                            }

                            int pointerAdjustment = 0;
                            if (localSymbol.name == "this")
                            {
                                pointerAdjustment = symbol.type.thisAdjust;
                            }

                            results.Add(new SNamedSymbol()
                            {
                                Symbol = new SSymbolResult()
                                {
                                    Module  = module.Name,
                                    Pointer = (ulong)((long)relativeAddress + localSymbol.offset),
                                    Type    = DiaHelpers.GetTypeName(localSymbol.type, pointerAdjustment)
                                },
                                Name = localSymbol.name
                            });
                        }
                    }

                    // If the symbol wasn't a function (e.g. it was a block) keep going until we reach containing function.
                } while ((SymTagEnum)symbol.symTag != SymTagEnum.SymTagFunction && ((symbol = symbol.lexicalParent) != null));
            }

            return(results);
        }