PROJECT: code formatting
This commit is contained in:
parent
4a51b9dc5f
commit
9b1867bb5b
|
|
@ -4,7 +4,7 @@
|
|||
#include <new>
|
||||
|
||||
static HINSTANCE hInst;
|
||||
static char szIniFile[1024]="";
|
||||
static char szIniFile[1024] = "";
|
||||
|
||||
#ifdef _WIN64
|
||||
#define dbg_lib "x64_dbg.dll"
|
||||
|
|
@ -34,17 +34,17 @@ BRIDGE_IMPEXP const char* BridgeInit()
|
|||
///Settings load
|
||||
if(!GetModuleFileNameA(0, szIniFile, 1024))
|
||||
return "Error getting module path!";
|
||||
int len=(int)strlen(szIniFile);
|
||||
while(szIniFile[len]!='.' && szIniFile[len]!='\\' && len)
|
||||
int len = (int)strlen(szIniFile);
|
||||
while(szIniFile[len] != '.' && szIniFile[len] != '\\' && len)
|
||||
len--;
|
||||
if(szIniFile[len]=='\\')
|
||||
if(szIniFile[len] == '\\')
|
||||
strcat(szIniFile, ".ini");
|
||||
else
|
||||
strcpy(&szIniFile[len], ".ini");
|
||||
|
||||
HINSTANCE hInst;
|
||||
const char* szLib;
|
||||
static char szError[256]="";
|
||||
static char szError[256] = "";
|
||||
|
||||
//GUI Load
|
||||
LOADLIBRARY(gui_lib);
|
||||
|
|
@ -86,7 +86,7 @@ BRIDGE_IMPEXP const char* BridgeStart()
|
|||
|
||||
BRIDGE_IMPEXP void* BridgeAlloc(size_t size)
|
||||
{
|
||||
unsigned char* a=(unsigned char*)GlobalAlloc(GMEM_FIXED, size);
|
||||
unsigned char* a = (unsigned char*)GlobalAlloc(GMEM_FIXED, size);
|
||||
if(!a)
|
||||
{
|
||||
MessageBoxA(0, "Could not allocate memory", "Error", MB_ICONERROR);
|
||||
|
|
@ -114,13 +114,13 @@ BRIDGE_IMPEXP bool BridgeSettingGetUint(const char* section, const char* key, du
|
|||
{
|
||||
if(!section || !key || !value)
|
||||
return false;
|
||||
char newvalue[MAX_SETTING_SIZE]="";
|
||||
char newvalue[MAX_SETTING_SIZE] = "";
|
||||
if(!BridgeSettingGet(section, key, newvalue))
|
||||
return false;
|
||||
#ifdef _WIN64
|
||||
int ret=sscanf(newvalue, "%llX", value);
|
||||
int ret = sscanf(newvalue, "%llX", value);
|
||||
#else
|
||||
int ret=sscanf(newvalue, "%X", value);
|
||||
int ret = sscanf(newvalue, "%X", value);
|
||||
#endif //_WIN64
|
||||
if(ret)
|
||||
return true;
|
||||
|
|
@ -140,7 +140,7 @@ BRIDGE_IMPEXP bool BridgeSettingSetUint(const char* section, const char* key, du
|
|||
{
|
||||
if(!section || !key)
|
||||
return false;
|
||||
char newvalue[MAX_SETTING_SIZE]="";
|
||||
char newvalue[MAX_SETTING_SIZE] = "";
|
||||
#ifdef _WIN64
|
||||
sprintf(newvalue, "%llX", value);
|
||||
#else
|
||||
|
|
@ -162,7 +162,7 @@ BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size)
|
|||
GuiAddLogMessage("DbgMemRead with invalid boundaries!\n");
|
||||
return false;
|
||||
}
|
||||
bool ret=_dbg_memread(va, dest, size, 0);
|
||||
bool ret = _dbg_memread(va, dest, size, 0);
|
||||
if(!ret)
|
||||
memset(dest, 0x90, size);
|
||||
return ret;
|
||||
|
|
@ -180,7 +180,7 @@ BRIDGE_IMPEXP bool DbgMemWrite(duint va, const unsigned char* src, duint size)
|
|||
|
||||
BRIDGE_IMPEXP duint DbgMemGetPageSize(duint base)
|
||||
{
|
||||
duint size=0;
|
||||
duint size = 0;
|
||||
_dbg_memfindbaseaddr(base, &size);
|
||||
return size;
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ BRIDGE_IMPEXP bool DbgMemMap(MEMMAP* memmap)
|
|||
|
||||
BRIDGE_IMPEXP bool DbgIsValidExpression(const char* expression)
|
||||
{
|
||||
duint value=0;
|
||||
duint value = 0;
|
||||
return _dbg_valfromstring(expression, &value);
|
||||
}
|
||||
|
||||
|
|
@ -222,10 +222,10 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //(
|
|||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flaglabel;
|
||||
info.flags = flaglabel;
|
||||
if(!_dbg_addrinfoget(addr, segment, &info))
|
||||
{
|
||||
duint addr_=0;
|
||||
duint addr_ = 0;
|
||||
if(!DbgMemIsValidReadPtr(addr))
|
||||
return false;
|
||||
DbgMemRead(addr, (unsigned char*)&addr_, sizeof(duint));
|
||||
|
|
@ -240,11 +240,11 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //(
|
|||
|
||||
BRIDGE_IMPEXP bool DbgSetLabelAt(duint addr, const char* text)
|
||||
{
|
||||
if(!text || strlen(text)>=MAX_LABEL_SIZE || !addr)
|
||||
if(!text || strlen(text) >= MAX_LABEL_SIZE || !addr)
|
||||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flaglabel;
|
||||
info.flags = flaglabel;
|
||||
strcpy(info.label, text);
|
||||
if(!_dbg_addrinfoset(addr, &info))
|
||||
return false;
|
||||
|
|
@ -257,7 +257,7 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live)
|
|||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagcomment;
|
||||
info.flags = flagcomment;
|
||||
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
|
||||
return false;
|
||||
strcpy(text, info.comment);
|
||||
|
|
@ -266,11 +266,11 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live)
|
|||
|
||||
BRIDGE_IMPEXP bool DbgSetCommentAt(duint addr, const char* text)
|
||||
{
|
||||
if(!text || strlen(text)>=MAX_COMMENT_SIZE || !addr)
|
||||
if(!text || strlen(text) >= MAX_COMMENT_SIZE || !addr)
|
||||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagcomment;
|
||||
info.flags = flagcomment;
|
||||
strcpy(info.comment, text);
|
||||
if(!_dbg_addrinfoset(addr, &info))
|
||||
return false;
|
||||
|
|
@ -283,7 +283,7 @@ BRIDGE_IMPEXP bool DbgGetModuleAt(duint addr, char* text)
|
|||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagmodule;
|
||||
info.flags = flagmodule;
|
||||
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
|
||||
return false;
|
||||
strcpy(text, info.module);
|
||||
|
|
@ -296,7 +296,7 @@ BRIDGE_IMPEXP bool DbgGetBookmarkAt(duint addr)
|
|||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagbookmark;
|
||||
info.flags = flagbookmark;
|
||||
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
|
||||
return false;
|
||||
return info.isbookmark;
|
||||
|
|
@ -308,8 +308,8 @@ BRIDGE_IMPEXP bool DbgSetBookmarkAt(duint addr, bool isbookmark)
|
|||
return false;
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagbookmark;
|
||||
info.isbookmark=isbookmark;
|
||||
info.flags = flagbookmark;
|
||||
info.isbookmark = isbookmark;
|
||||
return _dbg_addrinfoset(addr, &info);
|
||||
}
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ BRIDGE_IMPEXP BPXTYPE DbgGetBpxTypeAt(duint addr)
|
|||
|
||||
BRIDGE_IMPEXP duint DbgValFromString(const char* string)
|
||||
{
|
||||
duint value=0;
|
||||
duint value = 0;
|
||||
_dbg_valfromstring(string, &value);
|
||||
return value;
|
||||
}
|
||||
|
|
@ -342,7 +342,7 @@ BRIDGE_IMPEXP bool DbgGetRegDump(REGDUMP* regdump)
|
|||
|
||||
BRIDGE_IMPEXP bool DbgValToString(const char* string, duint value)
|
||||
{
|
||||
duint valueCopy=value;
|
||||
duint valueCopy = value;
|
||||
return _dbg_valtostring(string, &valueCopy);
|
||||
}
|
||||
|
||||
|
|
@ -365,16 +365,16 @@ BRIDGE_IMPEXP FUNCTYPE DbgGetFunctionTypeAt(duint addr)
|
|||
{
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagfunction;
|
||||
info.flags = flagfunction;
|
||||
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
|
||||
return FUNC_NONE;
|
||||
duint start=info.function.start;
|
||||
duint end=info.function.end;
|
||||
if(start==end)
|
||||
duint start = info.function.start;
|
||||
duint end = info.function.end;
|
||||
if(start == end)
|
||||
return FUNC_SINGLE;
|
||||
else if(addr==start)
|
||||
else if(addr == start)
|
||||
return FUNC_BEGIN;
|
||||
else if(addr==end)
|
||||
else if(addr == end)
|
||||
return FUNC_END;
|
||||
return FUNC_MIDDLE;
|
||||
}
|
||||
|
|
@ -383,15 +383,15 @@ BRIDGE_IMPEXP LOOPTYPE DbgGetLoopTypeAt(duint addr, int depth)
|
|||
{
|
||||
ADDRINFO info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.flags=flagloop;
|
||||
info.loop.depth=depth;
|
||||
info.flags = flagloop;
|
||||
info.loop.depth = depth;
|
||||
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
|
||||
return LOOP_NONE;
|
||||
duint start=info.loop.start;
|
||||
duint end=info.loop.end;
|
||||
if(addr==start)
|
||||
duint start = info.loop.start;
|
||||
duint end = info.loop.end;
|
||||
if(addr == start)
|
||||
return LOOP_BEGIN;
|
||||
else if(addr==end)
|
||||
else if(addr == end)
|
||||
return LOOP_END;
|
||||
return LOOP_MIDDLE;
|
||||
}
|
||||
|
|
@ -465,9 +465,9 @@ BRIDGE_IMPEXP bool DbgScriptGetBranchInfo(int line, SCRIPTBRANCH* info)
|
|||
BRIDGE_IMPEXP void DbgSymbolEnum(duint base, CBSYMBOLENUM cbSymbolEnum, void* user)
|
||||
{
|
||||
SYMBOLCBINFO cbInfo;
|
||||
cbInfo.base=base;
|
||||
cbInfo.cbSymbolEnum=cbSymbolEnum;
|
||||
cbInfo.user=user;
|
||||
cbInfo.base = base;
|
||||
cbInfo.cbSymbolEnum = cbSymbolEnum;
|
||||
cbInfo.user = user;
|
||||
_dbg_sendmessage(DBG_SYMBOL_ENUM, &cbInfo, 0);
|
||||
}
|
||||
|
||||
|
|
@ -517,19 +517,19 @@ BRIDGE_IMPEXP void DbgMenuEntryClicked(int hEntry)
|
|||
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.addr=addr;
|
||||
info.addr = addr;
|
||||
if(!_dbg_sendmessage(DBG_FUNCTION_GET, &info, 0))
|
||||
return false;
|
||||
*start=info.start;
|
||||
*end=info.end;
|
||||
*start = info.start;
|
||||
*end = info.end;
|
||||
return true;
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.start=start;
|
||||
info.end=end;
|
||||
info.start = start;
|
||||
info.end = end;
|
||||
if(!_dbg_sendmessage(DBG_FUNCTION_OVERLAPS, &info, 0))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -538,9 +538,9 @@ BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
|
|||
BRIDGE_IMPEXP bool DbgFunctionAdd(duint start, duint end)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.start=start;
|
||||
info.end=end;
|
||||
info.manual=false;
|
||||
info.start = start;
|
||||
info.end = end;
|
||||
info.manual = false;
|
||||
if(!_dbg_sendmessage(DBG_FUNCTION_ADD, &info, 0))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -549,7 +549,7 @@ BRIDGE_IMPEXP bool DbgFunctionAdd(duint start, duint end)
|
|||
BRIDGE_IMPEXP bool DbgFunctionDel(duint addr)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.addr=addr;
|
||||
info.addr = addr;
|
||||
if(!_dbg_sendmessage(DBG_FUNCTION_DEL, &info, 0))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -558,21 +558,21 @@ BRIDGE_IMPEXP bool DbgFunctionDel(duint addr)
|
|||
BRIDGE_IMPEXP bool DbgLoopGet(int depth, duint addr, duint* start, duint* end)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.addr=addr;
|
||||
info.depth=depth;
|
||||
info.addr = addr;
|
||||
info.depth = depth;
|
||||
if(!_dbg_sendmessage(DBG_LOOP_GET, &info, 0))
|
||||
return false;
|
||||
*start=info.start;
|
||||
*end=info.end;
|
||||
*start = info.start;
|
||||
*end = info.end;
|
||||
return true;
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP bool DbgLoopOverlaps(int depth, duint start, duint end)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.start=start;
|
||||
info.end=end;
|
||||
info.depth=depth;
|
||||
info.start = start;
|
||||
info.end = end;
|
||||
info.depth = depth;
|
||||
if(!_dbg_sendmessage(DBG_LOOP_OVERLAPS, &info, 0))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -581,9 +581,9 @@ BRIDGE_IMPEXP bool DbgLoopOverlaps(int depth, duint start, duint end)
|
|||
BRIDGE_IMPEXP bool DbgLoopAdd(duint start, duint end)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.start=start;
|
||||
info.end=end;
|
||||
info.manual=false;
|
||||
info.start = start;
|
||||
info.end = end;
|
||||
info.manual = false;
|
||||
if(!_dbg_sendmessage(DBG_LOOP_ADD, &info, 0))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -592,8 +592,8 @@ BRIDGE_IMPEXP bool DbgLoopAdd(duint start, duint end)
|
|||
BRIDGE_IMPEXP bool DbgLoopDel(int depth, duint addr)
|
||||
{
|
||||
FUNCTION_LOOP_INFO info;
|
||||
info.addr=addr;
|
||||
info.depth=depth;
|
||||
info.addr = addr;
|
||||
info.depth = depth;
|
||||
if(!_dbg_sendmessage(DBG_LOOP_DEL, &info, 0))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -842,9 +842,9 @@ BRIDGE_IMPEXP void GuiReferenceDeleteAllColumns()
|
|||
BRIDGE_IMPEXP void GuiReferenceSetCellContent(int row, int col, const char* str)
|
||||
{
|
||||
CELLINFO info;
|
||||
info.row=row;
|
||||
info.col=col;
|
||||
info.str=str;
|
||||
info.row = row;
|
||||
info.col = col;
|
||||
info.str = str;
|
||||
_gui_sendmessage(GUI_REF_SETCELLCONTENT, &info, 0);
|
||||
}
|
||||
|
||||
|
|
@ -981,7 +981,7 @@ BRIDGE_IMPEXP void GuiUpdateCallStack()
|
|||
//Main
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
hInst=hinstDLL;
|
||||
hInst = hinstDLL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,20 +87,20 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
flagmodule=1,
|
||||
flaglabel=2,
|
||||
flagcomment=4,
|
||||
flagbookmark=8,
|
||||
flagfunction=16,
|
||||
flagloop=32
|
||||
flagmodule = 1,
|
||||
flaglabel = 2,
|
||||
flagcomment = 4,
|
||||
flagbookmark = 8,
|
||||
flagfunction = 16,
|
||||
flagloop = 32
|
||||
} ADDRINFOFLAGS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
bp_none=0,
|
||||
bp_normal=1,
|
||||
bp_hardware=2,
|
||||
bp_memory=4
|
||||
bp_none = 0,
|
||||
bp_normal = 1,
|
||||
bp_hardware = 2,
|
||||
bp_memory = 4
|
||||
} BPXTYPE;
|
||||
|
||||
typedef enum
|
||||
|
|
@ -476,7 +476,7 @@ typedef struct
|
|||
bool branch; //jumps/calls
|
||||
bool call; //instruction is a call
|
||||
int size;
|
||||
char instruction[MAX_MNEMONIC_SIZE*4];
|
||||
char instruction[MAX_MNEMONIC_SIZE * 4];
|
||||
} BASIC_INSTRUCTION_INFO;
|
||||
|
||||
typedef struct
|
||||
|
|
|
|||
|
|
@ -382,9 +382,9 @@ enum SPECIAL_INFO
|
|||
extern "C"
|
||||
#endif
|
||||
|
||||
BEA_API int __bea_callspec__ Disasm (LPDISASM pDisAsm);
|
||||
BEA_API const__ char* __bea_callspec__ BeaEngineVersion (void);
|
||||
BEA_API const__ char* __bea_callspec__ BeaEngineRevision (void);
|
||||
BEA_API int __bea_callspec__ Disasm(LPDISASM pDisAsm);
|
||||
BEA_API const__ char* __bea_callspec__ BeaEngineVersion(void);
|
||||
BEA_API const__ char* __bea_callspec__ BeaEngineRevision(void);
|
||||
#if defined(__cplusplus) && defined(__BORLANDC__)
|
||||
};
|
||||
using namespace BeaEngine;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#if defined(__cplusplus)
|
||||
#define BEA_UNUSED_ID(identifier)
|
||||
template <class T>
|
||||
inline void BEA_UNUSED_ARG(const T& BEA_UNUSED_ID(t)) { }
|
||||
inline void BEA_UNUSED_ARG(const T & BEA_UNUSED_ID(t)) { }
|
||||
#else
|
||||
#define BEA_UNUSED_ARG(a)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -590,8 +590,8 @@ __declspec(dllexport) ULONG_PTR TITCALL ConvertVAtoFileOffset(ULONG_PTR FileMapV
|
|||
__declspec(dllexport) ULONG_PTR TITCALL ConvertVAtoFileOffsetEx(ULONG_PTR FileMapVA, DWORD FileSize, ULONG_PTR ImageBase, ULONG_PTR AddressToConvert, bool AddressIsRVA, bool ReturnType);
|
||||
__declspec(dllexport) ULONG_PTR TITCALL ConvertFileOffsetToVA(ULONG_PTR FileMapVA, ULONG_PTR AddressToConvert, bool ReturnType);
|
||||
__declspec(dllexport) ULONG_PTR TITCALL ConvertFileOffsetToVAEx(ULONG_PTR FileMapVA, DWORD FileSize, ULONG_PTR ImageBase, ULONG_PTR AddressToConvert, bool ReturnType);
|
||||
__declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T * lpNumberOfBytesRead);
|
||||
__declspec(dllexport) bool TITCALL MemoryWriteSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T * lpNumberOfBytesWritten);
|
||||
__declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead);
|
||||
__declspec(dllexport) bool TITCALL MemoryWriteSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten);
|
||||
// TitanEngine.Realigner.functions:
|
||||
__declspec(dllexport) bool TITCALL FixHeaderCheckSum(char* szFileName);
|
||||
__declspec(dllexport) bool TITCALL FixHeaderCheckSumW(wchar_t* szFileName);
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@
|
|||
#define XEDPARSE_MAXASMSIZE 16
|
||||
|
||||
//typedefs
|
||||
typedef bool (XEDPARSE_CALL *CBXEDPARSE_UNKNOWN)(const char* text, ULONGLONG* value);
|
||||
typedef bool (XEDPARSE_CALL* CBXEDPARSE_UNKNOWN)(const char* text, ULONGLONG* value);
|
||||
|
||||
//XEDParse enums
|
||||
enum XEDPARSE_STATUS
|
||||
{
|
||||
XEDPARSE_ERROR=0,
|
||||
XEDPARSE_OK=1
|
||||
XEDPARSE_ERROR = 0,
|
||||
XEDPARSE_OK = 1
|
||||
};
|
||||
|
||||
//XEDParse structs
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ static bool _assembleatex(duint addr, const char* instruction, char* error, bool
|
|||
|
||||
static bool _sectionfromaddr(duint addr, char* section)
|
||||
{
|
||||
HMODULE hMod=(HMODULE)modbasefromaddr(addr);
|
||||
HMODULE hMod = (HMODULE)modbasefromaddr(addr);
|
||||
if(!hMod)
|
||||
return false;
|
||||
char curModPath[MAX_PATH]="";
|
||||
char curModPath[MAX_PATH] = "";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, hMod, curModPath, MAX_PATH))
|
||||
return false;
|
||||
HANDLE FileHandle;
|
||||
|
|
@ -35,11 +35,11 @@ static bool _sectionfromaddr(duint addr, char* section)
|
|||
ULONG_PTR FileMapVA;
|
||||
if(StaticFileLoad(curModPath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
{
|
||||
uint rva=addr-(uint)hMod;
|
||||
int sectionNumber=GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE)+rva);
|
||||
if(sectionNumber>=0)
|
||||
uint rva = addr - (uint)hMod;
|
||||
int sectionNumber = GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE) + rva);
|
||||
if(sectionNumber >= 0)
|
||||
{
|
||||
const char* name=(const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
|
||||
const char* name = (const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
|
||||
if(section)
|
||||
strcpy(section, name);
|
||||
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
|
||||
|
|
@ -59,11 +59,11 @@ static bool _patchinrange(duint start, duint end)
|
|||
{
|
||||
if(start > end)
|
||||
{
|
||||
duint a=start;
|
||||
start=end;
|
||||
end=a;
|
||||
duint a = start;
|
||||
start = end;
|
||||
end = a;
|
||||
}
|
||||
for(duint i=start; i<end+1; i++)
|
||||
for(duint i = start; i < end + 1; i++)
|
||||
if(_patchget(i))
|
||||
return true;
|
||||
return false;
|
||||
|
|
@ -78,11 +78,11 @@ static void _patchrestorerange(duint start, duint end)
|
|||
{
|
||||
if(start > end)
|
||||
{
|
||||
duint a=start;
|
||||
start=end;
|
||||
end=a;
|
||||
duint a = start;
|
||||
start = end;
|
||||
end = a;
|
||||
}
|
||||
for(duint i=start; i<end+1; i++)
|
||||
for(duint i = start; i < end + 1; i++)
|
||||
patchdel(i, true);
|
||||
GuiUpdatePatches();
|
||||
}
|
||||
|
|
@ -124,26 +124,26 @@ static bool _getjit(char* jit, bool jit64)
|
|||
|
||||
void dbgfunctionsinit()
|
||||
{
|
||||
_dbgfunctions.AssembleAtEx=_assembleatex;
|
||||
_dbgfunctions.SectionFromAddr=_sectionfromaddr;
|
||||
_dbgfunctions.ModNameFromAddr=modnamefromaddr;
|
||||
_dbgfunctions.ModBaseFromAddr=modbasefromaddr;
|
||||
_dbgfunctions.ModBaseFromName=modbasefromname;
|
||||
_dbgfunctions.ModSizeFromAddr=modsizefromaddr;
|
||||
_dbgfunctions.Assemble=assemble;
|
||||
_dbgfunctions.PatchGet=_patchget;
|
||||
_dbgfunctions.PatchInRange=_patchinrange;
|
||||
_dbgfunctions.MemPatch=_mempatch;
|
||||
_dbgfunctions.PatchRestoreRange=_patchrestorerange;
|
||||
_dbgfunctions.PatchEnum=(PATCHENUM)patchenum;
|
||||
_dbgfunctions.PatchRestore=_patchrestore;
|
||||
_dbgfunctions.PatchFile=(PATCHFILE)patchfile;
|
||||
_dbgfunctions.ModPathFromAddr=_modpathfromaddr;
|
||||
_dbgfunctions.ModPathFromName=_modpathfromname;
|
||||
_dbgfunctions.DisasmFast=disasmfast;
|
||||
_dbgfunctions.MemUpdateMap=memupdatemap;
|
||||
_dbgfunctions.GetCallStack=_getcallstack;
|
||||
_dbgfunctions.SymbolDownloadAllSymbols=symdownloadallsymbols;
|
||||
_dbgfunctions.AssembleAtEx = _assembleatex;
|
||||
_dbgfunctions.SectionFromAddr = _sectionfromaddr;
|
||||
_dbgfunctions.ModNameFromAddr = modnamefromaddr;
|
||||
_dbgfunctions.ModBaseFromAddr = modbasefromaddr;
|
||||
_dbgfunctions.ModBaseFromName = modbasefromname;
|
||||
_dbgfunctions.ModSizeFromAddr = modsizefromaddr;
|
||||
_dbgfunctions.Assemble = assemble;
|
||||
_dbgfunctions.PatchGet = _patchget;
|
||||
_dbgfunctions.PatchInRange = _patchinrange;
|
||||
_dbgfunctions.MemPatch = _mempatch;
|
||||
_dbgfunctions.PatchRestoreRange = _patchrestorerange;
|
||||
_dbgfunctions.PatchEnum = (PATCHENUM)patchenum;
|
||||
_dbgfunctions.PatchRestore = _patchrestore;
|
||||
_dbgfunctions.PatchFile = (PATCHFILE)patchfile;
|
||||
_dbgfunctions.ModPathFromAddr = _modpathfromaddr;
|
||||
_dbgfunctions.ModPathFromName = _modpathfromname;
|
||||
_dbgfunctions.DisasmFast = disasmfast;
|
||||
_dbgfunctions.MemUpdateMap = memupdatemap;
|
||||
_dbgfunctions.GetCallStack = _getcallstack;
|
||||
_dbgfunctions.SymbolDownloadAllSymbols = symdownloadallsymbols;
|
||||
_dbgfunctions.GetJit=_getjit;
|
||||
_dbgfunctions.GetDefJit=dbggetdefjit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ extern "C" DLL_EXPORT bool _dbg_memwrite(duint addr, const unsigned char* src, d
|
|||
extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
|
||||
{
|
||||
CriticalSectionLocker locker(LockMemoryPages);
|
||||
int pagecount=(int)memoryPages.size();
|
||||
int pagecount = (int)memoryPages.size();
|
||||
memset(memmap, 0, sizeof(MEMMAP));
|
||||
memmap->count=pagecount;
|
||||
memmap->count = pagecount;
|
||||
if(!pagecount)
|
||||
return true;
|
||||
memmap->page=(MEMPAGE*)BridgeAlloc(sizeof(MEMPAGE)*pagecount);
|
||||
memmap->page = (MEMPAGE*)BridgeAlloc(sizeof(MEMPAGE) * pagecount);
|
||||
memset(memmap->page, 0, sizeof(MEMPAGE)*pagecount);
|
||||
int j=0;
|
||||
for(MemoryMap::iterator i=memoryPages.begin(); i!=memoryPages.end(); ++i,j++)
|
||||
int j = 0;
|
||||
for(MemoryMap::iterator i = memoryPages.begin(); i != memoryPages.end(); ++i, j++)
|
||||
memcpy(&memmap->page[j], &i->second, sizeof(MEMPAGE));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -71,11 +71,11 @@ extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
|
|||
static uint cacheFlags;
|
||||
static uint cacheAddr;
|
||||
static bool cacheResult;
|
||||
if(cacheAddr!=addr or cacheFlags!=GetContextDataEx(hActiveThread, UE_EFLAGS))
|
||||
if(cacheAddr != addr or cacheFlags != GetContextDataEx(hActiveThread, UE_EFLAGS))
|
||||
{
|
||||
cacheFlags=GetContextDataEx(hActiveThread, UE_EFLAGS);
|
||||
cacheAddr=addr;
|
||||
cacheResult=IsJumpGoingToExecuteEx(fdProcessInfo->hProcess, fdProcessInfo->hThread, (ULONG_PTR)cacheAddr, cacheFlags);
|
||||
cacheFlags = GetContextDataEx(hActiveThread, UE_EFLAGS);
|
||||
cacheAddr = addr;
|
||||
cacheResult = IsJumpGoingToExecuteEx(fdProcessInfo->hProcess, fdProcessInfo->hThread, (ULONG_PTR)cacheAddr, cacheFlags);
|
||||
}
|
||||
return cacheResult;
|
||||
}
|
||||
|
|
@ -84,23 +84,23 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
bool retval=false;
|
||||
if(addrinfo->flags&flagmodule) //get module
|
||||
bool retval = false;
|
||||
if(addrinfo->flags & flagmodule) //get module
|
||||
{
|
||||
char module[64]="";
|
||||
if(modnamefromaddr(addr, module, false) and strlen(module)<MAX_MODULE_SIZE) //get module name
|
||||
char module[64] = "";
|
||||
if(modnamefromaddr(addr, module, false) and strlen(module) < MAX_MODULE_SIZE) //get module name
|
||||
{
|
||||
strcpy(addrinfo->module, module);
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
if(addrinfo->flags&flaglabel)
|
||||
if(addrinfo->flags & flaglabel)
|
||||
{
|
||||
if(labelget(addr, addrinfo->label))
|
||||
retval=true;
|
||||
retval = true;
|
||||
else //no user labels
|
||||
{
|
||||
DWORD64 displacement=0;
|
||||
DWORD64 displacement = 0;
|
||||
char buffer[sizeof(SYMBOL_INFO) + MAX_LABEL_SIZE * sizeof(char)];
|
||||
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
|
||||
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
|
|
@ -109,7 +109,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
{
|
||||
if(settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
|
||||
strcpy(addrinfo->label, pSymbol->Name);
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
if(!retval) //search for CALL <jmp.&user32.MessageBoxA>
|
||||
{
|
||||
|
|
@ -117,40 +117,40 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
memset(&basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO));
|
||||
if(disasmfast(addr, &basicinfo) && basicinfo.branch && !basicinfo.call && basicinfo.memory.value) //thing is a JMP
|
||||
{
|
||||
uint val=0;
|
||||
uint val = 0;
|
||||
if(memread(fdProcessInfo->hProcess, (const void*)basicinfo.memory.value, &val, sizeof(val), 0))
|
||||
{
|
||||
if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement)
|
||||
{
|
||||
if(settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
|
||||
sprintf_s(addrinfo->label, "JMP.&%s", pSymbol->Name);
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(addrinfo->flags&flagbookmark)
|
||||
if(addrinfo->flags & flagbookmark)
|
||||
{
|
||||
addrinfo->isbookmark=bookmarkget(addr);
|
||||
retval=true;
|
||||
addrinfo->isbookmark = bookmarkget(addr);
|
||||
retval = true;
|
||||
}
|
||||
if(addrinfo->flags&flagfunction)
|
||||
if(addrinfo->flags & flagfunction)
|
||||
{
|
||||
if(functionget(addr, &addrinfo->function.start, &addrinfo->function.end))
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
if(addrinfo->flags&flagloop)
|
||||
if(addrinfo->flags & flagloop)
|
||||
{
|
||||
if(loopget(addrinfo->loop.depth, addr, &addrinfo->loop.start, &addrinfo->loop.end))
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
if(addrinfo->flags&flagcomment)
|
||||
if(addrinfo->flags & flagcomment)
|
||||
{
|
||||
*addrinfo->comment=0;
|
||||
*addrinfo->comment = 0;
|
||||
if(commentget(addr, addrinfo->comment))
|
||||
retval=true;
|
||||
retval = true;
|
||||
else
|
||||
{
|
||||
DWORD dwDisplacement;
|
||||
|
|
@ -158,50 +158,50 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
if(SymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement)
|
||||
{
|
||||
char filename[deflen]="";
|
||||
char filename[deflen] = "";
|
||||
strcpy(filename, line.FileName);
|
||||
int len=(int)strlen(filename);
|
||||
while(filename[len]!='\\' and len!=0)
|
||||
int len = (int)strlen(filename);
|
||||
while(filename[len] != '\\' and len != 0)
|
||||
len--;
|
||||
if(len)
|
||||
len++;
|
||||
sprintf(addrinfo->comment, "%s:%u", filename+len, line.LineNumber);
|
||||
retval=true;
|
||||
sprintf(addrinfo->comment, "%s:%u", filename + len, line.LineNumber);
|
||||
retval = true;
|
||||
}
|
||||
else if(!bOnlyCipAutoComments || addr == GetContextDataEx(hActiveThread, UE_CIP)) //no line number
|
||||
{
|
||||
DISASM_INSTR instr;
|
||||
std::string temp_string;
|
||||
ADDRINFO newinfo;
|
||||
char ascii[256*2]="";
|
||||
char unicode[256*2]="";
|
||||
char ascii[256 * 2] = "";
|
||||
char unicode[256 * 2] = "";
|
||||
|
||||
memset(&instr, 0, sizeof(DISASM_INSTR));
|
||||
disasmget(addr, &instr);
|
||||
int len_left=MAX_COMMENT_SIZE;
|
||||
for(int i=0,j=0; i<instr.argcount; i++)
|
||||
int len_left = MAX_COMMENT_SIZE;
|
||||
for(int i = 0, j = 0; i < instr.argcount; i++)
|
||||
{
|
||||
memset(&newinfo, 0, sizeof(ADDRINFO));
|
||||
newinfo.flags=flaglabel;
|
||||
newinfo.flags = flaglabel;
|
||||
|
||||
STRING_TYPE strtype=str_none;
|
||||
STRING_TYPE strtype = str_none;
|
||||
|
||||
if(instr.arg[i].constant==instr.arg[i].value) //avoid: call <module.label> ; addr:label
|
||||
if(instr.arg[i].constant == instr.arg[i].value) //avoid: call <module.label> ; addr:label
|
||||
{
|
||||
if(instr.type==instr_branch or !disasmgetstringat(instr.arg[i].constant, &strtype, ascii, unicode, len_left) or strtype==str_none)
|
||||
if(instr.type == instr_branch or !disasmgetstringat(instr.arg[i].constant, &strtype, ascii, unicode, len_left) or strtype == str_none)
|
||||
continue;
|
||||
switch(strtype)
|
||||
{
|
||||
case str_none:
|
||||
break;
|
||||
case str_ascii:
|
||||
temp_string=instr.arg[i].mnemonic;
|
||||
temp_string = instr.arg[i].mnemonic;
|
||||
temp_string.append(":\"");
|
||||
temp_string.append(ascii);
|
||||
temp_string.append("\"");
|
||||
break;
|
||||
case str_unicode:
|
||||
temp_string=instr.arg[i].mnemonic;
|
||||
temp_string = instr.arg[i].mnemonic;
|
||||
temp_string.append(":L\"");
|
||||
temp_string.append(unicode);
|
||||
temp_string.append("\"");
|
||||
|
|
@ -215,20 +215,20 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
case str_none:
|
||||
if(*newinfo.label)
|
||||
{
|
||||
temp_string="[";
|
||||
temp_string = "[";
|
||||
temp_string.append(instr.arg[i].mnemonic);
|
||||
temp_string.append("]:");
|
||||
temp_string.append(newinfo.label);
|
||||
}
|
||||
break;
|
||||
case str_ascii:
|
||||
temp_string="[";
|
||||
temp_string = "[";
|
||||
temp_string.append(instr.arg[i].mnemonic);
|
||||
temp_string.append("]:");
|
||||
temp_string.append(ascii);
|
||||
break;
|
||||
case str_unicode:
|
||||
temp_string="[";
|
||||
temp_string = "[";
|
||||
temp_string.append(instr.arg[i].mnemonic);
|
||||
temp_string.append("]:");
|
||||
temp_string.append(unicode);
|
||||
|
|
@ -237,26 +237,26 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
}
|
||||
else if(instr.arg[i].value and (disasmgetstringat(instr.arg[i].value, &strtype, ascii, unicode, len_left) or _dbg_addrinfoget(instr.arg[i].value, instr.arg[i].segment, &newinfo)))
|
||||
{
|
||||
if(instr.type!=instr_normal) //stack/jumps (eg add esp,4 or jmp 401110) cannot directly point to strings
|
||||
strtype=str_none;
|
||||
if(instr.type != instr_normal) //stack/jumps (eg add esp,4 or jmp 401110) cannot directly point to strings
|
||||
strtype = str_none;
|
||||
switch(strtype)
|
||||
{
|
||||
case str_none:
|
||||
if(*newinfo.label)
|
||||
{
|
||||
temp_string=instr.arg[i].mnemonic;
|
||||
temp_string = instr.arg[i].mnemonic;
|
||||
temp_string.append(":");
|
||||
temp_string.append(newinfo.label);
|
||||
}
|
||||
break;
|
||||
case str_ascii:
|
||||
temp_string=instr.arg[i].mnemonic;
|
||||
temp_string = instr.arg[i].mnemonic;
|
||||
temp_string.append(":\"");
|
||||
temp_string.append(ascii);
|
||||
temp_string.append("\"");
|
||||
break;
|
||||
case str_unicode:
|
||||
temp_string=instr.arg[i].mnemonic;
|
||||
temp_string = instr.arg[i].mnemonic;
|
||||
temp_string.append(":L\"");
|
||||
temp_string.append(unicode);
|
||||
temp_string.append("\"");
|
||||
|
|
@ -268,14 +268,14 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
|
||||
if(!strstr(addrinfo->comment, temp_string.c_str()))
|
||||
{
|
||||
unsigned int maxlen=MAX_COMMENT_SIZE-j-1;
|
||||
if(maxlen<temp_string.length())
|
||||
temp_string.at(maxlen-1)=0;
|
||||
unsigned int maxlen = MAX_COMMENT_SIZE - j - 1;
|
||||
if(maxlen < temp_string.length())
|
||||
temp_string.at(maxlen - 1) = 0;
|
||||
if(j)
|
||||
j+=sprintf(addrinfo->comment+j, ", %s", temp_string.c_str());
|
||||
j += sprintf(addrinfo->comment + j, ", %s", temp_string.c_str());
|
||||
else
|
||||
j+=sprintf(addrinfo->comment+j, "%s", temp_string.c_str());
|
||||
retval=true;
|
||||
j += sprintf(addrinfo->comment + j, "%s", temp_string.c_str());
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -286,23 +286,23 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
|
|||
|
||||
extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo)
|
||||
{
|
||||
bool retval=false;
|
||||
if(addrinfo->flags&flaglabel) //set label
|
||||
bool retval = false;
|
||||
if(addrinfo->flags & flaglabel) //set label
|
||||
{
|
||||
if(labelset(addr, addrinfo->label, true))
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
if(addrinfo->flags&flagcomment) //set comment
|
||||
if(addrinfo->flags & flagcomment) //set comment
|
||||
{
|
||||
if(commentset(addr, addrinfo->comment, true))
|
||||
retval=true;
|
||||
retval = true;
|
||||
}
|
||||
if(addrinfo->flags&flagbookmark) //set bookmark
|
||||
if(addrinfo->flags & flagbookmark) //set bookmark
|
||||
{
|
||||
if(addrinfo->isbookmark)
|
||||
retval=bookmarkset(addr, true);
|
||||
retval = bookmarkset(addr, true);
|
||||
else
|
||||
retval=bookmarkdel(addr);
|
||||
retval = bookmarkdel(addr);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
|
@ -312,22 +312,22 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
|
|||
static uint cacheAddr;
|
||||
static int cacheBpCount;
|
||||
static int cacheResult;
|
||||
int bpcount=bpgetlist(0);
|
||||
if(cacheAddr!=addr or cacheBpCount!=bpcount)
|
||||
int bpcount = bpgetlist(0);
|
||||
if(cacheAddr != addr or cacheBpCount != bpcount)
|
||||
{
|
||||
BREAKPOINT bp;
|
||||
cacheAddr=addr;
|
||||
cacheResult=0;
|
||||
cacheBpCount=bpcount;
|
||||
cacheAddr = addr;
|
||||
cacheResult = 0;
|
||||
cacheBpCount = bpcount;
|
||||
if(bpget(addr, BPNORMAL, 0, &bp))
|
||||
if(bp.enabled)
|
||||
cacheResult|=bp_normal;
|
||||
cacheResult |= bp_normal;
|
||||
if(bpget(addr, BPHARDWARE, 0, &bp))
|
||||
if(bp.enabled)
|
||||
cacheResult|=bp_hardware;
|
||||
cacheResult |= bp_hardware;
|
||||
if(bpget(addr, BPMEMORY, 0, &bp))
|
||||
if(bp.enabled)
|
||||
cacheResult|=bp_memory;
|
||||
cacheResult |= bp_memory;
|
||||
}
|
||||
return cacheResult;
|
||||
}
|
||||
|
|
@ -341,89 +341,89 @@ extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
|
|||
}
|
||||
REGDUMP r;
|
||||
#ifdef _WIN64
|
||||
r.cax=GetContextDataEx(hActiveThread, UE_RAX);
|
||||
r.cax = GetContextDataEx(hActiveThread, UE_RAX);
|
||||
#else
|
||||
r.cax=(duint)GetContextDataEx(hActiveThread, UE_EAX);
|
||||
r.cax = (duint)GetContextDataEx(hActiveThread, UE_EAX);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.ccx=GetContextDataEx(hActiveThread, UE_RCX);
|
||||
r.ccx = GetContextDataEx(hActiveThread, UE_RCX);
|
||||
#else
|
||||
r.ccx=(duint)GetContextDataEx(hActiveThread, UE_ECX);
|
||||
r.ccx = (duint)GetContextDataEx(hActiveThread, UE_ECX);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.cdx=GetContextDataEx(hActiveThread, UE_RDX);
|
||||
r.cdx = GetContextDataEx(hActiveThread, UE_RDX);
|
||||
#else
|
||||
r.cdx=(duint)GetContextDataEx(hActiveThread, UE_EDX);
|
||||
r.cdx = (duint)GetContextDataEx(hActiveThread, UE_EDX);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.cbx=GetContextDataEx(hActiveThread, UE_RBX);
|
||||
r.cbx = GetContextDataEx(hActiveThread, UE_RBX);
|
||||
#else
|
||||
r.cbx=(duint)GetContextDataEx(hActiveThread, UE_EBX);
|
||||
r.cbx = (duint)GetContextDataEx(hActiveThread, UE_EBX);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.cbp=GetContextDataEx(hActiveThread, UE_RBP);
|
||||
r.cbp = GetContextDataEx(hActiveThread, UE_RBP);
|
||||
#else
|
||||
r.cbp=(duint)GetContextDataEx(hActiveThread, UE_EBP);
|
||||
r.cbp = (duint)GetContextDataEx(hActiveThread, UE_EBP);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.csi=GetContextDataEx(hActiveThread, UE_RSI);
|
||||
r.csi = GetContextDataEx(hActiveThread, UE_RSI);
|
||||
#else
|
||||
r.csi=(duint)GetContextDataEx(hActiveThread, UE_ESI);
|
||||
r.csi = (duint)GetContextDataEx(hActiveThread, UE_ESI);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.cdi=GetContextDataEx(hActiveThread, UE_RDI);
|
||||
r.cdi = GetContextDataEx(hActiveThread, UE_RDI);
|
||||
#else
|
||||
r.cdi=(duint)GetContextDataEx(hActiveThread, UE_EDI);
|
||||
r.cdi = (duint)GetContextDataEx(hActiveThread, UE_EDI);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r8=GetContextDataEx(hActiveThread, UE_R8);
|
||||
r.r8 = GetContextDataEx(hActiveThread, UE_R8);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r9=GetContextDataEx(hActiveThread, UE_R9);
|
||||
r.r9 = GetContextDataEx(hActiveThread, UE_R9);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r10=GetContextDataEx(hActiveThread, UE_R10);
|
||||
r.r10 = GetContextDataEx(hActiveThread, UE_R10);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r11=GetContextDataEx(hActiveThread, UE_R11);
|
||||
r.r11 = GetContextDataEx(hActiveThread, UE_R11);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r12=GetContextDataEx(hActiveThread, UE_R12);
|
||||
r.r12 = GetContextDataEx(hActiveThread, UE_R12);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r13=GetContextDataEx(hActiveThread, UE_R13);
|
||||
r.r13 = GetContextDataEx(hActiveThread, UE_R13);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r14=GetContextDataEx(hActiveThread, UE_R14);
|
||||
r.r14 = GetContextDataEx(hActiveThread, UE_R14);
|
||||
#endif // _WIN64
|
||||
#ifdef _WIN64
|
||||
r.r15=GetContextDataEx(hActiveThread, UE_R15);
|
||||
r.r15 = GetContextDataEx(hActiveThread, UE_R15);
|
||||
#endif // _WIN64
|
||||
r.csp=(duint)GetContextDataEx(hActiveThread, UE_CSP);
|
||||
r.cip=(duint)GetContextDataEx(hActiveThread, UE_CIP);
|
||||
r.eflags=(unsigned int)GetContextDataEx(hActiveThread, UE_EFLAGS);
|
||||
r.gs=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_GS)&0xFFFF);
|
||||
r.fs=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_FS)&0xFFFF);
|
||||
r.es=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_ES)&0xFFFF);
|
||||
r.ds=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_DS)&0xFFFF);
|
||||
r.cs=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_CS)&0xFFFF);
|
||||
r.ss=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_SS)&0xFFFF);
|
||||
r.dr0=(duint)GetContextDataEx(hActiveThread, UE_DR0);
|
||||
r.dr1=(duint)GetContextDataEx(hActiveThread, UE_DR1);
|
||||
r.dr2=(duint)GetContextDataEx(hActiveThread, UE_DR2);
|
||||
r.dr3=(duint)GetContextDataEx(hActiveThread, UE_DR3);
|
||||
r.dr6=(duint)GetContextDataEx(hActiveThread, UE_DR6);
|
||||
r.dr7=(duint)GetContextDataEx(hActiveThread, UE_DR7);
|
||||
duint cflags=r.eflags;
|
||||
r.flags.c=valflagfromstring(cflags, "cf");
|
||||
r.flags.p=valflagfromstring(cflags, "pf");
|
||||
r.flags.a=valflagfromstring(cflags, "af");
|
||||
r.flags.z=valflagfromstring(cflags, "zf");
|
||||
r.flags.s=valflagfromstring(cflags, "sf");
|
||||
r.flags.t=valflagfromstring(cflags, "tf");
|
||||
r.flags.i=valflagfromstring(cflags, "if");
|
||||
r.flags.d=valflagfromstring(cflags, "df");
|
||||
r.flags.o=valflagfromstring(cflags, "of");
|
||||
r.csp = (duint)GetContextDataEx(hActiveThread, UE_CSP);
|
||||
r.cip = (duint)GetContextDataEx(hActiveThread, UE_CIP);
|
||||
r.eflags = (unsigned int)GetContextDataEx(hActiveThread, UE_EFLAGS);
|
||||
r.gs = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_GS) & 0xFFFF);
|
||||
r.fs = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_FS) & 0xFFFF);
|
||||
r.es = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_ES) & 0xFFFF);
|
||||
r.ds = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_DS) & 0xFFFF);
|
||||
r.cs = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_CS) & 0xFFFF);
|
||||
r.ss = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_SS) & 0xFFFF);
|
||||
r.dr0 = (duint)GetContextDataEx(hActiveThread, UE_DR0);
|
||||
r.dr1 = (duint)GetContextDataEx(hActiveThread, UE_DR1);
|
||||
r.dr2 = (duint)GetContextDataEx(hActiveThread, UE_DR2);
|
||||
r.dr3 = (duint)GetContextDataEx(hActiveThread, UE_DR3);
|
||||
r.dr6 = (duint)GetContextDataEx(hActiveThread, UE_DR6);
|
||||
r.dr7 = (duint)GetContextDataEx(hActiveThread, UE_DR7);
|
||||
duint cflags = r.eflags;
|
||||
r.flags.c = valflagfromstring(cflags, "cf");
|
||||
r.flags.p = valflagfromstring(cflags, "pf");
|
||||
r.flags.a = valflagfromstring(cflags, "af");
|
||||
r.flags.z = valflagfromstring(cflags, "zf");
|
||||
r.flags.s = valflagfromstring(cflags, "sf");
|
||||
r.flags.t = valflagfromstring(cflags, "tf");
|
||||
r.flags.i = valflagfromstring(cflags, "if");
|
||||
r.flags.d = valflagfromstring(cflags, "df");
|
||||
r.flags.o = valflagfromstring(cflags, "of");
|
||||
memcpy(regdump, &r, sizeof(REGDUMP));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -438,18 +438,18 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
|
|||
if(!bpmap)
|
||||
return 0;
|
||||
std::vector<BREAKPOINT> list;
|
||||
int bpcount=bpgetlist(&list);
|
||||
if(bpcount==0)
|
||||
int bpcount = bpgetlist(&list);
|
||||
if(bpcount == 0)
|
||||
{
|
||||
bpmap->count=0;
|
||||
bpmap->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int retcount=0;
|
||||
int retcount = 0;
|
||||
std::vector<BRIDGEBP> bridgeList;
|
||||
BRIDGEBP curBp;
|
||||
unsigned short slot=0;
|
||||
for(int i=0; i<bpcount; i++)
|
||||
unsigned short slot = 0;
|
||||
for(int i = 0; i < bpcount; i++)
|
||||
{
|
||||
memset(&curBp, 0, sizeof(BRIDGEBP));
|
||||
switch(type)
|
||||
|
|
@ -457,15 +457,15 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
|
|||
case bp_none: //all types
|
||||
break;
|
||||
case bp_normal: //normal
|
||||
if(list[i].type!=BPNORMAL)
|
||||
if(list[i].type != BPNORMAL)
|
||||
continue;
|
||||
break;
|
||||
case bp_hardware: //hardware
|
||||
if(list[i].type!=BPHARDWARE)
|
||||
if(list[i].type != BPHARDWARE)
|
||||
continue;
|
||||
break;
|
||||
case bp_memory: //memory
|
||||
if(list[i].type!=BPMEMORY)
|
||||
if(list[i].type != BPMEMORY)
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -474,39 +474,39 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
|
|||
switch(list[i].type)
|
||||
{
|
||||
case BPNORMAL:
|
||||
curBp.type=bp_normal;
|
||||
curBp.type = bp_normal;
|
||||
break;
|
||||
case BPHARDWARE:
|
||||
curBp.type=bp_hardware;
|
||||
curBp.type = bp_hardware;
|
||||
break;
|
||||
case BPMEMORY:
|
||||
curBp.type=bp_memory;
|
||||
curBp.type = bp_memory;
|
||||
break;
|
||||
}
|
||||
switch(((DWORD)list[i].titantype)>>8)
|
||||
switch(((DWORD)list[i].titantype) >> 8)
|
||||
{
|
||||
case UE_DR0:
|
||||
slot=0;
|
||||
slot = 0;
|
||||
break;
|
||||
case UE_DR1:
|
||||
slot=1;
|
||||
slot = 1;
|
||||
break;
|
||||
case UE_DR2:
|
||||
slot=2;
|
||||
slot = 2;
|
||||
break;
|
||||
case UE_DR3:
|
||||
slot=3;
|
||||
slot = 3;
|
||||
break;
|
||||
}
|
||||
curBp.addr=list[i].addr;
|
||||
curBp.enabled=list[i].enabled;
|
||||
curBp.addr = list[i].addr;
|
||||
curBp.enabled = list[i].enabled;
|
||||
//TODO: fix this
|
||||
if(memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr))
|
||||
curBp.active=true;
|
||||
curBp.active = true;
|
||||
strcpy(curBp.mod, list[i].mod);
|
||||
strcpy(curBp.name, list[i].name);
|
||||
curBp.singleshoot=list[i].singleshoot;
|
||||
curBp.slot=slot;
|
||||
curBp.singleshoot = list[i].singleshoot;
|
||||
curBp.slot = slot;
|
||||
if(curBp.active)
|
||||
{
|
||||
bridgeList.push_back(curBp);
|
||||
|
|
@ -515,12 +515,12 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
|
|||
}
|
||||
if(!retcount)
|
||||
{
|
||||
bpmap->count=retcount;
|
||||
bpmap->count = retcount;
|
||||
return retcount;
|
||||
}
|
||||
bpmap->count=retcount;
|
||||
bpmap->bp=(BRIDGEBP*)BridgeAlloc(sizeof(BRIDGEBP)*retcount);
|
||||
for(int i=0; i<retcount; i++)
|
||||
bpmap->count = retcount;
|
||||
bpmap->bp = (BRIDGEBP*)BridgeAlloc(sizeof(BRIDGEBP) * retcount);
|
||||
for(int i = 0; i < retcount; i++)
|
||||
memcpy(&bpmap->bp[i], &bridgeList.at(i), sizeof(BRIDGEBP));
|
||||
return retcount;
|
||||
}
|
||||
|
|
@ -530,17 +530,17 @@ extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr)
|
|||
DISASM_INSTR instr;
|
||||
memset(&instr, 0, sizeof(instr));
|
||||
disasmget(addr, &instr);
|
||||
if(instr.type!=instr_branch)
|
||||
if(instr.type != instr_branch)
|
||||
return 0;
|
||||
if(strstr(instr.instruction, "ret"))
|
||||
{
|
||||
uint atcsp=DbgValFromString("@csp");
|
||||
uint atcsp = DbgValFromString("@csp");
|
||||
if(DbgMemIsValidReadPtr(atcsp))
|
||||
return atcsp;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else if(instr.arg[0].type==arg_memory)
|
||||
else if(instr.arg[0].type == arg_memory)
|
||||
return instr.arg[0].memvalue;
|
||||
else
|
||||
return instr.arg[0].value;
|
||||
|
|
@ -623,7 +623,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
|
||||
case DBG_SYMBOL_ENUM:
|
||||
{
|
||||
SYMBOLCBINFO* cbInfo=(SYMBOLCBINFO*)param1;
|
||||
SYMBOLCBINFO* cbInfo = (SYMBOLCBINFO*)param1;
|
||||
symenum(cbInfo->base, cbInfo->cbSymbolEnum, cbInfo->user);
|
||||
}
|
||||
break;
|
||||
|
|
@ -695,23 +695,23 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
else
|
||||
SetEngineVariable(UE_ENGINE_SET_DEBUG_PRIVILEGE, false);
|
||||
}
|
||||
char exceptionRange[MAX_SETTING_SIZE]="";
|
||||
char exceptionRange[MAX_SETTING_SIZE] = "";
|
||||
dbgclearignoredexceptions();
|
||||
if(BridgeSettingGet("Exceptions", "IgnoreRange", exceptionRange))
|
||||
{
|
||||
char* entry=strtok(exceptionRange, ",");
|
||||
char* entry = strtok(exceptionRange, ",");
|
||||
while(entry)
|
||||
{
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
if(sscanf(entry, "%08X-%08X", &start, &end)==2 && start<=end)
|
||||
if(sscanf(entry, "%08X-%08X", &start, &end) == 2 && start <= end)
|
||||
{
|
||||
ExceptionRange range;
|
||||
range.start=start;
|
||||
range.end=end;
|
||||
range.start = start;
|
||||
range.end = end;
|
||||
dbgaddignoredexception(range);
|
||||
}
|
||||
entry=strtok(0, ",");
|
||||
entry = strtok(0, ",");
|
||||
}
|
||||
}
|
||||
if(BridgeSettingGetUint("Disassembler", "OnlyCipAutoComments", &setting))
|
||||
|
|
@ -734,77 +734,77 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(disasm));
|
||||
#ifdef _WIN64
|
||||
disasm.Archi=64;
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.EIP=(UIntPtr)data;
|
||||
disasm.VirtualAddr=(UInt64)param1;
|
||||
int len=Disasm(&disasm);
|
||||
uint i=0;
|
||||
BASIC_INSTRUCTION_INFO* basicinfo=(BASIC_INSTRUCTION_INFO*)param2;
|
||||
disasm.EIP = (UIntPtr)data;
|
||||
disasm.VirtualAddr = (UInt64)param1;
|
||||
int len = Disasm(&disasm);
|
||||
uint i = 0;
|
||||
BASIC_INSTRUCTION_INFO* basicinfo = (BASIC_INSTRUCTION_INFO*)param2;
|
||||
fillbasicinfo(&disasm, basicinfo);
|
||||
basicinfo->size=len;
|
||||
basicinfo->size = len;
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_MENU_ENTRY_CLICKED:
|
||||
{
|
||||
int hEntry=(int)(uint)param1;
|
||||
int hEntry = (int)(uint)param1;
|
||||
pluginmenucall(hEntry);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_FUNCTION_GET:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)functionget(info->addr, &info->start, &info->end);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_FUNCTION_OVERLAPS:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)functionoverlaps(info->start, info->end);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_FUNCTION_ADD:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)functionadd(info->start, info->end, info->manual);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_FUNCTION_DEL:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)functiondel(info->addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_LOOP_GET:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)loopget(info->depth, info->addr, &info->start, &info->end);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_LOOP_OVERLAPS:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)loopoverlaps(info->depth, info->start, info->end, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_LOOP_ADD:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)loopadd(info->start, info->end, info->manual);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_LOOP_DEL:
|
||||
{
|
||||
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
|
||||
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
|
||||
return (uint)loopdel(info->depth, info->addr);
|
||||
}
|
||||
break;
|
||||
|
|
@ -875,10 +875,10 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
case DBG_GET_STRING_AT:
|
||||
{
|
||||
STRING_TYPE strtype;
|
||||
char string[512]="";
|
||||
char string[512] = "";
|
||||
if(disasmgetstringat((uint)param1, &strtype, string, string, 500))
|
||||
{
|
||||
if(strtype==str_ascii)
|
||||
if(strtype == str_ascii)
|
||||
sprintf((char*)param2, "\"%s\"", string);
|
||||
else //unicode
|
||||
sprintf((char*)param2, "L\"%s\"", string);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#include <new>
|
||||
|
||||
HINSTANCE hInst;
|
||||
char dbbasepath[deflen]="";
|
||||
char dbpath[3*deflen]="";
|
||||
char dbbasepath[deflen] = "";
|
||||
char dbpath[3 * deflen] = "";
|
||||
|
||||
void* emalloc(size_t size)
|
||||
{
|
||||
|
|
@ -15,12 +15,12 @@ void efree(void* ptr)
|
|||
efree(ptr, "efree:???");
|
||||
}
|
||||
|
||||
static int emalloc_count=0;
|
||||
static char alloctrace[MAX_PATH]="";
|
||||
static int emalloc_count = 0;
|
||||
static char alloctrace[MAX_PATH] = "";
|
||||
|
||||
void* emalloc(size_t size, const char* reason)
|
||||
{
|
||||
unsigned char* a=(unsigned char*)GlobalAlloc(GMEM_FIXED, size);
|
||||
unsigned char* a = (unsigned char*)GlobalAlloc(GMEM_FIXED, size);
|
||||
if(!a)
|
||||
{
|
||||
MessageBoxA(0, "Could not allocate memory", "Error", MB_ICONERROR);
|
||||
|
|
@ -62,23 +62,23 @@ bool arraycontains(const char* cmd_list, const char* cmd)
|
|||
//TODO: fix this function a little
|
||||
if(!cmd_list or !cmd)
|
||||
return false;
|
||||
char temp[deflen]="";
|
||||
char temp[deflen] = "";
|
||||
strcpy(temp, cmd_list);
|
||||
int len=(int)strlen(cmd_list);
|
||||
if(len>=deflen)
|
||||
int len = (int)strlen(cmd_list);
|
||||
if(len >= deflen)
|
||||
return false;
|
||||
for(int i=0; i<len; i++)
|
||||
if(temp[i]==1)
|
||||
temp[i]=0;
|
||||
for(int i = 0; i < len; i++)
|
||||
if(temp[i] == 1)
|
||||
temp[i] = 0;
|
||||
if(!_stricmp(temp, cmd))
|
||||
return true;
|
||||
for(int i=(int)strlen(temp); i<len; i++)
|
||||
for(int i = (int)strlen(temp); i < len; i++)
|
||||
{
|
||||
if(!temp[i])
|
||||
{
|
||||
if(!_stricmp(temp+i+1, cmd))
|
||||
if(!_stricmp(temp + i + 1, cmd))
|
||||
return true;
|
||||
i+=(int)strlen(temp+i+1);
|
||||
i += (int)strlen(temp + i + 1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -93,40 +93,40 @@ bool scmp(const char* a, const char* b)
|
|||
|
||||
void formathex(char* string)
|
||||
{
|
||||
int len=(int)strlen(string);
|
||||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
char* new_string=(char*)emalloc(len+1, "formathex:new_string");
|
||||
memset(new_string, 0, len+1);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
char* new_string = (char*)emalloc(len + 1, "formathex:new_string");
|
||||
memset(new_string, 0, len + 1);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
if(isxdigit(string[i]))
|
||||
j+=sprintf(new_string+j, "%c", string[i]);
|
||||
j += sprintf(new_string + j, "%c", string[i]);
|
||||
strcpy(string, new_string);
|
||||
efree(new_string, "formathex:new_string");
|
||||
}
|
||||
|
||||
void formatdec(char* string)
|
||||
{
|
||||
int len=(int)strlen(string);
|
||||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
char* new_string=(char*)emalloc(len+1, "formatdec:new_string");
|
||||
memset(new_string, 0, len+1);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
char* new_string = (char*)emalloc(len + 1, "formatdec:new_string");
|
||||
memset(new_string, 0, len + 1);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
if(isdigit(string[i]))
|
||||
j+=sprintf(new_string+j, "%c", string[i]);
|
||||
j += sprintf(new_string + j, "%c", string[i]);
|
||||
strcpy(string, new_string);
|
||||
efree(new_string, "formatdec:new_string");
|
||||
}
|
||||
|
||||
bool FileExists(const char* file)
|
||||
{
|
||||
DWORD attrib=GetFileAttributes(file);
|
||||
DWORD attrib = GetFileAttributes(file);
|
||||
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
bool DirExists(const char* dir)
|
||||
{
|
||||
DWORD attrib=GetFileAttributes(dir);
|
||||
return (attrib==FILE_ATTRIBUTE_DIRECTORY);
|
||||
DWORD attrib = GetFileAttributes(dir);
|
||||
return (attrib == FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)
|
||||
|
|
|
|||
|
|
@ -56,38 +56,38 @@ typedef long sint;
|
|||
|
||||
enum BITMASK
|
||||
{
|
||||
BIT1=0x1,
|
||||
BIT2=0x2,
|
||||
BIT3=0x4,
|
||||
BIT4=0x8,
|
||||
BIT5=0x10,
|
||||
BIT6=0x20,
|
||||
BIT7=0x40,
|
||||
BIT8=0x80,
|
||||
BIT9=0x100,
|
||||
BIT10=0x200,
|
||||
BIT11=0x400,
|
||||
BIT12=0x800,
|
||||
BIT13=0x1000,
|
||||
BIT14=0x2000,
|
||||
BIT15=0x4000,
|
||||
BIT16=0x8000,
|
||||
BIT17=0x10000,
|
||||
BIT18=0x20000,
|
||||
BIT19=0x40000,
|
||||
BIT20=0x80000,
|
||||
BIT21=0x100000,
|
||||
BIT22=0x200000,
|
||||
BIT23=0x400000,
|
||||
BIT24=0x800000,
|
||||
BIT25=0x1000000,
|
||||
BIT26=0x2000000,
|
||||
BIT27=0x4000000,
|
||||
BIT28=0x8000000,
|
||||
BIT29=0x10000000,
|
||||
BIT30=0x20000000,
|
||||
BIT31=0x40000000,
|
||||
BIT32=0x80000000
|
||||
BIT1 = 0x1,
|
||||
BIT2 = 0x2,
|
||||
BIT3 = 0x4,
|
||||
BIT4 = 0x8,
|
||||
BIT5 = 0x10,
|
||||
BIT6 = 0x20,
|
||||
BIT7 = 0x40,
|
||||
BIT8 = 0x80,
|
||||
BIT9 = 0x100,
|
||||
BIT10 = 0x200,
|
||||
BIT11 = 0x400,
|
||||
BIT12 = 0x800,
|
||||
BIT13 = 0x1000,
|
||||
BIT14 = 0x2000,
|
||||
BIT15 = 0x4000,
|
||||
BIT16 = 0x8000,
|
||||
BIT17 = 0x10000,
|
||||
BIT18 = 0x20000,
|
||||
BIT19 = 0x40000,
|
||||
BIT20 = 0x80000,
|
||||
BIT21 = 0x100000,
|
||||
BIT22 = 0x200000,
|
||||
BIT23 = 0x400000,
|
||||
BIT24 = 0x800000,
|
||||
BIT25 = 0x1000000,
|
||||
BIT26 = 0x2000000,
|
||||
BIT27 = 0x4000000,
|
||||
BIT28 = 0x8000000,
|
||||
BIT29 = 0x10000000,
|
||||
BIT30 = 0x20000000,
|
||||
BIT31 = 0x40000000,
|
||||
BIT32 = 0x80000000
|
||||
};
|
||||
|
||||
enum arch
|
||||
|
|
@ -101,7 +101,7 @@ enum arch
|
|||
//superglobal variables
|
||||
extern HINSTANCE hInst;
|
||||
extern char dbbasepath[deflen];
|
||||
extern char dbpath[3*deflen];
|
||||
extern char dbpath[3 * deflen];
|
||||
|
||||
//functions
|
||||
void* emalloc(size_t size);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -10,7 +10,7 @@ typedef std::pair<int, ModuleRange> DepthModuleRange; //depth + modulerange
|
|||
|
||||
struct RangeCompare
|
||||
{
|
||||
bool operator()(const Range& a, const Range& b) const //a before b?
|
||||
bool operator()(const Range & a, const Range & b) const //a before b?
|
||||
{
|
||||
return a.second < b.first;
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ struct RangeCompare
|
|||
|
||||
struct OverlappingRangeCompare
|
||||
{
|
||||
bool operator()(const Range& a, const Range& b) const //a before b?
|
||||
bool operator()(const Range & a, const Range & b) const //a before b?
|
||||
{
|
||||
return a.second < b.first || a.second < b.second;
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ struct OverlappingRangeCompare
|
|||
|
||||
struct ModuleRangeCompare
|
||||
{
|
||||
bool operator()(const ModuleRange& a, const ModuleRange& b) const
|
||||
bool operator()(const ModuleRange & a, const ModuleRange & b) const
|
||||
{
|
||||
if(a.first < b.first) //module hash is smaller
|
||||
return true;
|
||||
|
|
@ -38,7 +38,7 @@ struct ModuleRangeCompare
|
|||
|
||||
struct DepthModuleRangeCompare
|
||||
{
|
||||
bool operator()(const DepthModuleRange& a, const DepthModuleRange& b) const
|
||||
bool operator()(const DepthModuleRange & a, const DepthModuleRange & b) const
|
||||
{
|
||||
if(a.first < b.first) //module depth is smaller
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -24,117 +24,117 @@ formatarg:
|
|||
*/
|
||||
void argformat(char* cmd)
|
||||
{
|
||||
if(strlen(cmd)>=deflen)
|
||||
if(strlen(cmd) >= deflen)
|
||||
return;
|
||||
char command_[deflen]="";
|
||||
char* command=command_;
|
||||
char command_[deflen] = "";
|
||||
char* command = command_;
|
||||
strcpy(command, cmd);
|
||||
while(*command==' ')
|
||||
while(*command == ' ')
|
||||
command++;
|
||||
int len=(int)strlen(command);
|
||||
int start=0;
|
||||
for(int i=0; i<len; i++)
|
||||
if(command[i]==' ')
|
||||
int len = (int)strlen(command);
|
||||
int start = 0;
|
||||
for(int i = 0; i < len; i++)
|
||||
if(command[i] == ' ')
|
||||
{
|
||||
command[i]=0;
|
||||
start=i+1;
|
||||
command[i] = 0;
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
if(!start)
|
||||
start=len;
|
||||
char arguments_[deflen]="";
|
||||
char* arguments=arguments_;
|
||||
strcpy(arguments, command+start);
|
||||
char temp[deflen]="";
|
||||
len=(int)strlen(arguments);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
start = len;
|
||||
char arguments_[deflen] = "";
|
||||
char* arguments = arguments_;
|
||||
strcpy(arguments, command + start);
|
||||
char temp[deflen] = "";
|
||||
len = (int)strlen(arguments);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if(arguments[i]=='"' and arguments[i+1]=='"')
|
||||
i+=2;
|
||||
j+=sprintf(temp+j, "%c", arguments[i]);
|
||||
if(arguments[i] == '"' and arguments[i + 1] == '"')
|
||||
i += 2;
|
||||
j += sprintf(temp + j, "%c", arguments[i]);
|
||||
}
|
||||
strcpy(arguments, temp);
|
||||
len=(int)strlen(arguments);
|
||||
for(int i=0; i<len; i++)
|
||||
if(arguments[i]=='\\' and arguments[i+1]=='\\')
|
||||
len = (int)strlen(arguments);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(arguments[i] == '\\' and arguments[i + 1] == '\\')
|
||||
{
|
||||
arguments[i]=1;
|
||||
arguments[i+1]=1;
|
||||
arguments[i] = 1;
|
||||
arguments[i + 1] = 1;
|
||||
}
|
||||
while((*arguments==',' or *arguments==' ') and *(arguments-1)!='\\')
|
||||
while((*arguments == ',' or * arguments == ' ') and * (arguments - 1) != '\\')
|
||||
arguments++;
|
||||
len=(int)strlen(arguments);
|
||||
while((arguments[len-1]==' ' or arguments[len-1]==',') and arguments[len-2]!='\\')
|
||||
len = (int)strlen(arguments);
|
||||
while((arguments[len - 1] == ' ' or arguments[len - 1] == ',') and arguments[len - 2] != '\\')
|
||||
len--;
|
||||
arguments[len]=0;
|
||||
len=(int)strlen(arguments);
|
||||
int quote_count=0;
|
||||
for(int i=0; i<len; i++)
|
||||
if(arguments[i]=='"')
|
||||
arguments[len] = 0;
|
||||
len = (int)strlen(arguments);
|
||||
int quote_count = 0;
|
||||
for(int i = 0; i < len; i++)
|
||||
if(arguments[i] == '"')
|
||||
quote_count++;
|
||||
if(!(quote_count%2))
|
||||
if(!(quote_count % 2))
|
||||
{
|
||||
for(int i=0; i<len; i++)
|
||||
if(arguments[i]=='"')
|
||||
arguments[i]=0;
|
||||
for(int i = 0; i < len; i++)
|
||||
if(arguments[i] == '"')
|
||||
arguments[i] = 0;
|
||||
|
||||
for(int i=0; i<len; i++)
|
||||
if(arguments[i]==1 and arguments[i+1]==1)
|
||||
for(int i = 0; i < len; i++)
|
||||
if(arguments[i] == 1 and arguments[i + 1] == 1)
|
||||
{
|
||||
arguments[i]='\\';
|
||||
arguments[i+1]='\\';
|
||||
arguments[i] = '\\';
|
||||
arguments[i + 1] = '\\';
|
||||
}
|
||||
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if(!arguments[i])
|
||||
{
|
||||
i++;
|
||||
int len2=(int)strlen(arguments+i);
|
||||
for(int k=0; k<len2; k++)
|
||||
int len2 = (int)strlen(arguments + i);
|
||||
for(int k = 0; k < len2; k++)
|
||||
{
|
||||
if(arguments[i+k]==',' or arguments[i+k]==' ' or arguments[i+k]=='\\')
|
||||
j+=sprintf(temp+j, "\\%c", arguments[i+k]);
|
||||
if(arguments[i + k] == ',' or arguments[i + k] == ' ' or arguments[i + k] == '\\')
|
||||
j += sprintf(temp + j, "\\%c", arguments[i + k]);
|
||||
else
|
||||
j+=sprintf(temp+j, "%c", arguments[i+k]);
|
||||
j += sprintf(temp + j, "%c", arguments[i + k]);
|
||||
}
|
||||
i+=len2;
|
||||
i += len2;
|
||||
}
|
||||
else
|
||||
j+=sprintf(temp+j, "%c", arguments[i]);
|
||||
j += sprintf(temp + j, "%c", arguments[i]);
|
||||
}
|
||||
arguments=arguments_;
|
||||
arguments = arguments_;
|
||||
strcpy(arguments, temp);
|
||||
}
|
||||
len=(int)strlen(arguments);
|
||||
for(int i=0; i<len; i++)
|
||||
if(arguments[i]=='\\' and arguments[i+1]=='\\')
|
||||
len = (int)strlen(arguments);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(arguments[i] == '\\' and arguments[i + 1] == '\\')
|
||||
{
|
||||
arguments[i]=1;
|
||||
arguments[i+1]=1;
|
||||
arguments[i] = 1;
|
||||
arguments[i + 1] = 1;
|
||||
}
|
||||
len=(int)strlen(arguments);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
len = (int)strlen(arguments);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if(arguments[i]==',' and arguments[i+1]==',')
|
||||
i+=2;
|
||||
j+=sprintf(temp+j, "%c", arguments[i]);
|
||||
if(arguments[i] == ',' and arguments[i + 1] == ',')
|
||||
i += 2;
|
||||
j += sprintf(temp + j, "%c", arguments[i]);
|
||||
}
|
||||
strcpy(arguments, temp);
|
||||
len=(int)strlen(arguments);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
len = (int)strlen(arguments);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
while(arguments[i]==' ' and arguments[i-1]!='\\')
|
||||
while(arguments[i] == ' ' and arguments[i - 1] != '\\')
|
||||
i++;
|
||||
j+=sprintf(temp+j, "%c", arguments[i]);
|
||||
j += sprintf(temp + j, "%c", arguments[i]);
|
||||
}
|
||||
strcpy(arguments, temp);
|
||||
len=(int)strlen(arguments);
|
||||
for(int i=0; i<len; i++)
|
||||
if(arguments[i]==1 and arguments[i+1]==1)
|
||||
len = (int)strlen(arguments);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(arguments[i] == 1 and arguments[i + 1] == 1)
|
||||
{
|
||||
arguments[i]='\\';
|
||||
arguments[i+1]='\\';
|
||||
arguments[i] = '\\';
|
||||
arguments[i + 1] = '\\';
|
||||
}
|
||||
if(strlen(arguments))
|
||||
sprintf(cmd, "%s %s", command, arguments);
|
||||
|
|
@ -148,30 +148,30 @@ void argformat(char* cmd)
|
|||
*/
|
||||
int arggetcount(const char* cmd)
|
||||
{
|
||||
int len=(int)strlen(cmd);
|
||||
if(!len or len>=deflen)
|
||||
int len = (int)strlen(cmd);
|
||||
if(!len or len >= deflen)
|
||||
return -1;
|
||||
|
||||
int arg_count=0;
|
||||
int arg_count = 0;
|
||||
|
||||
int start=0;
|
||||
while(cmd[start]!=' ' and start<len)
|
||||
int start = 0;
|
||||
while(cmd[start] != ' ' and start < len)
|
||||
start++;
|
||||
if(start==len)
|
||||
if(start == len)
|
||||
return arg_count;
|
||||
arg_count=1;
|
||||
char temp_[deflen]="";
|
||||
char* temp=temp_+1;
|
||||
arg_count = 1;
|
||||
char temp_[deflen] = "";
|
||||
char* temp = temp_ + 1;
|
||||
strcpy(temp, cmd);
|
||||
for(int i=start; i<len; i++)
|
||||
if(temp[i]=='\\' and temp[i+1]=='\\')
|
||||
for(int i = start; i < len; i++)
|
||||
if(temp[i] == '\\' and temp[i + 1] == '\\')
|
||||
{
|
||||
temp[i]=1;
|
||||
temp[i+1]=1;
|
||||
temp[i] = 1;
|
||||
temp[i + 1] = 1;
|
||||
}
|
||||
for(int i=start; i<len; i++)
|
||||
for(int i = start; i < len; i++)
|
||||
{
|
||||
if(temp[i]==',' and temp[i-1]!='\\')
|
||||
if(temp[i] == ',' and temp[i - 1] != '\\')
|
||||
arg_count++;
|
||||
}
|
||||
return arg_count;
|
||||
|
|
@ -185,68 +185,68 @@ int arggetcount(const char* cmd)
|
|||
*/
|
||||
bool argget(const char* cmd, char* arg, int arg_num, bool optional)
|
||||
{
|
||||
if(strlen(cmd)>=deflen)
|
||||
if(strlen(cmd) >= deflen)
|
||||
return false;
|
||||
int argcount=arggetcount(cmd);
|
||||
if((arg_num+1)>argcount)
|
||||
int argcount = arggetcount(cmd);
|
||||
if((arg_num + 1) > argcount)
|
||||
{
|
||||
if(!optional)
|
||||
dprintf("missing argument nr %d\n", arg_num+1);
|
||||
dprintf("missing argument nr %d\n", arg_num + 1);
|
||||
return false;
|
||||
}
|
||||
int start=0;
|
||||
while(cmd[start]!=' ') //ignore the command
|
||||
int start = 0;
|
||||
while(cmd[start] != ' ') //ignore the command
|
||||
start++;
|
||||
while(cmd[start]==' ') //ignore initial spaces
|
||||
while(cmd[start] == ' ') //ignore initial spaces
|
||||
start++;
|
||||
char temp_[deflen]="";
|
||||
char* temp=temp_+1;
|
||||
strcpy(temp, cmd+start);
|
||||
int len=(int)strlen(temp);
|
||||
for(int i=0; i<len; i++)
|
||||
if(temp[i]=='\\' and temp[i+1]=='\\')
|
||||
char temp_[deflen] = "";
|
||||
char* temp = temp_ + 1;
|
||||
strcpy(temp, cmd + start);
|
||||
int len = (int)strlen(temp);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(temp[i] == '\\' and temp[i + 1] == '\\')
|
||||
{
|
||||
temp[i]=1;
|
||||
temp[i+1]=1;
|
||||
temp[i] = 1;
|
||||
temp[i + 1] = 1;
|
||||
}
|
||||
for(int i=0; i<len; i++)
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
if(temp[i]==',' and temp[i-1]!='\\')
|
||||
temp[i]=0;
|
||||
if(temp[i] == ',' and temp[i - 1] != '\\')
|
||||
temp[i] = 0;
|
||||
}
|
||||
for(int i=0; i<len; i++)
|
||||
if(temp[i]==1 and temp[i+1]==1)
|
||||
for(int i = 0; i < len; i++)
|
||||
if(temp[i] == 1 and temp[i + 1] == 1)
|
||||
{
|
||||
temp[i]='\\';
|
||||
temp[i+1]='\\';
|
||||
temp[i] = '\\';
|
||||
temp[i + 1] = '\\';
|
||||
}
|
||||
char new_temp[deflen]="";
|
||||
int new_len=len;
|
||||
for(int i=0,j=0; i<len; i++) //handle escape characters
|
||||
char new_temp[deflen] = "";
|
||||
int new_len = len;
|
||||
for(int i = 0, j = 0; i < len; i++) //handle escape characters
|
||||
{
|
||||
if(temp[i]=='\\' and (temp[i+1]==',' or temp[i+1]==' ' or temp[i+1]=='\\'))
|
||||
if(temp[i] == '\\' and (temp[i + 1] == ',' or temp[i + 1] == ' ' or temp[i + 1] == '\\'))
|
||||
{
|
||||
new_len--;
|
||||
j+=sprintf(new_temp+j, "%c", temp[i+1]);
|
||||
j += sprintf(new_temp + j, "%c", temp[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
j+=sprintf(new_temp+j, "%c", temp[i]);
|
||||
j += sprintf(new_temp + j, "%c", temp[i]);
|
||||
}
|
||||
len=new_len;
|
||||
memcpy(temp, new_temp, len+1);
|
||||
if(arg_num==0) //first argument
|
||||
len = new_len;
|
||||
memcpy(temp, new_temp, len + 1);
|
||||
if(arg_num == 0) //first argument
|
||||
{
|
||||
strcpy(arg, temp);
|
||||
return true;
|
||||
}
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if(!temp[i])
|
||||
j++;
|
||||
if(j==arg_num)
|
||||
if(j == arg_num)
|
||||
{
|
||||
strcpy(arg, temp+i+1);
|
||||
strcpy(arg, temp + i + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,25 +13,25 @@ static bool cbUnknown(const char* text, ULONGLONG* value)
|
|||
uint val;
|
||||
if(!valfromstring(text, &val))
|
||||
return false;
|
||||
*value=val;
|
||||
*value = val;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction, char* error)
|
||||
{
|
||||
if(strlen(instruction)>=XEDPARSE_MAXBUFSIZE)
|
||||
if(strlen(instruction) >= XEDPARSE_MAXBUFSIZE)
|
||||
return false;
|
||||
XEDPARSE parse;
|
||||
memset(&parse, 0, sizeof(parse));
|
||||
#ifdef _WIN64
|
||||
parse.x64=true;
|
||||
parse.x64 = true;
|
||||
#else //x86
|
||||
parse.x64=false;
|
||||
parse.x64 = false;
|
||||
#endif
|
||||
parse.cbUnknown=cbUnknown;
|
||||
parse.cip=addr;
|
||||
parse.cbUnknown = cbUnknown;
|
||||
parse.cip = addr;
|
||||
strcpy(parse.instr, instruction);
|
||||
if(XEDParseAssemble(&parse)==XEDPARSE_ERROR)
|
||||
if(XEDParseAssemble(&parse) == XEDPARSE_ERROR)
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, parse.error);
|
||||
|
|
@ -41,7 +41,7 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction
|
|||
if(dest)
|
||||
memcpy(dest, parse.dest, parse.dest_size);
|
||||
if(size)
|
||||
*size=parse.dest_size;
|
||||
*size = parse.dest_size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -53,23 +53,23 @@ bool assembleat(uint addr, const char* instruction, int* size, char* error, bool
|
|||
if(!assemble(addr, dest, &destSize, instruction, error))
|
||||
return false;
|
||||
//calculate the number of NOPs to insert
|
||||
int origLen=disasmgetsize(addr);
|
||||
while(origLen<destSize)
|
||||
origLen+=disasmgetsize(addr+origLen);
|
||||
int nopsize=origLen-destSize;
|
||||
int origLen = disasmgetsize(addr);
|
||||
while(origLen < destSize)
|
||||
origLen += disasmgetsize(addr + origLen);
|
||||
int nopsize = origLen - destSize;
|
||||
unsigned char nops[16];
|
||||
memset(nops, 0x90, sizeof(nops));
|
||||
|
||||
if(size)
|
||||
*size=destSize;
|
||||
*size = destSize;
|
||||
|
||||
bool ret=mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0);
|
||||
bool ret = mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0);
|
||||
if(ret && fillnop && nopsize)
|
||||
{
|
||||
if(size)
|
||||
*size+=nopsize;
|
||||
if(!mempatch(fdProcessInfo->hProcess, (void*)(addr+destSize), nops, nopsize, 0))
|
||||
ret=false;
|
||||
*size += nopsize;
|
||||
if(!mempatch(fdProcessInfo->hProcess, (void*)(addr + destSize), nops, nopsize, 0))
|
||||
ret = false;
|
||||
}
|
||||
GuiUpdatePatches();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ int bpgetlist(std::vector<BREAKPOINT>* list)
|
|||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
BREAKPOINT curBp;
|
||||
int count=0;
|
||||
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
|
||||
int count = 0;
|
||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||
{
|
||||
curBp=i->second;
|
||||
curBp.addr+=modbasefromname(curBp.mod);
|
||||
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
|
||||
curBp = i->second;
|
||||
curBp.addr += modbasefromname(curBp.mod);
|
||||
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
|
||||
count++;
|
||||
if(list)
|
||||
list->push_back(curBp);
|
||||
|
|
@ -31,18 +31,18 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty
|
|||
return false;
|
||||
BREAKPOINT bp;
|
||||
modnamefromaddr(addr, bp.mod, true);
|
||||
uint modbase=modbasefromaddr(addr);
|
||||
bp.active=true;
|
||||
bp.addr=addr-modbase;
|
||||
bp.enabled=enabled;
|
||||
if(name and *name)
|
||||
uint modbase = modbasefromaddr(addr);
|
||||
bp.active = true;
|
||||
bp.addr = addr - modbase;
|
||||
bp.enabled = enabled;
|
||||
if(name and * name)
|
||||
strcpy(bp.name, name);
|
||||
else
|
||||
*bp.name='\0';
|
||||
bp.oldbytes=oldbytes;
|
||||
bp.singleshoot=singleshoot;
|
||||
bp.titantype=titantype;
|
||||
bp.type=type;
|
||||
*bp.name = '\0';
|
||||
bp.oldbytes = oldbytes;
|
||||
bp.singleshoot = singleshoot;
|
||||
bp.titantype = titantype;
|
||||
bp.type = type;
|
||||
breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -54,29 +54,29 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
|
|||
BREAKPOINT curBp;
|
||||
if(!name)
|
||||
{
|
||||
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found==breakpoints.end()) //not found
|
||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found == breakpoints.end()) //not found
|
||||
return false;
|
||||
if(!bp)
|
||||
return true;
|
||||
curBp=found->second;
|
||||
curBp.addr+=modbasefromaddr(addr);
|
||||
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
|
||||
*bp=curBp;
|
||||
curBp = found->second;
|
||||
curBp.addr += modbasefromaddr(addr);
|
||||
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
|
||||
*bp = curBp;
|
||||
return true;
|
||||
}
|
||||
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
|
||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||
{
|
||||
curBp=i->second;
|
||||
if(name and *name)
|
||||
curBp = i->second;
|
||||
if(name and * name)
|
||||
{
|
||||
if(!strcmp(name, curBp.name))
|
||||
{
|
||||
if(bp)
|
||||
{
|
||||
curBp.addr+=modbasefromname(curBp.mod);
|
||||
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
|
||||
*bp=curBp;
|
||||
curBp.addr += modbasefromname(curBp.mod);
|
||||
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
|
||||
*bp = curBp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -89,17 +89,17 @@ bool bpdel(uint addr, BP_TYPE type)
|
|||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr)))>0);
|
||||
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0);
|
||||
}
|
||||
|
||||
bool bpenable(uint addr, BP_TYPE type, bool enable)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found==breakpoints.end()) //not found
|
||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found == breakpoints.end()) //not found
|
||||
return false;
|
||||
breakpoints[found->first].enabled=enable;
|
||||
breakpoints[found->first].enabled = enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -107,8 +107,8 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name)
|
|||
{
|
||||
if(!DbgIsDebugging() or !name or !*name)
|
||||
return false;
|
||||
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found==breakpoints.end()) //not found
|
||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found == breakpoints.end()) //not found
|
||||
return false;
|
||||
strcpy(breakpoints[found->first].name, name);
|
||||
return true;
|
||||
|
|
@ -118,10 +118,10 @@ bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
|
|||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found==breakpoints.end()) //not found
|
||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||
if(found == breakpoints.end()) //not found
|
||||
return false;
|
||||
breakpoints[found->first].titantype=titantype;
|
||||
breakpoints[found->first].titantype = titantype;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -129,28 +129,28 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
|
|||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
bool retval=true;
|
||||
bool retval = true;
|
||||
BREAKPOINT curBp;
|
||||
BreakpointsInfo::iterator i=breakpoints.begin();
|
||||
while(i!=breakpoints.end())
|
||||
BreakpointsInfo::iterator i = breakpoints.begin();
|
||||
while(i != breakpoints.end())
|
||||
{
|
||||
BreakpointsInfo::iterator j=i;
|
||||
BreakpointsInfo::iterator j = i;
|
||||
++i;
|
||||
curBp=j->second;
|
||||
curBp.addr+=modbasefromname(curBp.mod); //RVA to VA
|
||||
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing?
|
||||
if(module and *module)
|
||||
curBp = j->second;
|
||||
curBp.addr += modbasefromname(curBp.mod); //RVA to VA
|
||||
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing?
|
||||
if(module and * module)
|
||||
{
|
||||
if(!strcmp(curBp.mod, module))
|
||||
{
|
||||
if(!cbEnum(&curBp))
|
||||
retval=false;
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!cbEnum(&curBp))
|
||||
retval=false;
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
|
|
@ -163,10 +163,10 @@ bool bpenumall(BPENUMCALLBACK cbEnum)
|
|||
|
||||
int bpgetcount(BP_TYPE type, bool enabledonly)
|
||||
{
|
||||
int count=0;
|
||||
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
|
||||
int count = 0;
|
||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||
{
|
||||
if(i->first.first==type && (!enabledonly || i->second.enabled))
|
||||
if(i->first.first == type && (!enabledonly || i->second.enabled))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
|
|
@ -177,39 +177,39 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
|
|||
if(!bp or !bridge)
|
||||
return;
|
||||
memset(bridge, 0, sizeof(BRIDGEBP));
|
||||
bridge->active=bp->active;
|
||||
bridge->addr=bp->addr;
|
||||
bridge->enabled=bp->enabled;
|
||||
bridge->active = bp->active;
|
||||
bridge->addr = bp->addr;
|
||||
bridge->enabled = bp->enabled;
|
||||
strcpy(bridge->mod, bp->mod);
|
||||
strcpy(bridge->name, bp->name);
|
||||
bridge->singleshoot=bp->singleshoot;
|
||||
bridge->singleshoot = bp->singleshoot;
|
||||
switch(bp->type)
|
||||
{
|
||||
case BPNORMAL:
|
||||
bridge->type=bp_normal;
|
||||
bridge->type = bp_normal;
|
||||
break;
|
||||
case BPHARDWARE:
|
||||
bridge->type=bp_hardware;
|
||||
bridge->type = bp_hardware;
|
||||
break;
|
||||
case BPMEMORY:
|
||||
bridge->type=bp_memory;
|
||||
bridge->type = bp_memory;
|
||||
default:
|
||||
bridge->type=bp_none;
|
||||
bridge->type = bp_none;
|
||||
}
|
||||
}
|
||||
|
||||
void bpcachesave(JSON root)
|
||||
{
|
||||
const JSON jsonbreakpoints=json_array();
|
||||
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
|
||||
const JSON jsonbreakpoints = json_array();
|
||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||
{
|
||||
const BREAKPOINT curBreakpoint=i->second;
|
||||
const BREAKPOINT curBreakpoint = i->second;
|
||||
if(curBreakpoint.singleshoot)
|
||||
continue; //skip
|
||||
JSON curjsonbreakpoint=json_object();
|
||||
JSON curjsonbreakpoint = json_object();
|
||||
json_object_set_new(curjsonbreakpoint, "address", json_hex(curBreakpoint.addr));
|
||||
json_object_set_new(curjsonbreakpoint, "enabled", json_boolean(curBreakpoint.enabled));
|
||||
if(curBreakpoint.type==BPNORMAL)
|
||||
if(curBreakpoint.type == BPNORMAL)
|
||||
json_object_set_new(curjsonbreakpoint, "oldbytes", json_hex(curBreakpoint.oldbytes));
|
||||
json_object_set_new(curjsonbreakpoint, "type", json_integer(curBreakpoint.type));
|
||||
json_object_set_new(curjsonbreakpoint, "titantype", json_hex(curBreakpoint.titantype));
|
||||
|
|
@ -225,7 +225,7 @@ void bpcachesave(JSON root)
|
|||
void bpcacheload(JSON root)
|
||||
{
|
||||
breakpoints.clear();
|
||||
const JSON jsonbreakpoints=json_object_get(root, "breakpoints");
|
||||
const JSON jsonbreakpoints = json_object_get(root, "breakpoints");
|
||||
if(jsonbreakpoints)
|
||||
{
|
||||
size_t i;
|
||||
|
|
@ -234,19 +234,19 @@ void bpcacheload(JSON root)
|
|||
{
|
||||
BREAKPOINT curBreakpoint;
|
||||
memset(&curBreakpoint, 0, sizeof(BREAKPOINT));
|
||||
curBreakpoint.type=(BP_TYPE)json_integer_value(json_object_get(value, "type"));
|
||||
if(curBreakpoint.type==BPNORMAL)
|
||||
curBreakpoint.oldbytes=(short)json_hex_value(json_object_get(value, "oldbytes"));
|
||||
curBreakpoint.addr=(uint)json_hex_value(json_object_get(value, "address"));
|
||||
curBreakpoint.enabled=json_boolean_value(json_object_get(value, "enabled"));
|
||||
curBreakpoint.titantype=(DWORD)json_hex_value(json_object_get(value, "titantype"));
|
||||
const char* name=json_string_value(json_object_get(value, "name"));
|
||||
curBreakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type"));
|
||||
if(curBreakpoint.type == BPNORMAL)
|
||||
curBreakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes"));
|
||||
curBreakpoint.addr = (uint)json_hex_value(json_object_get(value, "address"));
|
||||
curBreakpoint.enabled = json_boolean_value(json_object_get(value, "enabled"));
|
||||
curBreakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype"));
|
||||
const char* name = json_string_value(json_object_get(value, "name"));
|
||||
if(name)
|
||||
strcpy(curBreakpoint.name, name);
|
||||
const char* mod=json_string_value(json_object_get(value, "module"));
|
||||
if(mod && *mod && strlen(mod)<MAX_MODULE_SIZE)
|
||||
const char* mod = json_string_value(json_object_get(value, "module"));
|
||||
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
|
||||
strcpy(curBreakpoint.mod, mod);
|
||||
const uint key=modhashfromname(curBreakpoint.mod)+curBreakpoint.addr;
|
||||
const uint key = modhashfromname(curBreakpoint.mod) + curBreakpoint.addr;
|
||||
breakpoints.insert(std::make_pair(BreakpointKey(curBreakpoint.type, key), curBreakpoint));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
//enums
|
||||
enum BP_TYPE
|
||||
{
|
||||
BPNORMAL=0,
|
||||
BPHARDWARE=1,
|
||||
BPMEMORY=2
|
||||
BPNORMAL = 0,
|
||||
BPHARDWARE = 1,
|
||||
BPMEMORY = 2
|
||||
};
|
||||
|
||||
//structs
|
||||
|
|
|
|||
|
|
@ -7,40 +7,40 @@
|
|||
|
||||
COMMAND* cmdfind(COMMAND* command_list, const char* name, COMMAND** link)
|
||||
{
|
||||
COMMAND* cur=command_list;
|
||||
COMMAND* cur = command_list;
|
||||
if(!cur->name)
|
||||
return 0;
|
||||
COMMAND* prev=0;
|
||||
COMMAND* prev = 0;
|
||||
while(cur)
|
||||
{
|
||||
if(arraycontains(cur->name, name))
|
||||
{
|
||||
if(link)
|
||||
*link=prev;
|
||||
*link = prev;
|
||||
return cur;
|
||||
}
|
||||
prev=cur;
|
||||
cur=cur->next;
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
COMMAND* cmdinit()
|
||||
{
|
||||
COMMAND* cmd=(COMMAND*)emalloc(sizeof(COMMAND), "cmdinit:cmd");
|
||||
COMMAND* cmd = (COMMAND*)emalloc(sizeof(COMMAND), "cmdinit:cmd");
|
||||
memset(cmd, 0, sizeof(COMMAND));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void cmdfree(COMMAND* cmd_list)
|
||||
{
|
||||
COMMAND* cur=cmd_list;
|
||||
COMMAND* cur = cmd_list;
|
||||
while(cur)
|
||||
{
|
||||
efree(cur->name, "cmdfree:cur->name");
|
||||
COMMAND* next=cur->next;
|
||||
COMMAND* next = cur->next;
|
||||
efree(cur, "cmdfree:cur");
|
||||
cur=next;
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,39 +49,39 @@ bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool d
|
|||
if(!command_list or !cbCommand or !name or !*name or cmdfind(command_list, name, 0))
|
||||
return false;
|
||||
COMMAND* cmd;
|
||||
bool nonext=false;
|
||||
bool nonext = false;
|
||||
if(!command_list->name)
|
||||
{
|
||||
cmd=command_list;
|
||||
nonext=true;
|
||||
cmd = command_list;
|
||||
nonext = true;
|
||||
}
|
||||
else
|
||||
cmd=(COMMAND*)emalloc(sizeof(COMMAND), "cmdnew:cmd");
|
||||
cmd = (COMMAND*)emalloc(sizeof(COMMAND), "cmdnew:cmd");
|
||||
memset(cmd, 0, sizeof(COMMAND));
|
||||
cmd->name=(char*)emalloc(strlen(name)+1, "cmdnew:cmd->name");
|
||||
cmd->name = (char*)emalloc(strlen(name) + 1, "cmdnew:cmd->name");
|
||||
strcpy(cmd->name, name);
|
||||
cmd->cbCommand=cbCommand;
|
||||
cmd->debugonly=debugonly;
|
||||
COMMAND* cur=command_list;
|
||||
cmd->cbCommand = cbCommand;
|
||||
cmd->debugonly = debugonly;
|
||||
COMMAND* cur = command_list;
|
||||
if(!nonext)
|
||||
{
|
||||
while(cur->next)
|
||||
cur=cur->next;
|
||||
cur->next=cmd;
|
||||
cur = cur->next;
|
||||
cur->next = cmd;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
COMMAND* cmdget(COMMAND* command_list, const char* cmd)
|
||||
{
|
||||
char new_cmd[deflen]="";
|
||||
char new_cmd[deflen] = "";
|
||||
strcpy(new_cmd, cmd);
|
||||
int len=(int)strlen(new_cmd);
|
||||
int start=0;
|
||||
while(new_cmd[start]!=' ' and start<len)
|
||||
int len = (int)strlen(new_cmd);
|
||||
int start = 0;
|
||||
while(new_cmd[start] != ' ' and start < len)
|
||||
start++;
|
||||
new_cmd[start]=0;
|
||||
COMMAND* found=cmdfind(command_list, new_cmd, 0);
|
||||
new_cmd[start] = 0;
|
||||
COMMAND* found = cmdfind(command_list, new_cmd, 0);
|
||||
if(!found)
|
||||
return 0;
|
||||
return found;
|
||||
|
|
@ -91,29 +91,29 @@ CBCOMMAND cmdset(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, b
|
|||
{
|
||||
if(!cbCommand)
|
||||
return 0;
|
||||
COMMAND* found=cmdfind(command_list, name, 0);
|
||||
COMMAND* found = cmdfind(command_list, name, 0);
|
||||
if(!found)
|
||||
return 0;
|
||||
CBCOMMAND old=found->cbCommand;
|
||||
found->cbCommand=cbCommand;
|
||||
found->debugonly=debugonly;
|
||||
CBCOMMAND old = found->cbCommand;
|
||||
found->cbCommand = cbCommand;
|
||||
found->debugonly = debugonly;
|
||||
return old;
|
||||
}
|
||||
|
||||
bool cmddel(COMMAND* command_list, const char* name)
|
||||
{
|
||||
COMMAND* prev=0;
|
||||
COMMAND* found=cmdfind(command_list, name, &prev);
|
||||
COMMAND* prev = 0;
|
||||
COMMAND* found = cmdfind(command_list, name, &prev);
|
||||
if(!found)
|
||||
return false;
|
||||
efree(found->name, "cmddel:found->name");
|
||||
if(found==command_list)
|
||||
if(found == command_list)
|
||||
{
|
||||
COMMAND* next=command_list->next;
|
||||
COMMAND* next = command_list->next;
|
||||
if(next)
|
||||
{
|
||||
memcpy(command_list, command_list->next, sizeof(COMMAND));
|
||||
command_list->next=next->next;
|
||||
command_list->next = next->next;
|
||||
efree(next, "cmddel:next");
|
||||
}
|
||||
else
|
||||
|
|
@ -121,7 +121,7 @@ bool cmddel(COMMAND* command_list, const char* name)
|
|||
}
|
||||
else
|
||||
{
|
||||
prev->next=found->next;
|
||||
prev->next = found->next;
|
||||
efree(found, "cmddel:found");
|
||||
}
|
||||
return true;
|
||||
|
|
@ -138,8 +138,8 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
|
|||
{
|
||||
if(!cbUnknownCommand or !cbCommandProvider)
|
||||
return STATUS_ERROR;
|
||||
char command[deflen]="";
|
||||
bool bLoop=true;
|
||||
char command[deflen] = "";
|
||||
bool bLoop = true;
|
||||
while(bLoop)
|
||||
{
|
||||
if(!cbCommandProvider(command, deflen))
|
||||
|
|
@ -149,17 +149,17 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
|
|||
argformat(command); //default formatting
|
||||
COMMAND* cmd;
|
||||
if(!cbCommandFinder) //'clean' command processing
|
||||
cmd=cmdget(command_list, command);
|
||||
cmd = cmdget(command_list, command);
|
||||
else //'dirty' command processing
|
||||
cmd=cbCommandFinder(command_list, command);
|
||||
cmd = cbCommandFinder(command_list, command);
|
||||
|
||||
if(!cmd or !cmd->cbCommand) //unknown command
|
||||
{
|
||||
char* argv[1];
|
||||
*argv=command;
|
||||
CMDRESULT res=cbUnknownCommand(1, argv);
|
||||
if((error_is_fatal and res==STATUS_ERROR) or res==STATUS_EXIT)
|
||||
bLoop=false;
|
||||
*argv = command;
|
||||
CMDRESULT res = cbUnknownCommand(1, argv);
|
||||
if((error_is_fatal and res == STATUS_ERROR) or res == STATUS_EXIT)
|
||||
bLoop = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -167,25 +167,25 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
|
|||
{
|
||||
dputs("this command is debug-only");
|
||||
if(error_is_fatal)
|
||||
bLoop=false;
|
||||
bLoop = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argcount=arggetcount(command);
|
||||
char** argv=(char**)emalloc((argcount+1)*sizeof(char*), "cmdloop:argv");
|
||||
argv[0]=command;
|
||||
for(int i=0; i<argcount; i++)
|
||||
int argcount = arggetcount(command);
|
||||
char** argv = (char**)emalloc((argcount + 1) * sizeof(char*), "cmdloop:argv");
|
||||
argv[0] = command;
|
||||
for(int i = 0; i < argcount; i++)
|
||||
{
|
||||
argv[i+1]=(char*)emalloc(deflen, "cmdloop:argv[i+1]");
|
||||
*argv[i+1]=0;
|
||||
argget(command, argv[i+1], i, true);
|
||||
argv[i + 1] = (char*)emalloc(deflen, "cmdloop:argv[i+1]");
|
||||
*argv[i + 1] = 0;
|
||||
argget(command, argv[i + 1], i, true);
|
||||
}
|
||||
CMDRESULT res=cmd->cbCommand(argcount+1, argv);
|
||||
for(int i=0; i<argcount; i++)
|
||||
efree(argv[i+1], "cmdloop:argv[i+1]");
|
||||
CMDRESULT res = cmd->cbCommand(argcount + 1, argv);
|
||||
for(int i = 0; i < argcount; i++)
|
||||
efree(argv[i + 1], "cmdloop:argv[i+1]");
|
||||
efree(argv, "cmdloop:argv");
|
||||
if((error_is_fatal and res==STATUS_ERROR) or res==STATUS_EXIT)
|
||||
bLoop=false;
|
||||
if((error_is_fatal and res == STATUS_ERROR) or res == STATUS_EXIT)
|
||||
bLoop = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,36 +205,36 @@ static bool isvalidexpression(const char* expression)
|
|||
|
||||
static void specialformat(char* string)
|
||||
{
|
||||
int len=(int)strlen(string);
|
||||
char* found=strstr(string, "=");
|
||||
char* str=(char*)emalloc(len*2, "specialformat:str");
|
||||
char* backup=(char*)emalloc(len+1, "specialformat:backup");
|
||||
int len = (int)strlen(string);
|
||||
char* found = strstr(string, "=");
|
||||
char* str = (char*)emalloc(len * 2, "specialformat:str");
|
||||
char* backup = (char*)emalloc(len + 1, "specialformat:backup");
|
||||
strcpy(backup, string); //create a backup of the string
|
||||
memset(str, 0, len*2);
|
||||
memset(str, 0, len * 2);
|
||||
if(found) //contains =
|
||||
{
|
||||
char* a=(found-1);
|
||||
*found=0;
|
||||
char* a = (found - 1);
|
||||
*found = 0;
|
||||
found++;
|
||||
if(!*found)
|
||||
{
|
||||
*found='=';
|
||||
*found = '=';
|
||||
efree(str, "specialformat:str");
|
||||
efree(backup, "specialformat:backup");
|
||||
return;
|
||||
}
|
||||
int flen=(int)strlen(found); //n(+)=n++
|
||||
if((found[flen-1]=='+' and found[flen-2]=='+') or (found[flen-1]=='-' and found[flen-2]=='-')) //eax++/eax--
|
||||
int flen = (int)strlen(found); //n(+)=n++
|
||||
if((found[flen - 1] == '+' and found[flen - 2] == '+') or (found[flen - 1] == '-' and found[flen - 2] == '-')) //eax++/eax--
|
||||
{
|
||||
found[flen-2]=0;
|
||||
char op=found[flen-1];
|
||||
found[flen - 2] = 0;
|
||||
char op = found[flen - 1];
|
||||
sprintf(str, "%s%c1", found, op);
|
||||
strcpy(found, str);
|
||||
}
|
||||
if(mathisoperator(*a)>2) //x*=3 -> x=x*3
|
||||
if(mathisoperator(*a) > 2) //x*=3 -> x=x*3
|
||||
{
|
||||
char op=*a;
|
||||
*a=0;
|
||||
char op = *a;
|
||||
*a = 0;
|
||||
if(isvalidexpression(string))
|
||||
sprintf(str, "mov %s,%s%c%s", string, string, op, found);
|
||||
else
|
||||
|
|
@ -249,10 +249,10 @@ static void specialformat(char* string)
|
|||
}
|
||||
strcpy(string, str);
|
||||
}
|
||||
else if((string[len-1]=='+' and string[len-2]=='+') or (string[len-1]=='-' and string[len-2]=='-')) //eax++/eax--
|
||||
else if((string[len - 1] == '+' and string[len - 2] == '+') or (string[len - 1] == '-' and string[len - 2] == '-')) //eax++/eax--
|
||||
{
|
||||
string[len-2]=0;
|
||||
char op=string[len-1];
|
||||
string[len - 2] = 0;
|
||||
char op = string[len - 1];
|
||||
if(isvalidexpression(string))
|
||||
sprintf(str, "mov %s,%s%c1", string, string, op);
|
||||
else
|
||||
|
|
@ -268,11 +268,11 @@ static void specialformat(char* string)
|
|||
*/
|
||||
COMMAND* cmdfindmain(COMMAND* cmd_list, char* command)
|
||||
{
|
||||
COMMAND* cmd=cmdfind(cmd_list, command, 0);
|
||||
COMMAND* cmd = cmdfind(cmd_list, command, 0);
|
||||
if(!cmd)
|
||||
{
|
||||
specialformat(command);
|
||||
cmd=cmdget(cmd_list, command);
|
||||
cmd = cmdget(cmd_list, command);
|
||||
}
|
||||
if(!cmd or !cmd->cbCommand)
|
||||
mathformat(command);
|
||||
|
|
@ -283,26 +283,26 @@ CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
|
|||
{
|
||||
if(!cmd or !strlen(cmd))
|
||||
return STATUS_ERROR;
|
||||
char command[deflen]="";
|
||||
char command[deflen] = "";
|
||||
strcpy(command, cmd);
|
||||
argformat(command);
|
||||
COMMAND* found=cmdfindmain(cmd_list, command);
|
||||
COMMAND* found = cmdfindmain(cmd_list, command);
|
||||
if(!found or !found->cbCommand)
|
||||
return STATUS_ERROR;
|
||||
if(found->debugonly and !DbgIsDebugging())
|
||||
return STATUS_ERROR;
|
||||
int argcount=arggetcount(command);
|
||||
char** argv=(char**)emalloc((argcount+1)*sizeof(char*), "cmddirectexec:argv");
|
||||
argv[0]=command;
|
||||
for(int i=0; i<argcount; i++)
|
||||
int argcount = arggetcount(command);
|
||||
char** argv = (char**)emalloc((argcount + 1) * sizeof(char*), "cmddirectexec:argv");
|
||||
argv[0] = command;
|
||||
for(int i = 0; i < argcount; i++)
|
||||
{
|
||||
argv[i+1]=(char*)emalloc(deflen, "cmddirectexec:argv[i+1]");
|
||||
*argv[i+1]=0;
|
||||
argget(command, argv[i+1], i, true);
|
||||
argv[i + 1] = (char*)emalloc(deflen, "cmddirectexec:argv[i+1]");
|
||||
*argv[i + 1] = 0;
|
||||
argget(command, argv[i + 1], i, true);
|
||||
}
|
||||
CMDRESULT res=found->cbCommand(argcount+1, argv);
|
||||
for(int i=0; i<argcount; i++)
|
||||
efree(argv[i+1], "cmddirectexec:argv[i+1]");
|
||||
CMDRESULT res = found->cbCommand(argcount + 1, argv);
|
||||
for(int i = 0; i < argcount; i++)
|
||||
efree(argv[i + 1], "cmddirectexec:argv[i+1]");
|
||||
efree(argv, "cmddirectexec:argv");
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ struct COMMAND;
|
|||
|
||||
enum CMDRESULT
|
||||
{
|
||||
STATUS_ERROR=false,
|
||||
STATUS_CONTINUE=true,
|
||||
STATUS_EXIT=2,
|
||||
STATUS_PAUSE=3
|
||||
STATUS_ERROR = false,
|
||||
STATUS_CONTINUE = true,
|
||||
STATUS_EXIT = 2,
|
||||
STATUS_PAUSE = 3
|
||||
};
|
||||
|
||||
typedef CMDRESULT (*CBCOMMAND)(int, char**);
|
||||
typedef CMDRESULT(*CBCOMMAND)(int, char**);
|
||||
typedef bool (*CBCOMMANDPROVIDER)(char*, int);
|
||||
typedef COMMAND* (*CBCOMMANDFINDER)(COMMAND*, char*);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ void dprintf(const char* format, ...)
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
*msg=0;
|
||||
*msg = 0;
|
||||
vsnprintf(msg, sizeof(msg), format, args);
|
||||
GuiAddLogMessage(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ typedef struct _LOADED_IMAGE
|
|||
#define ERROR_NO_PDB_POINTER 0x8802 // image does not point to a pdb file
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(
|
||||
(CALLBACK* PFIND_DEBUG_FILE_CALLBACK)(
|
||||
__in HANDLE FileHandle,
|
||||
__in PCSTR FileName,
|
||||
__in PVOID CallerData
|
||||
|
|
@ -158,7 +158,7 @@ SymFindDebugInfoFile(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PFIND_DEBUG_FILE_CALLBACKW)(
|
||||
(CALLBACK* PFIND_DEBUG_FILE_CALLBACKW)(
|
||||
__in HANDLE FileHandle,
|
||||
__in PCWSTR FileName,
|
||||
__in PVOID CallerData
|
||||
|
|
@ -176,7 +176,7 @@ SymFindDebugInfoFileW(
|
|||
|
||||
HANDLE
|
||||
IMAGEAPI
|
||||
FindDebugInfoFile (
|
||||
FindDebugInfoFile(
|
||||
__in PCSTR FileName,
|
||||
__in PCSTR SymbolPath,
|
||||
__out_ecount(MAX_PATH + 1) PSTR DebugFilePath
|
||||
|
|
@ -184,7 +184,7 @@ FindDebugInfoFile (
|
|||
|
||||
HANDLE
|
||||
IMAGEAPI
|
||||
FindDebugInfoFileEx (
|
||||
FindDebugInfoFileEx(
|
||||
__in PCSTR FileName,
|
||||
__in PCSTR SymbolPath,
|
||||
__out_ecount(MAX_PATH + 1) PSTR DebugFilePath,
|
||||
|
|
@ -194,7 +194,7 @@ FindDebugInfoFileEx (
|
|||
|
||||
HANDLE
|
||||
IMAGEAPI
|
||||
FindDebugInfoFileExW (
|
||||
FindDebugInfoFileExW(
|
||||
__in PCWSTR FileName,
|
||||
__in PCWSTR SymbolPath,
|
||||
__out_ecount(MAX_PATH + 1) PWSTR DebugFilePath,
|
||||
|
|
@ -203,7 +203,7 @@ FindDebugInfoFileExW (
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PFINDFILEINPATHCALLBACK)(
|
||||
(CALLBACK* PFINDFILEINPATHCALLBACK)(
|
||||
__in PCSTR filename,
|
||||
__in PVOID context
|
||||
);
|
||||
|
|
@ -224,7 +224,7 @@ SymFindFileInPath(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PFINDFILEINPATHCALLBACKW)(
|
||||
(CALLBACK* PFINDFILEINPATHCALLBACKW)(
|
||||
__in PCWSTR filename,
|
||||
__in PVOID context
|
||||
);
|
||||
|
|
@ -245,7 +245,7 @@ SymFindFileInPathW(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PFIND_EXE_FILE_CALLBACK)(
|
||||
(CALLBACK* PFIND_EXE_FILE_CALLBACK)(
|
||||
__in HANDLE FileHandle,
|
||||
__in PCSTR FileName,
|
||||
__in_opt PVOID CallerData
|
||||
|
|
@ -262,7 +262,7 @@ SymFindExecutableImage(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PFIND_EXE_FILE_CALLBACKW)(
|
||||
(CALLBACK* PFIND_EXE_FILE_CALLBACKW)(
|
||||
__in HANDLE FileHandle,
|
||||
__in PCWSTR FileName,
|
||||
__in_opt PVOID CallerData
|
||||
|
|
@ -308,23 +308,23 @@ FindExecutableImageExW(
|
|||
|
||||
PIMAGE_NT_HEADERS
|
||||
IMAGEAPI
|
||||
ImageNtHeader (
|
||||
ImageNtHeader(
|
||||
__in PVOID Base
|
||||
);
|
||||
|
||||
PVOID
|
||||
IMAGEAPI
|
||||
ImageDirectoryEntryToDataEx (
|
||||
ImageDirectoryEntryToDataEx(
|
||||
__in PVOID Base,
|
||||
__in BOOLEAN MappedAsImage,
|
||||
__in USHORT DirectoryEntry,
|
||||
__out PULONG Size,
|
||||
__out_opt PIMAGE_SECTION_HEADER *FoundHeader
|
||||
__out_opt PIMAGE_SECTION_HEADER* FoundHeader
|
||||
);
|
||||
|
||||
PVOID
|
||||
IMAGEAPI
|
||||
ImageDirectoryEntryToData (
|
||||
ImageDirectoryEntryToData(
|
||||
__in PVOID Base,
|
||||
__in BOOLEAN MappedAsImage,
|
||||
__in USHORT DirectoryEntry,
|
||||
|
|
@ -345,7 +345,7 @@ ImageRvaToVa(
|
|||
__in PIMAGE_NT_HEADERS NtHeaders,
|
||||
__in PVOID Base,
|
||||
__in ULONG Rva,
|
||||
__in_opt OUT PIMAGE_SECTION_HEADER *LastRvaSection
|
||||
__in_opt OUT PIMAGE_SECTION_HEADER* LastRvaSection
|
||||
);
|
||||
|
||||
#ifndef _WIN64
|
||||
|
|
@ -433,7 +433,7 @@ SearchTreeForFileW(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PENUMDIRTREE_CALLBACK)(
|
||||
(CALLBACK* PENUMDIRTREE_CALLBACK)(
|
||||
__in PCSTR FilePath,
|
||||
__in_opt PVOID CallerData
|
||||
);
|
||||
|
|
@ -450,7 +450,7 @@ EnumDirTree(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PENUMDIRTREE_CALLBACKW)(
|
||||
(CALLBACK* PENUMDIRTREE_CALLBACKW)(
|
||||
__in PCWSTR FilePath,
|
||||
__in_opt PVOID CallerData
|
||||
);
|
||||
|
|
@ -800,7 +800,7 @@ typedef struct _tagSTACKFRAME
|
|||
|
||||
typedef
|
||||
BOOL
|
||||
(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
|
||||
(__stdcall* PREAD_PROCESS_MEMORY_ROUTINE64)(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD64 qwBaseAddress,
|
||||
__out_bcount(nSize) PVOID lpBuffer,
|
||||
|
|
@ -810,21 +810,21 @@ BOOL
|
|||
|
||||
typedef
|
||||
PVOID
|
||||
(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
|
||||
(__stdcall* PFUNCTION_TABLE_ACCESS_ROUTINE64)(
|
||||
__in HANDLE ahProcess,
|
||||
__in DWORD64 AddrBase
|
||||
);
|
||||
|
||||
typedef
|
||||
DWORD64
|
||||
(__stdcall *PGET_MODULE_BASE_ROUTINE64)(
|
||||
(__stdcall* PGET_MODULE_BASE_ROUTINE64)(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD64 Address
|
||||
);
|
||||
|
||||
typedef
|
||||
DWORD64
|
||||
(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
|
||||
(__stdcall* PTRANSLATE_ADDRESS_ROUTINE64)(
|
||||
__in HANDLE hProcess,
|
||||
__in HANDLE hThread,
|
||||
__in LPADDRESS64 lpaddr
|
||||
|
|
@ -857,7 +857,7 @@ StackWalk64(
|
|||
|
||||
typedef
|
||||
BOOL
|
||||
(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)(
|
||||
(__stdcall* PREAD_PROCESS_MEMORY_ROUTINE)(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD lpBaseAddress,
|
||||
__out_bcount(nSize) PVOID lpBuffer,
|
||||
|
|
@ -867,21 +867,21 @@ BOOL
|
|||
|
||||
typedef
|
||||
PVOID
|
||||
(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(
|
||||
(__stdcall* PFUNCTION_TABLE_ACCESS_ROUTINE)(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD AddrBase
|
||||
);
|
||||
|
||||
typedef
|
||||
DWORD
|
||||
(__stdcall *PGET_MODULE_BASE_ROUTINE)(
|
||||
(__stdcall* PGET_MODULE_BASE_ROUTINE)(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD Address
|
||||
);
|
||||
|
||||
typedef
|
||||
DWORD
|
||||
(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(
|
||||
(__stdcall* PTRANSLATE_ADDRESS_ROUTINE)(
|
||||
__in HANDLE hProcess,
|
||||
__in HANDLE hThread,
|
||||
__out LPADDRESS lpaddr
|
||||
|
|
@ -936,21 +936,21 @@ GetTimestampForLoadedLibrary(
|
|||
// typedefs for function pointers
|
||||
//
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(
|
||||
(CALLBACK* PSYM_ENUMMODULES_CALLBACK64)(
|
||||
__in PCSTR ModuleName,
|
||||
__in DWORD64 BaseOfDll,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)(
|
||||
(CALLBACK* PSYM_ENUMMODULES_CALLBACKW64)(
|
||||
__in PCWSTR ModuleName,
|
||||
__in DWORD64 BaseOfDll,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(
|
||||
(CALLBACK* PENUMLOADED_MODULES_CALLBACK64)(
|
||||
__in PCSTR ModuleName,
|
||||
__in DWORD64 ModuleBase,
|
||||
__in ULONG ModuleSize,
|
||||
|
|
@ -958,7 +958,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(
|
||||
(CALLBACK* PENUMLOADED_MODULES_CALLBACKW64)(
|
||||
__in PCWSTR ModuleName,
|
||||
__in DWORD64 ModuleBase,
|
||||
__in ULONG ModuleSize,
|
||||
|
|
@ -966,7 +966,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(
|
||||
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACK64)(
|
||||
__in PCSTR SymbolName,
|
||||
__in DWORD64 SymbolAddress,
|
||||
__in ULONG SymbolSize,
|
||||
|
|
@ -974,7 +974,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(
|
||||
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACK64W)(
|
||||
__in PCWSTR SymbolName,
|
||||
__in DWORD64 SymbolAddress,
|
||||
__in ULONG SymbolSize,
|
||||
|
|
@ -982,7 +982,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(
|
||||
(CALLBACK* PSYMBOL_REGISTERED_CALLBACK64)(
|
||||
__in HANDLE hProcess,
|
||||
__in ULONG ActionCode,
|
||||
__in_opt ULONG64 CallbackData,
|
||||
|
|
@ -991,7 +991,7 @@ typedef BOOL
|
|||
|
||||
typedef
|
||||
PVOID
|
||||
(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(
|
||||
(CALLBACK* PSYMBOL_FUNCENTRY_CALLBACK)(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD AddrBase,
|
||||
__in_opt PVOID UserContext
|
||||
|
|
@ -999,7 +999,7 @@ PVOID
|
|||
|
||||
typedef
|
||||
PVOID
|
||||
(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(
|
||||
(CALLBACK* PSYMBOL_FUNCENTRY_CALLBACK64)(
|
||||
__in HANDLE hProcess,
|
||||
__in ULONG64 AddrBase,
|
||||
__in ULONG64 UserContext
|
||||
|
|
@ -1017,14 +1017,14 @@ PVOID
|
|||
#else
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
|
||||
(CALLBACK* PSYM_ENUMMODULES_CALLBACK)(
|
||||
__in PCSTR ModuleName,
|
||||
__in ULONG BaseOfDll,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
|
||||
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACK)(
|
||||
__in PCSTR SymbolName,
|
||||
__in ULONG SymbolAddress,
|
||||
__in ULONG SymbolSize,
|
||||
|
|
@ -1032,7 +1032,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(
|
||||
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACKW)(
|
||||
__in PCWSTR SymbolName,
|
||||
__in ULONG SymbolAddress,
|
||||
__in ULONG SymbolSize,
|
||||
|
|
@ -1040,7 +1040,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
|
||||
(CALLBACK* PENUMLOADED_MODULES_CALLBACK)(
|
||||
__in PCSTR ModuleName,
|
||||
__in ULONG ModuleBase,
|
||||
__in ULONG ModuleSize,
|
||||
|
|
@ -1048,7 +1048,7 @@ typedef BOOL
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
|
||||
(CALLBACK* PSYMBOL_REGISTERED_CALLBACK)(
|
||||
__in HANDLE hProcess,
|
||||
__in ULONG ActionCode,
|
||||
__in_opt PVOID CallbackData,
|
||||
|
|
@ -1416,7 +1416,7 @@ typedef struct _IMAGEHLP_CBA_READ_MEMORY
|
|||
DWORD64 addr; // address to read from
|
||||
PVOID buf; // buffer to read to
|
||||
DWORD bytes; // amount of bytes to read
|
||||
DWORD *bytesread; // pointer to store amount of bytes read
|
||||
DWORD* bytesread; // pointer to store amount of bytes read
|
||||
} IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;
|
||||
|
||||
enum
|
||||
|
|
@ -1569,9 +1569,9 @@ IMAGEAPI
|
|||
SymGetOmaps(
|
||||
__in HANDLE hProcess,
|
||||
__in DWORD64 BaseOfDll,
|
||||
__out POMAP *OmapTo,
|
||||
__out POMAP* OmapTo,
|
||||
__out PDWORD64 cOmapTo,
|
||||
__out POMAP *OmapFrom,
|
||||
__out POMAP* OmapFrom,
|
||||
__out PDWORD64 cOmapFrom
|
||||
);
|
||||
|
||||
|
|
@ -1651,7 +1651,7 @@ SymMatchStringW(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)(
|
||||
(CALLBACK* PSYM_ENUMSOURCEFILES_CALLBACK)(
|
||||
__in PSOURCEFILE pSourceFile,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
|
@ -1670,7 +1670,7 @@ SymEnumSourceFiles(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)(
|
||||
(CALLBACK* PSYM_ENUMSOURCEFILES_CALLBACKW)(
|
||||
__in PSOURCEFILEW pSourceFile,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
|
@ -1862,7 +1862,7 @@ typedef struct _SRCCODEINFOW
|
|||
} SRCCODEINFOW, *PSRCCODEINFOW;
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMLINES_CALLBACK)(
|
||||
(CALLBACK* PSYM_ENUMLINES_CALLBACK)(
|
||||
__in PSRCCODEINFO LineInfo,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
|
@ -1879,7 +1879,7 @@ SymEnumLines(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMLINES_CALLBACKW)(
|
||||
(CALLBACK* PSYM_ENUMLINES_CALLBACKW)(
|
||||
__in PSRCCODEINFOW LineInfo,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
|
|
@ -2085,8 +2085,8 @@ IMAGEAPI
|
|||
SymMatchFileName(
|
||||
__in PCSTR FileName,
|
||||
__in PCSTR Match,
|
||||
__deref_opt_out PSTR *FileNameStop,
|
||||
__deref_opt_out PSTR *MatchStop
|
||||
__deref_opt_out PSTR* FileNameStop,
|
||||
__deref_opt_out PSTR* MatchStop
|
||||
);
|
||||
|
||||
BOOL
|
||||
|
|
@ -2094,8 +2094,8 @@ IMAGEAPI
|
|||
SymMatchFileNameW(
|
||||
__in PCWSTR FileName,
|
||||
__in PCWSTR Match,
|
||||
__deref_opt_out PWSTR *FileNameStop,
|
||||
__deref_opt_out PWSTR *MatchStop
|
||||
__deref_opt_out PWSTR* FileNameStop,
|
||||
__deref_opt_out PWSTR* MatchStop
|
||||
);
|
||||
|
||||
BOOL
|
||||
|
|
@ -2126,8 +2126,8 @@ SymGetSourceFileToken(
|
|||
__in HANDLE hProcess,
|
||||
__in ULONG64 Base,
|
||||
__in PCSTR FileSpec,
|
||||
__deref_out PVOID *Token,
|
||||
__out DWORD *Size
|
||||
__deref_out PVOID* Token,
|
||||
__out DWORD* Size
|
||||
);
|
||||
|
||||
BOOL
|
||||
|
|
@ -2136,8 +2136,8 @@ SymGetSourceFileTokenW(
|
|||
__in HANDLE hProcess,
|
||||
__in ULONG64 Base,
|
||||
__in PCWSTR FileSpec,
|
||||
__deref_out PVOID *Token,
|
||||
__out DWORD *Size
|
||||
__deref_out PVOID* Token,
|
||||
__out DWORD* Size
|
||||
);
|
||||
|
||||
BOOL
|
||||
|
|
@ -2182,7 +2182,7 @@ SymGetSourceVarFromTokenW(
|
|||
__in DWORD Size
|
||||
);
|
||||
|
||||
typedef BOOL (CALLBACK *PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size);
|
||||
typedef BOOL (CALLBACK* PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size);
|
||||
|
||||
BOOL
|
||||
IMAGEAPI
|
||||
|
|
@ -2457,7 +2457,7 @@ SymSetScopeFromIndex(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMPROCESSES_CALLBACK)(
|
||||
(CALLBACK* PSYM_ENUMPROCESSES_CALLBACK)(
|
||||
__in HANDLE hProcess,
|
||||
__in PVOID UserContext
|
||||
);
|
||||
|
|
@ -2556,7 +2556,7 @@ SymFromNameW(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(
|
||||
(CALLBACK* PSYM_ENUMERATESYMBOLS_CALLBACK)(
|
||||
__in PSYMBOL_INFO pSymInfo,
|
||||
__in ULONG SymbolSize,
|
||||
__in_opt PVOID UserContext
|
||||
|
|
@ -2573,7 +2573,7 @@ SymEnumSymbols(
|
|||
);
|
||||
|
||||
typedef BOOL
|
||||
(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)(
|
||||
(CALLBACK* PSYM_ENUMERATESYMBOLS_CALLBACKW)(
|
||||
__in PSYMBOL_INFOW pSymInfo,
|
||||
__in ULONG SymbolSize,
|
||||
__in_opt PVOID UserContext
|
||||
|
|
@ -2878,7 +2878,7 @@ SymAddSourceStream(
|
|||
__in size_t Size
|
||||
);
|
||||
|
||||
typedef BOOL (WINAPI *SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
|
||||
typedef BOOL (WINAPI* SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
|
||||
|
||||
BOOL
|
||||
IMAGEAPI
|
||||
|
|
@ -2890,7 +2890,7 @@ SymAddSourceStreamA(
|
|||
__in size_t Size
|
||||
);
|
||||
|
||||
typedef BOOL (WINAPI *SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
|
||||
typedef BOOL (WINAPI* SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
|
||||
|
||||
BOOL
|
||||
IMAGEAPI
|
||||
|
|
@ -2958,7 +2958,7 @@ BOOL
|
|||
IMAGEAPI
|
||||
SymSrvGetFileIndexes(
|
||||
__in PCSTR File,
|
||||
__out GUID *Id,
|
||||
__out GUID* Id,
|
||||
__out PDWORD Val1,
|
||||
__out_opt PDWORD Val2,
|
||||
__in DWORD Flags
|
||||
|
|
@ -2968,7 +2968,7 @@ BOOL
|
|||
IMAGEAPI
|
||||
SymSrvGetFileIndexesW(
|
||||
__in PCWSTR File,
|
||||
__out GUID *Id,
|
||||
__out GUID* Id,
|
||||
__out PDWORD Val1,
|
||||
__out_opt PDWORD Val2,
|
||||
__in DWORD Flags
|
||||
|
|
@ -2999,11 +2999,11 @@ SymSrvGetFileIndexString(
|
|||
typedef struct
|
||||
{
|
||||
DWORD sizeofstruct;
|
||||
char file[MAX_PATH +1];
|
||||
char file[MAX_PATH + 1];
|
||||
BOOL stripped;
|
||||
DWORD timestamp;
|
||||
DWORD size;
|
||||
char dbgfile[MAX_PATH +1];
|
||||
char dbgfile[MAX_PATH + 1];
|
||||
char pdbfile[MAX_PATH + 1];
|
||||
GUID guid;
|
||||
DWORD sig;
|
||||
|
|
@ -3013,11 +3013,11 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
DWORD sizeofstruct;
|
||||
WCHAR file[MAX_PATH +1];
|
||||
WCHAR file[MAX_PATH + 1];
|
||||
BOOL stripped;
|
||||
DWORD timestamp;
|
||||
DWORD size;
|
||||
WCHAR dbgfile[MAX_PATH +1];
|
||||
WCHAR dbgfile[MAX_PATH + 1];
|
||||
WCHAR pdbfile[MAX_PATH + 1];
|
||||
GUID guid;
|
||||
DWORD sig;
|
||||
|
|
@ -3119,7 +3119,7 @@ SymGetSymbolFileW(
|
|||
// Full user-mode dump creation.
|
||||
//
|
||||
|
||||
typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
|
||||
typedef BOOL (WINAPI* PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
|
||||
__in DWORD DataType,
|
||||
__in PVOID* Data,
|
||||
__out LPDWORD DataLength,
|
||||
|
|
@ -3199,36 +3199,36 @@ SymGetSymFromName(
|
|||
|
||||
// Symbol server exports
|
||||
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64);
|
||||
typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
|
||||
typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)();
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(PCSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCA)(PCSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCW)(PCWSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERGETVERSION)(LPAPI_VERSION);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERISSTORE)(PCSTR);
|
||||
typedef BOOL (WINAPI *PSYMBOLSERVERISSTOREW)(PCWSTR);
|
||||
typedef DWORD (WINAPI *PSYMBOLSERVERVERSION)();
|
||||
typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVEROPENPROC)(VOID);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERCLOSEPROC)(VOID);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64);
|
||||
typedef BOOL (CALLBACK WINAPI* PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
|
||||
typedef UINT_PTR(WINAPI* PSYMBOLSERVERGETOPTIONSPROC)();
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERPINGPROC)(PCSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERPINGPROCA)(PCSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERPINGPROCW)(PCWSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERGETVERSION)(LPAPI_VERSION);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERISSTORE)(PCSTR);
|
||||
typedef BOOL (WINAPI* PSYMBOLSERVERISSTOREW)(PCWSTR);
|
||||
typedef DWORD (WINAPI* PSYMBOLSERVERVERSION)();
|
||||
typedef BOOL (CALLBACK WINAPI* PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
|
||||
|
||||
#define SYMSRV_VERSION 2
|
||||
|
||||
|
|
@ -3857,7 +3857,7 @@ typedef struct _MINIDUMP_SYSTEM_INFO
|
|||
// ThreadId must be 4 bytes on all architectures.
|
||||
//
|
||||
|
||||
C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
|
||||
C_ASSERT(sizeof(((PPROCESS_INFORMATION)0)->dwThreadId) == 4);
|
||||
|
||||
typedef struct _MINIDUMP_THREAD
|
||||
{
|
||||
|
|
@ -4061,7 +4061,7 @@ typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2
|
|||
|
||||
// The latest MINIDUMP_HANDLE_DESCRIPTOR definition.
|
||||
typedef MINIDUMP_HANDLE_DESCRIPTOR_2 MINIDUMP_HANDLE_DESCRIPTOR_N;
|
||||
typedef MINIDUMP_HANDLE_DESCRIPTOR_N *PMINIDUMP_HANDLE_DESCRIPTOR_N;
|
||||
typedef MINIDUMP_HANDLE_DESCRIPTOR_N* PMINIDUMP_HANDLE_DESCRIPTOR_N;
|
||||
|
||||
typedef struct _MINIDUMP_HANDLE_DATA_STREAM
|
||||
{
|
||||
|
|
@ -4603,7 +4603,7 @@ typedef enum _MINIDUMP_SECONDARY_FLAGS
|
|||
|
||||
typedef
|
||||
BOOL
|
||||
(WINAPI * MINIDUMP_CALLBACK_ROUTINE) (
|
||||
(WINAPI* MINIDUMP_CALLBACK_ROUTINE)(
|
||||
__inout PVOID CallbackParam,
|
||||
__in PMINIDUMP_CALLBACK_INPUT CallbackInput,
|
||||
__inout PMINIDUMP_CALLBACK_OUTPUT CallbackOutput
|
||||
|
|
@ -4661,9 +4661,9 @@ WINAPI
|
|||
MiniDumpReadDumpStream(
|
||||
__in PVOID BaseOfDump,
|
||||
__in ULONG StreamNumber,
|
||||
__deref_out_opt PMINIDUMP_DIRECTORY * Dir,
|
||||
__deref_out_opt PVOID * StreamPointer,
|
||||
__out_opt ULONG * StreamSize
|
||||
__deref_out_opt PMINIDUMP_DIRECTORY* Dir,
|
||||
__deref_out_opt PVOID* StreamPointer,
|
||||
__out_opt ULONG* StreamSize
|
||||
);
|
||||
|
||||
#pragma pack(pop)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -11,7 +11,7 @@
|
|||
#include "simplescript.h"
|
||||
#include "symbolinfo.h"
|
||||
|
||||
static bool bScyllaLoaded=false;
|
||||
static bool bScyllaLoaded = false;
|
||||
|
||||
CMDRESULT cbDebugInit(int argc, char* argv[])
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
static char arg1[deflen]="";
|
||||
static char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, false))
|
||||
return STATUS_ERROR;
|
||||
if(!FileExists(arg1))
|
||||
|
|
@ -29,8 +29,8 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
|
|||
dputs("file does not exist!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
HANDLE hFile=CreateFileA(arg1, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
if(hFile==INVALID_HANDLE_VALUE)
|
||||
HANDLE hFile = CreateFileA(arg1, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
dputs("could not open file!");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -56,29 +56,29 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
static char arg2[deflen]="";
|
||||
static char arg2[deflen] = "";
|
||||
argget(*argv, arg2, 1, true);
|
||||
char* commandline=0;
|
||||
char* commandline = 0;
|
||||
if(strlen(arg2))
|
||||
commandline=arg2;
|
||||
commandline = arg2;
|
||||
|
||||
char arg3[deflen]="";
|
||||
char arg3[deflen] = "";
|
||||
argget(*argv, arg3, 2, true);
|
||||
|
||||
static char currentfolder[deflen]="";
|
||||
static char currentfolder[deflen] = "";
|
||||
strcpy(currentfolder, arg1);
|
||||
int len=(int)strlen(currentfolder);
|
||||
while(currentfolder[len]!='\\' and len!=0)
|
||||
int len = (int)strlen(currentfolder);
|
||||
while(currentfolder[len] != '\\' and len != 0)
|
||||
len--;
|
||||
currentfolder[len]=0;
|
||||
currentfolder[len] = 0;
|
||||
if(DirExists(arg3))
|
||||
strcpy(currentfolder, arg3);
|
||||
INIT_STRUCT* init=(INIT_STRUCT*)emalloc(sizeof(INIT_STRUCT), "cbDebugInit:init");
|
||||
INIT_STRUCT* init = (INIT_STRUCT*)emalloc(sizeof(INIT_STRUCT), "cbDebugInit:init");
|
||||
memset(init, 0, sizeof(INIT_STRUCT));
|
||||
init->exe=arg1;
|
||||
init->commandline=commandline;
|
||||
init->exe = arg1;
|
||||
init->commandline = commandline;
|
||||
if(*currentfolder)
|
||||
init->currentfolder=currentfolder;
|
||||
init->currentfolder = currentfolder;
|
||||
//initialize
|
||||
wait(WAITID_STOP); //wait for the debugger to stop
|
||||
waitclear(); //clear waiting flags NOTE: thread-unsafe
|
||||
|
|
@ -105,7 +105,7 @@ CMDRESULT cbDebugRun(int argc, char* argv[])
|
|||
GuiSetDebugState(running);
|
||||
unlock(WAITID_RUN);
|
||||
PLUG_CB_RESUMEDEBUG callbackInfo;
|
||||
callbackInfo.reserved=0;
|
||||
callbackInfo.reserved = 0;
|
||||
plugincbcall(CB_RESUMEDEBUG, &callbackInfo);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
|
@ -119,29 +119,29 @@ CMDRESULT cbDebugErun(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
|
||||
{
|
||||
char argtype[deflen]="";
|
||||
DWORD type=0;
|
||||
char argtype[deflen] = "";
|
||||
DWORD type = 0;
|
||||
if(!argget(*argv, argtype, 0, false))
|
||||
return STATUS_ERROR;
|
||||
const char* a=0;
|
||||
const char* a = 0;
|
||||
uint setting_type;
|
||||
if(strstr(argtype, "long"))
|
||||
{
|
||||
setting_type=1; //break_int3long
|
||||
a="TYPE_LONG_INT3";
|
||||
type=UE_BREAKPOINT_LONG_INT3;
|
||||
setting_type = 1; //break_int3long
|
||||
a = "TYPE_LONG_INT3";
|
||||
type = UE_BREAKPOINT_LONG_INT3;
|
||||
}
|
||||
else if(strstr(argtype, "ud2"))
|
||||
{
|
||||
setting_type=2; //break_ud2
|
||||
a="TYPE_UD2";
|
||||
type=UE_BREAKPOINT_UD2;
|
||||
setting_type = 2; //break_ud2
|
||||
a = "TYPE_UD2";
|
||||
type = UE_BREAKPOINT_UD2;
|
||||
}
|
||||
else if(strstr(argtype, "short"))
|
||||
{
|
||||
setting_type=0; //break_int3short
|
||||
a="TYPE_INT3";
|
||||
type=UE_BREAKPOINT_INT3;
|
||||
setting_type = 0; //break_int3short
|
||||
a = "TYPE_INT3";
|
||||
type = UE_BREAKPOINT_INT3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -156,44 +156,44 @@ CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
|
||||
{
|
||||
char argaddr[deflen]="";
|
||||
char argaddr[deflen] = "";
|
||||
if(!argget(*argv, argaddr, 0, false))
|
||||
return STATUS_ERROR;
|
||||
char argname[deflen]="";
|
||||
char argname[deflen] = "";
|
||||
argget(*argv, argname, 1, true);
|
||||
char argtype[deflen]="";
|
||||
bool has_arg2=argget(*argv, argtype, 2, true);
|
||||
char argtype[deflen] = "";
|
||||
bool has_arg2 = argget(*argv, argtype, 2, true);
|
||||
if(!has_arg2 and (scmp(argname, "ss") or scmp(argname, "long") or scmp(argname, "ud2")))
|
||||
{
|
||||
strcpy(argtype, argname);
|
||||
*argname=0;
|
||||
*argname = 0;
|
||||
}
|
||||
_strlwr(argtype);
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(argaddr, &addr))
|
||||
{
|
||||
dprintf("invalid addr: \"%s\"\n", argaddr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
int type=0;
|
||||
bool singleshoot=false;
|
||||
int type = 0;
|
||||
bool singleshoot = false;
|
||||
if(strstr(argtype, "ss"))
|
||||
{
|
||||
type|=UE_SINGLESHOOT;
|
||||
singleshoot=true;
|
||||
type |= UE_SINGLESHOOT;
|
||||
singleshoot = true;
|
||||
}
|
||||
else
|
||||
type|=UE_BREAKPOINT;
|
||||
type |= UE_BREAKPOINT;
|
||||
if(strstr(argtype, "long"))
|
||||
type|=UE_BREAKPOINT_TYPE_LONG_INT3;
|
||||
type |= UE_BREAKPOINT_TYPE_LONG_INT3;
|
||||
else if(strstr(argtype, "ud2"))
|
||||
type|=UE_BREAKPOINT_TYPE_UD2;
|
||||
type |= UE_BREAKPOINT_TYPE_UD2;
|
||||
else if(strstr(argtype, "short"))
|
||||
type|=UE_BREAKPOINT_TYPE_INT3;
|
||||
type |= UE_BREAKPOINT_TYPE_INT3;
|
||||
short oldbytes;
|
||||
const char* bpname=0;
|
||||
const char* bpname = 0;
|
||||
if(*argname)
|
||||
bpname=argname;
|
||||
bpname = argname;
|
||||
if(bpget(addr, BPNORMAL, bpname, 0))
|
||||
{
|
||||
dputs("breakpoint already set!");
|
||||
|
|
@ -226,7 +226,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
|
|||
|
||||
CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPNORMAL))
|
||||
|
|
@ -256,7 +256,7 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
|
|||
}
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
|
||||
{
|
||||
dprintf("no such breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -280,7 +280,7 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //enable all breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPNORMAL))
|
||||
|
|
@ -305,7 +305,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
|
|||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
|
||||
{
|
||||
dprintf("no such breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -329,7 +329,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPNORMAL))
|
||||
|
|
@ -354,7 +354,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
|
|||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
|
||||
{
|
||||
dprintf("no such breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -409,12 +409,12 @@ CMDRESULT cbDebugeStepOver(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSingleStep(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
uint stepcount=1;
|
||||
char arg1[deflen] = "";
|
||||
uint stepcount = 1;
|
||||
if(argget(*argv, arg1, 0, true))
|
||||
{
|
||||
if(!valfromstring(arg1, &stepcount))
|
||||
stepcount=1;
|
||||
stepcount = 1;
|
||||
}
|
||||
SingleStep((DWORD)stepcount, (void*)cbStep);
|
||||
dbgsetstepping(true);
|
||||
|
|
@ -438,11 +438,11 @@ CMDRESULT cbDebugHide(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDisasm(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
uint addr=GetContextDataEx(hActiveThread, UE_CIP);
|
||||
char arg1[deflen] = "";
|
||||
uint addr = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
if(argget(*argv, arg1, 0, true))
|
||||
if(!valfromstring(arg1, &addr))
|
||||
addr=GetContextDataEx(hActiveThread, UE_CIP);
|
||||
addr = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
if(!memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||
return STATUS_CONTINUE;
|
||||
DebugUpdateGui(addr, false);
|
||||
|
|
@ -451,49 +451,49 @@ CMDRESULT cbDebugDisasm(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]=""; //addr
|
||||
char arg1[deflen] = ""; //addr
|
||||
if(!argget(*argv, arg1, 0, false))
|
||||
return STATUS_ERROR;
|
||||
uint addr;
|
||||
if(!valfromstring(arg1, &addr))
|
||||
return STATUS_ERROR;
|
||||
bool restore=false;
|
||||
char arg2[deflen]=""; //restore
|
||||
char arg3[deflen]=""; //type
|
||||
bool restore = false;
|
||||
char arg2[deflen] = ""; //restore
|
||||
char arg3[deflen] = ""; //type
|
||||
argget(*argv, arg3, 2, true);
|
||||
if(argget(*argv, arg2, 1, true))
|
||||
{
|
||||
if(*arg2=='1')
|
||||
restore=true;
|
||||
else if(*arg2=='0')
|
||||
restore=false;
|
||||
if(*arg2 == '1')
|
||||
restore = true;
|
||||
else if(*arg2 == '0')
|
||||
restore = false;
|
||||
else
|
||||
strcpy(arg3, arg2);
|
||||
}
|
||||
DWORD type=UE_MEMORY;
|
||||
DWORD type = UE_MEMORY;
|
||||
if(*arg3)
|
||||
{
|
||||
switch(*arg3)
|
||||
{
|
||||
case 'r':
|
||||
type=UE_MEMORY_READ;
|
||||
type = UE_MEMORY_READ;
|
||||
break;
|
||||
case 'w':
|
||||
type=UE_MEMORY_WRITE;
|
||||
type = UE_MEMORY_WRITE;
|
||||
break;
|
||||
case 'x':
|
||||
type=UE_MEMORY_EXECUTE; //EXECUTE
|
||||
type = UE_MEMORY_EXECUTE; //EXECUTE
|
||||
break;
|
||||
default:
|
||||
dputs("invalid type (argument ignored)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint size=0;
|
||||
uint base=memfindbaseaddr(addr, &size, true);
|
||||
bool singleshoot=false;
|
||||
uint size = 0;
|
||||
uint base = memfindbaseaddr(addr, &size, true);
|
||||
bool singleshoot = false;
|
||||
if(!restore)
|
||||
singleshoot=true;
|
||||
singleshoot = true;
|
||||
if(bpget(base, BPMEMORY, 0, 0))
|
||||
{
|
||||
dputs("hardware breakpoint already set!");
|
||||
|
|
@ -511,7 +511,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPMEMORY))
|
||||
|
|
@ -537,7 +537,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
|
|||
}
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid breakpoint
|
||||
{
|
||||
dprintf("no such memory breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -570,23 +570,23 @@ CMDRESULT cbDebugeRtr(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]=""; //addr
|
||||
char arg1[deflen] = ""; //addr
|
||||
if(!argget(*argv, arg1, 0, false))
|
||||
return STATUS_ERROR;
|
||||
uint addr;
|
||||
if(!valfromstring(arg1, &addr))
|
||||
return STATUS_ERROR;
|
||||
DWORD type=UE_HARDWARE_EXECUTE;
|
||||
char arg2[deflen]=""; //type
|
||||
DWORD type = UE_HARDWARE_EXECUTE;
|
||||
char arg2[deflen] = ""; //type
|
||||
if(argget(*argv, arg2, 1, true))
|
||||
{
|
||||
switch(*arg2)
|
||||
{
|
||||
case 'r':
|
||||
type=UE_HARDWARE_READWRITE;
|
||||
type = UE_HARDWARE_READWRITE;
|
||||
break;
|
||||
case 'w':
|
||||
type=UE_HARDWARE_WRITE;
|
||||
type = UE_HARDWARE_WRITE;
|
||||
break;
|
||||
case 'x':
|
||||
break;
|
||||
|
|
@ -595,8 +595,8 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
|
|||
break;
|
||||
}
|
||||
}
|
||||
char arg3[deflen]=""; //size
|
||||
uint size=UE_HARDWARE_SIZE_1;
|
||||
char arg3[deflen] = ""; //size
|
||||
uint size = UE_HARDWARE_SIZE_1;
|
||||
if(argget(*argv, arg3, 2, true))
|
||||
{
|
||||
if(!valfromstring(arg3, &size))
|
||||
|
|
@ -604,33 +604,33 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
|
|||
switch(size)
|
||||
{
|
||||
case 2:
|
||||
size=UE_HARDWARE_SIZE_2;
|
||||
size = UE_HARDWARE_SIZE_2;
|
||||
break;
|
||||
case 4:
|
||||
size=UE_HARDWARE_SIZE_4;
|
||||
size = UE_HARDWARE_SIZE_4;
|
||||
break;
|
||||
#ifdef _WIN64
|
||||
case 8:
|
||||
size=UE_HARDWARE_SIZE_8;
|
||||
size = UE_HARDWARE_SIZE_8;
|
||||
break;
|
||||
#endif // _WIN64
|
||||
default:
|
||||
dputs("invalid size, using 1");
|
||||
break;
|
||||
}
|
||||
if((addr%size)!=0)
|
||||
if((addr % size) != 0)
|
||||
{
|
||||
dprintf("address not aligned to %d\n", size);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
DWORD drx=0;
|
||||
DWORD drx = 0;
|
||||
if(!GetUnusedHardwareBreakPointRegister(&drx))
|
||||
{
|
||||
dputs("you can only set 4 hardware breakpoints");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
int titantype=0;
|
||||
int titantype = 0;
|
||||
TITANSETDRX(titantype, drx);
|
||||
TITANSETTYPE(titantype, type);
|
||||
TITANSETSIZE(titantype, size);
|
||||
|
|
@ -652,7 +652,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPHARDWARE))
|
||||
|
|
@ -676,7 +676,7 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
|
|||
}
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid breakpoint
|
||||
{
|
||||
dprintf("no such hardware breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -694,12 +694,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugAlloc(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]=""; //size
|
||||
uint size=0x1000;
|
||||
char arg1[deflen] = ""; //size
|
||||
uint size = 0x1000;
|
||||
if(argget(*argv, arg1, 0, true))
|
||||
if(!valfromstring(arg1, &size, false))
|
||||
return STATUS_ERROR;
|
||||
uint mem=(uint)memalloc(fdProcessInfo->hProcess, 0, size, PAGE_EXECUTE_READWRITE);
|
||||
uint mem = (uint)memalloc(fdProcessInfo->hProcess, 0, size, PAGE_EXECUTE_READWRITE);
|
||||
if(!mem)
|
||||
dputs("VirtualAllocEx failed");
|
||||
else
|
||||
|
|
@ -716,8 +716,8 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
|
|||
{
|
||||
uint lastalloc;
|
||||
varget("$lastalloc", &lastalloc, 0, 0);
|
||||
char arg1[deflen]=""; //addr
|
||||
uint addr=lastalloc;
|
||||
char arg1[deflen] = ""; //addr
|
||||
uint addr = lastalloc;
|
||||
if(argget(*argv, arg1, 0, true))
|
||||
{
|
||||
if(!valfromstring(arg1, &addr, false))
|
||||
|
|
@ -728,9 +728,9 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
|
|||
dputs("lastalloc is zero, provide a page address");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(addr==lastalloc)
|
||||
if(addr == lastalloc)
|
||||
varset("$lastalloc", (uint)0, true);
|
||||
bool ok=!!VirtualFreeEx(fdProcessInfo->hProcess, (void*)addr, 0, MEM_RELEASE);
|
||||
bool ok = !!VirtualFreeEx(fdProcessInfo->hProcess, (void*)addr, 0, MEM_RELEASE);
|
||||
if(!ok)
|
||||
dputs("VirtualFreeEx failed");
|
||||
dbggetprivateusage(fdProcessInfo->hProcess, true);
|
||||
|
|
@ -741,11 +741,11 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugMemset(int argc, char* argv[])
|
||||
{
|
||||
char arg3[deflen]=""; //size
|
||||
char arg3[deflen] = ""; //size
|
||||
uint addr;
|
||||
uint value;
|
||||
uint size;
|
||||
if(argc<3)
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("not enough arguments");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -759,37 +759,37 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
uint base=memfindbaseaddr(addr, &size, true);
|
||||
uint base = memfindbaseaddr(addr, &size, true);
|
||||
if(!base)
|
||||
{
|
||||
dputs("invalid address specified");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
uint diff=addr-base;
|
||||
addr=base+diff;
|
||||
size-=diff;
|
||||
uint diff = addr - base;
|
||||
addr = base + diff;
|
||||
size -= diff;
|
||||
}
|
||||
BYTE fi=value&0xFF;
|
||||
if(!Fill((void*)addr, size&0xFFFFFFFF, &fi))
|
||||
BYTE fi = value & 0xFF;
|
||||
if(!Fill((void*)addr, size & 0xFFFFFFFF, &fi))
|
||||
dputs("memset failed");
|
||||
else
|
||||
dprintf("memory "fhex" (size: %.8X) set to %.2X\n", addr, size&0xFFFFFFFF, value&0xFF);
|
||||
dprintf("memory "fhex" (size: %.8X) set to %.2X\n", addr, size & 0xFFFFFFFF, value & 0xFF);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbDebugBenchmark(int argc, char* argv[])
|
||||
{
|
||||
uint addr=memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0);
|
||||
DWORD ticks=GetTickCount();
|
||||
char comment[MAX_COMMENT_SIZE]="";
|
||||
for(uint i=addr; i<addr+100000; i++)
|
||||
uint addr = memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0);
|
||||
DWORD ticks = GetTickCount();
|
||||
char comment[MAX_COMMENT_SIZE] = "";
|
||||
for(uint i = addr; i < addr + 100000; i++)
|
||||
{
|
||||
commentset(i, "test", false);
|
||||
labelset(i, "test", false);
|
||||
bookmarkset(i, false);
|
||||
functionadd(i, i, false);
|
||||
}
|
||||
dprintf("%ums\n", GetTickCount()-ticks);
|
||||
dprintf("%ums\n", GetTickCount() - ticks);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
@ -808,19 +808,19 @@ CMDRESULT cbDebugPause(int argc, char* argv[])
|
|||
static DWORD WINAPI scyllaThread(void* lpParam)
|
||||
{
|
||||
typedef INT (WINAPI * SCYLLASTARTGUI)(DWORD pid, HINSTANCE mod);
|
||||
SCYLLASTARTGUI ScyllaStartGui=0;
|
||||
HINSTANCE hScylla=LoadLibraryA("Scylla.dll");
|
||||
SCYLLASTARTGUI ScyllaStartGui = 0;
|
||||
HINSTANCE hScylla = LoadLibraryA("Scylla.dll");
|
||||
if(!hScylla)
|
||||
{
|
||||
dputs("error loading Scylla.dll!");
|
||||
bScyllaLoaded=false;
|
||||
bScyllaLoaded = false;
|
||||
return 0;
|
||||
}
|
||||
ScyllaStartGui=(SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui");
|
||||
ScyllaStartGui = (SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui");
|
||||
if(!ScyllaStartGui)
|
||||
{
|
||||
dputs("could not find export 'ScyllaStartGui' inside Scylla.dll");
|
||||
bScyllaLoaded=false;
|
||||
bScyllaLoaded = false;
|
||||
return 0;
|
||||
}
|
||||
if(dbgisdll())
|
||||
|
|
@ -828,7 +828,7 @@ static DWORD WINAPI scyllaThread(void* lpParam)
|
|||
else
|
||||
ScyllaStartGui(fdProcessInfo->dwProcessId, 0);
|
||||
FreeLibrary(hScylla);
|
||||
bScyllaLoaded=false;
|
||||
bScyllaLoaded = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -839,19 +839,19 @@ CMDRESULT cbDebugStartScylla(int argc, char* argv[])
|
|||
dputs("Scylla is already loaded");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
bScyllaLoaded=true;
|
||||
bScyllaLoaded = true;
|
||||
CloseHandle(CreateThread(0, 0, scyllaThread, 0, 0, 0));
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbDebugAttach(int argc, char* argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
uint pid=0;
|
||||
uint pid = 0;
|
||||
if(!valfromstring(argv[1], &pid))
|
||||
{
|
||||
dprintf("invalid expression \"%s\"!\n", argv[1]);
|
||||
|
|
@ -863,13 +863,13 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
|
|||
dputs("terminate the current session!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
HANDLE hProcess=TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid);
|
||||
HANDLE hProcess = TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid);
|
||||
if(!hProcess)
|
||||
{
|
||||
dprintf("could not open process %X!\n", pid);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
BOOL wow64=false, mewow64=false;
|
||||
BOOL wow64 = false, mewow64 = false;
|
||||
if(!IsWow64Process(hProcess, &wow64) or !IsWow64Process(GetCurrentProcess(), &mewow64))
|
||||
{
|
||||
dputs("IsWow64Process failed!");
|
||||
|
|
@ -908,12 +908,12 @@ CMDRESULT cbDebugDetach(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDump(int argc, char* argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
duint addr=0;
|
||||
duint addr = 0;
|
||||
if(!valfromstring(argv[1], &addr))
|
||||
{
|
||||
dprintf("invalid address \"%s\"!\n", argv[1]);
|
||||
|
|
@ -925,18 +925,18 @@ CMDRESULT cbDebugDump(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugStackDump(int argc, char* argv[])
|
||||
{
|
||||
duint addr=0;
|
||||
if(argc<2)
|
||||
addr=GetContextDataEx(hActiveThread, UE_CSP);
|
||||
duint addr = 0;
|
||||
if(argc < 2)
|
||||
addr = GetContextDataEx(hActiveThread, UE_CSP);
|
||||
else if(!valfromstring(argv[1], &addr))
|
||||
{
|
||||
dprintf("invalid address \"%s\"!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
duint csp=GetContextDataEx(hActiveThread, UE_CSP);
|
||||
duint size=0;
|
||||
duint base=memfindbaseaddr(csp, &size);
|
||||
if(base && addr>=base && addr<(base+size))
|
||||
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
|
||||
duint size = 0;
|
||||
duint base = memfindbaseaddr(csp, &size);
|
||||
if(base && addr >= base && addr < (base + size))
|
||||
GuiStackDumpAt(addr, csp);
|
||||
else
|
||||
dputs("invalid stack address!");
|
||||
|
|
@ -945,7 +945,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugContinue(int argc, char* argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
if(argc < 2)
|
||||
{
|
||||
SetNextDbgContinueStatus(DBG_CONTINUE);
|
||||
dputs("exception will be swallowed");
|
||||
|
|
@ -960,27 +960,27 @@ CMDRESULT cbDebugContinue(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugBpDll(int argc, char* argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
DWORD type=UE_ON_LIB_ALL;
|
||||
if(argc>2)
|
||||
DWORD type = UE_ON_LIB_ALL;
|
||||
if(argc > 2)
|
||||
{
|
||||
switch(*argv[2])
|
||||
{
|
||||
case 'l':
|
||||
type=UE_ON_LIB_LOAD;
|
||||
type = UE_ON_LIB_LOAD;
|
||||
break;
|
||||
case 'u':
|
||||
type=UE_ON_LIB_UNLOAD;
|
||||
type = UE_ON_LIB_UNLOAD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool singleshoot=true;
|
||||
if(argc>3)
|
||||
singleshoot=false;
|
||||
bool singleshoot = true;
|
||||
if(argc > 3)
|
||||
singleshoot = false;
|
||||
LibrarianSetBreakPoint(argv[1], type, singleshoot, (void*)cbLibrarianBreakpoint);
|
||||
dprintf("dll breakpoint set on \"%s\"!\n", argv[1]);
|
||||
return STATUS_CONTINUE;
|
||||
|
|
@ -988,7 +988,7 @@ CMDRESULT cbDebugBpDll(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugBcDll(int argc, char* argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("not enough arguments");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1004,8 +1004,8 @@ CMDRESULT cbDebugBcDll(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
|
||||
{
|
||||
uint threadid=fdProcessInfo->dwThreadId; //main thread
|
||||
if(argc>1)
|
||||
uint threadid = fdProcessInfo->dwThreadId; //main thread
|
||||
if(argc > 1)
|
||||
if(!valfromstring(argv[1], &threadid, false))
|
||||
return STATUS_ERROR;
|
||||
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
|
||||
|
|
@ -1014,7 +1014,7 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
}
|
||||
//switch thread
|
||||
hActiveThread=threadgethandle((DWORD)threadid);
|
||||
hActiveThread = threadgethandle((DWORD)threadid);
|
||||
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true);
|
||||
dputs("thread switched!");
|
||||
return STATUS_CONTINUE;
|
||||
|
|
@ -1023,7 +1023,7 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
|
|||
CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
|
||||
{
|
||||
uint threadid = fdProcessInfo->dwThreadId;
|
||||
if(argc>1)
|
||||
if(argc > 1)
|
||||
if(!valfromstring(argv[1], &threadid, false))
|
||||
return STATUS_ERROR;
|
||||
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
|
||||
|
|
@ -1045,7 +1045,7 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
|
|||
CMDRESULT cbDebugResumethread(int argc, char* argv[])
|
||||
{
|
||||
uint threadid = fdProcessInfo->dwThreadId;
|
||||
if(argc>1)
|
||||
if(argc > 1)
|
||||
if(!valfromstring(argv[1], &threadid, false))
|
||||
return STATUS_ERROR;
|
||||
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
|
||||
|
|
@ -1067,11 +1067,11 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[])
|
|||
CMDRESULT cbDebugKillthread(int argc, char* argv[])
|
||||
{
|
||||
uint threadid = fdProcessInfo->dwThreadId;
|
||||
if(argc>1)
|
||||
if(argc > 1)
|
||||
if(!valfromstring(argv[1], &threadid, false))
|
||||
return STATUS_ERROR;
|
||||
uint exitcode = 0;
|
||||
if(argc>2)
|
||||
if(argc > 2)
|
||||
if(!valfromstring(argv[2], &exitcode, false))
|
||||
return STATUS_ERROR;
|
||||
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
|
||||
|
|
@ -1092,7 +1092,7 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugSetPriority(int argc, char* argv[])
|
||||
{
|
||||
if(argc<3)
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1158,8 +1158,8 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
DWORD drx=0;
|
||||
char arg1[deflen] = "";
|
||||
DWORD drx = 0;
|
||||
if(!GetUnusedHardwareBreakPointRegister(&drx))
|
||||
{
|
||||
dputs("you can only set 4 hardware breakpoints");
|
||||
|
|
@ -1179,7 +1179,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
BREAKPOINT found;
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
|
||||
{
|
||||
dprintf("no such hardware breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -1205,7 +1205,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all hardware breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPHARDWARE))
|
||||
|
|
@ -1220,7 +1220,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
BREAKPOINT found;
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
|
||||
{
|
||||
dprintf("no such hardware breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -1243,8 +1243,8 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
DWORD drx=0;
|
||||
char arg1[deflen] = "";
|
||||
DWORD drx = 0;
|
||||
if(!GetUnusedHardwareBreakPointRegister(0))
|
||||
{
|
||||
dputs("you can only set 4 hardware breakpoints");
|
||||
|
|
@ -1264,7 +1264,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
BREAKPOINT found;
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
|
||||
{
|
||||
dprintf("no such memory breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -1276,7 +1276,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
|
|||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint size=0;
|
||||
uint size = 0;
|
||||
memfindbaseaddr(found.addr, &size);
|
||||
if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint))
|
||||
{
|
||||
|
|
@ -1290,7 +1290,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
char arg1[deflen] = "";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all memory breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPMEMORY))
|
||||
|
|
@ -1305,7 +1305,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
BREAKPOINT found;
|
||||
uint addr=0;
|
||||
uint addr = 0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
|
||||
{
|
||||
dprintf("no such memory breakpoint \"%s\"\n", arg1);
|
||||
|
|
@ -1316,7 +1316,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
|
|||
dputs("memory breakpoint already disabled!");
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint size=0;
|
||||
uint size = 0;
|
||||
memfindbaseaddr(found.addr, &size);
|
||||
if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,69 +25,69 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
|
|||
//copy instruction text
|
||||
strcpy(basicinfo->instruction, disasm->CompleteInstr);
|
||||
//find immidiat
|
||||
if(disasm->Instruction.BranchType==0) //no branch
|
||||
if(disasm->Instruction.BranchType == 0) //no branch
|
||||
{
|
||||
if((disasm->Argument1.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE)
|
||||
if((disasm->Argument1.ArgType & CONSTANT_TYPE) == CONSTANT_TYPE)
|
||||
{
|
||||
basicinfo->type|=TYPE_VALUE;
|
||||
basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat;
|
||||
basicinfo->value.size=argsize2memsize(disasm->Argument1.ArgSize);
|
||||
basicinfo->type |= TYPE_VALUE;
|
||||
basicinfo->value.value = (ULONG_PTR)disasm->Instruction.Immediat;
|
||||
basicinfo->value.size = argsize2memsize(disasm->Argument1.ArgSize);
|
||||
}
|
||||
else if((disasm->Argument2.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE)
|
||||
else if((disasm->Argument2.ArgType & CONSTANT_TYPE) == CONSTANT_TYPE)
|
||||
{
|
||||
basicinfo->type|=TYPE_VALUE;
|
||||
basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat;
|
||||
basicinfo->value.size=argsize2memsize(disasm->Argument2.ArgSize);
|
||||
basicinfo->type |= TYPE_VALUE;
|
||||
basicinfo->value.value = (ULONG_PTR)disasm->Instruction.Immediat;
|
||||
basicinfo->value.size = argsize2memsize(disasm->Argument2.ArgSize);
|
||||
}
|
||||
}
|
||||
else //branch
|
||||
{
|
||||
basicinfo->branch=true;
|
||||
if(disasm->Instruction.BranchType==CallType)
|
||||
basicinfo->call=true;
|
||||
if(disasm->Instruction.BranchType==RetType)
|
||||
basicinfo->branch=false;
|
||||
basicinfo->branch = true;
|
||||
if(disasm->Instruction.BranchType == CallType)
|
||||
basicinfo->call = true;
|
||||
if(disasm->Instruction.BranchType == RetType)
|
||||
basicinfo->branch = false;
|
||||
}
|
||||
//find memory displacement
|
||||
if((disasm->Argument1.ArgType&MEMORY_TYPE)==MEMORY_TYPE || (disasm->Argument2.ArgType&MEMORY_TYPE)==MEMORY_TYPE)
|
||||
if((disasm->Argument1.ArgType & MEMORY_TYPE) == MEMORY_TYPE || (disasm->Argument2.ArgType & MEMORY_TYPE) == MEMORY_TYPE)
|
||||
{
|
||||
if(disasm->Argument1.Memory.Displacement)
|
||||
{
|
||||
basicinfo->type|=TYPE_MEMORY;
|
||||
basicinfo->memory.value=(ULONG_PTR)disasm->Argument1.Memory.Displacement;
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Argument1.Memory.Displacement;
|
||||
strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
|
||||
basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize);
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
|
||||
}
|
||||
else if(disasm->Argument2.Memory.Displacement)
|
||||
{
|
||||
basicinfo->type|=TYPE_MEMORY;
|
||||
basicinfo->memory.value=(ULONG_PTR)disasm->Argument2.Memory.Displacement;
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Argument2.Memory.Displacement;
|
||||
strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
|
||||
basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize);
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
|
||||
}
|
||||
}
|
||||
//find address value
|
||||
if(disasm->Instruction.BranchType && disasm->Instruction.AddrValue)
|
||||
{
|
||||
basicinfo->type|=TYPE_ADDR;
|
||||
basicinfo->addr=(ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
basicinfo->type |= TYPE_ADDR;
|
||||
basicinfo->addr = (ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
}
|
||||
//rip-relative (non-branch)
|
||||
if(disasm->Instruction.BranchType==0)
|
||||
if(disasm->Instruction.BranchType == 0)
|
||||
{
|
||||
if((disasm->Argument1.ArgType&RELATIVE_)==RELATIVE_)
|
||||
if((disasm->Argument1.ArgType & RELATIVE_) == RELATIVE_)
|
||||
{
|
||||
basicinfo->type|=TYPE_MEMORY;
|
||||
basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
|
||||
basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize);
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
|
||||
}
|
||||
else if((disasm->Argument2.ArgType&RELATIVE_)==RELATIVE_)
|
||||
else if((disasm->Argument2.ArgType & RELATIVE_) == RELATIVE_)
|
||||
{
|
||||
basicinfo->type|=TYPE_MEMORY;
|
||||
basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
|
||||
basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize);
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,15 +99,15 @@ bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinf
|
|||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(disasm));
|
||||
#ifdef _WIN64
|
||||
disasm.Archi=64;
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.EIP=(UIntPtr)data;
|
||||
disasm.VirtualAddr=(UInt64)addr;
|
||||
int len=Disasm(&disasm);
|
||||
if(len==UNKNOWN_OPCODE)
|
||||
disasm.EIP = (UIntPtr)data;
|
||||
disasm.VirtualAddr = (UInt64)addr;
|
||||
int len = Disasm(&disasm);
|
||||
if(len == UNKNOWN_OPCODE)
|
||||
return false;
|
||||
fillbasicinfo(&disasm, basicinfo);
|
||||
basicinfo->size=len;
|
||||
basicinfo->size = len;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,16 +20,16 @@ uint disasmback(unsigned char* data, uint base, uint size, uint ip, int n)
|
|||
#ifdef _WIN64
|
||||
disasm.Archi = 64;
|
||||
#endif
|
||||
disasm.Options=NoformatNumeral;
|
||||
disasm.Options = NoformatNumeral;
|
||||
|
||||
// Check if the pointer is not null
|
||||
if (data == NULL)
|
||||
if(data == NULL)
|
||||
return 0;
|
||||
|
||||
// Round the number of back instructions to 127
|
||||
if(n < 0)
|
||||
n = 0;
|
||||
else if (n > 127)
|
||||
else if(n > 127)
|
||||
n = 127;
|
||||
|
||||
// Check if the instruction pointer ip is not outside the memory range
|
||||
|
|
@ -84,12 +84,12 @@ uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
|
|||
#ifdef _WIN64
|
||||
disasm.Archi = 64;
|
||||
#endif
|
||||
disasm.Options=NoformatNumeral;
|
||||
disasm.Options = NoformatNumeral;
|
||||
|
||||
if(data == NULL)
|
||||
return 0;
|
||||
|
||||
if (ip >= size)
|
||||
if(ip >= size)
|
||||
ip = size - 1;
|
||||
|
||||
if(n <= 0)
|
||||
|
|
@ -115,18 +115,18 @@ uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
|
|||
|
||||
const char* disasmtext(uint addr)
|
||||
{
|
||||
unsigned char buffer[16]="";
|
||||
unsigned char buffer[16] = "";
|
||||
DbgMemRead(addr, buffer, 16);
|
||||
DISASM disasm;
|
||||
disasm.Options=NoformatNumeral;
|
||||
disasm.Options = NoformatNumeral;
|
||||
#ifdef _WIN64
|
||||
disasm.Archi=64;
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.VirtualAddr=addr;
|
||||
disasm.EIP=(UIntPtr)buffer;
|
||||
int len=Disasm(&disasm);
|
||||
static char instruction[INSTRUCT_LENGTH]="";
|
||||
if(len==UNKNOWN_OPCODE)
|
||||
disasm.VirtualAddr = addr;
|
||||
disasm.EIP = (UIntPtr)buffer;
|
||||
int len = Disasm(&disasm);
|
||||
static char instruction[INSTRUCT_LENGTH] = "";
|
||||
if(len == UNKNOWN_OPCODE)
|
||||
strcpy(instruction, "???");
|
||||
else
|
||||
strcpy(instruction, disasm.CompleteInstr);
|
||||
|
|
@ -161,26 +161,26 @@ static SEGMENTREG ConvertBeaSeg(int beaSeg)
|
|||
|
||||
static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG* arg, uint addr)
|
||||
{
|
||||
int argtype=Argument->ArgType;
|
||||
const char* argmnemonic=Argument->ArgMnemonic;
|
||||
int argtype = Argument->ArgType;
|
||||
const char* argmnemonic = Argument->ArgMnemonic;
|
||||
if(!*argmnemonic)
|
||||
return false;
|
||||
arg->memvalue=0;
|
||||
arg->memvalue = 0;
|
||||
strcpy(arg->mnemonic, argmnemonic);
|
||||
if((argtype&MEMORY_TYPE)==MEMORY_TYPE)
|
||||
if((argtype & MEMORY_TYPE) == MEMORY_TYPE)
|
||||
{
|
||||
arg->type=arg_memory;
|
||||
arg->segment=ConvertBeaSeg(Argument->SegmentReg);
|
||||
uint value=(uint)Argument->Memory.Displacement;
|
||||
if((Argument->ArgType&RELATIVE_)==RELATIVE_)
|
||||
value=(uint)Instruction->AddrValue;
|
||||
arg->constant=value;
|
||||
arg->value=0;
|
||||
arg->type = arg_memory;
|
||||
arg->segment = ConvertBeaSeg(Argument->SegmentReg);
|
||||
uint value = (uint)Argument->Memory.Displacement;
|
||||
if((Argument->ArgType & RELATIVE_) == RELATIVE_)
|
||||
value = (uint)Instruction->AddrValue;
|
||||
arg->constant = value;
|
||||
arg->value = 0;
|
||||
if(!valfromstring(argmnemonic, &value, true, true))
|
||||
return false;
|
||||
if(DbgMemIsValidReadPtr(value))
|
||||
{
|
||||
arg->value=value;
|
||||
arg->value = value;
|
||||
switch(Argument->ArgSize) //TODO: segments
|
||||
{
|
||||
case 8:
|
||||
|
|
@ -200,17 +200,17 @@ static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG
|
|||
}
|
||||
else
|
||||
{
|
||||
arg->segment=SEG_DEFAULT;
|
||||
arg->type=arg_normal;
|
||||
uint value=0;
|
||||
arg->segment = SEG_DEFAULT;
|
||||
arg->type = arg_normal;
|
||||
uint value = 0;
|
||||
if(!valfromstring(argmnemonic, &value, true, true))
|
||||
return false;
|
||||
arg->value=value;
|
||||
char sValue[64]="";
|
||||
arg->value = value;
|
||||
char sValue[64] = "";
|
||||
sprintf(sValue, "%"fext"X", value);
|
||||
if(_stricmp(argmnemonic, sValue))
|
||||
value=0;
|
||||
arg->constant=value;
|
||||
value = 0;
|
||||
arg->constant = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -220,34 +220,34 @@ void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr)
|
|||
if(!DbgIsDebugging())
|
||||
{
|
||||
if(instr)
|
||||
instr->argcount=0;
|
||||
instr->argcount = 0;
|
||||
return;
|
||||
}
|
||||
memset(instr, 0, sizeof(DISASM_INSTR));
|
||||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(DISASM));
|
||||
disasm.Options=NoformatNumeral;
|
||||
disasm.Options = NoformatNumeral;
|
||||
#ifdef _WIN64
|
||||
disasm.Archi=64;
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.VirtualAddr=addr;
|
||||
disasm.EIP=(UIntPtr)buffer;
|
||||
int len=Disasm(&disasm);
|
||||
disasm.VirtualAddr = addr;
|
||||
disasm.EIP = (UIntPtr)buffer;
|
||||
int len = Disasm(&disasm);
|
||||
strcpy(instr->instruction, disasm.CompleteInstr);
|
||||
if(len==UNKNOWN_OPCODE)
|
||||
if(len == UNKNOWN_OPCODE)
|
||||
{
|
||||
instr->instr_size=1;
|
||||
instr->type=instr_normal;
|
||||
instr->argcount=0;
|
||||
instr->instr_size = 1;
|
||||
instr->type = instr_normal;
|
||||
instr->argcount = 0;
|
||||
return;
|
||||
}
|
||||
instr->instr_size=len;
|
||||
instr->instr_size = len;
|
||||
if(disasm.Instruction.BranchType)
|
||||
instr->type=instr_branch;
|
||||
instr->type = instr_branch;
|
||||
else if(strstr(disasm.CompleteInstr, "sp") or strstr(disasm.CompleteInstr, "bp"))
|
||||
instr->type=instr_stack;
|
||||
instr->type = instr_stack;
|
||||
else
|
||||
instr->type=instr_normal;
|
||||
instr->type = instr_normal;
|
||||
if(HandleArgument(&disasm.Argument1, &disasm.Instruction, &instr->arg[instr->argcount], addr))
|
||||
instr->argcount++;
|
||||
if(HandleArgument(&disasm.Argument2, &disasm.Instruction, &instr->arg[instr->argcount], addr))
|
||||
|
|
@ -261,10 +261,10 @@ void disasmget(uint addr, DISASM_INSTR* instr)
|
|||
if(!DbgIsDebugging())
|
||||
{
|
||||
if(instr)
|
||||
instr->argcount=0;
|
||||
instr->argcount = 0;
|
||||
return;
|
||||
}
|
||||
unsigned char buffer[16]="";
|
||||
unsigned char buffer[16] = "";
|
||||
DbgMemRead(addr, buffer, 16);
|
||||
disasmget(buffer, addr, instr);
|
||||
}
|
||||
|
|
@ -275,22 +275,22 @@ void disasmprint(uint addr)
|
|||
memset(&instr, 0, sizeof(instr));
|
||||
disasmget(addr, &instr);
|
||||
dprintf(">%d:\"%s\":\n", instr.type, instr.instruction);
|
||||
for(int i=0; i<instr.argcount; i++)
|
||||
for(int i = 0; i < instr.argcount; i++)
|
||||
dprintf(" %d:%d:%"fext"X:%"fext"X:%"fext"X\n", i, instr.arg[i].type, instr.arg[i].constant, instr.arg[i].value, instr.arg[i].memvalue);
|
||||
}
|
||||
|
||||
static bool isasciistring(const unsigned char* data, int maxlen)
|
||||
{
|
||||
int len = 0;
|
||||
for (char *p = (char *)data; *p; len++, p++)
|
||||
for(char* p = (char*)data; *p; len++, p++)
|
||||
{
|
||||
if (len >= maxlen)
|
||||
if(len >= maxlen)
|
||||
break;
|
||||
}
|
||||
|
||||
if(len<2 or len+1>=maxlen)
|
||||
if(len < 2 or len + 1 >= maxlen)
|
||||
return false;
|
||||
for(int i=0; i<len; i++)
|
||||
for(int i = 0; i < len; i++)
|
||||
if(!isprint(data[i]) and !isspace(data[i]))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -299,17 +299,17 @@ static bool isasciistring(const unsigned char* data, int maxlen)
|
|||
static bool isunicodestring(const unsigned char* data, int maxlen)
|
||||
{
|
||||
int len = 0;
|
||||
for (wchar_t *p = (wchar_t *)data; *p; len++, p++)
|
||||
for(wchar_t* p = (wchar_t*)data; *p; len++, p++)
|
||||
{
|
||||
if (len >= maxlen)
|
||||
if(len >= maxlen)
|
||||
break;
|
||||
}
|
||||
|
||||
if(len<2 or len+1>=maxlen)
|
||||
if(len < 2 or len + 1 >= maxlen)
|
||||
return false;
|
||||
for(int i=0; i<len*2; i+=2)
|
||||
for(int i = 0; i < len * 2; i += 2)
|
||||
{
|
||||
if(data[i+1])
|
||||
if(data[i + 1])
|
||||
return false;
|
||||
if(!isprint(data[i]) and !isspace(data[i]))
|
||||
return false;
|
||||
|
|
@ -321,9 +321,9 @@ bool disasmispossiblestring(uint addr)
|
|||
{
|
||||
unsigned char data[11];
|
||||
memset(data, 0, sizeof(data));
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data)-3, 0))
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data) - 3, 0))
|
||||
return false;
|
||||
uint test=0;
|
||||
uint test = 0;
|
||||
memcpy(&test, data, sizeof(uint));
|
||||
if(memisvalidreadptr(fdProcessInfo->hProcess, test)) //imports/pointers
|
||||
return false;
|
||||
|
|
@ -335,17 +335,17 @@ bool disasmispossiblestring(uint addr)
|
|||
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
|
||||
{
|
||||
if(type)
|
||||
*type=str_none;
|
||||
*type = str_none;
|
||||
if(!disasmispossiblestring(addr))
|
||||
return false;
|
||||
unsigned char* data=(unsigned char*)emalloc((maxlen+1)*2, "disasmgetstringat:data");
|
||||
memset(data, 0, (maxlen+1)*2);
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen+1)*2, 0))
|
||||
unsigned char* data = (unsigned char*)emalloc((maxlen + 1) * 2, "disasmgetstringat:data");
|
||||
memset(data, 0, (maxlen + 1) * 2);
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen + 1) * 2, 0))
|
||||
{
|
||||
efree(data, "disasmgetstringat:data");
|
||||
return false;
|
||||
}
|
||||
uint test=0;
|
||||
uint test = 0;
|
||||
memcpy(&test, data, sizeof(uint));
|
||||
if(memisvalidreadptr(fdProcessInfo->hProcess, test))
|
||||
{
|
||||
|
|
@ -355,35 +355,35 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
if(isasciistring(data, maxlen))
|
||||
{
|
||||
if(type)
|
||||
*type=str_ascii;
|
||||
int len=(int)strlen((const char*)data);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
*type = str_ascii;
|
||||
int len = (int)strlen((const char*)data);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
switch(data[i])
|
||||
{
|
||||
case '\t':
|
||||
j+=sprintf(ascii+j, "\\t");
|
||||
j += sprintf(ascii + j, "\\t");
|
||||
break;
|
||||
case '\f':
|
||||
j+=sprintf(ascii+j, "\\f");
|
||||
j += sprintf(ascii + j, "\\f");
|
||||
break;
|
||||
case '\v':
|
||||
j+=sprintf(ascii+j, "\\v");
|
||||
j += sprintf(ascii + j, "\\v");
|
||||
break;
|
||||
case '\n':
|
||||
j+=sprintf(ascii+j, "\\n");
|
||||
j += sprintf(ascii + j, "\\n");
|
||||
break;
|
||||
case '\r':
|
||||
j+=sprintf(ascii+j, "\\r");
|
||||
j += sprintf(ascii + j, "\\r");
|
||||
break;
|
||||
case '\\':
|
||||
j+=sprintf(ascii+j, "\\\\");
|
||||
j += sprintf(ascii + j, "\\\\");
|
||||
break;
|
||||
case '\"':
|
||||
j+=sprintf(ascii+j, "\\\"");
|
||||
j += sprintf(ascii + j, "\\\"");
|
||||
break;
|
||||
default:
|
||||
j+=sprintf(ascii+j, "%c", data[i]);
|
||||
j += sprintf(ascii + j, "%c", data[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -393,35 +393,35 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
else if(isunicodestring(data, maxlen))
|
||||
{
|
||||
if(type)
|
||||
*type=str_unicode;
|
||||
int len=(int)wcslen((const wchar_t*)data);
|
||||
for(int i=0,j=0; i<len*2; i+=2)
|
||||
*type = str_unicode;
|
||||
int len = (int)wcslen((const wchar_t*)data);
|
||||
for(int i = 0, j = 0; i < len * 2; i += 2)
|
||||
{
|
||||
switch(data[i])
|
||||
{
|
||||
case '\t':
|
||||
j+=sprintf(unicode+j, "\\t");
|
||||
j += sprintf(unicode + j, "\\t");
|
||||
break;
|
||||
case '\f':
|
||||
j+=sprintf(unicode+j, "\\f");
|
||||
j += sprintf(unicode + j, "\\f");
|
||||
break;
|
||||
case '\v':
|
||||
j+=sprintf(unicode+j, "\\v");
|
||||
j += sprintf(unicode + j, "\\v");
|
||||
break;
|
||||
case '\n':
|
||||
j+=sprintf(unicode+j, "\\n");
|
||||
j += sprintf(unicode + j, "\\n");
|
||||
break;
|
||||
case '\r':
|
||||
j+=sprintf(unicode+j, "\\r");
|
||||
j += sprintf(unicode + j, "\\r");
|
||||
break;
|
||||
case '\\':
|
||||
j+=sprintf(unicode+j, "\\\\");
|
||||
j += sprintf(unicode + j, "\\\\");
|
||||
break;
|
||||
case '\"':
|
||||
j+=sprintf(unicode+j, "\\\"");
|
||||
j += sprintf(unicode + j, "\\\"");
|
||||
break;
|
||||
default:
|
||||
j+=sprintf(unicode+j, "%c", data[i]);
|
||||
j += sprintf(unicode + j, "%c", data[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -436,15 +436,15 @@ int disasmgetsize(uint addr, unsigned char* data)
|
|||
{
|
||||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(DISASM));
|
||||
disasm.Options=NoformatNumeral;
|
||||
disasm.Options = NoformatNumeral;
|
||||
#ifdef _WIN64
|
||||
disasm.Archi=64;
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.VirtualAddr=addr;
|
||||
disasm.EIP=(UIntPtr)data;
|
||||
int len=Disasm(&disasm);
|
||||
if(len==UNKNOWN_OPCODE)
|
||||
len=1;
|
||||
disasm.VirtualAddr = addr;
|
||||
disasm.EIP = (UIntPtr)data;
|
||||
int len = Disasm(&disasm);
|
||||
if(len == UNKNOWN_OPCODE)
|
||||
len = 1;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -88,13 +88,13 @@ typedef long json_int_t;
|
|||
|
||||
__declspec(dllimport) json_t* json_object(void);
|
||||
__declspec(dllimport) json_t* json_array(void);
|
||||
__declspec(dllimport) json_t* json_string(const char *value);
|
||||
__declspec(dllimport) json_t* json_stringn(const char *value, size_t len);
|
||||
__declspec(dllimport) json_t* json_string_nocheck(const char *value);
|
||||
__declspec(dllimport) json_t* json_stringn_nocheck(const char *value, size_t len);
|
||||
__declspec(dllimport) json_t* json_string(const char* value);
|
||||
__declspec(dllimport) json_t* json_stringn(const char* value, size_t len);
|
||||
__declspec(dllimport) json_t* json_string_nocheck(const char* value);
|
||||
__declspec(dllimport) json_t* json_stringn_nocheck(const char* value, size_t len);
|
||||
__declspec(dllimport) json_t* json_integer(json_int_t value);
|
||||
static JSON_INLINE
|
||||
json_t *json_hex(json_int_t value)
|
||||
json_t* json_hex(json_int_t value)
|
||||
{
|
||||
char hexvalue[20];
|
||||
#ifdef _WIN64
|
||||
|
|
@ -111,20 +111,20 @@ __declspec(dllimport) json_t* json_false(void);
|
|||
__declspec(dllimport) json_t* json_null(void);
|
||||
|
||||
static JSON_INLINE
|
||||
json_t *json_incref(json_t *json)
|
||||
json_t* json_incref(json_t* json)
|
||||
{
|
||||
if(json && json->refcount != (size_t)-1)
|
||||
if(json && json->refcount != (size_t) - 1)
|
||||
++json->refcount;
|
||||
return json;
|
||||
}
|
||||
|
||||
/* do not call json_delete directly */
|
||||
__declspec(dllimport) void json_delete(json_t *json);
|
||||
__declspec(dllimport) void json_delete(json_t* json);
|
||||
|
||||
static JSON_INLINE
|
||||
void json_decref(json_t *json)
|
||||
void json_decref(json_t* json)
|
||||
{
|
||||
if(json && json->refcount != (size_t)-1 && --json->refcount == 0)
|
||||
if(json && json->refcount != (size_t) - 1 && --json->refcount == 0)
|
||||
json_delete(json);
|
||||
}
|
||||
|
||||
|
|
@ -147,22 +147,22 @@ typedef struct
|
|||
/* getters, setters, manipulation */
|
||||
|
||||
__declspec(dllimport) void json_object_seed(size_t seed);
|
||||
__declspec(dllimport) size_t json_object_size(const json_t *object);
|
||||
__declspec(dllimport) json_t* json_object_get(const json_t *object, const char *key);
|
||||
__declspec(dllimport) int json_object_set_new(json_t *object, const char *key, json_t *value);
|
||||
__declspec(dllimport) int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value);
|
||||
__declspec(dllimport) int json_object_del(json_t *object, const char *key);
|
||||
__declspec(dllimport) int json_object_clear(json_t *object);
|
||||
__declspec(dllimport) int json_object_update(json_t *object, json_t *other);
|
||||
__declspec(dllimport) int json_object_update_existing(json_t *object, json_t *other);
|
||||
__declspec(dllimport) int json_object_update_missing(json_t *object, json_t *other);
|
||||
__declspec(dllimport) void* json_object_iter(json_t *object);
|
||||
__declspec(dllimport) void* json_object_iter_at(json_t *object, const char *key);
|
||||
__declspec(dllimport) void* json_object_key_to_iter(const char *key);
|
||||
__declspec(dllimport) void* json_object_iter_next(json_t *object, void *iter);
|
||||
__declspec(dllimport) const char* json_object_iter_key(void *iter);
|
||||
__declspec(dllimport) json_t* json_object_iter_value(void *iter);
|
||||
__declspec(dllimport) int json_object_iter_set_new(json_t *object, void *iter, json_t *value);
|
||||
__declspec(dllimport) size_t json_object_size(const json_t* object);
|
||||
__declspec(dllimport) json_t* json_object_get(const json_t* object, const char* key);
|
||||
__declspec(dllimport) int json_object_set_new(json_t* object, const char* key, json_t* value);
|
||||
__declspec(dllimport) int json_object_set_new_nocheck(json_t* object, const char* key, json_t* value);
|
||||
__declspec(dllimport) int json_object_del(json_t* object, const char* key);
|
||||
__declspec(dllimport) int json_object_clear(json_t* object);
|
||||
__declspec(dllimport) int json_object_update(json_t* object, json_t* other);
|
||||
__declspec(dllimport) int json_object_update_existing(json_t* object, json_t* other);
|
||||
__declspec(dllimport) int json_object_update_missing(json_t* object, json_t* other);
|
||||
__declspec(dllimport) void* json_object_iter(json_t* object);
|
||||
__declspec(dllimport) void* json_object_iter_at(json_t* object, const char* key);
|
||||
__declspec(dllimport) void* json_object_key_to_iter(const char* key);
|
||||
__declspec(dllimport) void* json_object_iter_next(json_t* object, void* iter);
|
||||
__declspec(dllimport) const char* json_object_iter_key(void* iter);
|
||||
__declspec(dllimport) json_t* json_object_iter_value(void* iter);
|
||||
__declspec(dllimport) int json_object_iter_set_new(json_t* object, void* iter, json_t* value);
|
||||
|
||||
#define json_object_foreach(object, key, value) \
|
||||
for(key = json_object_iter_key(json_object_iter(object)); \
|
||||
|
|
@ -175,59 +175,59 @@ __declspec(dllimport) int json_object_iter_set_new(json_t *object, void *iter, j
|
|||
index++)
|
||||
|
||||
static JSON_INLINE
|
||||
int json_object_set(json_t *object, const char *key, json_t *value)
|
||||
int json_object_set(json_t* object, const char* key, json_t* value)
|
||||
{
|
||||
return json_object_set_new(object, key, json_incref(value));
|
||||
}
|
||||
|
||||
static JSON_INLINE
|
||||
int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
|
||||
int json_object_set_nocheck(json_t* object, const char* key, json_t* value)
|
||||
{
|
||||
return json_object_set_new_nocheck(object, key, json_incref(value));
|
||||
}
|
||||
|
||||
static JSON_INLINE
|
||||
int json_object_iter_set(json_t *object, void *iter, json_t *value)
|
||||
int json_object_iter_set(json_t* object, void* iter, json_t* value)
|
||||
{
|
||||
return json_object_iter_set_new(object, iter, json_incref(value));
|
||||
}
|
||||
|
||||
__declspec(dllimport) size_t json_array_size(const json_t *array);
|
||||
__declspec(dllimport) json_t* json_array_get(const json_t *array, size_t index);
|
||||
__declspec(dllimport) int json_array_set_new(json_t *array, size_t index, json_t *value);
|
||||
__declspec(dllimport) int json_array_append_new(json_t *array, json_t *value);
|
||||
__declspec(dllimport) int json_array_insert_new(json_t *array, size_t index, json_t *value);
|
||||
__declspec(dllimport) int json_array_remove(json_t *array, size_t index);
|
||||
__declspec(dllimport) int json_array_clear(json_t *array);
|
||||
__declspec(dllimport) int json_array_extend(json_t *array, json_t *other);
|
||||
__declspec(dllimport) size_t json_array_size(const json_t* array);
|
||||
__declspec(dllimport) json_t* json_array_get(const json_t* array, size_t index);
|
||||
__declspec(dllimport) int json_array_set_new(json_t* array, size_t index, json_t* value);
|
||||
__declspec(dllimport) int json_array_append_new(json_t* array, json_t* value);
|
||||
__declspec(dllimport) int json_array_insert_new(json_t* array, size_t index, json_t* value);
|
||||
__declspec(dllimport) int json_array_remove(json_t* array, size_t index);
|
||||
__declspec(dllimport) int json_array_clear(json_t* array);
|
||||
__declspec(dllimport) int json_array_extend(json_t* array, json_t* other);
|
||||
|
||||
static JSON_INLINE
|
||||
int json_array_set(json_t *array, size_t ind, json_t *value)
|
||||
int json_array_set(json_t* array, size_t ind, json_t* value)
|
||||
{
|
||||
return json_array_set_new(array, ind, json_incref(value));
|
||||
}
|
||||
|
||||
static JSON_INLINE
|
||||
int json_array_append(json_t *array, json_t *value)
|
||||
int json_array_append(json_t* array, json_t* value)
|
||||
{
|
||||
return json_array_append_new(array, json_incref(value));
|
||||
}
|
||||
|
||||
static JSON_INLINE
|
||||
int json_array_insert(json_t *array, size_t ind, json_t *value)
|
||||
int json_array_insert(json_t* array, size_t ind, json_t* value)
|
||||
{
|
||||
return json_array_insert_new(array, ind, json_incref(value));
|
||||
}
|
||||
|
||||
__declspec(dllimport) const char* json_string_value(const json_t *string);
|
||||
__declspec(dllimport) size_t json_string_length(const json_t *string);
|
||||
__declspec(dllimport) json_int_t json_integer_value(const json_t *integer);
|
||||
__declspec(dllimport) const char* json_string_value(const json_t* string);
|
||||
__declspec(dllimport) size_t json_string_length(const json_t* string);
|
||||
__declspec(dllimport) json_int_t json_integer_value(const json_t* integer);
|
||||
static JSON_INLINE
|
||||
json_int_t json_hex_value(const json_t* hex)
|
||||
{
|
||||
json_int_t ret;
|
||||
const char* hexvalue;
|
||||
hexvalue=json_string_value(hex);
|
||||
hexvalue = json_string_value(hex);
|
||||
if(!hexvalue)
|
||||
return 0;
|
||||
#ifdef _WIN64
|
||||
|
|
@ -237,39 +237,39 @@ json_int_t json_hex_value(const json_t* hex)
|
|||
#endif //_WIN64
|
||||
return ret;
|
||||
}
|
||||
__declspec(dllimport) double json_real_value(const json_t *real);
|
||||
__declspec(dllimport) double json_number_value(const json_t *json);
|
||||
__declspec(dllimport) double json_real_value(const json_t* real);
|
||||
__declspec(dllimport) double json_number_value(const json_t* json);
|
||||
|
||||
__declspec(dllimport) int json_string_set(json_t *string, const char *value);
|
||||
__declspec(dllimport) int json_string_setn(json_t *string, const char *value, size_t len);
|
||||
__declspec(dllimport) int json_string_set_nocheck(json_t *string, const char *value);
|
||||
__declspec(dllimport) int json_string_setn_nocheck(json_t *string, const char *value, size_t len);
|
||||
__declspec(dllimport) int json_integer_set(json_t *integer, json_int_t value);
|
||||
__declspec(dllimport) int json_real_set(json_t *real, double value);
|
||||
__declspec(dllimport) int json_string_set(json_t* string, const char* value);
|
||||
__declspec(dllimport) int json_string_setn(json_t* string, const char* value, size_t len);
|
||||
__declspec(dllimport) int json_string_set_nocheck(json_t* string, const char* value);
|
||||
__declspec(dllimport) int json_string_setn_nocheck(json_t* string, const char* value, size_t len);
|
||||
__declspec(dllimport) int json_integer_set(json_t* integer, json_int_t value);
|
||||
__declspec(dllimport) int json_real_set(json_t* real, double value);
|
||||
|
||||
/* pack, unpack */
|
||||
|
||||
__declspec(dllimport) json_t* json_pack(const char *fmt, ...);
|
||||
__declspec(dllimport) json_t* json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...);
|
||||
__declspec(dllimport) json_t* json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap);
|
||||
__declspec(dllimport) json_t* json_pack(const char* fmt, ...);
|
||||
__declspec(dllimport) json_t* json_pack_ex(json_error_t* error, size_t flags, const char* fmt, ...);
|
||||
__declspec(dllimport) json_t* json_vpack_ex(json_error_t* error, size_t flags, const char* fmt, va_list ap);
|
||||
|
||||
#define JSON_VALIDATE_ONLY 0x1
|
||||
#define JSON_STRICT 0x2
|
||||
|
||||
__declspec(dllimport) int json_unpack(json_t *root, const char *fmt, ...);
|
||||
__declspec(dllimport) int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...);
|
||||
__declspec(dllimport) int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap);
|
||||
__declspec(dllimport) int json_unpack(json_t* root, const char* fmt, ...);
|
||||
__declspec(dllimport) int json_unpack_ex(json_t* root, json_error_t* error, size_t flags, const char* fmt, ...);
|
||||
__declspec(dllimport) int json_vunpack_ex(json_t* root, json_error_t* error, size_t flags, const char* fmt, va_list ap);
|
||||
|
||||
|
||||
/* equality */
|
||||
|
||||
__declspec(dllimport) int json_equal(json_t *value1, json_t *value2);
|
||||
__declspec(dllimport) int json_equal(json_t* value1, json_t* value2);
|
||||
|
||||
|
||||
/* copying */
|
||||
|
||||
__declspec(dllimport) json_t* json_copy(json_t *value);
|
||||
__declspec(dllimport) json_t* json_deep_copy(const json_t *value);
|
||||
__declspec(dllimport) json_t* json_copy(json_t* value);
|
||||
__declspec(dllimport) json_t* json_deep_copy(const json_t* value);
|
||||
|
||||
|
||||
/* decoding */
|
||||
|
|
@ -280,13 +280,13 @@ __declspec(dllimport) json_t* json_deep_copy(const json_t *value);
|
|||
#define JSON_DECODE_INT_AS_REAL 0x8
|
||||
#define JSON_ALLOW_NUL 0x10
|
||||
|
||||
typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
|
||||
typedef size_t (*json_load_callback_t)(void* buffer, size_t buflen, void* data);
|
||||
|
||||
__declspec(dllimport) json_t* json_loads(const char *input, size_t flags, json_error_t *error);
|
||||
__declspec(dllimport) json_t* json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error);
|
||||
__declspec(dllimport) json_t* json_loadf(FILE *input, size_t flags, json_error_t *error);
|
||||
__declspec(dllimport) json_t* json_load_file(const char *path, size_t flags, json_error_t *error);
|
||||
__declspec(dllimport) json_t* json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error);
|
||||
__declspec(dllimport) json_t* json_loads(const char* input, size_t flags, json_error_t* error);
|
||||
__declspec(dllimport) json_t* json_loadb(const char* buffer, size_t buflen, size_t flags, json_error_t* error);
|
||||
__declspec(dllimport) json_t* json_loadf(FILE* input, size_t flags, json_error_t* error);
|
||||
__declspec(dllimport) json_t* json_load_file(const char* path, size_t flags, json_error_t* error);
|
||||
__declspec(dllimport) json_t* json_load_callback(json_load_callback_t callback, void* data, size_t flags, json_error_t* error);
|
||||
|
||||
|
||||
/* encoding */
|
||||
|
|
@ -300,17 +300,17 @@ __declspec(dllimport) json_t* json_load_callback(json_load_callback_t callback,
|
|||
#define JSON_ESCAPE_SLASH 0x400
|
||||
#define JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
|
||||
|
||||
typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);
|
||||
typedef int (*json_dump_callback_t)(const char* buffer, size_t size, void* data);
|
||||
|
||||
__declspec(dllimport) char* json_dumps(const json_t *json, size_t flags);
|
||||
__declspec(dllimport) int json_dumpf(const json_t *json, FILE *output, size_t flags);
|
||||
__declspec(dllimport) int json_dump_file(const json_t *json, const char *path, size_t flags);
|
||||
__declspec(dllimport) int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags);
|
||||
__declspec(dllimport) char* json_dumps(const json_t* json, size_t flags);
|
||||
__declspec(dllimport) int json_dumpf(const json_t* json, FILE* output, size_t flags);
|
||||
__declspec(dllimport) int json_dump_file(const json_t* json, const char* path, size_t flags);
|
||||
__declspec(dllimport) int json_dump_callback(const json_t* json, json_dump_callback_t callback, void* data, size_t flags);
|
||||
|
||||
/* custom memory allocation */
|
||||
|
||||
typedef void *(*json_malloc_t)(size_t);
|
||||
typedef void (*json_free_t)(void *);
|
||||
typedef void* (*json_malloc_t)(size_t);
|
||||
typedef void (*json_free_t)(void*);
|
||||
|
||||
__declspec(dllimport) void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ extern "C"
|
|||
Simple Functions
|
||||
**************************************/
|
||||
|
||||
__declspec(dllimport) int LZ4_compress (const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_decompress_safe (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_compress(const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_decompress_safe(const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/*
|
||||
LZ4_compress() :
|
||||
|
|
@ -112,7 +112,7 @@ LZ4_compress_limitedOutput() :
|
|||
return : the number of bytes written in buffer 'dest'
|
||||
or 0 if the compression fails
|
||||
*/
|
||||
__declspec(dllimport) int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -125,7 +125,7 @@ LZ4_decompress_fast() :
|
|||
Use this function preferably into a trusted environment (data to decode comes from a trusted source).
|
||||
Destination buffer must be already allocated. Its size must be a minimum of 'outputSize' bytes.
|
||||
*/
|
||||
__declspec(dllimport) int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
|
||||
__declspec(dllimport) int LZ4_decompress_fast(const char* source, char* dest, int originalSize);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -140,7 +140,7 @@ LZ4_decompress_safe_partial() :
|
|||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
|
||||
*/
|
||||
__declspec(dllimport) int LZ4_decompress_safe_partial (const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_decompress_safe_partial(const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -155,18 +155,18 @@ LZ4_compress_withState() and LZ4_compress_limitedOutput_withState() are equivale
|
|||
They just use the externally allocated memory area instead of allocating their own (on stack, or on heap).
|
||||
*/
|
||||
__declspec(dllimport) int LZ4_sizeofState(void);
|
||||
__declspec(dllimport) int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_compress_withState(void* state, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compress_limitedOutput_withState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
|
||||
/**************************************
|
||||
Streaming Functions
|
||||
**************************************/
|
||||
__declspec(dllimport) void* LZ4_create (const char* inputBuffer);
|
||||
__declspec(dllimport) int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) char* LZ4_slideInputBuffer (void* LZ4_Data);
|
||||
__declspec(dllimport) int LZ4_free (void* LZ4_Data);
|
||||
__declspec(dllimport) void* LZ4_create(const char* inputBuffer);
|
||||
__declspec(dllimport) int LZ4_compress_continue(void* LZ4_Data, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compress_limitedOutput_continue(void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) char* LZ4_slideInputBuffer(void* LZ4_Data);
|
||||
__declspec(dllimport) int LZ4_free(void* LZ4_Data);
|
||||
|
||||
/*
|
||||
These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
|
||||
|
|
@ -223,8 +223,8 @@ Any other value means there was an error (typically, pointer is not aligned on 4
|
|||
*/
|
||||
|
||||
|
||||
__declspec(dllimport) int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int outputSize);
|
||||
__declspec(dllimport) int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int outputSize);
|
||||
|
||||
/*
|
||||
*_withPrefix64k() :
|
||||
|
|
@ -241,8 +241,8 @@ __declspec(dllimport) int LZ4_decompress_fast_withPrefix64k (const char* source,
|
|||
These functions are deprecated and should no longer be used.
|
||||
They are provided here for compatibility with existing user programs.
|
||||
*/
|
||||
__declspec(dllimport) int LZ4_uncompress (const char* source, char* dest, int outputSize);
|
||||
__declspec(dllimport) int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_uncompress(const char* source, char* dest, int outputSize);
|
||||
__declspec(dllimport) int LZ4_uncompress_unknownOutputSize(const char* source, char* dest, int isize, int maxOutputSize);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ extern "C"
|
|||
#endif
|
||||
|
||||
|
||||
__declspec(dllimport) int LZ4_compressHC (const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC(const char* source, char* dest, int inputSize);
|
||||
/*
|
||||
LZ4_compressHC :
|
||||
return : the number of bytes in compressed buffer dest
|
||||
|
|
@ -50,7 +50,7 @@ LZ4_compressHC :
|
|||
Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
|
||||
*/
|
||||
|
||||
__declspec(dllimport) int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
/*
|
||||
LZ4_compress_limitedOutput() :
|
||||
Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
|
||||
|
|
@ -64,8 +64,8 @@ LZ4_compress_limitedOutput() :
|
|||
*/
|
||||
|
||||
|
||||
__declspec(dllimport) int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2(const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
/*
|
||||
Same functions as above, but with programmable 'compressionLevel'.
|
||||
Recommended values are between 4 and 9, although any value between 0 and 16 will work.
|
||||
|
|
@ -83,10 +83,10 @@ Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD l
|
|||
Using an external allocation
|
||||
**************************************/
|
||||
__declspec(dllimport) int LZ4_sizeofStateHC(void);
|
||||
__declspec(dllimport) int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC_withStateHC(void* state, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
__declspec(dllimport) int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_withStateHC(void* state, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
|
||||
/*
|
||||
|
|
@ -105,14 +105,14 @@ They just use the externally allocated memory area instead of allocating their o
|
|||
/**************************************
|
||||
Streaming Functions
|
||||
**************************************/
|
||||
__declspec(dllimport) void* LZ4_createHC (const char* inputBuffer);
|
||||
__declspec(dllimport) int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
||||
__declspec(dllimport) int LZ4_freeHC (void* LZ4HC_Data);
|
||||
__declspec(dllimport) void* LZ4_createHC(const char* inputBuffer);
|
||||
__declspec(dllimport) int LZ4_compressHC_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize);
|
||||
__declspec(dllimport) int LZ4_compressHC_limitedOutput_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
__declspec(dllimport) char* LZ4_slideInputBufferHC(void* LZ4HC_Data);
|
||||
__declspec(dllimport) int LZ4_freeHC(void* LZ4HC_Data);
|
||||
|
||||
__declspec(dllimport) int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
__declspec(dllimport) int LZ4_compressHC2_limitedOutput_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
|
||||
/*
|
||||
These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if(fdwReason==DLL_PROCESS_ATTACH)
|
||||
hInst=hinstDLL;
|
||||
if(fdwReason == DLL_PROCESS_ATTACH)
|
||||
hInst = hinstDLL;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,21 +30,21 @@ operator precedence
|
|||
|
||||
int mathisoperator(char ch)
|
||||
{
|
||||
if(ch=='(' or ch==')')
|
||||
if(ch == '(' or ch == ')')
|
||||
return 1;
|
||||
else if(ch=='~')
|
||||
else if(ch == '~')
|
||||
return 2;
|
||||
else if(ch=='*' or ch=='$' or ch=='/' or ch=='%')
|
||||
else if(ch == '*' or ch == '$' or ch == '/' or ch == '%')
|
||||
return 3;
|
||||
else if(ch=='+' or ch=='-')
|
||||
else if(ch == '+' or ch == '-')
|
||||
return 4;
|
||||
else if(ch=='<' or ch=='>')
|
||||
else if(ch == '<' or ch == '>')
|
||||
return 5;
|
||||
else if(ch=='&')
|
||||
else if(ch == '&')
|
||||
return 6;
|
||||
else if(ch=='^')
|
||||
else if(ch == '^')
|
||||
return 7;
|
||||
else if(ch=='|')
|
||||
else if(ch == '|')
|
||||
return 8;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -55,12 +55,12 @@ mathformat:
|
|||
*/
|
||||
void mathformat(char* text)
|
||||
{
|
||||
int len=(int)strlen(text);
|
||||
char* temp=(char*)emalloc(len+1, "mathformat:temp");
|
||||
memset(temp, 0, len+1);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
if(mathisoperator(text[i])<3 or text[i]!=text[i+1])
|
||||
j+=sprintf(temp+j, "%c", text[i]);
|
||||
int len = (int)strlen(text);
|
||||
char* temp = (char*)emalloc(len + 1, "mathformat:temp");
|
||||
memset(temp, 0, len + 1);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
if(mathisoperator(text[i]) < 3 or text[i] != text[i + 1])
|
||||
j += sprintf(temp + j, "%c", text[i]);
|
||||
strcpy(text, temp);
|
||||
efree(temp, "mathformat:temp");
|
||||
}
|
||||
|
|
@ -70,10 +70,10 @@ void mathformat(char* text)
|
|||
*/
|
||||
bool mathcontains(const char* text)
|
||||
{
|
||||
if(*text=='-') //ignore negative values
|
||||
if(*text == '-') //ignore negative values
|
||||
text++;
|
||||
int len=(int)strlen(text);
|
||||
for(int i=0; i<len; i++)
|
||||
int len = (int)strlen(text);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(mathisoperator(text[i]))
|
||||
return true;
|
||||
return false;
|
||||
|
|
@ -82,37 +82,37 @@ bool mathcontains(const char* text)
|
|||
#ifdef __MINGW64__
|
||||
static inline unsigned long long umulhi(unsigned long long x, unsigned long long y)
|
||||
{
|
||||
return (unsigned long long)(((__uint128_t)x*y)>>64);
|
||||
return (unsigned long long)(((__uint128_t)x * y) >> 64);
|
||||
}
|
||||
|
||||
static inline long long mulhi(long long x, long long y)
|
||||
{
|
||||
return (long long)(((__int128_t)x*y)>>64);
|
||||
return (long long)(((__int128_t)x * y) >> 64);
|
||||
}
|
||||
#elif _WIN64
|
||||
#include <intrin.h>
|
||||
static inline unsigned long long umulhi(unsigned long long x, unsigned long long y)
|
||||
{
|
||||
unsigned __int64 res;
|
||||
_umul128(x,y,&res);
|
||||
_umul128(x, y, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline long long mulhi(long long x, long long y)
|
||||
{
|
||||
__int64 res;
|
||||
_mul128(x,y,&res);
|
||||
_mul128(x, y, &res);
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
static inline unsigned int umulhi(unsigned int x, unsigned int y)
|
||||
{
|
||||
return (unsigned int)(((unsigned long long)x*y)>>32);
|
||||
return (unsigned int)(((unsigned long long)x * y) >> 32);
|
||||
}
|
||||
|
||||
static inline int mulhi(int x, int y)
|
||||
{
|
||||
return (int)(((long long)x*y)>>32);
|
||||
return (int)(((long long)x * y) >> 32);
|
||||
}
|
||||
#endif //__MINGW64__
|
||||
|
||||
|
|
@ -121,45 +121,45 @@ bool mathdounsignedoperation(char op, uint left, uint right, uint* result)
|
|||
switch(op)
|
||||
{
|
||||
case '*':
|
||||
*result=left*right;
|
||||
*result = left * right;
|
||||
return true;
|
||||
case '$':
|
||||
*result=umulhi(left, right);
|
||||
*result = umulhi(left, right);
|
||||
return true;
|
||||
case '/':
|
||||
if(right)
|
||||
{
|
||||
*result=left/right;
|
||||
*result = left / right;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case '%':
|
||||
if(right)
|
||||
{
|
||||
*result=left%right;
|
||||
*result = left % right;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case '+':
|
||||
*result=left+right;
|
||||
*result = left + right;
|
||||
return true;
|
||||
case '-':
|
||||
*result=left-right;
|
||||
*result = left - right;
|
||||
return true;
|
||||
case '<':
|
||||
*result=left<<right;
|
||||
*result = left << right;
|
||||
return true;
|
||||
case '>':
|
||||
*result=left>>right;
|
||||
*result = left >> right;
|
||||
return true;
|
||||
case '&':
|
||||
*result=left&right;
|
||||
*result = left & right;
|
||||
return true;
|
||||
case '^':
|
||||
*result=left^right;
|
||||
*result = left ^ right;
|
||||
return true;
|
||||
case '|':
|
||||
*result=left|right;
|
||||
*result = left | right;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -170,45 +170,45 @@ bool mathdosignedoperation(char op, sint left, sint right, sint* result)
|
|||
switch(op)
|
||||
{
|
||||
case '*':
|
||||
*result=left*right;
|
||||
*result = left * right;
|
||||
return true;
|
||||
case '$':
|
||||
*result=mulhi(left, right);
|
||||
*result = mulhi(left, right);
|
||||
return true;
|
||||
case '/':
|
||||
if(right)
|
||||
{
|
||||
*result=left/right;
|
||||
*result = left / right;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case '%':
|
||||
if(right)
|
||||
{
|
||||
*result=left%right;
|
||||
*result = left % right;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case '+':
|
||||
*result=left+right;
|
||||
*result = left + right;
|
||||
return true;
|
||||
case '-':
|
||||
*result=left-right;
|
||||
*result = left - right;
|
||||
return true;
|
||||
case '<':
|
||||
*result=left<<right;
|
||||
*result = left << right;
|
||||
return true;
|
||||
case '>':
|
||||
*result=left>>right;
|
||||
*result = left >> right;
|
||||
return true;
|
||||
case '&':
|
||||
*result=left&right;
|
||||
*result = left & right;
|
||||
return true;
|
||||
case '^':
|
||||
*result=left^right;
|
||||
*result = left ^ right;
|
||||
return true;
|
||||
case '|':
|
||||
*result=left|right;
|
||||
*result = left | right;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -216,19 +216,19 @@ bool mathdosignedoperation(char op, sint left, sint right, sint* result)
|
|||
|
||||
static void fillpair(EXPRESSION* expstruct, int pos, int layer)
|
||||
{
|
||||
for(int i=0; i<expstruct->total_pairs; i++)
|
||||
for(int i = 0; i < expstruct->total_pairs; i++)
|
||||
{
|
||||
if(!expstruct->pairs[i].isset)
|
||||
{
|
||||
expstruct->pairs[i].layer=layer;
|
||||
expstruct->pairs[i].openpos=pos;
|
||||
expstruct->pairs[i].isset=1;
|
||||
expstruct->pairs[i].layer = layer;
|
||||
expstruct->pairs[i].openpos = pos;
|
||||
expstruct->pairs[i].isset = 1;
|
||||
break;
|
||||
}
|
||||
else if(expstruct->pairs[i].layer==layer and expstruct->pairs[i].isset==1)
|
||||
else if(expstruct->pairs[i].layer == layer and expstruct->pairs[i].isset == 1)
|
||||
{
|
||||
expstruct->pairs[i].closepos=pos;
|
||||
expstruct->pairs[i].isset=2;
|
||||
expstruct->pairs[i].closepos = pos;
|
||||
expstruct->pairs[i].isset = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -237,22 +237,22 @@ static void fillpair(EXPRESSION* expstruct, int pos, int layer)
|
|||
|
||||
static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
|
||||
{
|
||||
int layer=endlayer;
|
||||
int len=(int)strlen(expression);
|
||||
for(int i=0; i<len; i++)
|
||||
int layer = endlayer;
|
||||
int len = (int)strlen(expression);
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
if(expression[i]=='(')
|
||||
if(expression[i] == '(')
|
||||
{
|
||||
layer++;
|
||||
int pos=(int)(expression+i-expstruct->expression);
|
||||
int pos = (int)(expression + i - expstruct->expression);
|
||||
fillpair(expstruct, pos, layer);
|
||||
i+=matchpairs(expstruct, expression+i+1, layer);
|
||||
i += matchpairs(expstruct, expression + i + 1, layer);
|
||||
}
|
||||
else if(expression[i]==')')
|
||||
else if(expression[i] == ')')
|
||||
{
|
||||
if(layer==endlayer)
|
||||
if(layer == endlayer)
|
||||
{
|
||||
int pos=(int)(expression+i-expstruct->expression);
|
||||
int pos = (int)(expression + i - expstruct->expression);
|
||||
fillpair(expstruct, pos, layer);
|
||||
return i;
|
||||
}
|
||||
|
|
@ -265,59 +265,59 @@ static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
|
|||
|
||||
static int expressionformat(char* exp)
|
||||
{
|
||||
int len=(int)strlen(exp);
|
||||
int open=0;
|
||||
int close=0;
|
||||
for(int i=0; i<len; i++)
|
||||
int len = (int)strlen(exp);
|
||||
int open = 0;
|
||||
int close = 0;
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
if(exp[i]=='(')
|
||||
if(exp[i] == '(')
|
||||
open++;
|
||||
else if(exp[i]==')')
|
||||
else if(exp[i] == ')')
|
||||
close++;
|
||||
}
|
||||
if(close>open)
|
||||
if(close > open)
|
||||
return -1;
|
||||
int add=open-close;
|
||||
int add = open - close;
|
||||
if(add)
|
||||
{
|
||||
memset(exp+len, ')', add);
|
||||
exp[len+add]=0;
|
||||
memset(exp + len, ')', add);
|
||||
exp[len + add] = 0;
|
||||
}
|
||||
return open;
|
||||
}
|
||||
|
||||
static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len)
|
||||
{
|
||||
for(int i=0; i<exps->total_pairs; i++)
|
||||
for(int i = 0; i < exps->total_pairs; i++)
|
||||
{
|
||||
if(exps->pairs[i].openpos>cur_open)
|
||||
exps->pairs[i].openpos+=new_len-cur_len;
|
||||
if(exps->pairs[i].closepos>cur_close)
|
||||
exps->pairs[i].closepos+=new_len-cur_len;
|
||||
if(exps->pairs[i].openpos > cur_open)
|
||||
exps->pairs[i].openpos += new_len - cur_len;
|
||||
if(exps->pairs[i].closepos > cur_close)
|
||||
exps->pairs[i].closepos += new_len - cur_len;
|
||||
}
|
||||
}
|
||||
|
||||
static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly)
|
||||
{
|
||||
for(int i=0; i<exps->total_pairs; i++)
|
||||
for(int i = 0; i < exps->total_pairs; i++)
|
||||
{
|
||||
if(exps->pairs[i].layer==layer)
|
||||
if(exps->pairs[i].layer == layer)
|
||||
{
|
||||
char temp[256]="";
|
||||
char backup[256]="";
|
||||
char temp[256] = "";
|
||||
char backup[256] = "";
|
||||
|
||||
int open=exps->pairs[i].openpos;
|
||||
int close=exps->pairs[i].closepos;
|
||||
int len=close-open;
|
||||
strncpy(temp, exp+open+1, len-1);
|
||||
int open = exps->pairs[i].openpos;
|
||||
int close = exps->pairs[i].closepos;
|
||||
int len = close - open;
|
||||
strncpy(temp, exp + open + 1, len - 1);
|
||||
|
||||
strcpy(backup, exp+open+len+1);
|
||||
strcpy(backup, exp + open + len + 1);
|
||||
|
||||
uint value;
|
||||
if(!mathfromstring(temp, &value, silent, baseonly, 0, 0))
|
||||
return false;
|
||||
|
||||
adjustpairs(exps, open, close, len+1, sprintf(exp+open, "%"fext"X", value));
|
||||
adjustpairs(exps, open, close, len + 1, sprintf(exp + open, "%"fext"X", value));
|
||||
|
||||
if(*backup)
|
||||
strcat(exp, backup);
|
||||
|
|
@ -330,23 +330,23 @@ static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool
|
|||
bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
|
||||
{
|
||||
EXPRESSION expstruct;
|
||||
expstruct.expression=expression;
|
||||
int total_pairs=expressionformat(expression);
|
||||
if(total_pairs==-1)
|
||||
expstruct.expression = expression;
|
||||
int total_pairs = expressionformat(expression);
|
||||
if(total_pairs == -1)
|
||||
return false;
|
||||
else if(!total_pairs)
|
||||
return true;
|
||||
expstruct.total_pairs=total_pairs;
|
||||
expstruct.total_pairs = total_pairs;
|
||||
|
||||
expstruct.pairs=(BRACKET_PAIR*)emalloc(expstruct.total_pairs*sizeof(BRACKET_PAIR), "mathhandlebrackets:expstruct.pairs");
|
||||
memset(expstruct.pairs, 0, expstruct.total_pairs*sizeof(BRACKET_PAIR));
|
||||
expstruct.pairs = (BRACKET_PAIR*)emalloc(expstruct.total_pairs * sizeof(BRACKET_PAIR), "mathhandlebrackets:expstruct.pairs");
|
||||
memset(expstruct.pairs, 0, expstruct.total_pairs * sizeof(BRACKET_PAIR));
|
||||
matchpairs(&expstruct, expression, 0);
|
||||
int deepest=0;
|
||||
for(int i=0; i<expstruct.total_pairs; i++)
|
||||
if(expstruct.pairs[i].layer>deepest)
|
||||
deepest=expstruct.pairs[i].layer;
|
||||
int deepest = 0;
|
||||
for(int i = 0; i < expstruct.total_pairs; i++)
|
||||
if(expstruct.pairs[i].layer > deepest)
|
||||
deepest = expstruct.pairs[i].layer;
|
||||
|
||||
for(int i=deepest; i>0; i--)
|
||||
for(int i = deepest; i > 0; i--)
|
||||
if(!printlayer(expression, &expstruct, i, silent, baseonly))
|
||||
{
|
||||
efree(expstruct.pairs, "mathhandlebrackets:expstruct.pairs");
|
||||
|
|
@ -362,32 +362,32 @@ bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
|
|||
*/
|
||||
bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar)
|
||||
{
|
||||
int highestop=0;
|
||||
int highestop_pos=0;
|
||||
int len=(int)strlen(string);
|
||||
bool negative=false;
|
||||
if(*string=='-')
|
||||
int highestop = 0;
|
||||
int highestop_pos = 0;
|
||||
int len = (int)strlen(string);
|
||||
bool negative = false;
|
||||
if(*string == '-')
|
||||
{
|
||||
negative=true;
|
||||
negative = true;
|
||||
string++;
|
||||
}
|
||||
for(int i=0; i<len; i++)
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
int curop=mathisoperator(string[i]);
|
||||
if(curop>1 and curop>highestop)
|
||||
int curop = mathisoperator(string[i]);
|
||||
if(curop > 1 and curop > highestop)
|
||||
{
|
||||
highestop=curop;
|
||||
highestop_pos=i;
|
||||
highestop = curop;
|
||||
highestop_pos = i;
|
||||
}
|
||||
}
|
||||
if(!highestop)
|
||||
return valfromstring(string, value, silent, baseonly, value_size, isvar, 0);
|
||||
char* strleft=(char*)emalloc(len+1+negative, "mathfromstring:strleft");
|
||||
char* strright=(char*)emalloc(len+1, "mathfromstring:strright");
|
||||
memset(strleft, 0, len+1);
|
||||
memset(strright, 0, len+1);
|
||||
strncpy(strleft, string-negative, highestop_pos+negative);
|
||||
strcpy(strright, string+highestop_pos+1);
|
||||
char* strleft = (char*)emalloc(len + 1 + negative, "mathfromstring:strleft");
|
||||
char* strright = (char*)emalloc(len + 1, "mathfromstring:strright");
|
||||
memset(strleft, 0, len + 1);
|
||||
memset(strright, 0, len + 1);
|
||||
strncpy(strleft, string - negative, highestop_pos + negative);
|
||||
strcpy(strright, string + highestop_pos + 1);
|
||||
//dprintf("left: %s, right: %s, op: %c\n", strleft, strright, string[highestop_pos]);
|
||||
if(!*strright)
|
||||
{
|
||||
|
|
@ -395,25 +395,25 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
|||
efree(strright, "mathfromstring:strright");
|
||||
return false;
|
||||
}
|
||||
uint right=0;
|
||||
uint right = 0;
|
||||
if(!valfromstring(strright, &right, silent, baseonly))
|
||||
{
|
||||
efree(strleft, "mathfromstring:strleft");
|
||||
efree(strright, "mathfromstring:strright");
|
||||
return false;
|
||||
}
|
||||
if(string[highestop_pos]=='~')
|
||||
if(string[highestop_pos] == '~')
|
||||
{
|
||||
right=~right;
|
||||
right = ~right;
|
||||
if(!strlen(strleft))
|
||||
{
|
||||
*value=right;
|
||||
*value = right;
|
||||
efree(strleft, "mathfromstring:strleft");
|
||||
efree(strright, "mathfromstring:strright");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
uint left=0;
|
||||
uint left = 0;
|
||||
if(!valfromstring(strleft, &left, silent, baseonly))
|
||||
{
|
||||
efree(strleft, "mathfromstring:strleft");
|
||||
|
|
@ -422,9 +422,9 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
|||
}
|
||||
bool math_ok;
|
||||
if(valuesignedcalc())
|
||||
math_ok=mathdosignedoperation(string[highestop_pos], left, right, (sint*)value);
|
||||
math_ok = mathdosignedoperation(string[highestop_pos], left, right, (sint*)value);
|
||||
else
|
||||
math_ok=mathdounsignedoperation(string[highestop_pos], left, right, value);
|
||||
math_ok = mathdounsignedoperation(string[highestop_pos], left, right, value);
|
||||
efree(strleft, "mathfromstring:strleft");
|
||||
efree(strright, "mathfromstring:strright");
|
||||
return math_ok;
|
||||
|
|
|
|||
|
|
@ -11,34 +11,34 @@ void memupdatemap(HANDLE hProcess)
|
|||
CriticalSectionLocker locker(LockMemoryPages);
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
SIZE_T numBytes;
|
||||
uint MyAddress=0, newAddress=0;
|
||||
uint curAllocationBase=0;
|
||||
uint MyAddress = 0, newAddress = 0;
|
||||
uint curAllocationBase = 0;
|
||||
|
||||
bool bListAllPages = false; //TODO: settings for this
|
||||
|
||||
std::vector<MEMPAGE> pageVector;
|
||||
do
|
||||
{
|
||||
numBytes=VirtualQueryEx(hProcess, (LPCVOID)MyAddress, &mbi, sizeof(mbi));
|
||||
if(mbi.State==MEM_COMMIT)
|
||||
numBytes = VirtualQueryEx(hProcess, (LPCVOID)MyAddress, &mbi, sizeof(mbi));
|
||||
if(mbi.State == MEM_COMMIT)
|
||||
{
|
||||
if(bListAllPages || curAllocationBase!=(uint)mbi.AllocationBase) //only list allocation bases
|
||||
if(bListAllPages || curAllocationBase != (uint)mbi.AllocationBase) //only list allocation bases
|
||||
{
|
||||
curAllocationBase=(uint)mbi.AllocationBase;
|
||||
curAllocationBase = (uint)mbi.AllocationBase;
|
||||
MEMPAGE curPage;
|
||||
*curPage.info=0;
|
||||
*curPage.info = 0;
|
||||
modnamefromaddr(MyAddress, curPage.info, true);
|
||||
memcpy(&curPage.mbi, &mbi, sizeof(mbi));
|
||||
pageVector.push_back(curPage);
|
||||
}
|
||||
else
|
||||
pageVector.at(pageVector.size()-1).mbi.RegionSize+=mbi.RegionSize;
|
||||
pageVector.at(pageVector.size() - 1).mbi.RegionSize += mbi.RegionSize;
|
||||
}
|
||||
newAddress=(uint)mbi.BaseAddress+mbi.RegionSize;
|
||||
if(newAddress<=MyAddress)
|
||||
numBytes=0;
|
||||
newAddress = (uint)mbi.BaseAddress + mbi.RegionSize;
|
||||
if(newAddress <= MyAddress)
|
||||
numBytes = 0;
|
||||
else
|
||||
MyAddress=newAddress;
|
||||
MyAddress = newAddress;
|
||||
}
|
||||
while(numBytes);
|
||||
|
||||
|
|
@ -46,21 +46,21 @@ void memupdatemap(HANDLE hProcess)
|
|||
int pagecount;
|
||||
if(bListAllPages)
|
||||
{
|
||||
pagecount=(int)pageVector.size();
|
||||
char curMod[MAX_MODULE_SIZE]="";
|
||||
for(int i=pagecount-1,curIdx=0; i>-1; i--)
|
||||
pagecount = (int)pageVector.size();
|
||||
char curMod[MAX_MODULE_SIZE] = "";
|
||||
for(int i = pagecount - 1, curIdx = 0; i > -1; i--)
|
||||
{
|
||||
if(pageVector.at(i).info[0]) //there is a module
|
||||
{
|
||||
if(!scmp(curMod, pageVector.at(i).info)) //mod is not the current mod
|
||||
{
|
||||
strcpy(curMod, pageVector.at(i).info);
|
||||
curIdx=i;
|
||||
curIdx = i;
|
||||
}
|
||||
else //current mod
|
||||
{
|
||||
pageVector.at(curIdx).mbi.RegionSize+=pageVector.at(i).mbi.RegionSize;
|
||||
pageVector.erase(pageVector.begin()+i);
|
||||
pageVector.at(curIdx).mbi.RegionSize += pageVector.at(i).mbi.RegionSize;
|
||||
pageVector.erase(pageVector.begin() + i);
|
||||
curIdx--; //the index changes when you remove an entry
|
||||
}
|
||||
}
|
||||
|
|
@ -68,94 +68,94 @@ void memupdatemap(HANDLE hProcess)
|
|||
}
|
||||
|
||||
//process file sections
|
||||
pagecount=(int)pageVector.size();
|
||||
char curMod[MAX_MODULE_SIZE]="";
|
||||
for(int i=pagecount-1; i>-1; i--)
|
||||
pagecount = (int)pageVector.size();
|
||||
char curMod[MAX_MODULE_SIZE] = "";
|
||||
for(int i = pagecount - 1; i > -1; i--)
|
||||
{
|
||||
if(bListAllPages || !pageVector.at(i).info[0] || scmp(curMod, pageVector.at(i).info)) //there is a module
|
||||
continue; //skip non-modules
|
||||
strcpy(curMod, pageVector.at(i).info);
|
||||
uint base=modbasefromname(pageVector.at(i).info);
|
||||
uint base = modbasefromname(pageVector.at(i).info);
|
||||
if(!base)
|
||||
continue;
|
||||
std::vector<MODSECTIONINFO> sections;
|
||||
if(!modsectionsfromaddr(base, §ions))
|
||||
continue;
|
||||
int SectionNumber=(int)sections.size();
|
||||
int SectionNumber = (int)sections.size();
|
||||
MEMPAGE newPage;
|
||||
//remove the current module page (page = size of module at this point) and insert the module sections
|
||||
pageVector.erase(pageVector.begin()+i); //remove the SizeOfImage page
|
||||
for(int j=SectionNumber-1; j>-1; j--)
|
||||
pageVector.erase(pageVector.begin() + i); //remove the SizeOfImage page
|
||||
for(int j = SectionNumber - 1; j > -1; j--)
|
||||
{
|
||||
memset(&newPage, 0, sizeof(MEMPAGE));
|
||||
|
||||
VirtualQueryEx(hProcess, (LPCVOID)sections.at(j).addr, &newPage.mbi, sizeof(MEMORY_BASIC_INFORMATION));
|
||||
uint SectionSize=sections.at(j).size;
|
||||
if(SectionSize%PAGE_SIZE) //unaligned page size
|
||||
SectionSize+=PAGE_SIZE-(SectionSize%PAGE_SIZE); //fix this
|
||||
uint SectionSize = sections.at(j).size;
|
||||
if(SectionSize % PAGE_SIZE) //unaligned page size
|
||||
SectionSize += PAGE_SIZE - (SectionSize % PAGE_SIZE); //fix this
|
||||
if(SectionSize)
|
||||
newPage.mbi.RegionSize=SectionSize;
|
||||
const char* SectionName=§ions.at(j).name[0];
|
||||
int len=(int)strlen(SectionName);
|
||||
int escape_count=0;
|
||||
for(int k=0; k<len; k++)
|
||||
if(SectionName[k]=='\\' or SectionName[k]=='\"' or !isprint(SectionName[k]))
|
||||
newPage.mbi.RegionSize = SectionSize;
|
||||
const char* SectionName = §ions.at(j).name[0];
|
||||
int len = (int)strlen(SectionName);
|
||||
int escape_count = 0;
|
||||
for(int k = 0; k < len; k++)
|
||||
if(SectionName[k] == '\\' or SectionName[k] == '\"' or !isprint(SectionName[k]))
|
||||
escape_count++;
|
||||
char* SectionNameEscaped=(char*)emalloc(len+escape_count*3+1, "_dbg_memmap:SectionNameEscaped");
|
||||
memset(SectionNameEscaped, 0, len+escape_count*3+1);
|
||||
for(int k=0,l=0; k<len; k++)
|
||||
char* SectionNameEscaped = (char*)emalloc(len + escape_count * 3 + 1, "_dbg_memmap:SectionNameEscaped");
|
||||
memset(SectionNameEscaped, 0, len + escape_count * 3 + 1);
|
||||
for(int k = 0, l = 0; k < len; k++)
|
||||
{
|
||||
switch(SectionName[k])
|
||||
{
|
||||
case '\t':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\t");
|
||||
l += sprintf(SectionNameEscaped + l, "\\t");
|
||||
break;
|
||||
case '\f':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\f");
|
||||
l += sprintf(SectionNameEscaped + l, "\\f");
|
||||
break;
|
||||
case '\v':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\v");
|
||||
l += sprintf(SectionNameEscaped + l, "\\v");
|
||||
break;
|
||||
case '\n':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\n");
|
||||
l += sprintf(SectionNameEscaped + l, "\\n");
|
||||
break;
|
||||
case '\r':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\r");
|
||||
l += sprintf(SectionNameEscaped + l, "\\r");
|
||||
break;
|
||||
case '\\':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\\\");
|
||||
l += sprintf(SectionNameEscaped + l, "\\\\");
|
||||
break;
|
||||
case '\"':
|
||||
l+=sprintf(SectionNameEscaped+l, "\\\"");
|
||||
l += sprintf(SectionNameEscaped + l, "\\\"");
|
||||
break;
|
||||
default:
|
||||
if(!isprint(SectionName[k])) //unknown unprintable character
|
||||
l+=sprintf(SectionNameEscaped+l, "\\x%.2X", SectionName[k]);
|
||||
l += sprintf(SectionNameEscaped + l, "\\x%.2X", SectionName[k]);
|
||||
else
|
||||
l+=sprintf(SectionNameEscaped+l, "%c", SectionName[k]);
|
||||
l += sprintf(SectionNameEscaped + l, "%c", SectionName[k]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sprintf(newPage.info, " \"%s\"", SectionNameEscaped);
|
||||
efree(SectionNameEscaped, "_dbg_memmap:SectionNameEscaped");
|
||||
pageVector.insert(pageVector.begin()+i, newPage);
|
||||
pageVector.insert(pageVector.begin() + i, newPage);
|
||||
}
|
||||
//insert the module itself (the module header)
|
||||
memset(&newPage, 0, sizeof(MEMPAGE));
|
||||
VirtualQueryEx(hProcess, (LPCVOID)base, &newPage.mbi, sizeof(MEMORY_BASIC_INFORMATION));
|
||||
strcpy(newPage.info, curMod);
|
||||
pageVector.insert(pageVector.begin()+i, newPage);
|
||||
pageVector.insert(pageVector.begin() + i, newPage);
|
||||
}
|
||||
|
||||
//convert to memoryPages map
|
||||
pagecount=(int)pageVector.size();
|
||||
pagecount = (int)pageVector.size();
|
||||
memoryPages.clear();
|
||||
for(int i=0; i<pagecount; i++)
|
||||
for(int i = 0; i < pagecount; i++)
|
||||
{
|
||||
const MEMPAGE & curPage = pageVector.at(i);
|
||||
uint start=(uint)curPage.mbi.BaseAddress;
|
||||
uint size=curPage.mbi.RegionSize;
|
||||
memoryPages.insert(std::make_pair(std::make_pair(start, start+size-1), curPage));
|
||||
uint start = (uint)curPage.mbi.BaseAddress;
|
||||
uint size = curPage.mbi.RegionSize;
|
||||
memoryPages.insert(std::make_pair(std::make_pair(start, start + size - 1), curPage));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,11 +164,11 @@ uint memfindbaseaddr(uint addr, uint* size, bool refresh)
|
|||
if(refresh)
|
||||
memupdatemap(fdProcessInfo->hProcess); //update memory map
|
||||
CriticalSectionLocker locker(LockMemoryPages);
|
||||
MemoryMap::iterator found=memoryPages.find(std::make_pair(addr, addr));
|
||||
if(found==memoryPages.end())
|
||||
MemoryMap::iterator found = memoryPages.find(std::make_pair(addr, addr));
|
||||
if(found == memoryPages.end())
|
||||
return 0;
|
||||
if(size)
|
||||
*size=found->second.mbi.RegionSize;
|
||||
*size = found->second.mbi.RegionSize;
|
||||
return found->first.first;
|
||||
}
|
||||
|
||||
|
|
@ -176,24 +176,24 @@ bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T
|
|||
{
|
||||
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
|
||||
return false;
|
||||
SIZE_T read=0;
|
||||
DWORD oldprotect=0;
|
||||
bool ret=MemoryReadSafe(hProcess, (void*)lpBaseAddress, lpBuffer, nSize, &read); //try 'normal' RPM
|
||||
if(ret and read==nSize) //'normal' RPM worked!
|
||||
SIZE_T read = 0;
|
||||
DWORD oldprotect = 0;
|
||||
bool ret = MemoryReadSafe(hProcess, (void*)lpBaseAddress, lpBuffer, nSize, &read); //try 'normal' RPM
|
||||
if(ret and read == nSize) //'normal' RPM worked!
|
||||
{
|
||||
if(lpNumberOfBytesRead)
|
||||
*lpNumberOfBytesRead=read;
|
||||
*lpNumberOfBytesRead = read;
|
||||
return true;
|
||||
}
|
||||
for(uint i=0; i<nSize; i++) //read byte-per-byte
|
||||
for(uint i = 0; i < nSize; i++) //read byte-per-byte
|
||||
{
|
||||
unsigned char* curaddr=(unsigned char*)lpBaseAddress+i;
|
||||
unsigned char* curbuf=(unsigned char*)lpBuffer+i;
|
||||
ret=MemoryReadSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' RPM
|
||||
unsigned char* curaddr = (unsigned char*)lpBaseAddress + i;
|
||||
unsigned char* curbuf = (unsigned char*)lpBuffer + i;
|
||||
ret = MemoryReadSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' RPM
|
||||
if(!ret) //we failed
|
||||
{
|
||||
if(lpNumberOfBytesRead)
|
||||
*lpNumberOfBytesRead=i;
|
||||
*lpNumberOfBytesRead = i;
|
||||
SetLastError(ERROR_PARTIAL_COPY);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -205,24 +205,24 @@ bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T
|
|||
{
|
||||
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
|
||||
return false;
|
||||
SIZE_T written=0;
|
||||
DWORD oldprotect=0;
|
||||
bool ret=MemoryWriteSafe(hProcess, lpBaseAddress, lpBuffer, nSize, &written);
|
||||
if(ret and written==nSize) //'normal' WPM worked!
|
||||
SIZE_T written = 0;
|
||||
DWORD oldprotect = 0;
|
||||
bool ret = MemoryWriteSafe(hProcess, lpBaseAddress, lpBuffer, nSize, &written);
|
||||
if(ret and written == nSize) //'normal' WPM worked!
|
||||
{
|
||||
if(lpNumberOfBytesWritten)
|
||||
*lpNumberOfBytesWritten=written;
|
||||
*lpNumberOfBytesWritten = written;
|
||||
return true;
|
||||
}
|
||||
for(uint i=0; i<nSize; i++) //write byte-per-byte
|
||||
for(uint i = 0; i < nSize; i++) //write byte-per-byte
|
||||
{
|
||||
unsigned char* curaddr=(unsigned char*)lpBaseAddress+i;
|
||||
unsigned char* curbuf=(unsigned char*)lpBuffer+i;
|
||||
ret=MemoryWriteSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' WPM
|
||||
unsigned char* curaddr = (unsigned char*)lpBaseAddress + i;
|
||||
unsigned char* curbuf = (unsigned char*)lpBuffer + i;
|
||||
ret = MemoryWriteSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' WPM
|
||||
if(!ret) //we failed
|
||||
{
|
||||
if(lpNumberOfBytesWritten)
|
||||
*lpNumberOfBytesWritten=i;
|
||||
*lpNumberOfBytesWritten = i;
|
||||
SetLastError(ERROR_PARTIAL_COPY);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -234,28 +234,28 @@ bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T
|
|||
{
|
||||
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
|
||||
return false;
|
||||
unsigned char* olddata=(unsigned char*)emalloc(nSize, "mempatch:olddata");
|
||||
unsigned char* olddata = (unsigned char*)emalloc(nSize, "mempatch:olddata");
|
||||
if(!memread(hProcess, lpBaseAddress, olddata, nSize, 0))
|
||||
{
|
||||
efree(olddata, "mempatch:olddata");
|
||||
return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
|
||||
}
|
||||
unsigned char* newdata=(unsigned char*)lpBuffer;
|
||||
for(uint i=0; i<nSize; i++)
|
||||
patchset((uint)lpBaseAddress+i, olddata[i], newdata[i]);
|
||||
unsigned char* newdata = (unsigned char*)lpBuffer;
|
||||
for(uint i = 0; i < nSize; i++)
|
||||
patchset((uint)lpBaseAddress + i, olddata[i], newdata[i]);
|
||||
efree(olddata, "mempatch:olddata");
|
||||
return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
|
||||
}
|
||||
|
||||
bool memisvalidreadptr(HANDLE hProcess, uint addr)
|
||||
{
|
||||
unsigned char a=0;
|
||||
unsigned char a = 0;
|
||||
return memread(hProcess, (void*)addr, &a, 1, 0);
|
||||
}
|
||||
|
||||
void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect)
|
||||
{
|
||||
return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE|MEM_COMMIT, fdProtect);
|
||||
return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE | MEM_COMMIT, fdProtect);
|
||||
}
|
||||
|
||||
void memfree(HANDLE hProcess, uint addr)
|
||||
|
|
@ -265,13 +265,13 @@ void memfree(HANDLE hProcess, uint addr)
|
|||
|
||||
static int formathexpattern(char* string)
|
||||
{
|
||||
int len=(int)strlen(string);
|
||||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
char* new_string=(char*)emalloc(len+1, "formathexpattern:new_string");
|
||||
memset(new_string, 0, len+1);
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
if(string[i]=='?' or isxdigit(string[i]))
|
||||
j+=sprintf(new_string+j, "%c", string[i]);
|
||||
char* new_string = (char*)emalloc(len + 1, "formathexpattern:new_string");
|
||||
memset(new_string, 0, len + 1);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
if(string[i] == '?' or isxdigit(string[i]))
|
||||
j += sprintf(new_string + j, "%c", string[i]);
|
||||
strcpy(string, new_string);
|
||||
efree(new_string, "formathexpattern:new_string");
|
||||
return (int)strlen(string);
|
||||
|
|
@ -282,41 +282,41 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
|
|||
if(!text or !pattern)
|
||||
return false;
|
||||
pattern->clear();
|
||||
int len=(int)strlen(text);
|
||||
int len = (int)strlen(text);
|
||||
if(!len)
|
||||
return false;
|
||||
char* newtext=(char*)emalloc(len+2, "transformpattern:newtext");
|
||||
char* newtext = (char*)emalloc(len + 2, "transformpattern:newtext");
|
||||
strcpy(newtext, text);
|
||||
len=formathexpattern(newtext);
|
||||
if(len%2) //not a multiple of 2
|
||||
len = formathexpattern(newtext);
|
||||
if(len % 2) //not a multiple of 2
|
||||
{
|
||||
newtext[len]='?';
|
||||
newtext[len+1]='\0';
|
||||
newtext[len] = '?';
|
||||
newtext[len + 1] = '\0';
|
||||
len++;
|
||||
}
|
||||
PATTERNBYTE newByte;
|
||||
for(int i=0,j=0; i<len; i++)
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if(newtext[i]=='?') //wildcard
|
||||
if(newtext[i] == '?') //wildcard
|
||||
{
|
||||
newByte.n[j].all=true; //match anything
|
||||
newByte.n[j].n=0;
|
||||
newByte.n[j].all = true; //match anything
|
||||
newByte.n[j].n = 0;
|
||||
j++;
|
||||
}
|
||||
else //hex
|
||||
{
|
||||
char x[2]="";
|
||||
*x=newtext[i];
|
||||
unsigned int val=0;
|
||||
char x[2] = "";
|
||||
*x = newtext[i];
|
||||
unsigned int val = 0;
|
||||
sscanf(x, "%x", &val);
|
||||
newByte.n[j].all=false;
|
||||
newByte.n[j].n=val&0xF;
|
||||
newByte.n[j].all = false;
|
||||
newByte.n[j].n = val & 0xF;
|
||||
j++;
|
||||
}
|
||||
|
||||
if(j==2) //two nibbles = one byte
|
||||
if(j == 2) //two nibbles = one byte
|
||||
{
|
||||
j=0;
|
||||
j = 0;
|
||||
pattern->push_back(newByte);
|
||||
}
|
||||
}
|
||||
|
|
@ -326,18 +326,18 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
|
|||
|
||||
static bool patternmatchbyte(unsigned char byte, PATTERNBYTE* pbyte)
|
||||
{
|
||||
unsigned char n1=(byte>>4)&0xF;
|
||||
unsigned char n2=byte&0xF;
|
||||
int matched=0;
|
||||
unsigned char n1 = (byte >> 4) & 0xF;
|
||||
unsigned char n2 = byte & 0xF;
|
||||
int matched = 0;
|
||||
if(pbyte->n[0].all)
|
||||
matched++;
|
||||
else if(pbyte->n[0].n==n1)
|
||||
else if(pbyte->n[0].n == n1)
|
||||
matched++;
|
||||
if(pbyte->n[1].all)
|
||||
matched++;
|
||||
else if(pbyte->n[1].n==n2)
|
||||
else if(pbyte->n[1].n == n2)
|
||||
matched++;
|
||||
return (matched==2);
|
||||
return (matched == 2);
|
||||
}
|
||||
|
||||
uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* patternsize)
|
||||
|
|
@ -345,21 +345,21 @@ uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* pa
|
|||
std::vector<PATTERNBYTE> searchpattern;
|
||||
if(!patterntransform(pattern, &searchpattern))
|
||||
return -1;
|
||||
int searchpatternsize=(int)searchpattern.size();
|
||||
int searchpatternsize = (int)searchpattern.size();
|
||||
if(patternsize)
|
||||
*patternsize=searchpatternsize;
|
||||
for(uint i=0,pos=0; i<size; i++) //search for the pattern
|
||||
*patternsize = searchpatternsize;
|
||||
for(uint i = 0, pos = 0; i < size; i++) //search for the pattern
|
||||
{
|
||||
if(patternmatchbyte(data[i], &searchpattern.at(pos))) //check if our pattern matches the current byte
|
||||
{
|
||||
pos++;
|
||||
if(pos==searchpatternsize) //everything matched
|
||||
return i-searchpatternsize+1;
|
||||
if(pos == searchpatternsize) //everything matched
|
||||
return i - searchpatternsize + 1;
|
||||
}
|
||||
else if (pos>0) //fix by Computer_Angel
|
||||
else if(pos > 0) //fix by Computer_Angel
|
||||
{
|
||||
i-=pos; // return to previous byte
|
||||
pos=0; //reset current pattern position
|
||||
i -= pos; // return to previous byte
|
||||
pos = 0; //reset current pattern position
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ static void msgfree(MESSAGE* msg)
|
|||
//allocate a message stack
|
||||
MESSAGE_STACK* msgallocstack()
|
||||
{
|
||||
MESSAGE_STACK* msgstack=(MESSAGE_STACK*)emalloc(sizeof(MESSAGE_STACK), "msgallocstack:msgstack");
|
||||
MESSAGE_STACK* msgstack = (MESSAGE_STACK*)emalloc(sizeof(MESSAGE_STACK), "msgallocstack:msgstack");
|
||||
if(!msgstack)
|
||||
return 0;
|
||||
memset(msgstack, 0, sizeof(MESSAGE_STACK));
|
||||
|
|
@ -28,8 +28,8 @@ MESSAGE_STACK* msgallocstack()
|
|||
void msgfreestack(MESSAGE_STACK* msgstack)
|
||||
{
|
||||
DeleteCriticalSection(&msgstack->cr);
|
||||
int stackpos=msgstack->stackpos;
|
||||
for(int i=0; i<stackpos; i++) //free all messages left in stack
|
||||
int stackpos = msgstack->stackpos;
|
||||
for(int i = 0; i < stackpos; i++) //free all messages left in stack
|
||||
msgfree(msgstack->msg[i]);
|
||||
efree(msgstack, "msgfreestack:msgstack");
|
||||
}
|
||||
|
|
@ -37,24 +37,24 @@ void msgfreestack(MESSAGE_STACK* msgstack)
|
|||
//add a message to the stack
|
||||
bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
|
||||
{
|
||||
CRITICAL_SECTION* cr=&msgstack->cr;
|
||||
CRITICAL_SECTION* cr = &msgstack->cr;
|
||||
EnterCriticalSection(cr);
|
||||
int stackpos=msgstack->stackpos;
|
||||
if(stackpos>=MAX_MESSAGES)
|
||||
int stackpos = msgstack->stackpos;
|
||||
if(stackpos >= MAX_MESSAGES)
|
||||
{
|
||||
LeaveCriticalSection(cr);
|
||||
return false;
|
||||
}
|
||||
MESSAGE* newmsg=msgalloc();
|
||||
MESSAGE* newmsg = msgalloc();
|
||||
if(!newmsg)
|
||||
{
|
||||
LeaveCriticalSection(cr);
|
||||
return false;
|
||||
}
|
||||
newmsg->msg=msg;
|
||||
newmsg->param1=param1;
|
||||
newmsg->param2=param2;
|
||||
msgstack->msg[stackpos]=newmsg;
|
||||
newmsg->msg = msg;
|
||||
newmsg->param1 = param1;
|
||||
newmsg->param2 = param2;
|
||||
msgstack->msg[stackpos] = newmsg;
|
||||
msgstack->stackpos++; //increase stack pointer
|
||||
LeaveCriticalSection(cr);
|
||||
return true;
|
||||
|
|
@ -63,9 +63,9 @@ bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
|
|||
//get a message from the stack (will return false when there are no messages)
|
||||
bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
|
||||
{
|
||||
CRITICAL_SECTION* cr=&msgstack->cr;
|
||||
CRITICAL_SECTION* cr = &msgstack->cr;
|
||||
EnterCriticalSection(cr);
|
||||
int stackpos=msgstack->stackpos;
|
||||
int stackpos = msgstack->stackpos;
|
||||
if(!msgstack->stackpos) //no messages to process
|
||||
{
|
||||
LeaveCriticalSection(cr);
|
||||
|
|
@ -73,10 +73,10 @@ bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
|
|||
}
|
||||
msgstack->stackpos--; //current message is at stackpos-1
|
||||
stackpos--;
|
||||
MESSAGE* stackmsg=msgstack->msg[stackpos];
|
||||
MESSAGE* stackmsg = msgstack->msg[stackpos];
|
||||
memcpy(msg, stackmsg, sizeof(MESSAGE));
|
||||
msgfree(stackmsg);
|
||||
msgstack->msg[stackpos]=0;
|
||||
msgstack->msg[stackpos] = 0;
|
||||
LeaveCriticalSection(cr);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@
|
|||
|
||||
#define FORCE_INLINE inline __attribute__((always_inline))
|
||||
|
||||
inline uint32_t rotl32 ( uint32_t x, int8_t r )
|
||||
inline uint32_t rotl32(uint32_t x, int8_t r)
|
||||
{
|
||||
return (x << r) | (x >> (32 - r));
|
||||
}
|
||||
|
||||
inline uint64_t rotl64 ( uint64_t x, int8_t r )
|
||||
inline uint64_t rotl64(uint64_t x, int8_t r)
|
||||
{
|
||||
return (x << r) | (x >> (64 - r));
|
||||
}
|
||||
|
|
@ -52,12 +52,12 @@ inline uint64_t rotl64 ( uint64_t x, int8_t r )
|
|||
// Block read - if your platform needs to do endian-swapping or can only
|
||||
// handle aligned reads, do the conversion here
|
||||
|
||||
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
|
||||
FORCE_INLINE uint32_t getblock32(const uint32_t* p, int i)
|
||||
{
|
||||
return p[i];
|
||||
}
|
||||
|
||||
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
|
||||
FORCE_INLINE uint64_t getblock64(const uint64_t* p, int i)
|
||||
{
|
||||
return p[i];
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
|
|||
//-----------------------------------------------------------------------------
|
||||
// Finalization mix - force all bits of a hash block to avalanche
|
||||
|
||||
FORCE_INLINE uint32_t fmix32 ( uint32_t h )
|
||||
FORCE_INLINE uint32_t fmix32(uint32_t h)
|
||||
{
|
||||
h ^= h >> 16;
|
||||
h *= 0x85ebca6b;
|
||||
|
|
@ -78,7 +78,7 @@ FORCE_INLINE uint32_t fmix32 ( uint32_t h )
|
|||
|
||||
//----------
|
||||
|
||||
FORCE_INLINE uint64_t fmix64 ( uint64_t k )
|
||||
FORCE_INLINE uint64_t fmix64(uint64_t k)
|
||||
{
|
||||
k ^= k >> 33;
|
||||
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
|
||||
|
|
@ -91,10 +91,10 @@ FORCE_INLINE uint64_t fmix64 ( uint64_t k )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MurmurHash3_x86_32 ( const void * key, int len,
|
||||
uint32_t seed, void * out )
|
||||
void MurmurHash3_x86_32(const void* key, int len,
|
||||
uint32_t seed, void* out)
|
||||
{
|
||||
const uint8_t * data = (const uint8_t*)key;
|
||||
const uint8_t* data = (const uint8_t*)key;
|
||||
const int nblocks = len / 4;
|
||||
|
||||
uint32_t h1 = seed;
|
||||
|
|
@ -105,25 +105,25 @@ void MurmurHash3_x86_32 ( const void * key, int len,
|
|||
//----------
|
||||
// body
|
||||
|
||||
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
|
||||
const uint32_t* blocks = (const uint32_t*)(data + nblocks * 4);
|
||||
|
||||
for(int i = -nblocks; i; i++)
|
||||
{
|
||||
uint32_t k1 = getblock32(blocks,i);
|
||||
uint32_t k1 = getblock32(blocks, i);
|
||||
|
||||
k1 *= c1;
|
||||
k1 = ROTL32(k1,15);
|
||||
k1 = ROTL32(k1, 15);
|
||||
k1 *= c2;
|
||||
|
||||
h1 ^= k1;
|
||||
h1 = ROTL32(h1,13);
|
||||
h1 = h1*5+0xe6546b64;
|
||||
h1 = ROTL32(h1, 13);
|
||||
h1 = h1 * 5 + 0xe6546b64;
|
||||
}
|
||||
|
||||
//----------
|
||||
// tail
|
||||
|
||||
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
|
||||
const uint8_t* tail = (const uint8_t*)(data + nblocks * 4);
|
||||
|
||||
uint32_t k1 = 0;
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ void MurmurHash3_x86_32 ( const void * key, int len,
|
|||
case 1:
|
||||
k1 ^= tail[0];
|
||||
k1 *= c1;
|
||||
k1 = ROTL32(k1,15);
|
||||
k1 = ROTL32(k1, 15);
|
||||
k1 *= c2;
|
||||
h1 ^= k1;
|
||||
};
|
||||
|
|
@ -153,10 +153,10 @@ void MurmurHash3_x86_32 ( const void * key, int len,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MurmurHash3_x86_128 ( const void * key, const int len,
|
||||
uint32_t seed, void * out )
|
||||
void MurmurHash3_x86_128(const void* key, const int len,
|
||||
uint32_t seed, void* out)
|
||||
{
|
||||
const uint8_t * data = (const uint8_t*)key;
|
||||
const uint8_t* data = (const uint8_t*)key;
|
||||
const int nblocks = len / 16;
|
||||
|
||||
uint32_t h1 = seed;
|
||||
|
|
@ -172,56 +172,56 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
|
|||
//----------
|
||||
// body
|
||||
|
||||
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
|
||||
const uint32_t* blocks = (const uint32_t*)(data + nblocks * 16);
|
||||
|
||||
for(int i = -nblocks; i; i++)
|
||||
{
|
||||
uint32_t k1 = getblock32(blocks,i*4+0);
|
||||
uint32_t k2 = getblock32(blocks,i*4+1);
|
||||
uint32_t k3 = getblock32(blocks,i*4+2);
|
||||
uint32_t k4 = getblock32(blocks,i*4+3);
|
||||
uint32_t k1 = getblock32(blocks, i * 4 + 0);
|
||||
uint32_t k2 = getblock32(blocks, i * 4 + 1);
|
||||
uint32_t k3 = getblock32(blocks, i * 4 + 2);
|
||||
uint32_t k4 = getblock32(blocks, i * 4 + 3);
|
||||
|
||||
k1 *= c1;
|
||||
k1 = ROTL32(k1,15);
|
||||
k1 = ROTL32(k1, 15);
|
||||
k1 *= c2;
|
||||
h1 ^= k1;
|
||||
|
||||
h1 = ROTL32(h1,19);
|
||||
h1 = ROTL32(h1, 19);
|
||||
h1 += h2;
|
||||
h1 = h1*5+0x561ccd1b;
|
||||
h1 = h1 * 5 + 0x561ccd1b;
|
||||
|
||||
k2 *= c2;
|
||||
k2 = ROTL32(k2,16);
|
||||
k2 = ROTL32(k2, 16);
|
||||
k2 *= c3;
|
||||
h2 ^= k2;
|
||||
|
||||
h2 = ROTL32(h2,17);
|
||||
h2 = ROTL32(h2, 17);
|
||||
h2 += h3;
|
||||
h2 = h2*5+0x0bcaa747;
|
||||
h2 = h2 * 5 + 0x0bcaa747;
|
||||
|
||||