1
0
Fork 0

Merge branch 'flowgraph' of https://bitbucket.org/mrexodia/x64_dbg into flowgraph

Conflicts:
	x64_dbg_dbg/Analysis/AnalysisRunner.cpp
	x64_dbg_dbg/Analysis/ClientApiResolver.cpp
	x64_dbg_dbg/Analysis/ClientFunctionFinder.cpp
	x64_dbg_dbg/Analysis/FlowGraph.cpp
	x64_dbg_dbg/Analysis/FlowGraph.h
	x64_dbg_dbg/Analysis/Meta.h
	x64_dbg_dbg/Analysis/Node_t.cpp
	x64_dbg_dbg/Analysis/Node_t.h
This commit is contained in:
tr4ceflow 2014-08-27 19:25:00 +02:00
commit 26d53fdb7f
100 changed files with 1022 additions and 841 deletions

View File

@ -52,7 +52,7 @@ del /Q *.exp
del /Q *.a
del /Q *.lib
del /Q *.def
del /Q launcher.exe
del /Q x96_dbg.exe
cd..
echo cleaning bin\x32...
cd bin\x32

View File

@ -46,7 +46,7 @@ mkdir %RELEASEDIR%\release
mkdir %RELEASEDIR%\release\x32
mkdir %RELEASEDIR%\release\x64
copy bin\launcher.exe %RELEASEDIR%\release\launcher.exe
copy bin\x96_dbg.exe %RELEASEDIR%\release\x96_dbg.exe
copy bin\x32\x32_bridge.dll %RELEASEDIR%\release\x32\x32_bridge.dll
copy bin\x32\x32_dbg.dll %RELEASEDIR%\release\x32\x32_dbg.dll
copy bin\x32\x32_dbg.exe %RELEASEDIR%\release\x32\x32_dbg.exe

View File

@ -112,6 +112,26 @@ static bool _getjitauto(bool* jit_auto)
return dbggetjitauto(jit_auto, notfound, NULL, NULL);
}
static bool _isprocesselevated(void)
{
return IsProcessElevated();
}
static bool _getpagerights(uint* addr, char* rights)
{
return dbggetpagerights(addr, rights);
}
static bool _pagerightstostring(DWORD protect, char* rights)
{
return dbgpagerightstostring(protect, rights);
}
static bool _setpagerights(uint* addr, char* rights)
{
return dbgsetpagerights(addr, rights);
}
static bool _getjit(char* jit, bool jit64)
{
arch dummy;
@ -180,4 +200,8 @@ void dbgfunctionsinit()
_dbgfunctions.GetJitAuto = _getjitauto;
_dbgfunctions.GetDefJit = dbggetdefjit;
_dbgfunctions.GetProcessList = _getprocesslist;
_dbgfunctions.GetPageRights = _getpagerights;
_dbgfunctions.SetPageRights = _setpagerights;
_dbgfunctions.PageRightsToString = _pagerightstostring;
_dbgfunctions.IsProcessElevated = _isprocesselevated;
}

View File

@ -57,6 +57,10 @@ typedef bool (*GETJIT)(char* jit, bool x64);
typedef bool (*GETJITAUTO)(bool*);
typedef bool (*GETDEFJIT)(char*);
typedef bool (*GETPROCESSLIST)(DBGPROCESSINFO** entries, int* count);
typedef bool (*GETPAGERIGHTS)(duint*, char*);
typedef bool (*SETPAGERIGHTS)(duint*, char*);
typedef bool (*PAGERIGHTSTOSTRING)(DWORD, char*);
typedef bool (*ISPROCESSELEVATED)(void);
typedef struct DBGFUNCTIONS_
{
@ -84,6 +88,10 @@ typedef struct DBGFUNCTIONS_
GETJIT GetJit;
GETDEFJIT GetDefJit;
GETPROCESSLIST GetProcessList;
GETPAGERIGHTS GetPageRights;
SETPAGERIGHTS SetPageRights;
PAGERIGHTSTOSTRING PageRightsToString;
ISPROCESSELEVATED IsProcessElevated;
} DBGFUNCTIONS;
#ifdef BUILD_DBG

View File

@ -99,6 +99,7 @@ bool modload(uint base, uint size, const char* fullpath)
while(name[len] != '.' and len)
len--;
MODINFO info;
memset(&info, 0, sizeof(MODINFO));
info.sections.clear();
info.hash = modhashfromname(name);
if(len)
@ -117,6 +118,7 @@ bool modload(uint base, uint size, const char* fullpath)
ULONG_PTR FileMapVA;
if(StaticFileLoad((char*)fullpath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
{
info.entry = GetPE32DataFromMappedFile(FileMapVA, 0, UE_OEP) + info.base; //get entry point
int SectionCount = (int)GetPE32DataFromMappedFile(FileMapVA, 0, UE_SECTIONNUMBER);
if(SectionCount > 0)
{
@ -268,6 +270,14 @@ bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections)
return true;
}
uint modentryfromaddr(uint addr)
{
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
if(found == modinfo.end()) //not found
return 0;
return found->second.entry;
}
///api functions
bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum)
{
@ -1019,6 +1029,7 @@ bool loopadd(uint start, uint end, bool manual)
return true;
}
//get the start/end of a loop at a certain depth and addr
bool loopget(int depth, uint addr, uint* start, uint* end)
{
if(!DbgIsDebugging())
@ -1070,6 +1081,7 @@ bool loopoverlaps(int depth, uint start, uint end, int* finaldepth)
return false;
}
//this should delete a loop and all sub-loops that matches a certain addr
bool loopdel(int depth, uint addr)
{
return false;

View File

@ -65,6 +65,7 @@ struct MODINFO
uint base; //module base
uint size; //module size
uint hash; //full module name hash
uint entry; //entry point
char name[MAX_MODULE_SIZE]; //module name (without extension)
char extension[MAX_MODULE_SIZE]; //file extension
std::vector<MODSECTIONINFO> sections;
@ -134,6 +135,7 @@ uint modhashfromname(const char* mod);
uint modbasefromname(const char* modname);
uint modsizefromaddr(uint addr);
bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections);
uint modentryfromaddr(uint addr);
bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum);

View File

@ -1480,6 +1480,22 @@ void cbDetach()
return;
}
bool IsProcessElevated()
{
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID SecurityIdentifier;
if(!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &SecurityIdentifier))
return 0;
BOOL IsAdminMember;
if(!CheckTokenMembership(NULL, SecurityIdentifier, &IsAdminMember))
IsAdminMember = FALSE;
FreeSid(SecurityIdentifier);
return IsAdminMember ? true : false;
}
bool _readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char* key, arch arch_in, arch* arch_out, readwritejitkey_error_t* error, bool write)
{
DWORD key_flags;
@ -1491,7 +1507,15 @@ bool _readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char* key,
* error = ERROR_RW;
if(write)
{
if(!IsProcessElevated())
{
if(error != NULL)
* error = ERROR_RW_NOTADMIN;
return false;
}
key_flags = KEY_WRITE;
}
else
key_flags = KEY_READ;
@ -1512,7 +1536,7 @@ bool _readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char* key,
if(arch_in == x64)
{
#ifdef _WIN32
#ifndef _WIN64
if(!IsWow64())
{
if(error != NULL)
@ -1562,6 +1586,118 @@ bool _readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char* key,
return true;
}
bool dbgpagerightstostring(DWORD protect, char* rights)
{
memset(rights, 0, RIGHTS_STRING);
switch(protect & 0xFF)
{
case PAGE_EXECUTE:
strcpy(rights, "E---");
break;
case PAGE_EXECUTE_READ:
strcpy(rights, "ER--");
break;
case PAGE_EXECUTE_READWRITE:
strcpy(rights, "ERW-");
break;
case PAGE_EXECUTE_WRITECOPY:
strcpy(rights, "ERWC");
break;
case PAGE_NOACCESS:
strcpy(rights, "----");
break;
case PAGE_READONLY:
strcpy(rights, "-R--");
break;
case PAGE_READWRITE:
strcpy(rights, "-RW-");
break;
case PAGE_WRITECOPY:
strcpy(rights, "-RWC");
break;
}
if(protect & PAGE_GUARD)
strcat(rights, "G");
else
strcat(rights, "-");
return true;
}
void dbggetpageligned(uint* addr)
{
#ifdef _WIN64
* addr &= 0xFFFFFFFFFFFFF000;
#else // _WIN32
* addr &= 0xFFFFF000;
#endif // _WIN64
}
bool dbgpagerightsfromstring(DWORD* protect, char* rights_string)
{
if(strlen(rights_string) < 2)
return false;
* protect = 0;
if(rights_string[0] == 'G' || rights_string[0] == 'g')
{
* protect |= PAGE_GUARD;
rights_string++;
}
if(_strcmpi(rights_string, "Execute") == 0)
* protect |= PAGE_EXECUTE;
else if(_strcmpi(rights_string, "ExecuteRead") == 0)
* protect |= PAGE_EXECUTE_READ;
else if(_strcmpi(rights_string, "ExecuteReadWrite") == 0)
* protect |= PAGE_EXECUTE_READWRITE;
else if(_strcmpi(rights_string, "ExecuteWriteCopy") == 0)
* protect |= PAGE_EXECUTE_WRITECOPY;
else if(_strcmpi(rights_string, "NoAccess") == 0)
* protect |= PAGE_NOACCESS;
else if(_strcmpi(rights_string, "ReadOnly") == 0)
* protect |= PAGE_READONLY;
else if(_strcmpi(rights_string, "ReadWrite") == 0)
* protect |= PAGE_READWRITE;
else if(_strcmpi(rights_string, "WriteCopy") == 0)
* protect |= PAGE_WRITECOPY;
if(* protect == 0)
return false;
return true;
}
bool dbgsetpagerights(uint* addr, char* rights_string)
{
DWORD protect;
DWORD old_protect;
dbggetpageligned(addr);
if(!dbgpagerightsfromstring(& protect, rights_string))
return false;
if(VirtualProtectEx(fdProcessInfo->hProcess, (void*)*addr, PAGE_SIZE, protect, & old_protect) == 0)
return false;
return true;
}
bool dbggetpagerights(uint* addr, char* rights)
{
dbggetpageligned(addr);
MEMORY_BASIC_INFORMATION mbi;
if(VirtualQueryEx(fdProcessInfo->hProcess, (const void*)*addr, &mbi, sizeof(mbi)) == 0)
return false;
return dbgpagerightstostring(mbi.Protect, rights);
}
bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
{
char jit_entry[4];

View File

@ -10,12 +10,14 @@
#define JIT_ENTRY_DEF_SIZE (MAX_PATH + sizeof(ATTACH_CMD_LINE) + 2)
#define JIT_ENTRY_MAX_SIZE 512
#define JIT_REG_KEY TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug")
#define RIGHTS_STRING (sizeof("ERWCG") + 1)
typedef enum
{
ERROR_RW = 0,
ERROR_RW_FILE_NOT_FOUND,
ERROR_RW_NOTWOW64
ERROR_RW_NOTWOW64,
ERROR_RW_NOTADMIN
} readwritejitkey_error_t;
//structures
@ -62,12 +64,18 @@ bool dbgisignoredexception(unsigned int exception);
bool dbgcmdnew(const char* name, CBCOMMAND cbCommand, bool debugonly);
bool dbgcmddel(const char* name);
bool dbggetjit(char jit_entry[JIT_ENTRY_MAX_SIZE], arch arch_in, arch* arch_out, readwritejitkey_error_t*);
bool dbggetpagerights(uint*, char*);
bool dbgpagerightstostring(DWORD, char*);
void dbggetpageligned(uint*);
bool dbgpagerightsfromstring(DWORD*, char*);
bool dbgsetpagerights(uint*, char*);
bool dbgsetjit(char* jit_cmd, arch arch_in, arch* arch_out, readwritejitkey_error_t*);
bool dbggetdefjit(char* jit_entry);
bool _readwritejitkey(char*, DWORD*, char*, arch, arch*, readwritejitkey_error_t*, bool);
bool dbggetjitauto(bool*, arch, arch*, readwritejitkey_error_t*);
bool dbgsetjitauto(bool, arch, arch*, readwritejitkey_error_t*);
bool dbglistprocesses(std::vector<PROCESSENTRY32>* list);
bool IsProcessElevated();
void cbStep();
void cbRtrStep();

View File

@ -1001,6 +1001,9 @@ CMDRESULT cbDebugAnalyse(int argc, char* argv[])
{
dputs("init analysis");
uint cipAddr = GetContextData(UE_CIP);
uint oep = modentryfromaddr(cipAddr);
if(!oep)
oep = cipAddr;
uint size;
uint base = memfindbaseaddr(cipAddr, &size);
@ -1010,7 +1013,7 @@ CMDRESULT cbDebugAnalyse(int argc, char* argv[])
return STATUS_ERROR;
}
dprintf("start analysis, assuming oep="fhex", baseaddr="fhex", size="fhex"!\n", cipAddr, base, size);
dprintf("start analysis, assuming oep="fhex", baseaddr="fhex", size="fhex"!\n", oep, base, size);
// tr4ce::ApiDB* db = new tr4ce::ApiDB();
@ -1465,6 +1468,11 @@ CMDRESULT cbDebugSetJITAuto(int argc, char* argv[])
{
arch actual_arch;
bool set_jit_auto;
if(!IsProcessElevated())
{
dprintf("Error run the debugger as Admin to setjitauto\n");
return STATUS_ERROR;
}
if(argc < 2)
{
dprintf("Error setting JIT Auto. Use ON:1 or OFF:0 arg or x64/x32, ON:1 or OFF:0.\n");
@ -1540,6 +1548,11 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
arch actual_arch;
char* jit_debugger_cmd;
char oldjit[MAX_SETTING_SIZE] = "";
if(!IsProcessElevated())
{
dprintf("Error run the debugger as Admin to setjit\n");
return STATUS_ERROR;
}
if(argc < 2)
{
char path[JIT_ENTRY_DEF_SIZE];
@ -1647,7 +1660,7 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
if(rw_error == ERROR_RW_NOTWOW64)
dprintf("Error using x64 arg. The debugger is not a WOW64 process\n");
else
dprintf("Error getting JIT %s\n", (actual_arch == x64) ? "x64" : "x32");
dprintf("Error setting JIT %s\n", (actual_arch == x64) ? "x64" : "x32");
return STATUS_ERROR;
}
}
@ -1714,5 +1727,55 @@ CMDRESULT cbDebugGetJIT(int argc, char* argv[])
dprintf("JIT %s: %s\n", (actual_arch == x64) ? "x64" : "x32", get_entry);
return STATUS_CONTINUE;
}
CMDRESULT cbDebugGetPageRights(int argc, char* argv[])
{
uint addr = 0;
char rights[RIGHTS_STRING];
if(argc != 2 || !valfromstring(argv[1], &addr))
{
dprintf("Error: using an address as arg1\n");
return STATUS_ERROR;
}
if(!dbggetpagerights(&addr, rights))
{
dprintf("Error getting rights of page: %s\n", argv[1]);
return STATUS_ERROR;
}
dprintf("Page: "fhex", Rights: %s\n", addr, rights);
return STATUS_CONTINUE;
}
CMDRESULT cbDebugSetPageRights(int argc, char* argv[])
{
uint addr = 0;
char rights[RIGHTS_STRING];
if(argc != 3 || !valfromstring(argv[1], &addr))
{
dprintf("Error: using an address as arg1 and as arg2: Execute, ExecuteRead, ExecuteReadWrite, ExecuteWriteCopy, NoAccess, ReadOnly, ReadWrite, WriteCopy. You can add a G at first for add PAGE GUARD, example: GReadOnly\n");
return STATUS_ERROR;
}
if(!dbgsetpagerights(&addr, argv[2]))
{
dprintf("Error: Set rights of "fhex" with Rights: %s\n", addr, argv[2]);
return STATUS_ERROR;
}
if(!dbggetpagerights(&addr, rights))
{
dprintf("Error getting rights of page: %s\n", argv[1]);
return STATUS_ERROR;
}
dprintf("New rights of "fhex": %s\n", addr, rights);
return STATUS_CONTINUE;
}

View File

@ -56,5 +56,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]);
CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]);
CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]);
CMDRESULT cbDebugAnalyse(int argc, char* argv[]);
CMDRESULT cbDebugGetPageRights(int argc, char* argv[]);
CMDRESULT cbDebugSetPageRights(int argc, char* argv[]);
#endif //_DEBUGGER_COMMANDS_H

View File

@ -352,11 +352,8 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
return STATUS_CONTINUE;
}
CMDRESULT res = cmddirectexec(dbggetcommandlist(), command);
if(DbgIsDebugging())
{
while(!waitislocked(WAITID_RUN)) //while not locked (NOTE: possible deadlock)
Sleep(10);
}
while(DbgIsDebugging() && !waitislocked(WAITID_RUN)) //while not locked (NOTE: possible deadlock)
Sleep(10);
return res;
}

View File

@ -162,6 +162,8 @@ static void registercommands()
dbgcmdnew("alloc", cbDebugAlloc, true); //allocate memory
dbgcmdnew("free", cbDebugFree, true); //free memory
dbgcmdnew("Fill\1memset", cbDebugMemset, true); //memset
dbgcmdnew("getpagerights\1getrightspage", cbDebugGetPageRights, true);
dbgcmdnew("setpagerights\1setrightspage", cbDebugSetPageRights, true);
//plugins
dbgcmdnew("StartScylla\1scylla\1imprec", cbDebugStartScylla, false); //start scylla

View File

@ -34,11 +34,11 @@
<Filter Include="Header Files\lz4">
<UniqueIdentifier>{6a8d58f0-1417-4bff-aecd-0f9f5e0641f9}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Analysis">
<UniqueIdentifier>{68e04c31-9f66-4c9a-ae1d-54b2f6cf2d1c}</UniqueIdentifier>
<Filter Include="Header Files\Analysis">
<UniqueIdentifier>{4e0317ac-ab94-4f10-9c11-e685d7a9842b}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\fa">
<UniqueIdentifier>{70e48ca5-7813-4da6-95c8-3717ace25093}</UniqueIdentifier>
<Filter Include="Source Files\Analysis">
<UniqueIdentifier>{336c8da2-0baf-4af3-a0d6-71cc5bce296e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
@ -135,35 +135,35 @@
<ClCompile Include="debugger_commands.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Analysis\Node_t.cpp">
<Filter>Header Files\fa</Filter>
</ClCompile>
<ClCompile Include="Analysis\Edge_t.cpp">
<Filter>Header Files\fa</Filter>
<ClCompile Include="Analysis\StackEmulator.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\AnalysisRunner.cpp">
<Filter>Header Files\fa</Filter>
</ClCompile>
<ClCompile Include="Analysis\StackEmulator.cpp">
<Filter>Header Files\fa</Filter>
</ClCompile>
<ClCompile Include="Analysis\FlowGraph.cpp">
<Filter>Header Files\fa</Filter>
</ClCompile>
<ClCompile Include="Analysis\RegisterEmulator.cpp">
<Filter>Header Files\fa</Filter>
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\ClientApiResolver.cpp">
<Filter>Header Files\fa</Filter>
</ClCompile>
<ClCompile Include="Analysis\ClientInterface.cpp">
<Filter>Header Files\fa</Filter>
</ClCompile>
<ClCompile Include="Analysis\FunctionInfo.cpp">
<Filter>Header Files\fa</Filter>
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\ClientFunctionFinder.cpp">
<Filter>Header Files\fa</Filter>
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\ClientInterface.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\Edge_t.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\FlowGraph.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\FunctionInfo.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\Node_t.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
<ClCompile Include="Analysis\RegisterEmulator.cpp">
<Filter>Source Files\Analysis</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -312,37 +312,37 @@
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Analysis\AnalysisRunner.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\StackEmulator.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\RegisterEmulator.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\FlowGraph.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\Meta.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\Node_t.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\Edge_t.h">
<Filter>Header Files\fa</Filter>
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\ClientApiResolver.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\ClientInterface.h">
<Filter>Header Files\fa</Filter>
</ClInclude>
<ClInclude Include="Analysis\FunctionInfo.h">
<Filter>Header Files\fa</Filter>
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\ClientFunctionFinder.h">
<Filter>Header Files\fa</Filter>
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\ClientInterface.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\Edge_t.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\FlowGraph.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\FunctionInfo.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\Meta.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\Node_t.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\RegisterEmulator.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
<ClInclude Include="Analysis\StackEmulator.h">
<Filter>Header Files\Analysis</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,4 +1,5 @@
#include "AbstractTableView.h"
#include <QStyleOptionButton>
#include "Configuration.h"
AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(parent)

View File

@ -1,14 +1,13 @@
#ifndef ABSTRACTTABLEVIEW_H
#define ABSTRACTTABLEVIEW_H
#include <QtGui>
#include <QScrollBar>
#include <QAbstractScrollArea>
#include <QPushButton>
#include <QStyleOptionButton>
#include <QStyle>
#include <QScrollBar>
#include <qdebug.h>
#include <NewTypes.h>
#include <QApplication>
#include <QMouseEvent>
#include <QPainter>
#include "NewTypes.h"
//Hacky class that fixes a really annoying cursor problem
class AbstractTableScrollBar : public QScrollBar

View File

@ -1,5 +1,6 @@
#include "Disassembly.h"
#include "Configuration.h"
#include "Bridge.h"
Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent)
{

View File

@ -1,14 +1,8 @@
#ifndef DISASSEMBLY_H
#define DISASSEMBLY_H
#include <QtGui>
#include <QtDebug>
#include "NewTypes.h"
#include "Bridge.h"
#include "AbstractTableView.h"
#include "QBeaEngine.h"
#include "RichTextPainter.h"
#include "BeaTokenizer.h"
#include "MemoryPage.h"
class Disassembly : public AbstractTableView

View File

@ -1,5 +1,7 @@
#include "HexDump.h"
#include <sstream>
#include "Configuration.h"
#include "Bridge.h"
HexDump::HexDump(QWidget* parent) : AbstractTableView(parent)
{

View File

@ -1,15 +1,9 @@
#ifndef _HEXDUMP_H
#define _HEXDUMP_H
#include <QtGui>
#include <QtDebug>
#include "NewTypes.h"
#include "AbstractTableView.h"
#include "MemoryPage.h"
#include "QBeaEngine.h"
#include "Bridge.h"
#include <sstream>
#include "RichTextPainter.h"
#include "MemoryPage.h"
class HexDump : public AbstractTableView
{

View File

@ -1,5 +1,4 @@
#include "HistoryLineEdit.h"
#include "Bridge.h"
HistoryLineEdit::HistoryLineEdit(QWidget* parent) : QLineEdit(parent)
{

View File

@ -1,8 +1,8 @@
#ifndef HISTORYLINEEDIT_H
#define HISTORYLINEEDIT_H
#include <QtGui>
#include <QLineEdit>
#include <QKeyEvent>
class HistoryLineEdit : public QLineEdit
{

View File

@ -1,5 +1,7 @@
#include "ReferenceView.h"
#include <QMessageBox>
#include "Configuration.h"
#include "Bridge.h"
ReferenceView::ReferenceView()
{

View File

@ -2,10 +2,7 @@
#define REFERENCEVIEW_H
#include <QProgressBar>
#include <QAction>
#include <QMenu>
#include "SearchListView.h"
#include "Bridge.h"
class ReferenceView : public SearchListView
{

View File

@ -2,6 +2,7 @@
#define SEARCHLISTVIEW_H
#include <QWidget>
#include <QMenu>
#include <QVBoxLayout>
#include <QLineEdit>
#include "SearchListViewTable.h"

View File

@ -1,5 +1,6 @@
#include "SearchListViewTable.h"
#include "Configuration.h"
#include "RichTextPainter.h"
SearchListViewTable::SearchListViewTable(StdTable* parent) : StdTable(parent)
{

View File

@ -1,5 +1,4 @@
#include "ShortcutEdit.h"
#include <QKeyEvent>
ShortcutEdit::ShortcutEdit(QWidget* parent) : QLineEdit(parent)
{
@ -57,7 +56,7 @@ void ShortcutEdit::keyPressEvent(QKeyEvent* event)
QString KeyText = QKeySequence(keyInt).toString(QKeySequence::NativeText) ;
for(int i = 0; i < KeyText.length(); i++)
{
if(KeyText[i].toAscii() == 0)
if(KeyText[i].toLatin1() == 0)
{
setText("");
keyInt = -1;

View File

@ -2,6 +2,8 @@
#define SHORTCUTEDIT_H
#include <QLineEdit>
#include <QKeySequence>
#include <QKeyEvent>
class ShortcutEdit : public QLineEdit
{

View File

@ -1,9 +1,6 @@
#ifndef STDTABLE_H
#define STDTABLE_H
#include <QtGui>
#include <QMenu>
#include "NewTypes.h"
#include "AbstractTableView.h"
class StdTable : public AbstractTableView

View File

@ -1,4 +1,8 @@
#include "Bridge.h"
#include <QClipboard>
#include "QBeaEngine.h"
#include "main.h"
#include "Exports.h"
/************************************************************************************
Global Variables

View File

@ -2,16 +2,10 @@
#define BRIDGE_H
#include <QObject>
#include <QtGui>
#include "NewTypes.h"
#include "ReferenceView.h"
#include "BeaTokenizer.h"
#include "QBeaEngine.h"
#include "main.h"
#include "Exports.h"
#include <QMutex>
#include "Imports.h"
#include "NewTypes.h"
#include "SearchListView.h"
class Bridge : public QObject
{

View File

@ -1,14 +1,11 @@
#ifndef BEATOKENIZER_H
#define BEATOKENIZER_H
#include <QList>
#include <QRect>
#include <QString>
#include <QStringList>
#include <QMap>
#include <QSet>
#include "RichTextPainter.h"
#include "BeaEngine.h"
#include "NewTypes.h"
#include "RichTextPainter.h"
class BeaTokenizer : RichTextPainter
{

View File

@ -1,6 +1,5 @@
#include "QBeaEngine.h"
QBeaEngine::QBeaEngine()
{
// Reset the Disasm structure
@ -8,7 +7,6 @@ QBeaEngine::QBeaEngine()
BeaTokenizer::Init();
}
/**
* @brief Return the address of the nth instruction before the instruction pointed by ip. @n
* This function has been grabbed from OllyDbg ("Disassembleback" in asmserv.c)
@ -88,7 +86,6 @@ ulong QBeaEngine::DisassembleBack(byte_t* data, uint_t base, uint_t size, uint_t
return abuf[(i - n + max_instructions) % max_instructions];
}
/**
* @brief Return the address of the nth instruction after the instruction pointed by ip. @n
* This function has been grabbed from OllyDbg ("Disassembleforward" in asmserv.c)
@ -144,7 +141,6 @@ ulong QBeaEngine::DisassembleNext(byte_t* data, uint_t base, uint_t size, uint_t
return ip;
}
/**
* @brief Disassemble the instruction at the given ip RVA.
*
@ -190,6 +186,3 @@ Instruction_t QBeaEngine::DisassembleAt(byte_t* data, uint_t size, uint_t instIn
return wInst;
}

View File

@ -1,9 +1,7 @@
#ifndef QBEAENGINE_H
#define QBEAENGINE_H
#include <QtGui>
#include "BeaEngine.h"
#include <QString>
#include "NewTypes.h"
#include "BeaTokenizer.h"
@ -19,21 +17,14 @@ typedef struct _Instruction_t
class QBeaEngine
{
public:
explicit QBeaEngine();
ulong DisassembleBack(byte_t* data, uint_t base, uint_t size, uint_t ip, int n);
ulong DisassembleNext(byte_t* data, uint_t base, uint_t size, uint_t ip, int n);
Instruction_t DisassembleAt(byte_t* data, uint_t size, uint_t instIndex, uint_t origBase, uint_t origInstRVA);
signals:
public slots:
private:
DISASM mDisasmStruct;
};
#endif // QBEAENGINE_H

View File

@ -1,8 +1,9 @@
#include "AppearanceDialog.h"
#include "ui_AppearanceDialog.h"
#include "Bridge.h"
#include "Configuration.h"
#include <QColorDialog>
#include <QFontDialog>
#include <QMessageBox>
#include "Configuration.h"
AppearanceDialog::AppearanceDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AppearanceDialog)
{

View File

@ -2,8 +2,6 @@
#define APPEARANCEDIALOG_H
#include <QDialog>
#include <QColorDialog>
#include <QMessageBox>
#include <QMap>
namespace Ui

View File

@ -1,5 +1,6 @@
#include "AttachDialog.h"
#include "ui_AttachDialog.h"
#include <QMenu>
AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AttachDialog)
{

View File

@ -1,5 +1,7 @@
#include "BreakpointsView.h"
#include "Configuration.h"
#include "Bridge.h"
#include "Breakpoints.h"
BreakpointsView::BreakpointsView(QWidget* parent) : QWidget(parent)
{

View File

@ -1,13 +1,10 @@
#ifndef BREAKPOINTSVIEW_H
#define BREAKPOINTSVIEW_H
#include <QtGui>
#include "StdTable.h"
#include "Bridge.h"
#include "Breakpoints.h"
#include <QSplitter>
#include <QMenu>
#include <QWidget>
#include <QVBoxLayout>
#include <QSplitter>
#include "StdTable.h"
class BreakpointsView : public QWidget
{

View File

@ -1,5 +1,10 @@
#include "CPUDisassembly.h"
#include <QMessageBox>
#include <QClipboard>
#include "Configuration.h"
#include "Bridge.h"
#include "LineEditDialog.h"
#include "WordEditDialog.h"
#include "HexEditDialog.h"
CPUDisassembly::CPUDisassembly(QWidget* parent) : Disassembly(parent)
@ -477,6 +482,7 @@ void CPUDisassembly::setupRightClickContextMenu()
mSearchCommand->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mSearchCommand);
connect(mSearchCommand, SIGNAL(triggered()), this, SLOT(findCommand()));
mSearchMenu->addAction(mSearchCommand);
// Constant
mSearchConstant = new QAction("&Constant", this);

View File

@ -1,18 +1,8 @@
#ifndef CPUDISASSEMBLY_H
#define CPUDISASSEMBLY_H
#include <QtGui>
#include <QtDebug>
#include "NewTypes.h"
#include "Disassembly.h"
#include "Bridge.h"
#include "LineEditDialog.h"
#include "QBeaEngine.h"
#include "GotoDialog.h"
#include <QAction>
#include <QMessageBox>
#include <QMenu>
#include "WordEditDialog.h"
class CPUDisassembly : public Disassembly
{

View File

@ -1,5 +1,9 @@
#include "CPUDump.h"
#include <QMessageBox>
#include <QClipboard>
#include "Configuration.h"
#include "Bridge.h"
#include "LineEditDialog.h"
#include "HexEditDialog.h"
CPUDump::CPUDump(QWidget* parent) : HexDump(parent)

View File

@ -1,15 +1,7 @@
#ifndef CPUDUMP_H
#define CPUDUMP_H
#include <QtGui>
#include <QtDebug>
#include <QAction>
#include <QMenu>
#include <QMessageBox>
#include "NewTypes.h"
#include "LineEditDialog.h"
#include "HexDump.h"
#include "Bridge.h"
#include "GotoDialog.h"
class CPUDump : public HexDump

View File

@ -1,4 +1,6 @@
#include "CPUInfoBox.h"
#include "Configuration.h"
#include "Bridge.h"
CPUInfoBox::CPUInfoBox(StdTable* parent) : StdTable(parent)
{
@ -81,7 +83,7 @@ QString CPUInfoBox::getSymbolicName(int_t addr)
}
return finalText;
}
#include "Configuration.h"
void CPUInfoBox::disasmSelectionChanged(int_t parVA)
{
curAddr = parVA;
@ -90,8 +92,10 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA)
clear();
DISASM_INSTR instr;
memset(&instr, 0, sizeof(instr));
DbgDisasmAt(parVA, &instr);
BASIC_INSTRUCTION_INFO basicinfo;
memset(&basicinfo, 0, sizeof(basicinfo));
DbgDisasmFastAt(parVA, &basicinfo);
int start = 0;

View File

@ -1,10 +1,7 @@
#ifndef INFOBOX_H
#define INFOBOX_H
#include <QtGui>
#include "StdTable.h"
#include "Bridge.h"
#include "CPUDisassembly.h"
class CPUInfoBox : public StdTable
{

View File

@ -1,11 +1,8 @@
#ifndef CPUSIDEBAR_H
#define CPUSIDEBAR_H
#include "NewTypes.h"
#include "Bridge.h"
#include "CPUDisassembly.h"
#include <QAbstractScrollArea>
#include "CPUDisassembly.h"
class CPUSideBar : public QAbstractScrollArea
{
@ -32,7 +29,6 @@ protected:
bool isJump(int i) const;
void drawJump(QPainter* painter, int startLine, int endLine, int jumpoffset, bool conditional, bool isexecute, bool isactive);
private:
int_t topVA;
int_t selectedVA;

View File

@ -1,5 +1,7 @@
#include "CPUStack.h"
#include <QClipboard>
#include "Configuration.h"
#include "Bridge.h"
#include "HexEditDialog.h"
#include "WordEditDialog.h"

View File

@ -1,13 +1,7 @@
#ifndef CPUSTACK_H
#define CPUSTACK_H
#include <QtGui>
#include <QtDebug>
#include <QAction>
#include <QMenu>
#include "NewTypes.h"
#include "HexDump.h"
#include "Bridge.h"
#include "GotoDialog.h"
class CPUStack : public HexDump

View File

@ -1,15 +1,14 @@
#ifndef CPUWIDGET_H
#define CPUWIDGET_H
#include <QtGui>
#include <QVBoxLayout>
#include <QTableWidget>
#include <QWidget>
#include <QTabWidget>
#include "CPUSideBar.h"
#include "CPUDisassembly.h"
#include "CPUDump.h"
#include "CPUStack.h"
#include "RegistersView.h"
#include "CPUInfoBox.h"
#include "CPUSideBar.h"
namespace Ui
{

View File

@ -1,6 +1,5 @@
#include "CalculatorDialog.h"
#include "ui_CalculatorDialog.h"
#include <QString>
CalculatorDialog::CalculatorDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CalculatorDialog)
{
@ -222,7 +221,7 @@ void CalculatorDialog::on_txtAscii_textEdited(const QString & arg1)
return;
}
ui->txtAscii->setStyleSheet("");
ui->txtExpression->setText(QString().sprintf("%X", text[0].toAscii()));
ui->txtExpression->setText(QString().sprintf("%X", text[0].toLatin1()));
ui->txtAscii->setCursorPosition(1);
}

View File

@ -3,7 +3,7 @@
#include <QDialog>
#include <QThread>
#include "Bridge.h"
#include "NewTypes.h"
namespace Ui
{

View File

@ -1,9 +1,7 @@
#include "CloseDialog.h"
#include "ui_CloseDialog.h"
CloseDialog::CloseDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::CloseDialog)
CloseDialog::CloseDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CloseDialog)
{
ui->setupUi(this);
setModal(true);

View File

@ -1,9 +1,7 @@
#include "CommandHelpView.h"
#include "ui_CommandHelpView.h"
CommandHelpView::CommandHelpView(QWidget* parent) :
QWidget(parent),
ui(new Ui::CommandHelpView)
CommandHelpView::CommandHelpView(QWidget* parent) : QWidget(parent), ui(new Ui::CommandHelpView)
{
ui->setupUi(this);

View File

@ -3,10 +3,6 @@
#include <QWidget>
#include <QVBoxLayout>
#include <QList>
#include <QMenu>
#include "StdTable.h"
#include "Bridge.h"
#include "SearchListView.h"
namespace Ui

View File

@ -1,4 +1,6 @@
#include "CommandLineEdit.h"
#include <QStringListModel>
#include "Bridge.h"
CommandLineEdit::CommandLineEdit(QWidget* parent) : HistoryLineEdit(parent)
{

View File

@ -2,7 +2,6 @@
#define COMMANDLINEEDIT_H
#include "HistoryLineEdit.h"
#include "Bridge.h"
#include <QCompleter>
class CommandLineEdit : public HistoryLineEdit

View File

@ -2,9 +2,8 @@
#define GOTODIALOG_H
#include <QDialog>
#include <QPalette>
#include <QThread>
#include "Bridge.h"
#include "NewTypes.h"
namespace Ui
{

View File

@ -1,11 +1,9 @@
#include "HexEditDialog.h"
#include "ui_HexEditDialog.h"
#include "QHexEdit/QHexEdit.h"
#include "Configuration.h"
#include "Bridge.h"
HexEditDialog::HexEditDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::HexEditDialog)
HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexEditDialog)
{
ui->setupUi(this);
@ -68,7 +66,7 @@ void HexEditDialog::on_btnAscii2Hex_clicked()
QString text = ui->lineEditAscii->text();
QByteArray data;
for(int i = 0; i < text.length(); i++)
data.append(text[i].toAscii());
data.append(text[i].toLatin1());
if(ui->chkKeepSize->isChecked()) //keep size
{
int dataSize = mHexEdit->data().size();
@ -107,7 +105,7 @@ void HexEditDialog::dataChangedSlot()
{
QChar ch(data.constData()[i]);
if(ch.isPrint())
ascii += ch.toAscii();
ascii += ch.toLatin1();
else
ascii += '.';
}

View File

@ -1,6 +1,5 @@
#include "LineEditDialog.h"
#include "ui_LineEditDialog.h"
#include "Bridge.h"
LineEditDialog::LineEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::LineEditDialog)
{

View File

@ -1,5 +1,6 @@
#include "LogView.h"
#include "Configuration.h"
#include "Bridge.h"
LogView::LogView(QWidget* parent) : QTextEdit(parent)
{

View File

@ -1,9 +1,7 @@
#ifndef LOGVIEW_H
#define LOGVIEW_H
#include <QtGui>
#include <QTextEdit>
#include "Bridge.h"
class LogView : public QTextEdit
{

View File

@ -1,5 +1,17 @@
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QMessageBox>
#include <QIcon>
#include <QUrl>
#include <QFileDialog>
#include <QMimeData>
#include <QDesktopServices>
#include "Configuration.h"
#include "SettingsDialog.h"
#include "AppearanceDialog.h"
#include "ShortcutsDialog.h"
#include "AttachDialog.h"
#include "LineEditDialog.h"
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{

View File

@ -2,31 +2,23 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtGui>
#include <QFileDialog>
#include <QMdiArea>
#include <QMdiSubWindow>
#include "CPUWidget.h"
#include <QDragEnterEvent>
#include "CloseDialog.h"
#include "CommandLineEdit.h"
#include "TabWidget.h"
#include "CPUWidget.h"
#include "MemoryMapView.h"
#include "CallStackView.h"
#include "LogView.h"
#include "StatusLabel.h"
#include "SymbolView.h"
#include "BreakpointsView.h"
#include "ScriptView.h"
#include "SymbolView.h"
#include "ReferenceView.h"
#include "ThreadView.h"
#include "SettingsDialog.h"
#include "tabwidget.h"
#include "Configuration.h"
#include "AppearanceDialog.h"
#include "ShortcutsDialog.h"
#include "CloseDialog.h"
#include "PatchDialog.h"
#include "UpdateChecker.h"
#include "CallStackView.h"
#include "CalculatorDialog.h"
#include "AttachDialog.h"
#include "StatusLabel.h"
#include "UpdateChecker.h"
namespace Ui
{
@ -101,7 +93,6 @@ public slots:
private:
Ui::MainWindow* ui;
CloseDialog* mCloseDialog;
CommandLineEdit* mCmdLineEdit;
MHTabWidget* mTabWidget;
CPUWidget* mCpuWidget;

View File

@ -1,5 +1,7 @@
#include "MemoryMapView.h"
#include "Configuration.h"
#include "Bridge.h"
#include "PageMemoryRights.h"
MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent)
{
@ -34,6 +36,10 @@ void MemoryMapView::setupContextMenu()
connect(mFollowDisassembly, SIGNAL(triggered()), this, SLOT(followDisassemblerSlot()));
connect(this, SIGNAL(enterPressedSignal()), this, SLOT(followDisassemblerSlot()));
//Set PageMemory Rights
mPageMemoryRights = new QAction("Set Page Memory Rights", this);
connect(mPageMemoryRights, SIGNAL(triggered()), this, SLOT(pageMemoryRights()));
//Switch View
mSwitchView = new QAction("&Switch View", this);
connect(mSwitchView, SIGNAL(triggered()), this, SLOT(switchView()));
@ -104,6 +110,8 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
wMenu->addAction(mFollowDump);
wMenu->addAction(mSwitchView);
wMenu->addSeparator();
wMenu->addAction(mPageMemoryRights);
wMenu->addSeparator();
wMenu->addMenu(mBreakpointMenu);
QMenu wCopyMenu("&Copy", this);
setupCopyMenu(&wCopyMenu);
@ -139,39 +147,13 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
QString MemoryMapView::getProtectionString(DWORD Protect)
{
QString wS;
switch(Protect & 0xFF)
{
case PAGE_EXECUTE:
wS = QString("E---");
break;
case PAGE_EXECUTE_READ:
wS = QString("ER--");
break;
case PAGE_EXECUTE_READWRITE:
wS = QString("ERW-");
break;
case PAGE_EXECUTE_WRITECOPY:
wS = QString("ERWC");
break;
case PAGE_NOACCESS:
wS = QString("----");
break;
case PAGE_READONLY:
wS = QString("-R--");
break;
case PAGE_READWRITE:
wS = QString("-RW-");
break;
case PAGE_WRITECOPY:
wS = QString("-RWC");
break;
}
if(Protect & PAGE_GUARD)
wS += QString("G");
else
wS += QString("-");
return wS;
#define RIGHTS_STRING (sizeof("ERWCG") + 1)
char rights[RIGHTS_STRING];
if(!DbgFunctions()->PageRightsToString(Protect, rights))
return "bad";
return QString(rights);
}
QString MemoryMapView::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h)
@ -221,84 +203,87 @@ QString MemoryMapView::paintContent(QPainter* painter, int_t rowBase, int rowOff
return StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
}
void MemoryMapView::refreshMap()
{
MEMMAP wMemMapStruct;
int wI;
memset(&wMemMapStruct, 0, sizeof(MEMMAP));
DbgMemMap(&wMemMapStruct);
setRowCount(wMemMapStruct.count);
for(wI = 0; wI < wMemMapStruct.count; wI++)
{
QString wS;
MEMORY_BASIC_INFORMATION wMbi = (wMemMapStruct.page)[wI].mbi;
// Base address
wS = QString("%1").arg((uint_t)wMbi.BaseAddress, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(wI, 0, wS);
// Size
wS = QString("%1").arg((uint_t)wMbi.RegionSize, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(wI, 1, wS);
// Information
wS = QString((wMemMapStruct.page)[wI].info);
setCellContent(wI, 2, wS);
// State
switch(wMbi.State)
{
case MEM_FREE:
wS = QString("FREE");
break;
case MEM_COMMIT:
wS = QString("COMM");
break;
case MEM_RESERVE:
wS = QString("RESV");
break;
default:
wS = QString("????");
}
setCellContent(wI, 3, wS);
// Type
switch(wMbi.Type)
{
case MEM_IMAGE:
wS = QString("IMG");
break;
case MEM_MAPPED:
wS = QString("MAP");
break;
case MEM_PRIVATE:
wS = QString("PRV");
break;
default:
wS = QString("N/A");
break;
}
setCellContent(wI, 3, wS);
// current access protection
wS = getProtectionString(wMbi.Protect);
setCellContent(wI, 4, wS);
// allocation protection
wS = getProtectionString(wMbi.AllocationProtect);
setCellContent(wI, 5, wS);
}
if(wMemMapStruct.page != 0)
BridgeFree(wMemMapStruct.page);
reloadData(); //refresh memory map
}
void MemoryMapView::stateChangedSlot(DBGSTATE state)
{
if(state == paused)
{
MEMMAP wMemMapStruct;
int wI;
memset(&wMemMapStruct, 0, sizeof(MEMMAP));
DbgMemMap(&wMemMapStruct);
setRowCount(wMemMapStruct.count);
for(wI = 0; wI < wMemMapStruct.count; wI++)
{
QString wS;
MEMORY_BASIC_INFORMATION wMbi = (wMemMapStruct.page)[wI].mbi;
// Base address
wS = QString("%1").arg((uint_t)wMbi.BaseAddress, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(wI, 0, wS);
// Size
wS = QString("%1").arg((uint_t)wMbi.RegionSize, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(wI, 1, wS);
// Information
wS = QString((wMemMapStruct.page)[wI].info);
setCellContent(wI, 2, wS);
// State
switch(wMbi.State)
{
case MEM_FREE:
wS = QString("FREE");
break;
case MEM_COMMIT:
wS = QString("COMM");
break;
case MEM_RESERVE:
wS = QString("RESV");
break;
default:
wS = QString("????");
}
setCellContent(wI, 3, wS);
// Type
switch(wMbi.Type)
{
case MEM_IMAGE:
wS = QString("IMG");
break;
case MEM_MAPPED:
wS = QString("MAP");
break;
case MEM_PRIVATE:
wS = QString("PRV");
break;
default:
wS = QString("N/A");
break;
}
setCellContent(wI, 3, wS);
// current access protection
wS = getProtectionString(wMbi.Protect);
setCellContent(wI, 4, wS);
// allocation protection
wS = getProtectionString(wMbi.AllocationProtect);
setCellContent(wI, 5, wS);
}
if(wMemMapStruct.page != 0)
BridgeFree(wMemMapStruct.page);
reloadData(); //refresh memory map
}
refreshMap();
}
void MemoryMapView::followDumpSlot()
@ -371,6 +356,15 @@ void MemoryMapView::memoryExecuteSingleshootToggleSlot()
memoryExecuteSingleshootSlot();
}
void MemoryMapView::pageMemoryRights()
{
PageMemoryRights PageMemoryRightsDialog(this);
connect(&PageMemoryRightsDialog, SIGNAL(refreshMemoryMap()), this, SLOT(refreshMap()));
uint_t addr = getCellContent(getInitialSelection(), 0).toULongLong(0, 16);
uint_t size = getCellContent(getInitialSelection(), 1).toULongLong(0, 16);
PageMemoryRightsDialog.RunAddrSize(addr, size, getCellContent(getInitialSelection(), 3));
}
void MemoryMapView::switchView()
{
duint setting = 0;

View File

@ -1,9 +1,7 @@
#ifndef MEMORYMAPVIEW_H
#define MEMORYMAPVIEW_H
#include <QtGui>
#include "StdTable.h"
#include "Bridge.h"
class MemoryMapView : public StdTable
{
@ -31,6 +29,8 @@ public slots:
void memoryExecuteSingleshootToggleSlot();
void contextMenuSlot(const QPoint & pos);
void switchView();
void pageMemoryRights();
void refreshMap();
private:
QString getProtectionString(DWORD Protect);
@ -38,6 +38,7 @@ private:
QAction* mFollowDump;
QAction* mFollowDisassembly;
QAction* mSwitchView;
QAction* mPageMemoryRights;
QMenu* mBreakpointMenu;
QMenu* mMemoryAccessMenu;

View File

@ -0,0 +1,126 @@
#include "PageMemoryRights.h"
#include "ui_PageMemoryRights.h"
PageMemoryRights::PageMemoryRights(QWidget* parent) : QDialog(parent), ui(new Ui::PageMemoryRights)
{
ui->setupUi(this);
//set window flags
setModal(true);
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
}
PageMemoryRights::~PageMemoryRights()
{
delete ui;
}
void PageMemoryRights::RunAddrSize(uint_t addrin, uint_t sizein, QString pagetypein)
{
addr = addrin;
size = sizein;
pagetype = pagetypein;
QTableWidget* tableWidget = ui->pagetableWidget;
tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
uint_t nr_pages = size / PAGE_SIZE;
tableWidget->setColumnCount(2);
tableWidget->setRowCount(nr_pages);
tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString("Address")));
tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString("Rights")));
#define RIGHTS_STRING (sizeof("ERWCG") + 1)
duint actual_addr;
char rights[RIGHTS_STRING];
for(uint_t i = 0; i < nr_pages; i++)
{
actual_addr = addr + (i * PAGE_SIZE);
tableWidget->setItem(i, 0, new QTableWidgetItem(QString("%1").arg(actual_addr, sizeof(uint_t) * 2, 16, QChar('0')).toUpper()));
if(DbgFunctions()->GetPageRights(& actual_addr, rights))
tableWidget->setItem(i, 1, new QTableWidgetItem(QString(rights)));
}
QModelIndex idx = (ui->pagetableWidget->model()->index(0, 0));
ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
idx = (ui->pagetableWidget->model()->index(0, 1));
ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
ui->radioFullaccess->setChecked(true);
ui->chkPageguard->setCheckable(true);
exec();
}
void PageMemoryRights::on_btnSelectall_clicked()
{
for(int i = 0; i < ui->pagetableWidget->rowCount(); i++)
{
for(int j = 0; j < ui->pagetableWidget->columnCount(); j++)
{
QModelIndex idx = (ui->pagetableWidget->model()->index(i, j));
ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
}
}
}
void PageMemoryRights::on_btnDeselectall_clicked()
{
QModelIndexList indexList = ui->pagetableWidget->selectionModel()->selectedIndexes();
foreach(QModelIndex index, indexList)
{
ui->pagetableWidget->selectionModel()->select(index, QItemSelectionModel::Deselect);
}
}
void PageMemoryRights::on_btnSetrights_clicked()
{
duint actual_addr;
QString rights;
char newrights[RIGHTS_STRING];
bool one_right_changed = false;
if(ui->radioExecute->isChecked())
rights = "Execute";
else if(ui->radioExecuteread->isChecked())
rights = "ExecuteRead";
else if(ui->radioNoaccess->isChecked())
rights = "NoAccess";
else if(ui->radioFullaccess ->isChecked())
rights = "ExecuteReadWrite";
else if(ui->radioReadonly->isChecked())
rights = "ReadOnly";
else if(ui->radioReadwrite->isChecked())
rights = "ReadWrite";
else if(ui->radioWritecopy->isChecked())
rights = "WriteCopy";
else if(ui->radioExecutewritecopy->isChecked())
rights = "ExecuteWriteCopy";
else
return;
if(ui->chkPageguard->isChecked())
rights = "G" + rights;
QModelIndexList indexList = ui->pagetableWidget->selectionModel()->selectedIndexes();
foreach(QModelIndex index, indexList)
{
#ifdef _WIN64
actual_addr = ui->pagetableWidget->item(index.row(), 0)->text().toULongLong(0, 16);
#else //x86
actual_addr = ui->pagetableWidget->item(index.row(), 0)->text().toULong(0, 16);
#endif //_WIN64
if(DbgFunctions()->SetPageRights(& actual_addr, (char*) rights.toUtf8().constData()))
{
one_right_changed = true;
if(DbgFunctions()->GetPageRights(& actual_addr, newrights))
ui->pagetableWidget->setItem(index.row(), 1, new QTableWidgetItem(QString(newrights)));
}
}
DbgFunctions()->MemUpdateMap();
emit refreshMemoryMap();
if(one_right_changed)
ui->LnEdStatus->setText("Pages Rights Changed to: " + rights);
else
ui->LnEdStatus->setText("Error setting rights, read the MSDN to learn the valid rights of: " + pagetype);
}

View File

@ -0,0 +1,38 @@
#ifndef PAGEMEMORYRIGHTS_H
#define PAGEMEMORYRIGHTS_H
#include <QDialog>
#include "NewTypes.h"
#define PAGE_SIZE 0x1000
namespace Ui
{
class PageMemoryRights;
}
class PageMemoryRights : public QDialog
{
Q_OBJECT
public:
explicit PageMemoryRights(QWidget* parent = 0);
void RunAddrSize(uint_t, uint_t, QString);
~PageMemoryRights();
private slots:
void on_btnSelectall_clicked();
void on_btnDeselectall_clicked();
void on_btnSetrights_clicked();
signals:
void refreshMemoryMap();
private:
Ui::PageMemoryRights* ui;
uint_t addr;
uint_t size;
QString pagetype;
};
#endif // PAGEMEMORYRIGHTS_H

View File

@ -0,0 +1,261 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PageMemoryRights</class>
<widget class="QDialog" name="PageMemoryRights">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>346</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Set Page Memory Rights</string>
</property>
<property name="windowIcon">
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/memory-map.png</normaloff>:/icons/images/memory-map.png</iconset>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>350</x>
<y>310</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QTableWidget" name="pagetableWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>11</y>
<width>291</width>
<height>241</height>
</rect>
</property>
<property name="autoScroll">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>330</x>
<y>10</y>
<width>161</width>
<height>242</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Rights</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radioNoaccess">
<property name="text">
<string>NO ACCESS</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioReadonly">
<property name="text">
<string>READ ONLY</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radioReadwrite">
<property name="text">
<string>READ WRITE</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="radioExecute">
<property name="text">
<string>EXECUTE</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="radioExecuteread">
<property name="text">
<string>EXECUTE READ</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QRadioButton" name="radioFullaccess">
<property name="text">
<string>FULL ACCESS</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QRadioButton" name="radioWritecopy">
<property name="text">
<string>WRITE COPY</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QRadioButton" name="radioExecutewritecopy">
<property name="text">
<string>EXECUTE WRITE COPY</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSetrights">
<property name="text">
<string>Set Rights</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>260</y>
<width>230</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnSelectall">
<property name="text">
<string>Select ALL</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDeselectall">
<property name="text">
<string>Deselect ALL</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLineEdit" name="LnEdStatus">
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<width>371</width>
<height>20</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>260</x>
<y>280</y>
<width>241</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Press CTRL or SHIFT key to select multiple pages</string>
</property>
</widget>
<widget class="QCheckBox" name="chkPageguard">
<property name="geometry">
<rect>
<x>400</x>
<y>260</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>PAGE GUARD</string>
</property>
</widget>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>buttonBox</zorder>
<zorder>LnEdStatus</zorder>
<zorder>pagetableWidget</zorder>
<zorder>label</zorder>
<zorder>chkPageguard</zorder>
</widget>
<resources>
<include location="../../resource.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PageMemoryRights</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PageMemoryRights</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,5 +1,10 @@
#include "PatchDialog.h"
#include "ui_PatchDialog.h"
#include <QMessageBox>
#include <QIcon>
#include <QDesktopServices>
#include <QFileDialog>
#include <QTextStream>
PatchDialog::PatchDialog(QWidget* parent) :
QDialog(parent),

View File

@ -2,8 +2,9 @@
#define PATCHDIALOG_H
#include <QDialog>
#include "Bridge.h"
#include <QListWidgetItem>
#include "PatchDialogGroupSelector.h"
#include "Bridge.h"
namespace Ui
{

View File

@ -1,5 +1,7 @@
#include "RegistersView.h"
#include <QClipboard>
#include "Configuration.h"
#include "WordEditDialog.h"
RegistersView::RegistersView(QWidget* parent) : QAbstractScrollArea(parent), mVScrollOffset(0)
{

View File

@ -1,14 +1,10 @@
#ifndef REGISTERSVIEW_H
#define REGISTERSVIEW_H
#include <QtGui>
#include <QLabel>
#include <QMenu>
#include <QSet>
#include "Bridge.h"
#include "WordEditDialog.h"
#include "LineEditDialog.h"
#include <QAbstractScrollArea>
#include <QSet>
#include <QMap>
#include "Bridge.h"
#define IsCharacterRegister(x) ((x>=CAX && x<CIP))

View File

@ -1,5 +1,10 @@
#include "ScriptView.h"
#include <QMessageBox>
#include <QFileDialog>
#include "Configuration.h"
#include "Bridge.h"
#include "RichTextPainter.h"
#include "LineEditDialog.h"
ScriptView::ScriptView(StdTable* parent) : StdTable(parent)
{

View File

@ -1,14 +1,7 @@
#ifndef SCRIPTVIEW_H
#define SCRIPTVIEW_H
#include <QtGui>
#include <QAction>
#include <QMessageBox>
#include <QFileDialog>
#include <QMenu>
#include "StdTable.h"
#include "Bridge.h"
#include "LineEditDialog.h"
class ScriptView : public StdTable
{

View File

@ -1,6 +1,9 @@
#include "SettingsDialog.h"
#include "ui_SettingsDialog.h"
#include <QMessageBox>
#include "Configuration.h"
#include "Bridge.h"
#include "ExceptionRangeDialog.h"
SettingsDialog::SettingsDialog(QWidget* parent) :
QDialog(parent),
@ -191,6 +194,13 @@ void SettingsDialog::LoadSettings()
ui->chkConfirmBeforeAtt->setCheckState(bool2check(settings.miscSetJITAuto));
}
if(!DbgFunctions()->IsProcessElevated())
{
ui->chkSetJIT->setDisabled(true);
ui->chkConfirmBeforeAtt->setDisabled(true);
ui->lbladminwarning->setText(QString("Warning: Run the debugger as Admin to enable JIT."));
}
}
}
bJitOld = settings.miscSetJIT;

View File

@ -2,9 +2,6 @@
#define SETTINGSDIALOG_H
#include <QDialog>
#include <QMessageBox>
#include "Bridge.h"
#include "ExceptionRangeDialog.h"
namespace Ui
{

View File

@ -516,6 +516,19 @@
<string>Confirm before attaching</string>
</property>
</widget>
<widget class="QLabel" name="lbladminwarning">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>271</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
<widget class="QPushButton" name="btnSave">

View File

@ -2,8 +2,7 @@
#define SHORTCUTSDIALOG_H
#include <QDialog>
#include <QTableWidget>
#include "ShortcutEdit.h"
#include <QHeaderView>
#include "Configuration.h"
namespace Ui

View File

@ -1,6 +1,8 @@
#include "SymbolView.h"
#include "ui_SymbolView.h"
#include <QMessageBox>
#include "Configuration.h"
#include "Bridge.h"
SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView)
{

View File

@ -2,12 +2,7 @@
#define SYMBOLVIEW_H
#include <QWidget>
#include <QVBoxLayout>
#include <QList>
#include <QMenu>
#include "StdTable.h"
#include "Bridge.h"
#include "SearchListView.h"
namespace Ui
{

View File

@ -1,7 +1,6 @@
#include "ThreadView.h"
#include "Configuration.h"
// Dreg code x86_64dbg GPLv3
#include "Bridge.h"
void ThreadView::contextMenuSlot(const QPoint & pos)
{

View File

@ -2,7 +2,7 @@
#define THREADVIEW_H
#include "StdTable.h"
#include "Bridge.h"
#include <QMenu>
class ThreadView : public StdTable
{

View File

@ -1,11 +1,10 @@
#ifndef WORDEDITDIALOG_H
#define WORDEDITDIALOG_H
#include <QtGui>
#include <QDialog>
#include <QThread>
#include <QPushButton>
#include "Bridge.h"
#include "NewTypes.h"
namespace Ui
{

View File

@ -1,130 +0,0 @@
#include "MapViewOfMem.h"
MapViewOfMem::MapViewOfMem()
{
mSelectedData.fromIndex = -1;
mSelectedData.toIndex = -1;
}
MapViewOfMem::MapViewOfMem(QString file)
{
MemDataCacheStruct_t data;
memset(&data, 0, sizeof(MemDataCacheStruct_t));
data.memDataCachePtr = new QVector<byte_t>(0);
mGuiMemDataCache = data;
mSelectedData.fromIndex = -1;
mSelectedData.toIndex = -1;
//qDebug() << "MapViewOfMem() Load data from file.";
QFile wFile(file);
if(wFile.open(QIODevice::ReadOnly) == false)
//qDebug() << "File has not been opened.";
mData = wFile.readAll();
//qDebug() << "Size: " << mData.size();
if(mData.size() == 0)
{
//qDebug() << "No Data";
}
mSize = mData.size();
mBase = 0x00401000;
}
MapViewOfMem::MapViewOfMem(uint_t startAddress , uint_t size)
{
mStartAddress = startAddress;
mEndAddress = startAddress + size - 1;
mSize = size;
}
MapViewOfMem::~MapViewOfMem()
{
}
byte_t MapViewOfMem::readByte(uint_t rva)
{
return mData.data()[rva];
}
uint_t MapViewOfMem::size()
{
return mSize;
}
unsigned char* MapViewOfMem::data()
{
return (unsigned char*)(mData.data());
}
Selection_t MapViewOfMem::getSelection()
{
return mSelectedData;
}
void MapViewOfMem::setSelection(Selection_t sel)
{
mSelectedData = sel;
}
uint_t MapViewOfMem::getBase()
{
return mBase;
}
byte_t* MapViewOfMem::getDataPtrForGui(uint_t rva, uint_t maxNbrOfBytesToRead, uint_t newCacheSize)
{
byte_t* wBytePtr = 0;
if(maxNbrOfBytesToRead > 0)
{
// Bound maxNbrOfBytesToRead to the max value it can take
if(maxNbrOfBytesToRead > (this->size() - rva))
maxNbrOfBytesToRead = this->size() - rva;
if((mGuiMemDataCache.isInit == true) && (rva >= mGuiMemDataCache.rva) && ((rva + (uint_t)maxNbrOfBytesToRead) <= (mGuiMemDataCache.rva + (uint_t)mGuiMemDataCache.memDataCacheSize)))
{
// Cache Success
wBytePtr = mGuiMemDataCache.memDataCachePtr->data() + (rva - mGuiMemDataCache.rva);
}
else
{
// Cache Miss
mGuiMemDataCache.memDataCacheSize = newCacheSize;
mGuiMemDataCache.memDataCachePtr->resize(newCacheSize);
mGuiMemDataCache.rva = rva;
wBytePtr = mGuiMemDataCache.memDataCachePtr->data();
// TODO: Fill cache
for(uint_t wI = 0; wI < newCacheSize; wI++)
{
wBytePtr[wI] = readByte(rva + (uint_t)wI);
}
mGuiMemDataCache.isInit = true;
}
}
return wBytePtr;
}

View File

@ -1,58 +0,0 @@
#ifndef MAPVIEWOFMEM_H
#define MAPVIEWOFMEM_H
#include <QtGui>
#include "NewTypes.h"
typedef struct _Selection_t
{
int firstSelectedIndex;
int fromIndex;
int toIndex;
} Selection_t;
class MapViewOfMem
{
public:
MapViewOfMem();
explicit MapViewOfMem(QString file);
explicit MapViewOfMem(uint_t startAddress , uint_t size);
~MapViewOfMem();
byte_t readByte(uint_t rva);
uint_t size();
unsigned char* data();
Selection_t getSelection();
void setSelection(Selection_t sel);
uint_t getBase();
byte_t* getDataPtrForGui(uint_t rva, uint_t maxNbrOfBytesToRead, uint_t newCacheSize);
private:
typedef struct _MemDataCacheStruct_t
{
QVector<byte_t>* memDataCachePtr;
uint_t memDataCacheSize;
uint_t rva;
bool isInit;
} MemDataCacheStruct_t;
uint_t mBase;
unsigned long mStartAddress;
unsigned long mEndAddress;
unsigned long mSize;
QByteArray mData;
Selection_t mSelectedData;
MemDataCacheStruct_t mGuiMemDataCache;
};
#endif // MAPVIEWOFMEM_H

View File

@ -2,11 +2,7 @@
#define MEMORYPAGE_H
#include <QObject>
#include <QtGui>
#include "NewTypes.h"
#include "windows.h"
#include "main.h"
#include "Bridge.h"
class MemoryPage : public QObject
{

View File

@ -1,217 +0,0 @@
#include "ProcessMemoryMap.h"
ProcessMemoryMap::ProcessMemoryMap(QString fileName, QObject* parent) : QObject(parent)
{
Q_UNUSED(fileName);
STARTUPINFO si;
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
LPCTSTR target = TEXT("UnPackMe.exe");
if(!CreateProcess((LPCTSTR)target, 0, NULL, NULL, 0, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi))
{
//qDebug() << "CreateProcess failed (" << GetLastError() << ").\n";
}
else
{
mhProcess = pi.hProcess;
QWidget* widget = new QWidget();
widget->show();
Sleep(800);
printVirtualMemoryMap(BruteForceProcessMemory());
}
}
QList<MEMORY_BASIC_INFORMATION> ProcessMemoryMap::BruteForceProcessMemory()
{
QList<MEMORY_BASIC_INFORMATION> wMemoryRegionsList;
MEMORY_BASIC_INFORMATION wMemInfo;
uint_t wVirtualAddress = 0;
uint_t wUpperLimit = 0x80000000;//0x000007FFFFFFFFFF; // x64 User Space Limit
SIZE_T wErr;
// For each page in memory
while(wVirtualAddress <= wUpperLimit)
{
// Query the page
wErr = VirtualQueryEx(mhProcess, (LPCVOID)wVirtualAddress, &wMemInfo, sizeof(wMemInfo));
// If VirtualQueryEx failed, try the next region
if(wErr == 0)
{
wVirtualAddress += 0x1000;
}
else
{
wMemoryRegionsList.append(wMemInfo);
wVirtualAddress += wMemInfo.RegionSize;
}
}
return wMemoryRegionsList;
}
void ProcessMemoryMap::printVirtualMemoryMap(QList<MEMORY_BASIC_INFORMATION> parList)
{
int wI;
QString wStr = "";
QString wTmpStr = "";
MEMORY_BASIC_INFORMATION wMemInfo;
// Header
wTmpStr = "Address";
wStr += wTmpStr + QString(" ").repeated(20 - wTmpStr.length());
wStr += " | ";
wTmpStr = "Size";
wStr += wTmpStr + QString(" ").repeated(20 - wTmpStr.length());
wStr += " | ";
wTmpStr = "State";
wStr += wTmpStr + QString(" ").repeated(10 - wTmpStr.length());
wStr += " | ";
wTmpStr = "Access";
wStr += wTmpStr + QString(" ").repeated(30 - wTmpStr.length());
wStr += " | ";
wTmpStr = "Type";
wStr += wTmpStr + QString(" ").repeated(10 - wTmpStr.length());
//qDebug() << wStr;
wStr = "-------------------------------------------------------------------------------------------------";
//qDebug() << wStr;
for(wI = 0; wI < parList.size(); wI++)
{
wStr = "";
wMemInfo = parList.at(wI);
// Base address
wTmpStr = "0x" + QString("%1").arg((uint_t)wMemInfo.BaseAddress, 16, 16, QChar('0')).toUpper();
wStr += wTmpStr + QString(" ").repeated(20 - wTmpStr.length());
wStr += " | ";
// Size
wTmpStr = "0x" + QString("%1").arg((uint_t)wMemInfo.RegionSize, 16, 16, QChar('0')).toUpper();
wStr += wTmpStr + QString(" ").repeated(20 - wTmpStr.length());
wStr += " | ";
// State
switch(wMemInfo.State)
{
case MEM_FREE:
wTmpStr = QString("Free");
break;
case MEM_COMMIT:
wTmpStr = QString("Commited");
break;
case MEM_RESERVE:
wTmpStr = QString("Reserved");
break;
default:
wTmpStr = QString("N/A");
}
wStr += wTmpStr + QString(" ").repeated(10 - wTmpStr.length());
wStr += " | ";
// Access
if(wMemInfo.State != MEM_COMMIT)
{
wTmpStr = QString("N/A");
wStr += wTmpStr + QString(" ").repeated(30 - wTmpStr.length());
wStr += " | ";
}
else
{
switch(wMemInfo.Protect & 0xFF)
{
case PAGE_EXECUTE:
wTmpStr = QString("Execute");
break;
case PAGE_EXECUTE_READ:
wTmpStr = QString("Execute/Read");
break;
case PAGE_EXECUTE_READWRITE:
wTmpStr = QString("Execute/Read/Write");
break;
case PAGE_NOACCESS:
wTmpStr = QString("No Access");
break;
case PAGE_READONLY:
wTmpStr = QString("Read");
break;
case PAGE_READWRITE:
wTmpStr = QString("Read/Write");
break;
case PAGE_WRITECOPY:
wTmpStr = QString("Copy on Write");
break;
case PAGE_EXECUTE_WRITECOPY:
wTmpStr = QString("Execute/Copy on Write");
break;
}
switch(wMemInfo.Protect & 0xFF00)
{
case PAGE_GUARD:
wTmpStr += QString(" + Guard");
}
wStr += wTmpStr + QString(" ").repeated(30 - wTmpStr.length());
wStr += " | ";
}
// Type
switch(wMemInfo.Type)
{
case MEM_IMAGE:
wTmpStr = QString("Image");
break;
case MEM_MAPPED:
wTmpStr = QString("Mapped");
break;
case MEM_PRIVATE:
wTmpStr = QString("Private");
break;
default:
wTmpStr = QString("N/A");
break;
}
wStr += wTmpStr + QString(" ").repeated(10 - wTmpStr.length());
//qDebug() << wStr;
}
}

View File

@ -1,34 +0,0 @@
#ifndef MEMORYMAP_H
#define MEMORYMAP_H
#include <QObject>
#include <QtGui>
#include <QWidget>
#include "NewTypes.h"
#include "windows.h"
class ProcessMemoryMap : public QObject
{
Q_OBJECT
public:
explicit ProcessMemoryMap(QString fileName, QObject* parent = 0);
QList<MEMORY_BASIC_INFORMATION> BruteForceProcessMemory();
void printVirtualMemoryMap(QList<MEMORY_BASIC_INFORMATION> parList);
signals:
public slots:
private:
HANDLE mhProcess;
QByteArray mData;
QList<QByteArray> mMemoryRegionsDataList;
QList<MEMORY_BASIC_INFORMATION> mMemoryRegionsList;
};
#endif // MEMORYMAP_H

View File

@ -63,7 +63,7 @@ void QHexEdit::fill(int index, const QString & pattern)
}
else
{
data[i] = convert[i].toAscii();
data[i] = convert[i].toLatin1();
mask[i] = '0';
}
}
@ -124,7 +124,7 @@ void QHexEdit::setData(const QString & pattern)
}
else
{
data[i] = convert[i].toAscii();
data[i] = convert[i].toLatin1();
mask[i] = '0';
}
}

View File

@ -1,7 +1,8 @@
#ifndef QHEXEDIT_H
#define QHEXEDIT_H
#include <QtGui>
#include <QScrollArea>
#include <QHBoxLayout>
#include "QHexEditPrivate.h"
class QHexEdit : public QScrollArea

View File

@ -1,6 +1,7 @@
#include <QtGui>
#include "QHexEditPrivate.h"
#include <QApplication>
#include <QClipboard>
#include <QPainter>
#include "ArrayCommand.h"
const int HEXCHARS_IN_LINE = 47;
@ -422,7 +423,7 @@ void QHexEditPrivate::keyPressEvent(QKeyEvent* event)
/* Edit Commands */
/*****************************************************************************/
/* Hex input */
int key = int(event->text().toLower()[0].toAscii());
int key = int(event->text().toLower()[0].toLatin1());
if((key >= '0' && key <= '9') || (key >= 'a' && key <= 'f') || (_wildcardEnabled && key == '?'))
{
if(getSelectionBegin() != getSelectionEnd())
@ -528,7 +529,7 @@ void QHexEditPrivate::keyPressEvent(QKeyEvent* event)
}
else
{
data[i] = convert[i].toAscii();
data[i] = convert[i].toLatin1();
mask[i] = '0';
}
}

View File

@ -1,7 +1,10 @@
#ifndef QHEXEDITPRIVATE_H
#define QHEXEDITPRIVATE_H
#include <QtGui>
#include <QWidget>
#include <QScrollArea>
#include <QUndoStack>
#include <QKeyEvent>
#include "XByteArray.h"
class QHexEditPrivate : public QWidget

View File

@ -47,7 +47,6 @@ void Breakpoints::setBP(BPXTYPE type, uint_t va)
DbgCmdExec(wCmd.toUtf8().constData());
}
/**
* @brief Enable breakpoint according to the given breakpoint descriptor.
*
@ -378,7 +377,4 @@ void Breakpoints::toggleBPByRemoving(BPXTYPE type, uint_t va)
{
setBP(bp_hardware, va);
}
}

View File

@ -16,29 +16,17 @@ class Breakpoints : public QObject
Q_OBJECT
public:
explicit Breakpoints(QObject* parent = 0);
static void setBP(BPXTYPE type, uint_t va);
static void enableBP(BRIDGEBP bp);
static void enableBP(BPXTYPE type, uint_t va);
static void disableBP(BRIDGEBP bp);
static void disableBP(BPXTYPE type, uint_t va);
static void removeBP(BRIDGEBP bp);
static void removeBP(BPXTYPE type, uint_t va);
static void toggleBPByDisabling(BRIDGEBP bp);
static void toggleBPByDisabling(BPXTYPE type, uint_t va);
static void toggleBPByRemoving(BPXTYPE type, uint_t va);
static BPXSTATE BPState(BPXTYPE type, uint_t va);
signals:
public slots:
private:
};

View File

@ -1,6 +1,8 @@
#include "Configuration.h"
#include "Bridge.h"
#include <QApplication>
#include <QFontInfo>
#include <QMessageBox>
#include <QIcon>
Configuration* Configuration::mPtr = NULL;

View File

@ -1,13 +1,12 @@
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <QFile>
#include <QString>
#include <QColor>
#include <QMap>
#include <QObject>
#include <QKeySequence>
#include "Bridge.h"
#include <QMap>
#include <QColor>
#include <QFont>
#include "NewTypes.h"
#define Config() (Configuration::instance())
#define ConfigColor(x) (Config()->getColor(x))

View File

@ -1,7 +1,8 @@
#ifndef RICHTEXTPAINTER_H
#define RICHTEXTPAINTER_H
#include <QList>
#include <QString>
#include <QColor>
#include <QPainter>
class RichTextPainter

View File

@ -1,5 +1,9 @@
#include "UpdateChecker.h"
#include <QUrl>
#include <QNetworkRequest>
#include <QMessageBox>
#include <QNetworkReply>
#include <QIcon>
#include "Bridge.h"
UpdateChecker::UpdateChecker(QWidget* parent)

View File

@ -1,8 +1,7 @@
#ifndef UPDATECHECKER_H
#define UPDATECHECKER_H
#include <QtNetwork>
#include <QtGui>
#include <QNetworkAccessManager>
class UpdateChecker : public QNetworkAccessManager
{

View File

@ -1,9 +1,9 @@
#include <QtGui>
#include "MainWindow.h"
#include "NewTypes.h"
#include "Bridge.h"
#include "main.h"
#include <QAbstractEventDispatcher>
#include <QMessageBox>
#include "Bridge.h"
#include "Configuration.h"
#include "MainWindow.h"
MyApplication::MyApplication(int & argc, char** argv) : QApplication(argc, argv)
{

View File

@ -36,9 +36,7 @@ SOURCES += \
Src/BasicView/HexDump.cpp \
Src/BasicView/AbstractTableView.cpp \
Src/Disassembler/QBeaEngine.cpp \
Src/Memory/ProcessMemoryMap.cpp \
Src/Memory/MemoryPage.cpp \
Src/Memory/MapViewOfMem.cpp \
Src/Bridge/Bridge.cpp \
Src/BasicView/StdTable.cpp \
Src/Gui/MemoryMapView.cpp \
@ -84,7 +82,8 @@ SOURCES += \
Src/Gui/ShortcutsDialog.cpp \
Src/BasicView/ShortcutEdit.cpp \
Src/Gui/CalculatorDialog.cpp \
Src/Gui/AttachDialog.cpp
Src/Gui/AttachDialog.cpp \
Src/Gui/PageMemoryRights.cpp
HEADERS += \
@ -96,9 +95,7 @@ HEADERS += \
Src/BasicView/HexDump.h \
Src/BasicView/AbstractTableView.h \
Src/Disassembler/QBeaEngine.h \
Src/Memory/ProcessMemoryMap.h \
Src/Memory/MemoryPage.h \
Src/Memory/MapViewOfMem.h \
Src/Bridge/Bridge.h \
Src/Global/NewTypes.h \
Src/Exports.h \
@ -147,7 +144,8 @@ HEADERS += \
Src/Gui/ShortcutsDialog.h \
Src/BasicView/ShortcutEdit.h \
Src/Gui/CalculatorDialog.h \
Src/Gui/AttachDialog.h
Src/Gui/AttachDialog.h \
Src/Gui/PageMemoryRights.h
INCLUDEPATH += \
@ -180,7 +178,8 @@ FORMS += \
Src/Gui/PatchDialogGroupSelector.ui \
Src/Gui/ShortcutsDialog.ui \
Src/Gui/CalculatorDialog.ui \
Src/Gui/AttachDialog.ui
Src/Gui/AttachDialog.ui \
Src/Gui/PageMemoryRights.ui
INCLUDEPATH += $$PWD/Src/Bridge