1
0
Fork 0

doxygen template

This commit is contained in:
Mr. eXoDia 2014-09-14 16:28:23 +02:00
parent ee88a8bd72
commit ebbc42a451
37 changed files with 10046 additions and 42 deletions

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ release/
build/
debug/
*XE Results*/
doxygen*/
#global filetypes to ignore
*.depend

2363
doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,139 @@
/**
@file _global.cpp
@brief Implements the global class.
*/
#include "_global.h"
//GUI functions
/**
@brief GUI functions.
*/
GUIGUIINIT _gui_guiinit;
/**
@brief The graphical user interface sendmessage.
*/
GUISENDMESSAGE _gui_sendmessage;
//DBG functions
/**
@brief DBG functions.
*/
DBGDBGINIT _dbg_dbginit;
/**
@brief The debug memfindbaseaddr.
*/
DBGMEMFINDBASEADDR _dbg_memfindbaseaddr;
/**
@brief The debug memread.
*/
DBGMEMREAD _dbg_memread;
/**
@brief The debug memwrite.
*/
DBGMEMWRITE _dbg_memwrite;
/**
@brief The debug dbgcmdexec.
*/
DBGDBGCMDEXEC _dbg_dbgcmdexec;
/**
@brief The debug memmap.
*/
DBGMEMMAP _dbg_memmap;
/**
@brief The debug dbgexitsignal.
*/
DBGDBGEXITSIGNAL _dbg_dbgexitsignal;
/**
@brief The debug valfromstring.
*/
DBGVALFROMSTRING _dbg_valfromstring;
/**
@brief The debug isdebugging.
*/
DBGISDEBUGGING _dbg_isdebugging;
/**
@brief The debug isjumpgoingtoexecute.
*/
DBGISJUMPGOINGTOEXECUTE _dbg_isjumpgoingtoexecute;
/**
@brief The debug addrinfoget.
*/
DBGADDRINFOGET _dbg_addrinfoget;
/**
@brief The debug addrinfoset.
*/
DBGADDRINFOSET _dbg_addrinfoset;
/**
@brief The debug bpgettypeat.
*/
DBGBPGETTYPEAT _dbg_bpgettypeat;
/**
@brief The debug getregdump.
*/
DBGGETREGDUMP _dbg_getregdump;
/**
@brief The debug valtostring.
*/
DBGVALTOSTRING _dbg_valtostring;
/**
@brief The debug memisvalidreadptr.
*/
DBGMEMISVALIDREADPTR _dbg_memisvalidreadptr;
/**
@brief The debug getbplist.
*/
DBGGETBPLIST _dbg_getbplist;
/**
@brief The debug dbgcmddirectexec.
*/
DBGDBGCMDEXECDIRECT _dbg_dbgcmddirectexec;
/**
@brief The debug getbranchdestination.
*/
DBGGETBRANCHDESTINATION _dbg_getbranchdestination;
/**
@brief The debug sendmessage.
*/
DBGSENDMESSAGE _dbg_sendmessage;

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,9 @@
/**
@file _dbgfunctions.cpp
@brief Implements the dbgfunctions class.
*/
#include "_global.h"
#include "_dbgfunctions.h"
#include "assemble.h"
@ -9,18 +15,54 @@
#include "stackinfo.h"
#include "symbolinfo.h"
/**
@brief The dbgfunctions.
*/
static DBGFUNCTIONS _dbgfunctions;
/**
@fn const DBGFUNCTIONS* dbgfunctionsget()
@brief Gets the dbgfunctionsget.
@return null if it fails, else a DBGFUNCTIONS*.
*/
const DBGFUNCTIONS* dbgfunctionsget()
{
return &_dbgfunctions;
}
/**
@fn static bool _assembleatex(duint addr, const char* instruction, char* error, bool fillnop)
@brief Assembleatexes.
@param addr The address.
@param instruction The instruction.
@param [in,out] error If non-null, the error.
@param fillnop true to fillnop.
@return true if it succeeds, false if it fails.
*/
static bool _assembleatex(duint addr, const char* instruction, char* error, bool fillnop)
{
return assembleat(addr, instruction, 0, error, fillnop);
}
/**
@fn static bool _sectionfromaddr(duint addr, char* section)
@brief Sectionfromaddrs.
@param addr The address.
@param [in,out] section If non-null, the section.
@return true if it succeeds, false if it fails.
*/
static bool _sectionfromaddr(duint addr, char* section)
{
HMODULE hMod = (HMODULE)modbasefromaddr(addr);
@ -50,11 +92,32 @@ static bool _sectionfromaddr(duint addr, char* section)
return false;
}
/**
@fn static bool _patchget(duint addr)
@brief Patchgets the given address.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
static bool _patchget(duint addr)
{
return patchget(addr, 0);
}
/**
@fn static bool _patchinrange(duint start, duint end)
@brief Patchinranges.
@param start The start.
@param end The end.
@return true if it succeeds, false if it fails.
*/
static bool _patchinrange(duint start, duint end)
{
if(start > end)
@ -69,11 +132,32 @@ static bool _patchinrange(duint start, duint end)
return false;
}
/**
@fn static bool _mempatch(duint va, const unsigned char* src, duint size)
@brief Mempatches.
@param va The variable arguments.
@param src Source for the.
@param size The size.
@return true if it succeeds, false if it fails.
*/
static bool _mempatch(duint va, const unsigned char* src, duint size)
{
return mempatch(fdProcessInfo->hProcess, (void*)va, src, size, 0);
}
/**
@fn static void _patchrestorerange(duint start, duint end)
@brief Patchrestoreranges.
@param start The start.
@param end The end.
*/
static void _patchrestorerange(duint start, duint end)
{
if(start > end)
@ -87,31 +171,94 @@ static void _patchrestorerange(duint start, duint end)
GuiUpdatePatches();
}
/**
@fn static bool _patchrestore(duint addr)
@brief Patchrestores the given address.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
static bool _patchrestore(duint addr)
{
return patchdel(addr, true);
}
/**
@fn static int _modpathfromaddr(duint addr, char* path, int size)
@brief Modpathfromaddrs.
@param addr The address.
@param [in,out] path If non-null, full pathname of the file.
@param size The size.
@return An int.
*/
static int _modpathfromaddr(duint addr, char* path, int size)
{
return GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), path, size);
}
/**
@fn static int _modpathfromname(const char* modname, char* path, int size)
@brief Modpathfromnames.
@param modname The modname.
@param [in,out] path If non-null, full pathname of the file.
@param size The size.
@return An int.
*/
static int _modpathfromname(const char* modname, char* path, int size)
{
return _modpathfromaddr(modbasefromname(modname), path, size);
}
/**
@fn static void _getcallstack(DBGCALLSTACK* callstack)
@brief Getcallstacks the given callstack.
@param [in,out] callstack If non-null, the callstack.
*/
static void _getcallstack(DBGCALLSTACK* callstack)
{
stackgetcallstack(GetContextDataEx(hActiveThread, UE_CSP), (CALLSTACK*)callstack);
}
/**
@fn static bool _getjitauto(bool* jit_auto)
@brief Getjitautoes the given just-in-time automatic.
@param [in,out] jit_auto If non-null, the just-in-time automatic.
@return true if it succeeds, false if it fails.
*/
static bool _getjitauto(bool* jit_auto)
{
return dbggetjitauto(jit_auto, notfound, NULL, NULL);
}
/**
@fn static bool _getcmdline(char* cmd_line, size_t* cbsize)
@brief Getcmdlines.
@param [in,out] cmd_line If non-null, the command line.
@param [in,out] cbsize If non-null, the cbsize.
@return true if it succeeds, false if it fails.
*/
static bool _getcmdline(char* cmd_line, size_t* cbsize)
{
if(!cmd_line && !cbsize)
@ -127,11 +274,32 @@ static bool _getcmdline(char* cmd_line, size_t* cbsize)
return true;
}
/**
@fn static bool _setcmdline(const char* cmd_line)
@brief Setcmdlines the given command line.
@param cmd_line The command line.
@return true if it succeeds, false if it fails.
*/
static bool _setcmdline(const char* cmd_line)
{
return dbgsetcmdline(cmd_line, NULL);
}
/**
@fn static bool _getjit(char* jit, bool jit64)
@brief Getjits.
@param [in,out] jit If non-null, the just-in-time.
@param jit64 true to just-in-time 64.
@return true if it succeeds, false if it fails.
*/
static bool _getjit(char* jit, bool jit64)
{
arch dummy;
@ -152,6 +320,17 @@ static bool _getjit(char* jit, bool jit64)
return true;
}
/**
@fn bool _getprocesslist(DBGPROCESSINFO** entries, int* count)
@brief Getprocesslists.
@param [in,out] entries If non-null, the entries.
@param [in,out] count If non-null, number of.
@return true if it succeeds, false if it fails.
*/
bool _getprocesslist(DBGPROCESSINFO** entries, int* count)
{
std::vector<PROCESSENTRY32> list;
@ -169,11 +348,23 @@ bool _getprocesslist(DBGPROCESSINFO** entries, int* count)
return true;
}
/**
@fn static void _memupdatemap()
@brief Memupdatemaps this object.
*/
static void _memupdatemap()
{
memupdatemap(fdProcessInfo->hProcess);
}
/**
@fn void dbgfunctionsinit()
@brief Dbgfunctionsinits this object.
*/
void dbgfunctionsinit()
{
_dbgfunctions.AssembleAtEx = _assembleatex;

View File

@ -1,3 +1,9 @@
/**
@file _exports.cpp
@brief Implements the exports class.
*/
#include "_exports.h"
#include "memory.h"
#include "debugger.h"
@ -16,23 +22,74 @@
#include "plugin_loader.h"
#include "_dbgfunctions.h"
/**
@brief The only cip automatic comments.
*/
static bool bOnlyCipAutoComments = false;
/**
@fn extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size)
@brief Debug memfindbaseaddr.
@param addr The address.
@param [in,out] size If non-null, the size.
@return A duint.
*/
extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size)
{
return memfindbaseaddr(addr, size);
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_memread(duint addr, unsigned char* dest, duint size, duint* read)
@brief Debug memread.
@param addr The address.
@param [in,out] dest If non-null, destination for the.
@param size The size.
@param [in,out] read If non-null, the read.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_memread(duint addr, unsigned char* dest, duint size, duint* read)
{
return memread(fdProcessInfo->hProcess, (void*)addr, dest, size, read);
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_memwrite(duint addr, const unsigned char* src, duint size, duint* written)
@brief Debug memwrite.
@param addr The address.
@param src Source for the.
@param size The size.
@param [in,out] written If non-null, the written.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_memwrite(duint addr, const unsigned char* src, duint size, duint* written)
{
return memwrite(fdProcessInfo->hProcess, (void*)addr, src, size, written);
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
@brief Debug memmap.
@param [in,out] memmap If non-null, the memmap.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
{
CriticalSectionLocker locker(LockMemoryPages);
@ -49,16 +106,45 @@ extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
return true;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_memisvalidreadptr(duint addr)
@brief Debug memisvalidreadptr.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_memisvalidreadptr(duint addr)
{
return memisvalidreadptr(fdProcessInfo->hProcess, addr);
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_valfromstring(const char* string, duint* value)
@brief Debug valfromstring.
@param string The string.
@param [in,out] value If non-null, the value.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_valfromstring(const char* string, duint* value)
{
return valfromstring(string, value);
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_isdebugging()
@brief Determines if we can debug isdebugging.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_isdebugging()
{
if(IsFileBeingDebugged())
@ -66,6 +152,16 @@ extern "C" DLL_EXPORT bool _dbg_isdebugging()
return false;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
@brief Debug isjumpgoingtoexecute.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
{
static uint cacheFlags;
@ -80,6 +176,18 @@ extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
return cacheResult;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDRINFO* addrinfo)
@brief Debug addrinfoget.
@param addr The address.
@param segment The segment.
@param [in,out] addrinfo If non-null, the addrinfo.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDRINFO* addrinfo)
{
if(!DbgIsDebugging())
@ -284,6 +392,17 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
return retval;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo)
@brief Debug addrinfoset.
@param addr The address.
@param [in,out] addrinfo If non-null, the addrinfo.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo)
{
bool retval = false;
@ -307,6 +426,16 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo)
return retval;
}
/**
@fn extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
@brief Debug bpgettypeat.
@param addr The address.
@return An int.
*/
extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
{
static uint cacheAddr;
@ -332,6 +461,16 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
return cacheResult;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
@brief Debug getregdump.
@param [in,out] regdump If non-null, the regdump.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
{
if(!DbgIsDebugging())
@ -397,11 +536,33 @@ extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
return true;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_valtostring(const char* string, duint* value)
@brief Debug valtostring.
@param string The string.
@param [in,out] value If non-null, the value.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_valtostring(const char* string, duint* value)
{
return valtostring(string, value, true);
}
/**
@fn extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
@brief Debug getbplist.
@param type The type.
@param [in,out] bpmap If non-null, the bpmap.
@return An int.
*/
extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
{
if(!bpmap)
@ -494,6 +655,16 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
return retcount;
}
/**
@fn extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr)
@brief Debug getbranchdestination.
@param addr The address.
@return An uint.
*/
extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr)
{
DISASM_INSTR instr;
@ -515,11 +686,34 @@ extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr)
return instr.arg[0].value;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end)
@brief Debug functionoverlaps.
@param start The start.
@param end The end.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end)
{
return functionoverlaps(start, end);
}
/**
@fn extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* param2)
@brief Debug sendmessage.
@param type The type.
@param [in,out] param1 If non-null, the first parameter.
@param [in,out] param2 If non-null, the second parameter.
@return An uint.
*/
extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* param2)
{
switch(type)

View File

@ -1,28 +1,97 @@
/**
@file _global.cpp
@brief Implements the global class.
*/
#include "_global.h"
#include <new>
/**
@brief The instance.
*/
HINSTANCE hInst;
/**
@brief The dbbasepath[deflen].
*/
char dbbasepath[deflen] = "";
/**
@brief The dbpath[ 3*deflen].
*/
char dbpath[3 * deflen] = "";
/**
@fn void* emalloc(size_t size)
@brief Emallocs the given size.
@param size The size.
@return null if it fails, else a void*.
*/
void* emalloc(size_t size)
{
return emalloc(size, "emalloc:???");
}
/**
@fn void* erealloc(void* ptr, size_t size)
@brief Ereallocs.
@param [in,out] ptr If non-null, the pointer.
@param size The size.
@return null if it fails, else a void*.
*/
void* erealloc(void* ptr, size_t size)
{
return erealloc(ptr, size, "erealloc:???");
}
/**
@fn void efree(void* ptr)
@brief Efrees the given pointer.
@param [in,out] ptr If non-null, the pointer.
*/
void efree(void* ptr)
{
efree(ptr, "efree:???");
}
/**
@brief Number of emallocs.
*/
static int emalloc_count = 0;
/**
@brief The alloctrace[ maximum path].
*/
static char alloctrace[MAX_PATH] = "";
/**
@fn void* emalloc(size_t size, const char* reason)
@brief Emallocs.
@param size The size.
@param reason The reason.
@return null if it fails, else a void*.
*/
void* emalloc(size_t size, const char* reason)
{
unsigned char* a = (unsigned char*)GlobalAlloc(GMEM_FIXED, size);
@ -41,6 +110,18 @@ void* emalloc(size_t size, const char* reason)
return a;
}
/**
@fn void* erealloc(void* ptr, size_t size, const char* reason)
@brief Ereallocs.
@param [in,out] ptr If non-null, the pointer.
@param size The size.
@param reason The reason.
@return null if it fails, else a void*.
*/
void* erealloc(void* ptr, size_t size, const char* reason)
{
if(!ptr)
@ -60,6 +141,15 @@ void* erealloc(void* ptr, size_t size, const char* reason)
return a;
}
/**
@fn void efree(void* ptr, const char* reason)
@brief Efrees.
@param [in,out] ptr If non-null, the pointer.
@param reason The reason.
*/
void efree(void* ptr, const char* reason)
{
emalloc_count--;
@ -71,16 +161,43 @@ void efree(void* ptr, const char* reason)
GlobalFree(ptr);
}
/**
@fn int memleaks()
@brief Gets the memleaks.
@return An int.
*/
int memleaks()
{
return emalloc_count;
}
/**
@fn void setalloctrace(const char* file)
@brief Setalloctraces the given file.
@param file The file.
*/
void setalloctrace(const char* file)
{
strcpy_s(alloctrace, file);
}
/**
@fn bool arraycontains(const char* cmd_list, const char* cmd)
@brief Arraycontains.
@param cmd_list List of commands.
@param cmd The command.
@return true if it succeeds, false if it fails.
*/
bool arraycontains(const char* cmd_list, const char* cmd)
{
//TODO: fix this function a little
@ -108,6 +225,17 @@ bool arraycontains(const char* cmd_list, const char* cmd)
return false;
}
/**
@fn bool scmp(const char* a, const char* b)
@brief Scmps.
@param a The const char* to process.
@param b The const char* to process.
@return true if it succeeds, false if it fails.
*/
bool scmp(const char* a, const char* b)
{
if(_stricmp(a, b))
@ -115,6 +243,14 @@ bool scmp(const char* a, const char* b)
return true;
}
/**
@fn void formathex(char* string)
@brief Formathexes the given string.
@param [in,out] string If non-null, the string.
*/
void formathex(char* string)
{
int len = (int)strlen(string);
@ -127,6 +263,14 @@ void formathex(char* string)
strcpy(string, new_string);
}
/**
@fn void formatdec(char* string)
@brief Formatdecs the given string.
@param [in,out] string If non-null, the string.
*/
void formatdec(char* string)
{
int len = (int)strlen(string);
@ -139,23 +283,65 @@ void formatdec(char* string)
strcpy(string, new_string);
}
/**
@fn bool FileExists(const char* file)
@brief Queries if a given file exists.
@param file The file.
@return true if it succeeds, false if it fails.
*/
bool FileExists(const char* file)
{
DWORD attrib = GetFileAttributes(file);
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
}
/**
@fn bool DirExists(const char* dir)
@brief Queries if a given dir exists.
@param dir The dir.
@return true if it succeeds, false if it fails.
*/
bool DirExists(const char* dir)
{
DWORD attrib = GetFileAttributes(dir);
return (attrib == FILE_ATTRIBUTE_DIRECTORY);
}
/**
@fn bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)
@brief Gets file name from handle.
@param hFile Handle of the file.
@param [in,out] szFileName If non-null, filename of the file.
@return true if it succeeds, false if it fails.
*/
bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)
{
return PathFromFileHandleA(hFile, szFileName, MAX_PATH);
}
/**
@fn bool settingboolget(const char* section, const char* name)
@brief Settingboolgets.
@param section The section.
@param name The name.
@return true if it succeeds, false if it fails.
*/
bool settingboolget(const char* section, const char* name)
{
uint setting;
@ -166,6 +352,16 @@ bool settingboolget(const char* section, const char* name)
return false;
}
/**
@fn arch GetFileArchitecture(const char* szFileName)
@brief Gets file architecture.
@param szFileName Filename of the file.
@return The file architecture.
*/
arch GetFileArchitecture(const char* szFileName)
{
arch retval = notfound;
@ -199,6 +395,14 @@ arch GetFileArchitecture(const char* szFileName)
return retval;
}
/**
@fn bool IsWow64()
@brief Query if this object is wow 64.
@return true if wow 64, false if not.
*/
bool IsWow64()
{
BOOL bIsWow64Process = FALSE;

View File

@ -1,32 +1,94 @@
/**
@file _plugins.cpp
@brief Implements the plugins class.
*/
#include "_plugins.h"
#include "plugin_loader.h"
#include "console.h"
#include "debugger.h"
#include "threading.h"
/**
@brief The msg[ 66000].
*/
static char msg[66000];
///debugger plugin exports (wrappers)
/**
@fn PLUG_IMPEXP void _plugin_registercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin)
@brief debugger plugin exports (wrappers)
@param pluginHandle Handle of the plugin.
@param cbType The type.
@param cbPlugin The plugin.
*/
PLUG_IMPEXP void _plugin_registercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin)
{
pluginregistercallback(pluginHandle, cbType, cbPlugin);
}
/**
@fn PLUG_IMPEXP bool _plugin_unregistercallback(int pluginHandle, CBTYPE cbType)
@brief Unregistercallback, called when the plugin unregister.
@param pluginHandle Handle of the plugin.
@param cbType The type.
@return true if it succeeds, false if it fails.
*/
PLUG_IMPEXP bool _plugin_unregistercallback(int pluginHandle, CBTYPE cbType)
{
return pluginunregistercallback(pluginHandle, cbType);
}
/**
@fn PLUG_IMPEXP bool _plugin_registercommand(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
@brief Plugin registercommand.
@param pluginHandle Handle of the plugin.
@param command The command.
@param cbCommand The command.
@param debugonly true to debugonly.
@return true if it succeeds, false if it fails.
*/
PLUG_IMPEXP bool _plugin_registercommand(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
{
return plugincmdregister(pluginHandle, command, cbCommand, debugonly);
}
/**
@fn PLUG_IMPEXP bool _plugin_unregistercommand(int pluginHandle, const char* command)
@brief Plugin unregistercommand.
@param pluginHandle Handle of the plugin.
@param command The command.
@return true if it succeeds, false if it fails.
*/
PLUG_IMPEXP bool _plugin_unregistercommand(int pluginHandle, const char* command)
{
return plugincmdunregister(pluginHandle, command);
}
/**
@fn PLUG_IMPEXP void _plugin_logprintf(const char* format, ...)
@brief Plugin logprintf.
@param format Describes the format to use.
*/
PLUG_IMPEXP void _plugin_logprintf(const char* format, ...)
{
va_list args;
@ -35,11 +97,25 @@ PLUG_IMPEXP void _plugin_logprintf(const char* format, ...)
GuiAddLogMessage(msg);
}
/**
@fn PLUG_IMPEXP void _plugin_logputs(const char* text)
@brief Plugin logputs.
@param text The text.
*/
PLUG_IMPEXP void _plugin_logputs(const char* text)
{
dputs(text);
}
/**
@fn PLUG_IMPEXP void _plugin_debugpause()
@brief Plugin debugpause.
*/
PLUG_IMPEXP void _plugin_debugpause()
{
GuiSetDebugState(paused);
@ -50,26 +126,77 @@ PLUG_IMPEXP void _plugin_debugpause()
wait(WAITID_RUN);
}
/**
@fn PLUG_IMPEXP void _plugin_debugskipexceptions(bool skip)
@brief Plugin debugskipexceptions.
@param skip true to skip.
*/
PLUG_IMPEXP void _plugin_debugskipexceptions(bool skip)
{
dbgsetskipexceptions(skip);
}
/**
@fn PLUG_IMPEXP int _plugin_menuadd(int hMenu, const char* title)
@brief Plugin menuadd.
@param hMenu The menu.
@param title The title.
@return An int.
*/
PLUG_IMPEXP int _plugin_menuadd(int hMenu, const char* title)
{
return pluginmenuadd(hMenu, title);
}
/**
@fn PLUG_IMPEXP bool _plugin_menuaddentry(int hMenu, int hEntry, const char* title)
@brief Plugin menuaddentry.
@param hMenu The menu.
@param hEntry The entry.
@param title The title.
@return true if it succeeds, false if it fails.
*/
PLUG_IMPEXP bool _plugin_menuaddentry(int hMenu, int hEntry, const char* title)
{
return pluginmenuaddentry(hMenu, hEntry, title);
}
/**
@fn PLUG_IMPEXP bool _plugin_menuaddseparator(int hMenu)
@brief Plugin menuaddseparator.
@param hMenu The menu.
@return true if it succeeds, false if it fails.
*/
PLUG_IMPEXP bool _plugin_menuaddseparator(int hMenu)
{
return pluginmenuaddseparator(hMenu);
}
/**
@fn PLUG_IMPEXP bool _plugin_menuclear(int hMenu)
@brief Plugin menuclear.
@param hMenu The menu.
@return true if it succeeds, false if it fails.
*/
PLUG_IMPEXP bool _plugin_menuclear(int hMenu)
{
return pluginmenuclear(hMenu);

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,9 @@
/**
@file argument.cpp
@brief Implements the argument class.
*/
#include "argument.h"
#include "console.h"
@ -22,6 +28,15 @@ formatarg:
12) restore double backslash
13) combine formatted arguments and command
*/
/**
@fn void argformat(char* cmd)
@brief Argformats the given command.
@param [in,out] cmd If non-null, the command.
*/
void argformat(char* cmd)
{
if(strlen(cmd) >= deflen)
@ -146,6 +161,17 @@ void argformat(char* cmd)
1) remove double backslash
2) count unescaped commas
*/
/**
@fn int arggetcount(const char* cmd)
@brief Arggetcounts the given command.
@param cmd The command.
@return An int.
*/
int arggetcount(const char* cmd)
{
int len = (int)strlen(cmd);
@ -183,6 +209,20 @@ int arggetcount(const char* cmd)
4) restore double backslash
5) handle escape characters
*/
/**
@fn bool argget(const char* cmd, char* arg, int arg_num, bool optional)
@brief Arggets.
@param cmd The command.
@param [in,out] arg If non-null, the argument.
@param arg_num The argument number.
@param optional true to optional.
@return true if it succeeds, false if it fails.
*/
bool argget(const char* cmd, char* arg, int arg_num, bool optional)
{
if(strlen(cmd) >= deflen)

View File

@ -1,3 +1,9 @@
/**
@file assemble.cpp
@brief Implements the assemble class.
*/
#include "assemble.h"
#include "memory.h"
#include "debugger.h"
@ -6,6 +12,17 @@
#include "disasm_helper.h"
#include "console.h"
/**
@fn static bool cbUnknown(const char* text, ULONGLONG* value)
@brief Unknowns.
@param text The text.
@param [in,out] value If non-null, the value.
@return true if it succeeds, false if it fails.
*/
static bool cbUnknown(const char* text, ULONGLONG* value)
{
if(!text or !value)
@ -17,6 +34,20 @@ static bool cbUnknown(const char* text, ULONGLONG* value)
return true;
}
/**
@fn bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction, char* error)
@brief Assembles.
@param addr The address.
@param [in,out] dest If non-null, destination for the.
@param [in,out] size If non-null, the size.
@param instruction The instruction.
@param [in,out] error If non-null, the error.
@return true if it succeeds, false if it fails.
*/
bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction, char* error)
{
if(strlen(instruction) >= XEDPARSE_MAXBUFSIZE)
@ -46,6 +77,20 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction
return true;
}
/**
@fn bool assembleat(uint addr, const char* instruction, int* size, char* error, bool fillnop)
@brief Assembleats.
@param addr The address.
@param instruction The instruction.
@param [in,out] size If non-null, the size.
@param [in,out] error If non-null, the error.
@param fillnop true to fillnop.
@return true if it succeeds, false if it fails.
*/
bool assembleat(uint addr, const char* instruction, int* size, char* error, bool fillnop)
{
int destSize;

View File

@ -1,3 +1,9 @@
/**
@file breakpoint.cpp
@brief Implements the breakpoint class.
*/
#include "breakpoint.h"
#include "debugger.h"
#include "addrinfo.h"
@ -5,8 +11,22 @@
#include "memory.h"
#include "threading.h"
/**
@brief The breakpoints.
*/
static BreakpointsInfo breakpoints;
/**
@fn int bpgetlist(std::vector<BREAKPOINT>* list)
@brief Bpgetlists the given list.
@param [in,out] list If non-null, the list.
@return An int.
*/
int bpgetlist(std::vector<BREAKPOINT>* list)
{
if(!DbgIsDebugging())
@ -25,6 +45,22 @@ int bpgetlist(std::vector<BREAKPOINT>* list)
return count;
}
/**
@fn bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name)
@brief Bpnews.
@param addr The address.
@param enabled true to enable, false to disable.
@param singleshoot true to singleshoot.
@param oldbytes The oldbytes.
@param type The type.
@param titantype The titantype.
@param name The name.
@return true if it succeeds, false if it fails.
*/
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name)
{
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or bpget(addr, type, name, 0))
@ -47,6 +83,19 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty
return true;
}
/**
@fn bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
@brief Bpgets.
@param addr The address.
@param type The type.
@param name The name.
@param [in,out] bp If non-null, the bp.
@return true if it succeeds, false if it fails.
*/
bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
{
if(!DbgIsDebugging())
@ -85,6 +134,17 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
return false;
}
/**
@fn bool bpdel(uint addr, BP_TYPE type)
@brief Bpdels.
@param addr The address.
@param type The type.
@return true if it succeeds, false if it fails.
*/
bool bpdel(uint addr, BP_TYPE type)
{
if(!DbgIsDebugging())
@ -92,6 +152,18 @@ bool bpdel(uint addr, BP_TYPE type)
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0);
}
/**
@fn bool bpenable(uint addr, BP_TYPE type, bool enable)
@brief Bpenables.
@param addr The address.
@param type The type.
@param enable true to enable, false to disable.
@return true if it succeeds, false if it fails.
*/
bool bpenable(uint addr, BP_TYPE type, bool enable)
{
if(!DbgIsDebugging())
@ -103,6 +175,18 @@ bool bpenable(uint addr, BP_TYPE type, bool enable)
return true;
}
/**
@fn bool bpsetname(uint addr, BP_TYPE type, const char* name)
@brief Bpsetnames.
@param addr The address.
@param type The type.
@param name The name.
@return true if it succeeds, false if it fails.
*/
bool bpsetname(uint addr, BP_TYPE type, const char* name)
{
if(!DbgIsDebugging() or !name or !*name)
@ -114,6 +198,18 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name)
return true;
}
/**
@fn bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
@brief Bpsettitantypes.
@param addr The address.
@param type The type.
@param titantype The titantype.
@return true if it succeeds, false if it fails.
*/
bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
{
if(!DbgIsDebugging())
@ -125,6 +221,17 @@ bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
return true;
}
/**
@fn bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
@brief Bpenumalls.
@param cbEnum The enum.
@param module The module.
@return true if it succeeds, false if it fails.
*/
bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
{
if(!DbgIsDebugging())
@ -156,11 +263,32 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
return retval;
}
/**
@fn bool bpenumall(BPENUMCALLBACK cbEnum)
@brief Bpenumalls the given cb enum.
@param cbEnum The enum.
@return true if it succeeds, false if it fails.
*/
bool bpenumall(BPENUMCALLBACK cbEnum)
{
return bpenumall(cbEnum, 0);
}
/**
@fn int bpgetcount(BP_TYPE type, bool enabledonly)
@brief Bpgetcounts.
@param type The type.
@param enabledonly true to enabledonly.
@return An int.
*/
int bpgetcount(BP_TYPE type, bool enabledonly)
{
int count = 0;
@ -172,6 +300,15 @@ int bpgetcount(BP_TYPE type, bool enabledonly)
return count;
}
/**
@fn void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
@brief Bptobridges.
@param bp The bp.
@param [in,out] bridge If non-null, the bridge.
*/
void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
{
if(!bp or !bridge)
@ -200,6 +337,14 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
}
}
/**
@fn void bpcachesave(JSON root)
@brief Bpcachesaves the given root.
@param root The root.
*/
void bpcachesave(JSON root)
{
const JSON jsonbreakpoints = json_array();
@ -232,6 +377,20 @@ void bpcacheload(JSON root)
{
size_t i;
JSON value;
/**
@fn json_array_foreach(jsonbreakpoints, i, value)
@brief Constructor.
@author mrexodia
@date 9/14/2014
@param parameter1 The first parameter.
@param parameter2 The second parameter.
@param parameter3 The third parameter.
*/
json_array_foreach(jsonbreakpoints, i, value)
{
BREAKPOINT curBreakpoint;
@ -254,6 +413,12 @@ void bpcacheload(JSON root)
}
}
/**
@fn void bpclear()
@brief Bpclears this object.
*/
void bpclear()
{
BreakpointsInfo().swap(breakpoints);

View File

@ -1,3 +1,9 @@
/**
@file command.cpp
@brief Implements the command class.
*/
#include "command.h"
#include "argument.h"
#include "value.h"
@ -5,6 +11,18 @@
#include "debugger.h"
#include "math.h"
/**
@fn COMMAND* cmdfind(COMMAND* command_list, const char* name, COMMAND** link)
@brief Cmdfinds.
@param [in,out] command_list If non-null, list of commands.
@param name The name.
@param [in,out] link If non-null, the link.
@return null if it fails, else a COMMAND*.
*/
COMMAND* cmdfind(COMMAND* command_list, const char* name, COMMAND** link)
{
COMMAND* cur = command_list;
@ -25,6 +43,14 @@ COMMAND* cmdfind(COMMAND* command_list, const char* name, COMMAND** link)
return 0;
}
/**
@fn COMMAND* cmdinit()
@brief Gets the cmdinit.
@return null if it fails, else a COMMAND*.
*/
COMMAND* cmdinit()
{
COMMAND* cmd = (COMMAND*)emalloc(sizeof(COMMAND), "cmdinit:cmd");
@ -32,6 +58,14 @@ COMMAND* cmdinit()
return cmd;
}
/**
@fn void cmdfree(COMMAND* cmd_list)
@brief Cmdfrees the given command list.
@param [in,out] cmd_list If non-null, list of commands.
*/
void cmdfree(COMMAND* cmd_list)
{
COMMAND* cur = cmd_list;
@ -44,6 +78,19 @@ void cmdfree(COMMAND* cmd_list)
}
}
/**
@fn bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool debugonly)
@brief Cmdnews.
@param [in,out] command_list If non-null, list of commands.
@param name The name.
@param cbCommand The command.
@param debugonly true to debugonly.
@return true if it succeeds, false if it fails.
*/
bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool debugonly)
{
if(!command_list or !cbCommand or !name or !*name or cmdfind(command_list, name, 0))
@ -72,6 +119,17 @@ bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool d
return true;
}
/**
@fn COMMAND* cmdget(COMMAND* command_list, const char* cmd)
@brief Cmdgets.
@param [in,out] command_list If non-null, list of commands.
@param cmd The command.
@return null if it fails, else a COMMAND*.
*/
COMMAND* cmdget(COMMAND* command_list, const char* cmd)
{
char new_cmd[deflen] = "";
@ -87,6 +145,19 @@ COMMAND* cmdget(COMMAND* command_list, const char* cmd)
return found;
}
/**
@fn CBCOMMAND cmdset(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool debugonly)
@brief Cmdsets.
@param [in,out] command_list If non-null, list of commands.
@param name The name.
@param cbCommand The command.
@param debugonly true to debugonly.
@return A CBCOMMAND.
*/
CBCOMMAND cmdset(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool debugonly)
{
if(!cbCommand)
@ -100,6 +171,17 @@ CBCOMMAND cmdset(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, b
return old;
}
/**
@fn bool cmddel(COMMAND* command_list, const char* name)
@brief Cmddels.
@param [in,out] command_list If non-null, list of commands.
@param name The name.
@return true if it succeeds, false if it fails.
*/
bool cmddel(COMMAND* command_list, const char* name)
{
COMMAND* prev = 0;
@ -134,6 +216,21 @@ cbCommandProvider: function that provides commands (fgets for example), does
cbCommandFinder: non-default command finder
error_is_fatal: error return of a command callback stops the command processing
*/
/**
@fn CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPROVIDER cbCommandProvider, CBCOMMANDFINDER cbCommandFinder, bool error_is_fatal)
@brief Cmdloops.
@param [in,out] command_list If non-null, list of commands.
@param cbUnknownCommand The unknown command.
@param cbCommandProvider The command provider.
@param cbCommandFinder The command finder.
@param error_is_fatal true if error is fatal.
@return A CMDRESULT.
*/
CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPROVIDER cbCommandProvider, CBCOMMANDFINDER cbCommandFinder, bool error_is_fatal)
{
if(!cbUnknownCommand or !cbCommandProvider)
@ -197,12 +294,30 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
- custom command formatting rules
*/
/**
@fn static bool isvalidexpression(const char* expression)
@brief Query if 'expression' isvalidexpression.
@param expression The expression.
@return true if it succeeds, false if it fails.
*/
static bool isvalidexpression(const char* expression)
{
uint value;
return valfromstring(expression, &value);
}
/**
@fn static void specialformat(char* string)
@brief Specialformats the given string.
@param [in,out] string If non-null, the string.
*/
static void specialformat(char* string)
{
int len = (int)strlen(string);
@ -266,6 +381,18 @@ static void specialformat(char* string)
/*
- 'default' command finder, with some custom rules
*/
/**
@fn COMMAND* cmdfindmain(COMMAND* cmd_list, char* command)
@brief Cmdfindmains.
@param [in,out] cmd_list If non-null, list of commands.
@param [in,out] command If non-null, the command.
@return null if it fails, else a COMMAND*.
*/
COMMAND* cmdfindmain(COMMAND* cmd_list, char* command)
{
COMMAND* cmd = cmdfind(cmd_list, command, 0);
@ -279,6 +406,17 @@ COMMAND* cmdfindmain(COMMAND* cmd_list, char* command)
return cmd;
}
/**
@fn CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
@brief Cmddirectexecs.
@param [in,out] cmd_list If non-null, list of commands.
@param cmd The command.
@return A CMDRESULT.
*/
CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
{
if(!cmd or !strlen(cmd))

View File

@ -1,12 +1,38 @@
/**
@file console.cpp
@brief Implements the console class.
*/
#include "console.h"
/**
@brief The msg[ 66000].
*/
static char msg[66000];
/**
@fn void dputs(const char* text)
@brief Dputs the given text.
@param text The text.
*/
void dputs(const char* text)
{
dprintf("%s\n", text);
}
/**
@fn void dprintf(const char* format, ...)
@brief Dprintfs the given format.
@param format Describes the format to use.
*/
void dprintf(const char* format, ...)
{
va_list args;

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,9 @@
/**
@file debugger_commands.cpp
@brief Implements the debugger commands class.
*/
#include "debugger_commands.h"
#include "console.h"
#include "value.h"
@ -10,8 +16,23 @@
#include "simplescript.h"
#include "symbolinfo.h"
/**
@brief The scylla loaded.
*/
static bool bScyllaLoaded = false;
/**
@fn CMDRESULT cbDebugInit(int argc, char* argv[])
@brief Debug initialise.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugInit(int argc, char* argv[])
{
if(DbgIsDebugging())
@ -83,6 +104,17 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbStopDebug(int argc, char* argv[])
@brief Stops a debug.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbStopDebug(int argc, char* argv[])
{
scriptreset(); //reset the currently-loaded script
@ -92,6 +124,17 @@ CMDRESULT cbStopDebug(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugRun(int argc, char* argv[])
@brief Debug run.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugRun(int argc, char* argv[])
{
if(!waitislocked(WAITID_RUN))
@ -107,6 +150,17 @@ CMDRESULT cbDebugRun(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugErun(int argc, char* argv[])
@brief Debug erun.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugErun(int argc, char* argv[])
{
if(waitislocked(WAITID_RUN))
@ -114,6 +168,17 @@ CMDRESULT cbDebugErun(int argc, char* argv[])
return cbDebugRun(argc, argv);
}
/**
@fn CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
@brief Debug set bpx options.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
{
char argtype[deflen] = "";
@ -151,6 +216,17 @@ CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSetBPX(int argc, char* argv[])
@brief Debug set bpx.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
{
char argaddr[deflen] = "";
@ -221,6 +297,17 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
@brief Debug delete bpx.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -275,6 +362,17 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
@brief Debug enable bpx.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -324,6 +422,17 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
@brief Debug disable bpx.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -372,12 +481,34 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugBplist(int argc, char* argv[])
@brief Debug bplist.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugBplist(int argc, char* argv[])
{
bpenumall(cbBreakpointList);
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugStepInto(int argc, char* argv[])
@brief Debug step into.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugStepInto(int argc, char* argv[])
{
StepInto((void*)cbStep);
@ -385,12 +516,34 @@ CMDRESULT cbDebugStepInto(int argc, char* argv[])
return cbDebugRun(argc, argv);
}
/**
@fn CMDRESULT cbDebugeStepInto(int argc, char* argv[])
@brief Debuge step into.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugeStepInto(int argc, char* argv[])
{
dbgsetskipexceptions(true);
return cbDebugStepInto(argc, argv);
}
/**
@fn CMDRESULT cbDebugStepOver(int argc, char* argv[])
@brief Debug step over.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugStepOver(int argc, char* argv[])
{
StepOver((void*)cbStep);
@ -398,12 +551,34 @@ CMDRESULT cbDebugStepOver(int argc, char* argv[])
return cbDebugRun(argc, argv);
}
/**
@fn CMDRESULT cbDebugeStepOver(int argc, char* argv[])
@brief Debuge step over.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugeStepOver(int argc, char* argv[])
{
dbgsetskipexceptions(true);
return cbDebugStepOver(argc, argv);
}
/**
@fn CMDRESULT cbDebugSingleStep(int argc, char* argv[])
@brief Debug single step.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSingleStep(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -418,12 +593,34 @@ CMDRESULT cbDebugSingleStep(int argc, char* argv[])
return cbDebugRun(argc, argv);
}
/**
@fn CMDRESULT cbDebugeSingleStep(int argc, char* argv[])
@brief Debuge single step.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugeSingleStep(int argc, char* argv[])
{
dbgsetskipexceptions(true);
return cbDebugSingleStep(argc, argv);
}
/**
@fn CMDRESULT cbDebugHide(int argc, char* argv[])
@brief Debug hide.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugHide(int argc, char* argv[])
{
if(HideDebugger(fdProcessInfo->hProcess, UE_HIDE_PEBONLY))
@ -433,6 +630,17 @@ CMDRESULT cbDebugHide(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDisasm(int argc, char* argv[])
@brief Debug disasm.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDisasm(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -446,6 +654,17 @@ CMDRESULT cbDebugDisasm(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
@brief Debug set memory bpx.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
{
char arg1[deflen] = ""; //addr
@ -506,6 +725,17 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
@brief Debug delete memory breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -552,6 +782,17 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugRtr(int argc, char* argv[])
@brief Debug rtr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugRtr(int argc, char* argv[])
{
StepOver((void*)cbRtrStep);
@ -559,12 +800,34 @@ CMDRESULT cbDebugRtr(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugeRtr(int argc, char* argv[])
@brief Debuge rtr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugeRtr(int argc, char* argv[])
{
dbgsetskipexceptions(true);
return cbDebugRtr(argc, argv);
}
/**
@fn CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
@brief Debug set hardware breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = ""; //addr
@ -647,6 +910,17 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
@brief Debug delete hardware breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -689,6 +963,17 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugAlloc(int argc, char* argv[])
@brief Debug allocate.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugAlloc(int argc, char* argv[])
{
char arg1[deflen] = ""; //size
@ -711,6 +996,17 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugFree(int argc, char* argv[])
@brief Debug free.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugFree(int argc, char* argv[])
{
uint lastalloc;
@ -740,6 +1036,17 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugMemset(int argc, char* argv[])
@brief Debug memset.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugMemset(int argc, char* argv[])
{
char arg3[deflen] = ""; //size
@ -778,6 +1085,17 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugBenchmark(int argc, char* argv[])
@brief Debug benchmark.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugBenchmark(int argc, char* argv[])
{
uint addr = memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0);
@ -794,6 +1112,17 @@ CMDRESULT cbDebugBenchmark(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugPause(int argc, char* argv[])
@brief Debug pause.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugPause(int argc, char* argv[])
{
if(waitislocked(WAITID_RUN))
@ -806,6 +1135,16 @@ CMDRESULT cbDebugPause(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn static DWORD WINAPI scyllaThread(void* lpParam)
@brief Scylla thread.
@param [in,out] lpParam If non-null, the parameter.
@return A WINAPI.
*/
static DWORD WINAPI scyllaThread(void* lpParam)
{
typedef INT (WINAPI * SCYLLASTARTGUI)(DWORD pid, HINSTANCE mod);
@ -835,6 +1174,17 @@ static DWORD WINAPI scyllaThread(void* lpParam)
return 0;
}
/**
@fn CMDRESULT cbDebugStartScylla(int argc, char* argv[])
@brief Debug start scylla.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugStartScylla(int argc, char* argv[])
{
if(bScyllaLoaded)
@ -847,6 +1197,17 @@ CMDRESULT cbDebugStartScylla(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugAttach(int argc, char* argv[])
@brief Debug attach.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugAttach(int argc, char* argv[])
{
if(argc < 2)
@ -896,6 +1257,17 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDetach(int argc, char* argv[])
@brief Debug detach.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDetach(int argc, char* argv[])
{
unlock(WAITID_RUN); //run
@ -905,6 +1277,17 @@ CMDRESULT cbDebugDetach(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDump(int argc, char* argv[])
@brief Debug dump.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDump(int argc, char* argv[])
{
if(argc < 2)
@ -922,6 +1305,17 @@ CMDRESULT cbDebugDump(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugStackDump(int argc, char* argv[])
@brief Debug stack dump.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugStackDump(int argc, char* argv[])
{
duint addr = 0;
@ -942,6 +1336,17 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugContinue(int argc, char* argv[])
@brief Debug continue.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugContinue(int argc, char* argv[])
{
if(argc < 2)
@ -957,6 +1362,17 @@ CMDRESULT cbDebugContinue(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugBpDll(int argc, char* argv[])
@brief Debug bp DLL.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugBpDll(int argc, char* argv[])
{
if(argc < 2)
@ -985,6 +1401,17 @@ CMDRESULT cbDebugBpDll(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugBcDll(int argc, char* argv[])
@brief Debug bc DLL.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugBcDll(int argc, char* argv[])
{
if(argc < 2)
@ -1001,6 +1428,17 @@ CMDRESULT cbDebugBcDll(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
@brief Debug switchthread.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId; //main thread
@ -1019,6 +1457,17 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
@brief Debug suspendthread.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId;
@ -1041,6 +1490,17 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugResumethread(int argc, char* argv[])
@brief Debug resumethread.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugResumethread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId;
@ -1063,6 +1523,17 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugKillthread(int argc, char* argv[])
@brief Debug killthread.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugKillthread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId;
@ -1089,6 +1560,17 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[])
return STATUS_ERROR;
}
/**
@fn CMDRESULT cbDebugSetPriority(int argc, char* argv[])
@brief Debug set priority.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetPriority(int argc, char* argv[])
{
if(argc < 3)
@ -1155,6 +1637,17 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
@brief Debug enable hardware breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -1202,6 +1695,17 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
@brief Debug disable hardware breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -1240,6 +1744,17 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
@brief Debug enable memory breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -1287,6 +1802,17 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
@brief Debug disable memory breakpoint.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -1327,6 +1853,17 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
@brief Debug download symbol.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
{
char szDefaultStore[MAX_SETTING_SIZE] = "";
@ -1393,6 +1930,17 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugGetJITAuto(int argc, char* argv[])
@brief Debug get just-in-time automatic.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugGetJITAuto(int argc, char* argv[])
{
bool jit_auto = false;
@ -1438,6 +1986,17 @@ CMDRESULT cbDebugGetJITAuto(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSetJITAuto(int argc, char* argv[])
@brief Debug set just-in-time automatic.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetJITAuto(int argc, char* argv[])
{
arch actual_arch;
@ -1516,6 +2075,16 @@ CMDRESULT cbDebugSetJITAuto(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSetJIT(int argc, char* argv[])
@brief Debug set just-in-time.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetJIT(int argc, char* argv[])
{
@ -1649,6 +2218,17 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugGetJIT(int argc, char* argv[])
@brief Debug get just-in-time.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugGetJIT(int argc, char* argv[])
{
char get_entry[JIT_ENTRY_MAX_SIZE] = "";
@ -1704,6 +2284,17 @@ CMDRESULT cbDebugGetJIT(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugGetPageRights(int argc, char* argv[])
@brief Debug get page rights.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugGetPageRights(int argc, char* argv[])
{
uint addr = 0;
@ -1726,6 +2317,17 @@ CMDRESULT cbDebugGetPageRights(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSetPageRights(int argc, char* argv[])
@brief Debug set page rights.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetPageRights(int argc, char* argv[])
{
uint addr = 0;
@ -1754,6 +2356,14 @@ CMDRESULT cbDebugSetPageRights(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn void showcommandlineerror(cmdline_error_t* cmdline_error)
@brief Showcommandlineerrors the given cmdline error.
@param [in,out] cmdline_error If non-null, the cmdline error.
*/
void showcommandlineerror(cmdline_error_t* cmdline_error)
{
bool unkown = false;
@ -1816,6 +2426,17 @@ void showcommandlineerror(cmdline_error_t* cmdline_error)
}
}
/**
@fn CMDRESULT cbDebugGetCmdline(int argc, char* argv[])
@brief Debug get cmdline.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugGetCmdline(int argc, char* argv[])
{
char* cmd_line;
@ -1834,6 +2455,17 @@ CMDRESULT cbDebugGetCmdline(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbDebugSetCmdline(int argc, char* argv[])
@brief Debug set cmdline.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbDebugSetCmdline(int argc, char* argv[])
{
cmdline_error_t cmdline_error = {(cmdline_error_type_t) 0, 0};

View File

@ -1,7 +1,23 @@
/**
@file disasm_fast.cpp
@brief Implements the disasm fast class.
*/
#include "disasm_fast.h"
#include "debugger.h"
#include "memory.h"
/**
@fn static MEMORY_SIZE argsize2memsize(int argsize)
@brief Argsize 2memsize.
@param argsize The argsize.
@return A MEMORY_SIZE.
*/
static MEMORY_SIZE argsize2memsize(int argsize)
{
switch(argsize)
@ -18,6 +34,15 @@ static MEMORY_SIZE argsize2memsize(int argsize)
return size_byte;
}
/**
@fn void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
@brief Fillbasicinfoes.
@param [in,out] disasm If non-null, the disasm.
@param [in,out] basicinfo If non-null, the basicinfo.
*/
void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
{
//zero basicinfo
@ -95,6 +120,18 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
}
}
/**
@fn bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinfo)
@brief Disasmfasts.
@param [in,out] data If non-null, the data.
@param addr The address.
@param [in,out] basicinfo If non-null, the basicinfo.
@return true if it succeeds, false if it fails.
*/
bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinfo)
{
if(!data or !basicinfo)
@ -114,6 +151,17 @@ bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinf
return true;
}
/**
@fn bool disasmfast(uint addr, BASIC_INSTRUCTION_INFO* basicinfo)
@brief Disasmfasts.
@param addr The address.
@param [in,out] basicinfo If non-null, the basicinfo.
@return true if it succeeds, false if it fails.
*/
bool disasmfast(uint addr, BASIC_INSTRUCTION_INFO* basicinfo)
{
unsigned int data[16];

View File

@ -1,3 +1,9 @@
/**
@file disasm_helper.cpp
@brief Implements the disasm helper class.
*/
#include "disasm_helper.h"
#include "BeaEngine\BeaEngine.h"
#include "value.h"
@ -7,6 +13,20 @@
#include <cwctype>
#include <cwchar>
/**
@fn uint disasmback(unsigned char* data, uint base, uint size, uint ip, int n)
@brief Disasmbacks.
@param [in,out] data If non-null, the data.
@param base The base.
@param size The size.
@param ip The IP.
@param n The int to process.
@return An uint.
*/
uint disasmback(unsigned char* data, uint base, uint size, uint ip, int n)
{
int i;
@ -71,6 +91,20 @@ uint disasmback(unsigned char* data, uint base, uint size, uint ip, int n)
return abuf[(i - n + 128) % 128];
}
/**
@fn uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
@brief Disasmnexts.
@param [in,out] data If non-null, the data.
@param base The base.
@param size The size.
@param ip The IP.
@param n The int to process.
@return An uint.
*/
uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
{
int i;
@ -113,6 +147,16 @@ uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
return ip;
}
/**
@fn const char* disasmtext(uint addr)
@brief Disasmtexts the given address.
@param addr The address.
@return null if it fails, else a char*.
*/
const char* disasmtext(uint addr)
{
unsigned char buffer[16] = "";
@ -133,6 +177,16 @@ const char* disasmtext(uint addr)
return instruction;
}
/**
@fn static SEGMENTREG ConvertBeaSeg(int beaSeg)
@brief Convert bea segment.
@param beaSeg The bea segment.
@return The bea converted segment.
*/
static SEGMENTREG ConvertBeaSeg(int beaSeg)
{
switch(beaSeg)
@ -159,6 +213,19 @@ static SEGMENTREG ConvertBeaSeg(int beaSeg)
return SEG_DEFAULT;
}
/**
@fn static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG* arg, uint addr)
@brief Handles the argument.
@param [in,out] Argument If non-null, the argument.
@param [in,out] Instruction If non-null, the instruction.
@param [in,out] arg If non-null, the argument.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG* arg, uint addr)
{
int argtype = Argument->ArgType;
@ -215,6 +282,16 @@ static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG
return true;
}
/**
@fn void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr)
@brief Disasmgets.
@param [in,out] buffer If non-null, the buffer.
@param addr The address.
@param [in,out] instr If non-null, the instr.
*/
void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr)
{
if(!DbgIsDebugging())
@ -256,6 +333,15 @@ void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr)
instr->argcount++;
}
/**
@fn void disasmget(uint addr, DISASM_INSTR* instr)
@brief Disasmgets.
@param addr The address.
@param [in,out] instr If non-null, the instr.
*/
void disasmget(uint addr, DISASM_INSTR* instr)
{
if(!DbgIsDebugging())
@ -269,6 +355,14 @@ void disasmget(uint addr, DISASM_INSTR* instr)
disasmget(buffer, addr, instr);
}
/**
@fn void disasmprint(uint addr)
@brief Disasmprints the given address.
@param addr The address.
*/
void disasmprint(uint addr)
{
DISASM_INSTR instr;
@ -279,6 +373,17 @@ void disasmprint(uint addr)
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);
}
/**
@fn static bool isasciistring(const unsigned char* data, int maxlen)
@brief Query if 'data' isasciistring.
@param data The data.
@param maxlen The maxlen.
@return true if it succeeds, false if it fails.
*/
static bool isasciistring(const unsigned char* data, int maxlen)
{
int len = 0;
@ -296,6 +401,17 @@ static bool isasciistring(const unsigned char* data, int maxlen)
return true;
}
/**
@fn static bool isunicodestring(const unsigned char* data, int maxlen)
@brief Query if 'data' isunicodestring.
@param data The data.
@param maxlen The maxlen.
@return true if it succeeds, false if it fails.
*/
static bool isunicodestring(const unsigned char* data, int maxlen)
{
int len = 0;
@ -317,6 +433,16 @@ static bool isunicodestring(const unsigned char* data, int maxlen)
return true;
}
/**
@fn bool disasmispossiblestring(uint addr)
@brief Disasmispossiblestrings the given address.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
bool disasmispossiblestring(uint addr)
{
unsigned char data[11];
@ -332,6 +458,20 @@ bool disasmispossiblestring(uint addr)
return false;
}
/**
@fn bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
@brief Disasmgetstringats.
@param addr The address.
@param [in,out] type If non-null, the type.
@param [in,out] ascii If non-null, the ASCII.
@param [in,out] unicode If non-null, the unicode.
@param maxlen The maxlen.
@return true if it succeeds, false if it fails.
*/
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
{
if(type)
@ -423,6 +563,17 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
return false;
}
/**
@fn int disasmgetsize(uint addr, unsigned char* data)
@brief Disasmgetsizes.
@param addr The address.
@param [in,out] data If non-null, the data.
@return An int.
*/
int disasmgetsize(uint addr, unsigned char* data)
{
DISASM disasm;
@ -439,6 +590,16 @@ int disasmgetsize(uint addr, unsigned char* data)
return len;
}
/**
@fn int disasmgetsize(uint addr)
@brief Disasmgetsizes the given address.
@param addr The address.
@return An int.
*/
int disasmgetsize(uint addr)
{
char data[16];

View File

@ -1,3 +1,9 @@
/**
@file instruction.cpp
@brief Implements the instruction class.
*/
#include "instruction.h"
#include "argument.h"
#include "variable.h"
@ -13,8 +19,23 @@
#include "reference.h"
#include "disasm_helper.h"
/**
@brief The refinit.
*/
static bool bRefinit = false;
/**
@fn CMDRESULT cbBadCmd(int argc, char* argv[])
@brief Bad command.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbBadCmd(int argc, char* argv[])
{
uint value = 0;
@ -71,6 +92,17 @@ CMDRESULT cbBadCmd(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrVar(int argc, char* argv[])
@brief Instr variable.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrVar(int argc, char* argv[])
{
if(argc < 2)
@ -109,6 +141,17 @@ CMDRESULT cbInstrVar(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrVarDel(int argc, char* argv[])
@brief Instr variable delete.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrVarDel(int argc, char* argv[])
{
if(argc < 2)
@ -123,6 +166,17 @@ CMDRESULT cbInstrVarDel(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrMov(int argc, char* argv[])
@brief Instr mov.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrMov(int argc, char* argv[])
{
if(argc < 3)
@ -154,6 +208,17 @@ CMDRESULT cbInstrMov(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrVarList(int argc, char* argv[])
@brief Instr variable list.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrVarList(int argc, char* argv[])
{
char arg1[deflen] = "";
@ -211,6 +276,17 @@ CMDRESULT cbInstrVarList(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrChd(int argc, char* argv[])
@brief Instr chd.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrChd(int argc, char* argv[])
{
if(argc < 2)
@ -228,6 +304,17 @@ CMDRESULT cbInstrChd(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrCmt(int argc, char* argv[])
@brief Instr comment.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrCmt(int argc, char* argv[])
{
if(argc < 3)
@ -246,6 +333,17 @@ CMDRESULT cbInstrCmt(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrCmtdel(int argc, char* argv[])
@brief Instr cmtdel.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrCmtdel(int argc, char* argv[])
{
if(argc < 2)
@ -265,6 +363,17 @@ CMDRESULT cbInstrCmtdel(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrLbl(int argc, char* argv[])
@brief Instr label.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrLbl(int argc, char* argv[])
{
if(argc < 3)
@ -284,6 +393,17 @@ CMDRESULT cbInstrLbl(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrLbldel(int argc, char* argv[])
@brief Instr lbldel.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrLbldel(int argc, char* argv[])
{
if(argc < 2)
@ -302,6 +422,17 @@ CMDRESULT cbInstrLbldel(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrBookmarkSet(int argc, char* argv[])
@brief Instr bookmark set.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrBookmarkSet(int argc, char* argv[])
{
if(argc < 2)
@ -321,6 +452,17 @@ CMDRESULT cbInstrBookmarkSet(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrBookmarkDel(int argc, char* argv[])
@brief Instr bookmark delete.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrBookmarkDel(int argc, char* argv[])
{
if(argc < 2)
@ -340,6 +482,17 @@ CMDRESULT cbInstrBookmarkDel(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbLoaddb(int argc, char* argv[])
@brief Loaddbs.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbLoaddb(int argc, char* argv[])
{
dbload();
@ -347,12 +500,34 @@ CMDRESULT cbLoaddb(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbSavedb(int argc, char* argv[])
@brief Savedbs.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbSavedb(int argc, char* argv[])
{
dbsave();
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbAssemble(int argc, char* argv[])
@brief Assembles.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbAssemble(int argc, char* argv[])
{
if(argc < 3)
@ -387,6 +562,17 @@ CMDRESULT cbAssemble(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbFunctionAdd(int argc, char* argv[])
@brief Function add.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbFunctionAdd(int argc, char* argv[])
{
if(argc < 3)
@ -408,6 +594,17 @@ CMDRESULT cbFunctionAdd(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbFunctionDel(int argc, char* argv[])
@brief Function delete.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbFunctionDel(int argc, char* argv[])
{
if(argc < 2)
@ -428,6 +625,17 @@ CMDRESULT cbFunctionDel(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrCmp(int argc, char* argv[])
@brief Instr compare.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrCmp(int argc, char* argv[])
{
if(argc < 3)
@ -467,6 +675,17 @@ CMDRESULT cbInstrCmp(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrGpa(int argc, char* argv[])
@brief Instr gpa.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrGpa(int argc, char* argv[])
{
if(argc < 2)
@ -486,6 +705,17 @@ CMDRESULT cbInstrGpa(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrAdd(int argc, char* argv[])
@brief Instr add.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrAdd(int argc, char* argv[])
{
if(argc < 3)
@ -498,6 +728,17 @@ CMDRESULT cbInstrAdd(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrAnd(int argc, char* argv[])
@brief Instr and.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrAnd(int argc, char* argv[])
{
if(argc < 3)
@ -510,6 +751,17 @@ CMDRESULT cbInstrAnd(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrDec(int argc, char* argv[])
@brief Instr decrement.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrDec(int argc, char* argv[])
{
if(argc < 2)
@ -522,6 +774,17 @@ CMDRESULT cbInstrDec(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrDiv(int argc, char* argv[])
@brief Instr div.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrDiv(int argc, char* argv[])
{
if(argc < 3)
@ -534,6 +797,17 @@ CMDRESULT cbInstrDiv(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrInc(int argc, char* argv[])
@brief Instr increment.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrInc(int argc, char* argv[])
{
if(argc < 2)
@ -546,6 +820,17 @@ CMDRESULT cbInstrInc(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrMul(int argc, char* argv[])
@brief Instr mul.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrMul(int argc, char* argv[])
{
if(argc < 3)
@ -558,6 +843,17 @@ CMDRESULT cbInstrMul(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrNeg(int argc, char* argv[])
@brief Instr negative.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrNeg(int argc, char* argv[])
{
if(argc < 2)
@ -570,6 +866,17 @@ CMDRESULT cbInstrNeg(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrNot(int argc, char* argv[])
@brief Instr not.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrNot(int argc, char* argv[])
{
if(argc < 2)
@ -582,6 +889,17 @@ CMDRESULT cbInstrNot(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrOr(int argc, char* argv[])
@brief Instr or.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrOr(int argc, char* argv[])
{
if(argc < 3)
@ -594,6 +912,17 @@ CMDRESULT cbInstrOr(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrRol(int argc, char* argv[])
@brief Instr rol.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrRol(int argc, char* argv[])
{
if(argc < 3)
@ -610,6 +939,17 @@ CMDRESULT cbInstrRol(int argc, char* argv[])
return res;
}
/**
@fn CMDRESULT cbInstrRor(int argc, char* argv[])
@brief Instr ror.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrRor(int argc, char* argv[])
{
if(argc < 3)
@ -626,6 +966,17 @@ CMDRESULT cbInstrRor(int argc, char* argv[])
return res;
}
/**
@fn CMDRESULT cbInstrShl(int argc, char* argv[])
@brief Instr shl.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrShl(int argc, char* argv[])
{
if(argc < 3)
@ -642,6 +993,17 @@ CMDRESULT cbInstrShl(int argc, char* argv[])
return res;
}
/**
@fn CMDRESULT cbInstrShr(int argc, char* argv[])
@brief Instr shr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrShr(int argc, char* argv[])
{
if(argc < 3)
@ -658,6 +1020,17 @@ CMDRESULT cbInstrShr(int argc, char* argv[])
return res;
}
/**
@fn CMDRESULT cbInstrSub(int argc, char* argv[])
@brief Instr sub.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrSub(int argc, char* argv[])
{
if(argc < 3)
@ -670,6 +1043,17 @@ CMDRESULT cbInstrSub(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrTest(int argc, char* argv[])
@brief Tests instr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrTest(int argc, char* argv[])
{
//TODO: test
@ -696,6 +1080,17 @@ CMDRESULT cbInstrTest(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrXor(int argc, char* argv[])
@brief Instr exclusive-or.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrXor(int argc, char* argv[])
{
if(argc < 3)
@ -708,6 +1103,17 @@ CMDRESULT cbInstrXor(int argc, char* argv[])
return cmddirectexec(dbggetcommandlist(), newcmd);
}
/**
@fn CMDRESULT cbInstrRefinit(int argc, char* argv[])
@brief Instr refinit.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrRefinit(int argc, char* argv[])
{
GuiReferenceDeleteAllColumns();
@ -719,6 +1125,17 @@ CMDRESULT cbInstrRefinit(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrRefadd(int argc, char* argv[])
@brief Instr refadd.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrRefadd(int argc, char* argv[])
{
if(argc < 3)
@ -741,7 +1158,18 @@ CMDRESULT cbInstrRefadd(int argc, char* argv[])
return STATUS_CONTINUE;
}
//reffind value[,page]
/**
@fn static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
@brief reffind value[,page].
@param [in,out] disasm If non-null, the disasm.
@param [in,out] basicinfo If non-null, the basicinfo.
@param [in,out] refinfo If non-null, the refinfo.
@return true if it succeeds, false if it fails.
*/
static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!refinfo) //initialize
@ -784,6 +1212,17 @@ static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO
return found;
}
/**
@fn CMDRESULT cbInstrRefFind(int argc, char* argv[])
@brief Instr reference find.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrRefFind(int argc, char* argv[])
{
if(argc < 2)
@ -808,7 +1247,18 @@ CMDRESULT cbInstrRefFind(int argc, char* argv[])
return STATUS_CONTINUE;
}
//refstr [page]
/**
@fn bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
@brief refstr [page].
@param [in,out] disasm If non-null, the disasm.
@param [in,out] basicinfo If non-null, the basicinfo.
@param [in,out] refinfo If non-null, the refinfo.
@return true if it succeeds, false if it fails.
*/
bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!refinfo) //initialize
@ -857,6 +1307,17 @@ bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinf
return found;
}
/**
@fn CMDRESULT cbInstrRefStr(int argc, char* argv[])
@brief Instr reference string.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrRefStr(int argc, char* argv[])
{
uint addr;
@ -873,6 +1334,17 @@ CMDRESULT cbInstrRefStr(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrSetstr(int argc, char* argv[])
@brief Instr setstr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrSetstr(int argc, char* argv[])
{
if(argc < 3)
@ -897,6 +1369,17 @@ CMDRESULT cbInstrSetstr(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrGetstr(int argc, char* argv[])
@brief Instr getstr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrGetstr(int argc, char* argv[])
{
if(argc < 2)
@ -932,6 +1415,17 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrCopystr(int argc, char* argv[])
@brief Instr copystr.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrCopystr(int argc, char* argv[])
{
if(argc < 3)
@ -980,6 +1474,17 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrFind(int argc, char* argv[])
@brief Instr find.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrFind(int argc, char* argv[])
{
if(argc < 3)
@ -1031,6 +1536,17 @@ CMDRESULT cbInstrFind(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrFindAll(int argc, char* argv[])
@brief Instr find all.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrFindAll(int argc, char* argv[])
{
if(argc < 3)
@ -1128,7 +1644,18 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
return STATUS_CONTINUE;
}
//modcallfind [page]
/**
@fn static bool cbModCallFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
@brief modcallfind [page].
@param [in,out] disasm If non-null, the disasm.
@param [in,out] basicinfo If non-null, the basicinfo.
@param [in,out] refinfo If non-null, the refinfo.
@return true if it succeeds, false if it fails.
*/
static bool cbModCallFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!refinfo) //initialize
@ -1161,6 +1688,17 @@ static bool cbModCallFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REF
return found;
}
/**
@fn CMDRESULT cbInstrModCallFind(int argc, char* argv[])
@brief Instr modifier call find.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrModCallFind(int argc, char* argv[])
{
uint addr;
@ -1177,6 +1715,17 @@ CMDRESULT cbInstrModCallFind(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrCommentList(int argc, char* argv[])
@brief Instr comment list.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrCommentList(int argc, char* argv[])
{
//setup reference view
@ -1212,6 +1761,17 @@ CMDRESULT cbInstrCommentList(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrLabelList(int argc, char* argv[])
@brief Instr label list.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrLabelList(int argc, char* argv[])
{
//setup reference view
@ -1247,6 +1807,17 @@ CMDRESULT cbInstrLabelList(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrBookmarkList(int argc, char* argv[])
@brief Instr bookmark list.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrBookmarkList(int argc, char* argv[])
{
//setup reference view
@ -1280,6 +1851,17 @@ CMDRESULT cbInstrBookmarkList(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrFunctionList(int argc, char* argv[])
@brief Instr function list.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrFunctionList(int argc, char* argv[])
{
//setup reference view
@ -1326,6 +1908,17 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrLoopList(int argc, char* argv[])
@brief Instr loop list.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrLoopList(int argc, char* argv[])
{
//setup reference view
@ -1372,6 +1965,17 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbInstrSleep(int argc, char* argv[])
@brief Instr sleep.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrSleep(int argc, char* argv[])
{
uint ms = 100;
@ -1384,7 +1988,18 @@ CMDRESULT cbInstrSleep(int argc, char* argv[])
return STATUS_CONTINUE;
}
//reffindasm value[,page]
/**
@fn static bool cbFindAsm(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
@brief reffindasm value[,page].
@param [in,out] disasm If non-null, the disasm.
@param [in,out] basicinfo If non-null, the basicinfo.
@param [in,out] refinfo If non-null, the refinfo.
@return true if it succeeds, false if it fails.
*/
static bool cbFindAsm(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!refinfo) //initialize
@ -1412,6 +2027,17 @@ static bool cbFindAsm(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO
return found;
}
/**
@fn CMDRESULT cbInstrFindAsm(int argc, char* argv[])
@brief Instr find assembly.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbInstrFindAsm(int argc, char* argv[])
{
if(argc < 2)

View File

@ -1,5 +1,23 @@
/**
@file main.cpp
@brief Implements the main class.
*/
#include "_global.h"
/**
@fn extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@brief DLL main.
@param hinstDLL The hinst DLL.
@param fdwReason The fdw reason.
@param lpvReserved The lpv reserved.
@return An APIENTRY.
*/
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if(fdwReason == DLL_PROCESS_ATTACH)

View File

@ -1,18 +1,69 @@
/**
@file math.cpp
@brief Implements the mathematics class.
*/
#include "math.h"
#include "value.h"
/**
@struct BRACKET_PAIR
@brief A bracket pair.
*/
struct BRACKET_PAIR
{
/**
@brief The openpos.
*/
int openpos;
/**
@brief The closepos.
*/
int closepos;
/**
@brief The layer.
*/
int layer;
int isset; //0=free, 1=open, 2=close
/**
@brief 0=free, 1=open, 2=close.
*/
int isset;
};
/**
@struct EXPRESSION
@brief An expression.
*/
struct EXPRESSION
{
/**
@brief The pairs.
*/
BRACKET_PAIR* pairs;
/**
@brief The total pairs.
*/
int total_pairs;
/**
@brief The expression.
*/
char* expression;
};
@ -28,6 +79,16 @@ operator precedence
8 | (OR)
*/
/**
@fn int mathisoperator(char ch)
@brief casting operator.
@param ch The ch.
@return The result of the operation.
*/
int mathisoperator(char ch)
{
if(ch == '(' or ch == ')')
@ -53,6 +114,15 @@ int mathisoperator(char ch)
mathformat:
- remove doubles
*/
/**
@fn void mathformat(char* text)
@brief Mathformats the given text.
@param [in,out] text If non-null, the text.
*/
void mathformat(char* text)
{
int len = (int)strlen(text);
@ -67,6 +137,17 @@ void mathformat(char* text)
/*
- check for math operators
*/
/**
@fn bool mathcontains(const char* text)
@brief Mathcontains the given text.
@param text The text.
@return true if it succeeds, false if it fails.
*/
bool mathcontains(const char* text)
{
if(*text == '-') //ignore negative values
@ -115,6 +196,19 @@ static inline int mulhi(int x, int y)
}
#endif //__MINGW64__
/**
@fn bool mathdounsignedoperation(char op, uint left, uint right, uint* result)
@brief Mathdounsignedoperations.
@param op The operation.
@param left The left.
@param right The right.
@param [out] result If non-null, the result.
@return true if it succeeds, false if it fails.
*/
bool mathdounsignedoperation(char op, uint left, uint right, uint* result)
{
switch(op)
@ -164,6 +258,19 @@ bool mathdounsignedoperation(char op, uint left, uint right, uint* result)
return false;
}
/**
@fn bool mathdosignedoperation(char op, sint left, sint right, sint* result)
@brief Mathdosignedoperations.
@param op The operation.
@param left The left.
@param right The right.
@param [out] result If non-null, the result.
@return true if it succeeds, false if it fails.
*/
bool mathdosignedoperation(char op, sint left, sint right, sint* result)
{
switch(op)
@ -213,6 +320,16 @@ bool mathdosignedoperation(char op, sint left, sint right, sint* result)
return false;
}
/**
@fn static void fillpair(EXPRESSION* expstruct, int pos, int layer)
@brief Fillpairs.
@param [in,out] expstruct If non-null, the expstruct.
@param pos The position.
@param layer The layer.
*/
static void fillpair(EXPRESSION* expstruct, int pos, int layer)
{
for(int i = 0; i < expstruct->total_pairs; i++)
@ -233,6 +350,17 @@ static void fillpair(EXPRESSION* expstruct, int pos, int layer)
}
}
/**
@fn static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
@brief Matchpairs.
@param [in,out] expstruct If non-null, the expstruct.
@param [in,out] expression If non-null, the expression.
@param endlayer The endlayer.
@return An int.
*/
static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
{
@ -262,6 +390,16 @@ static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
return 0;
}
/**
@fn static int expressionformat(char* exp)
@brief Expressionformats the given exponent.
@param [in,out] exp If non-null, the exponent.
@return An int.
*/
static int expressionformat(char* exp)
{
int len = (int)strlen(exp);
@ -285,6 +423,18 @@ static int expressionformat(char* exp)
return open;
}
/**
@fn static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len)
@brief Adjustpairs.
@param [in,out] exps If non-null, the exps.
@param cur_open The current open.
@param cur_close The current close.
@param cur_len The current length.
@param new_len Length of the new.
*/
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++)
@ -296,6 +446,20 @@ static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_l
}
}
/**
@fn static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly)
@brief Printlayers.
@param [in,out] exp If non-null, the exponent.
@param [in,out] exps If non-null, the exps.
@param layer The layer.
@param silent true to silent.
@param baseonly true to baseonly.
@return true if it succeeds, false if it fails.
*/
static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly)
{
for(int i = 0; i < exps->total_pairs; i++)
@ -326,6 +490,18 @@ static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool
return true;
}
/**
@fn bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
@brief Mathhandlebrackets.
@param [in,out] expression If non-null, the expression.
@param silent true to silent.
@param baseonly true to baseonly.
@return true if it succeeds, false if it fails.
*/
bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
{
EXPRESSION expstruct;
@ -355,6 +531,22 @@ bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
/*
- handle math
*/
/**
@fn bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar)
@brief Mathfromstrings.
@param string The string.
@param [in,out] value If non-null, the value.
@param silent true to silent.
@param baseonly true to baseonly.
@param [in,out] value_size If non-null, size of the value.
@param [in,out] isvar If non-null, the isvar.
@return true if it succeeds, false if it fails.
*/
bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar)
{
int highestop = 0;

View File

@ -1,11 +1,29 @@
/**
@file memory.cpp
@brief Implements the memory class.
*/
#include "memory.h"
#include "debugger.h"
#include "patches.h"
#include "console.h"
#include "threading.h"
/**
@brief The memory pages.
*/
MemoryMap memoryPages;
/**
@fn void memupdatemap(HANDLE hProcess)
@brief Memupdatemaps the given h process.
@param hProcess Handle of the process.
*/
void memupdatemap(HANDLE hProcess)
{
CriticalSectionLocker locker(LockMemoryPages);
@ -126,6 +144,18 @@ void memupdatemap(HANDLE hProcess)
}
}
/**
@fn uint memfindbaseaddr(uint addr, uint* size, bool refresh)
@brief Memfindbaseaddrs.
@param addr The address.
@param [in,out] size If non-null, the size.
@param refresh true to refresh.
@return An uint.
*/
uint memfindbaseaddr(uint addr, uint* size, bool refresh)
{
if(refresh)
@ -139,6 +169,20 @@ uint memfindbaseaddr(uint addr, uint* size, bool refresh)
return found->first.first;
}
/**
@fn bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead)
@brief Memreads.
@param hProcess Handle of the process.
@param lpBaseAddress The base address.
@param [in,out] lpBuffer If non-null, the buffer.
@param nSize The size.
@param [in,out] lpNumberOfBytesRead If non-null, number of bytes reads.
@return true if it succeeds, false if it fails.
*/
bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead)
{
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
@ -168,6 +212,20 @@ bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T
return true;
}
/**
@fn bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten)
@brief Memwrites.
@param hProcess Handle of the process.
@param [in,out] lpBaseAddress If non-null, the base address.
@param lpBuffer The buffer.
@param nSize The size.
@param [in,out] lpNumberOfBytesWritten If non-null, number of bytes writtens.
@return true if it succeeds, false if it fails.
*/
bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten)
{
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
@ -197,6 +255,20 @@ bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T
return true;
}
/**
@fn bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten)
@brief Mempatches.
@param hProcess Handle of the process.
@param [in,out] lpBaseAddress If non-null, the base address.
@param lpBuffer The buffer.
@param nSize The size.
@param [in,out] lpNumberOfBytesWritten If non-null, number of bytes writtens.
@return true if it succeeds, false if it fails.
*/
bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten)
{
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
@ -210,22 +282,65 @@ bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T
return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
}
/**
@fn bool memisvalidreadptr(HANDLE hProcess, uint addr)
@brief Memisvalidreadptrs.
@param hProcess Handle of the process.
@param addr The address.
@return true if it succeeds, false if it fails.
*/
bool memisvalidreadptr(HANDLE hProcess, uint addr)
{
unsigned char a = 0;
return memread(hProcess, (void*)addr, &a, 1, 0);
}
/**
@fn void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect)
@brief Memallocs.
@param hProcess Handle of the process.
@param addr The address.
@param size The size.
@param fdProtect The fd protect.
@return null if it fails, else a void*.
*/
void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect)
{
return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE | MEM_COMMIT, fdProtect);
}
/**
@fn void memfree(HANDLE hProcess, uint addr)
@brief Memfrees.
@param hProcess Handle of the process.
@param addr The address.
*/
void memfree(HANDLE hProcess, uint addr)
{
VirtualFreeEx(hProcess, (void*)addr, 0, MEM_RELEASE);
}
/**
@fn static int formathexpattern(char* string)
@brief Formathexpatterns the given string.
@param [in,out] string If non-null, the string.
@return An int.
*/
static int formathexpattern(char* string)
{
int len = (int)strlen(string);
@ -239,6 +354,17 @@ static int formathexpattern(char* string)
return (int)strlen(string);
}
/**
@fn static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern)
@brief Patterntransforms.
@param text The text.
@param [in,out] pattern If non-null, specifies the pattern.
@return true if it succeeds, false if it fails.
*/
static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern)
{
if(!text or !pattern)
@ -285,6 +411,17 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
return true;
}
/**
@fn static bool patternmatchbyte(unsigned char byte, PATTERNBYTE* pbyte)
@brief Patternmatchbytes.
@param byte The byte.
@param [in,out] pbyte If non-null, the pbyte.
@return true if it succeeds, false if it fails.
*/
static bool patternmatchbyte(unsigned char byte, PATTERNBYTE* pbyte)
{
unsigned char n1 = (byte >> 4) & 0xF;
@ -301,6 +438,19 @@ static bool patternmatchbyte(unsigned char byte, PATTERNBYTE* pbyte)
return (matched == 2);
}
/**
@fn uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* patternsize)
@brief Memfindpatterns.
@param [in,out] data If non-null, the data.
@param size The size.
@param pattern Specifies the pattern.
@param [in,out] patternsize If non-null, the patternsize.
@return An uint.
*/
uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* patternsize)
{
std::vector<PATTERNBYTE> searchpattern;

View File

@ -1,19 +1,46 @@
/**
@file msgqueue.cpp
@brief Implements the msgqueue class.
*/
#include "msgqueue.h"
#include <stdio.h>
//allocate a message (internal)
/**
@fn static MESSAGE* msgalloc()
@brief allocate a message (internal)
@return null if it fails, else a MESSAGE*.
*/
static MESSAGE* msgalloc()
{
return (MESSAGE*)emalloc(sizeof(MESSAGE), "msgalloc:msg");
}
//free a message (internal)
/**
@fn static void msgfree(MESSAGE* msg)
@brief free a message (internal)
@param [in,out] msg If non-null, the message.
*/
static void msgfree(MESSAGE* msg)
{
efree(msg, "msgfree:msg");
}
//allocate a message stack
/**
@fn MESSAGE_STACK* msgallocstack()
@brief allocate a message stack.
@return null if it fails, else a MESSAGE_STACK*.
*/
MESSAGE_STACK* msgallocstack()
{
MESSAGE_STACK* msgstack = (MESSAGE_STACK*)emalloc(sizeof(MESSAGE_STACK), "msgallocstack:msgstack");
@ -24,7 +51,14 @@ MESSAGE_STACK* msgallocstack()
return msgstack;
}
//free a message stack
/**
@fn void msgfreestack(MESSAGE_STACK* msgstack)
@brief free a message stack.
@param [in,out] msgstack If non-null, the msgstack.
*/
void msgfreestack(MESSAGE_STACK* msgstack)
{
DeleteCriticalSection(&msgstack->cr);
@ -34,7 +68,19 @@ void msgfreestack(MESSAGE_STACK* msgstack)
efree(msgstack, "msgfreestack:msgstack");
}
//add a message to the stack
/**
@fn bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
@brief add a message to the stack.
@param [in,out] msgstack If non-null, the msgstack.
@param msg The message.
@param param1 The first parameter.
@param param2 The second parameter.
@return true if it succeeds, false if it fails.
*/
bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
{
CRITICAL_SECTION* cr = &msgstack->cr;
@ -60,7 +106,17 @@ bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
return true;
}
//get a message from the stack (will return false when there are no messages)
/**
@fn bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
@brief get a message from the stack (will return false when there are no messages)
@param [in,out] msgstack If non-null, the msgstack.
@param [in,out] msg If non-null, the message.
@return true if it succeeds, false if it fails.
*/
bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
{
CRITICAL_SECTION* cr = &msgstack->cr;
@ -81,7 +137,15 @@ bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
return true;
}
//wait for a message on the specified stack
/**
@fn void msgwait(MESSAGE_STACK* msgstack, MESSAGE* msg)
@brief wait for a message on the specified stack.
@param [in,out] msgstack If non-null, the msgstack.
@param [in,out] msg If non-null, the message.
*/
void msgwait(MESSAGE_STACK* msgstack, MESSAGE* msg)
{
while(!msgget(msgstack, msg))

View File

@ -16,19 +16,56 @@
#if defined(_MSC_VER)
/**
@def FORCE_INLINE
@brief A macro that defines force inline.
*/
#define FORCE_INLINE __forceinline
#include <stdlib.h>
/**
@def ROTL32(x,y) _rotl(x,y)
@brief A macro that defines rotl 32.
@param x The void to process.
@param y The void to process.
*/
#define ROTL32(x,y) _rotl(x,y)
/**
@def ROTL64(x,y) _rotl64(x,y)
@brief A macro that defines rotl 64.
@param x The void to process.
@param y The void to process.
*/
#define ROTL64(x,y) _rotl64(x,y)
/**
@def BIG_CONSTANT(x) (x)
@brief A macro that defines big constant.
@param x The void to process.
*/
#define BIG_CONSTANT(x) (x)
// Other compilers
#else // defined(_MSC_VER)
/**
@brief The force inline.
*/
#define FORCE_INLINE inline __attribute__((always_inline))
inline uint32_t rotl32(uint32_t x, int8_t r)
@ -41,29 +78,84 @@ inline uint64_t rotl64(uint64_t x, int8_t r)
return (x << r) | (x >> (64 - r));
}
/**
@def ROTL32(x,y) rotl32(x,y)
@brief A macro that defines rotl 32.
@param x The void to process.
@param y The void to process.
*/
#define ROTL32(x,y) rotl32(x,y)
/**
@def ROTL64(x,y) rotl64(x,y)
@brief A macro that defines rotl 64.
@param x The void to process.
@param y The void to process.
*/
#define ROTL64(x,y) rotl64(x,y)
/**
@def BIG_CONSTANT(x) (x##LLU)
@brief A macro that defines big constant.
@param x The void to process.
*/
#define BIG_CONSTANT(x) (x##LLU)
#endif // !defined(_MSC_VER)
//-----------------------------------------------------------------------------
// Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here
/**
@fn FORCE_INLINE uint32_t getblock32(const uint32_t* p, int i)
@brief -----------------------------------------------------------------------------
Block read - if your platform needs to do endian-swapping or can only handle aligned reads, do
the conversion here.
@param p The const uint32_t* to process.
@param i Zero-based index of the.
@return An uint32_t.
*/
FORCE_INLINE uint32_t getblock32(const uint32_t* p, int i)
{
return p[i];
}
/**
@fn FORCE_INLINE uint64_t getblock64(const uint64_t* p, int i)
@brief Getblock 64.
@param p The const uint64_t* to process.
@param i Zero-based index of the.
@return An uint64_t.
*/
FORCE_INLINE uint64_t getblock64(const uint64_t* p, int i)
{
return p[i];
}
//-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche
/**
@fn FORCE_INLINE uint32_t fmix32(uint32_t h)
@brief -----------------------------------------------------------------------------
Finalization mix - force all bits of a hash block to avalanche.
@param h The uint32_t to process.
@return An uint32_t.
*/
FORCE_INLINE uint32_t fmix32(uint32_t h)
{
@ -78,6 +170,16 @@ FORCE_INLINE uint32_t fmix32(uint32_t h)
//----------
/**
@fn FORCE_INLINE uint64_t fmix64(uint64_t k)
@brief Fmix 64.
@param k The uint64_t to process.
@return An uint64_t.
*/
FORCE_INLINE uint64_t fmix64(uint64_t k)
{
k ^= k >> 33;
@ -91,6 +193,17 @@ FORCE_INLINE uint64_t fmix64(uint64_t k)
//-----------------------------------------------------------------------------
/**
@fn void MurmurHash3_x86_32(const void* key, int len, uint32_t seed, void* out)
@brief Murmur hash 3 x coordinate 86 32.
@param key The key.
@param len The length.
@param seed The seed.
@param [in,out] out If non-null, the out.
*/
void MurmurHash3_x86_32(const void* key, int len,
uint32_t seed, void* out)
{
@ -153,6 +266,17 @@ void MurmurHash3_x86_32(const void* key, int len,
//-----------------------------------------------------------------------------
/**
@fn void MurmurHash3_x86_128(const void* key, const int len, uint32_t seed, void* out)
@brief Murmur hash 3 x coordinate 86 128.
@param key The key.
@param len The length.
@param seed The seed.
@param [in,out] out If non-null, the out.
*/
void MurmurHash3_x86_128(const void* key, const int len,
uint32_t seed, void* out)
{
@ -316,6 +440,17 @@ void MurmurHash3_x86_128(const void* key, const int len,
//-----------------------------------------------------------------------------
/**
@fn void MurmurHash3_x64_128(const void* key, const int len, const uint32_t seed, void* out)
@brief Murmur hash 3 x coordinate 64 128.
@param key The key.
@param len The length.
@param seed The seed.
@param [in,out] out If non-null, the out.
*/
void MurmurHash3_x64_128(const void* key, const int len,
const uint32_t seed, void* out)
{

View File

@ -1,11 +1,33 @@
/**
@file patches.cpp
@brief Implements the patches class.
*/
#include "patches.h"
#include "addrinfo.h"
#include "memory.h"
#include "debugger.h"
#include "console.h"
/**
@brief The patches.
*/
PatchesInfo patches;
/**
@fn bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
@brief Patchsets.
@param addr The address.
@param oldbyte The oldbyte.
@param newbyte The newbyte.
@return true if it succeeds, false if it fails.
*/
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
{
if(!DbgIsDebugging() || !memisvalidreadptr(fdProcessInfo->hProcess, addr))
@ -37,6 +59,17 @@ bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
return true;
}
/**
@fn bool patchget(uint addr, PATCHINFO* patch)
@brief Patchgets.
@param addr The address.
@param [in,out] patch If non-null, the patch.
@return true if it succeeds, false if it fails.
*/
bool patchget(uint addr, PATCHINFO* patch)
{
if(!DbgIsDebugging())
@ -53,6 +86,17 @@ bool patchget(uint addr, PATCHINFO* patch)
return (found->second.oldbyte != found->second.newbyte);
}
/**
@fn bool patchdel(uint addr, bool restore)
@brief Patchdels.
@param addr The address.
@param restore true to restore.
@return true if it succeeds, false if it fails.
*/
bool patchdel(uint addr, bool restore)
{
if(!DbgIsDebugging())
@ -66,6 +110,16 @@ bool patchdel(uint addr, bool restore)
return true;
}
/**
@fn void patchdelrange(uint start, uint end, bool restore)
@brief Patchdelranges.
@param start The start.
@param end The end.
@param restore true to restore.
*/
void patchdelrange(uint start, uint end, bool restore)
{
if(!DbgIsDebugging())
@ -90,6 +144,14 @@ void patchdelrange(uint start, uint end, bool restore)
}
}
/**
@fn void patchclear(const char* mod)
@brief Patchclears the given modifier.
@param mod The modifier.
*/
void patchclear(const char* mod)
{
if(!mod or !*mod)
@ -107,6 +169,17 @@ void patchclear(const char* mod)
}
}
/**
@fn bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
@brief Patchenums.
@param [in,out] patcheslist If non-null, the patcheslist.
@param [in,out] cbsize If non-null, the cbsize.
@return true if it succeeds, false if it fails.
*/
bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
{
if(!DbgIsDebugging())
@ -128,6 +201,19 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
return true;
}
/**
@fn int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, char* error)
@brief Patchfiles.
@param patchlist The patchlist.
@param count Number of.
@param szFileName Filename of the file.
@param [in,out] error If non-null, the error.
@return An int.
*/
int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, char* error)
{
if(!count)

View File

@ -1,16 +1,53 @@
/**
@file plugin_loader.cpp
@brief Implements the plugin loader class.
*/
#include "plugin_loader.h"
#include "console.h"
#include "debugger.h"
#include "memory.h"
#include "x64_dbg.h"
/**
@brief List of plugins.
*/
static std::vector<PLUG_DATA> pluginList;
/**
@brief The current plugin handle.
*/
static int curPluginHandle = 0;
/**
@brief List of plugin callbacks.
*/
static std::vector<PLUG_CALLBACK> pluginCallbackList;
/**
@brief List of plugin commands.
*/
static std::vector<PLUG_COMMAND> pluginCommandList;
/**
@brief List of plugin menus.
*/
static std::vector<PLUG_MENU> pluginMenuList;
///internal plugin functions
/**
@fn void pluginload(const char* pluginDir)
@brief internal plugin functions.
@param pluginDir The plugin dir.
*/
void pluginload(const char* pluginDir)
{
//load new plugins
@ -189,6 +226,14 @@ void pluginload(const char* pluginDir)
SetCurrentDirectoryA(currentDir);
}
/**
@fn static void plugincmdunregisterall(int pluginHandle)
@brief Plugincmdunregisteralls.
@param pluginHandle Handle of the plugin.
*/
static void plugincmdunregisterall(int pluginHandle)
{
int listsize = (int)pluginCommandList.size();
@ -202,6 +247,12 @@ static void plugincmdunregisterall(int pluginHandle)
}
}
/**
@fn void pluginunload()
@brief Pluginunloads this object.
*/
void pluginunload()
{
int pluginCount = (int)pluginList.size();
@ -219,7 +270,16 @@ void pluginunload()
GuiMenuClear(GUI_PLUGIN_MENU); //clear the plugin menu
}
///debugging plugin exports
/**
@fn void pluginregistercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin)
@brief debugging plugin exports.
@param pluginHandle Handle of the plugin.
@param cbType The type.
@param cbPlugin The plugin.
*/
void pluginregistercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin)
{
pluginunregistercallback(pluginHandle, cbType); //remove previous callback
@ -230,6 +290,17 @@ void pluginregistercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin)
pluginCallbackList.push_back(cbStruct);
}
/**
@fn bool pluginunregistercallback(int pluginHandle, CBTYPE cbType)
@brief Pluginunregistercallback, called when the pluginunregister.
@param pluginHandle Handle of the plugin.
@param cbType The type.
@return true if it succeeds, false if it fails.
*/
bool pluginunregistercallback(int pluginHandle, CBTYPE cbType)
{
int pluginCallbackCount = (int)pluginCallbackList.size();
@ -244,6 +315,15 @@ bool pluginunregistercallback(int pluginHandle, CBTYPE cbType)
return false;
}
/**
@fn void plugincbcall(CBTYPE cbType, void* callbackInfo)
@brief Plugincbcalls.
@param cbType The type.
@param [in,out] callbackInfo If non-null, information describing the callback.
*/
void plugincbcall(CBTYPE cbType, void* callbackInfo)
{
int pluginCallbackCount = (int)pluginCallbackList.size();
@ -258,6 +338,19 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo)
}
}
/**
@fn bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
@brief Plugincmdregisters.
@param pluginHandle Handle of the plugin.
@param command The command.
@param cbCommand The command.
@param debugonly true to debugonly.
@return true if it succeeds, false if it fails.
*/
bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
{
if(!command or strlen(command) >= deflen or strstr(command, "\1"))
@ -272,6 +365,17 @@ bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cb
return true;
}
/**
@fn bool plugincmdunregister(int pluginHandle, const char* command)
@brief Plugincmdunregisters.
@param pluginHandle Handle of the plugin.
@param command The command.
@return true if it succeeds, false if it fails.
*/
bool plugincmdunregister(int pluginHandle, const char* command)
{
if(!command or strlen(command) >= deflen or strstr(command, "\1"))
@ -291,6 +395,17 @@ bool plugincmdunregister(int pluginHandle, const char* command)
return false;
}
/**
@fn int pluginmenuadd(int hMenu, const char* title)
@brief Pluginmenuadds.
@param hMenu The menu.
@param title The title.
@return An int.
*/
int pluginmenuadd(int hMenu, const char* title)
{
if(!title or !strlen(title))
@ -315,6 +430,18 @@ int pluginmenuadd(int hMenu, const char* title)
return hMenuNew;
}
/**
@fn bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
@brief Pluginmenuaddentries.
@param hMenu The menu.
@param hEntry The entry.
@param title The title.
@return true if it succeeds, false if it fails.
*/
bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
{
if(!title or !strlen(title) or hEntry == -1)
@ -346,6 +473,16 @@ bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
return true;
}
/**
@fn bool pluginmenuaddseparator(int hMenu)
@brief Pluginmenuaddseparators.
@param hMenu The menu.
@return true if it succeeds, false if it fails.
*/
bool pluginmenuaddseparator(int hMenu)
{
bool bFound = false;
@ -363,6 +500,16 @@ bool pluginmenuaddseparator(int hMenu)
return true;
}
/**
@fn bool pluginmenuclear(int hMenu)
@brief Pluginmenuclears.
@param hMenu The menu.
@return true if it succeeds, false if it fails.
*/
bool pluginmenuclear(int hMenu)
{
bool bFound = false;
@ -380,6 +527,14 @@ bool pluginmenuclear(int hMenu)
return false;
}
/**
@fn void pluginmenucall(int hEntry)
@brief Pluginmenucalls.
@param hEntry The entry.
*/
void pluginmenucall(int hEntry)
{
if(hEntry == -1)
@ -405,6 +560,17 @@ void pluginmenucall(int hEntry)
}
}
/**
@fn bool pluginwinevent(MSG* message, long* result)
@brief Pluginwinevents.
@param [in,out] message If non-null, the message.
@param [out] result If non-null, the result.
@return true if it succeeds, false if it fails.
*/
bool pluginwinevent(MSG* message, long* result)
{
PLUG_CB_WINEVENT winevent;
@ -415,6 +581,16 @@ bool pluginwinevent(MSG* message, long* result)
return winevent.retval;
}
/**
@fn bool pluginwineventglobal(MSG* message)
@brief Pluginwineventglobals the given message.
@param [in,out] message If non-null, the message.
@return true if it succeeds, false if it fails.
*/
bool pluginwineventglobal(MSG* message)
{
PLUG_CB_WINEVENTGLOBAL winevent;

View File

@ -1,8 +1,28 @@
/**
@file reference.cpp
@brief Implements the reference class.
*/
#include "reference.h"
#include "debugger.h"
#include "memory.h"
#include "console.h"
/**
@fn int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent)
@brief Reffinds.
@param addr The address.
@param size The size.
@param cbRef The reference.
@param [in,out] userinfo If non-null, the userinfo.
@param silent true to silent.
@return An int.
*/
int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent)
{
uint start_addr;

View File

@ -1,3 +1,9 @@
/**
@file simplescript.cpp
@brief Implements the simplescript class.
*/
#include "simplescript.h"
#include "value.h"
#include "console.h"
@ -7,13 +13,52 @@
#include "x64_dbg.h"
#include "debugger.h"
/**
@brief The linemap.
*/
static std::vector<LINEMAPENTRY> linemap;
/**
@brief The scriptbplist.
*/
static std::vector<SCRIPTBP> scriptbplist;
/**
@brief The scriptstack.
*/
static std::vector<int> scriptstack;
/**
@brief The script IP.
*/
static int scriptIp = 0;
/**
@brief The abort.
*/
static bool volatile bAbort = false;
/**
@brief The is running.
*/
static bool volatile bIsRunning = false;
/**
@fn static SCRIPTBRANCHTYPE scriptgetbranchtype(const char* text)
@brief Scriptgetbranchtypes the given text.
@param text The text.
@return A SCRIPTBRANCHTYPE.
*/
static SCRIPTBRANCHTYPE scriptgetbranchtype(const char* text)
{
char newtext[MAX_SCRIPT_LINE_SIZE] = "";
@ -40,6 +85,16 @@ static SCRIPTBRANCHTYPE scriptgetbranchtype(const char* text)
return scriptnobranch;
}
/**
@fn static int scriptlabelfind(const char* labelname)
@brief Scriptlabelfinds the given labelname.
@param labelname The labelname.
@return An int.
*/
static int scriptlabelfind(const char* labelname)
{
int linecount = (int)linemap.size();
@ -49,6 +104,16 @@ static int scriptlabelfind(const char* labelname)
return 0;
}
/**
@fn static int scriptinternalstep(int fromIp)
@brief Scriptinternalsteps.
@param fromIp from IP.
@return An int.
*/
static int scriptinternalstep(int fromIp) //internal step routine
{
int maxIp = (int)linemap.size(); //maximum ip
@ -60,6 +125,16 @@ static int scriptinternalstep(int fromIp) //internal step routine
return fromIp;
}
/**
@fn static bool scriptcreatelinemap(const char* filename)
@brief Scriptcreatelinemaps the given file.
@param filename Filename of the file.
@return true if it succeeds, false if it fails.
*/
static bool scriptcreatelinemap(const char* filename)
{
HANDLE hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
@ -253,6 +328,16 @@ static bool scriptcreatelinemap(const char* filename)
return true;
}
/**
@fn static bool scriptinternalbpget(int line)
@brief Scriptinternalbpgets.
@param line The line.
@return true if it succeeds, false if it fails.
*/
static bool scriptinternalbpget(int line) //internal bpget routine
{
int bpcount = (int)scriptbplist.size();
@ -262,6 +347,16 @@ static bool scriptinternalbpget(int line) //internal bpget routine
return false;
}
/**
@fn static bool scriptinternalbptoggle(int line)
@brief Scriptinternalbptoggles.
@param line The line.
@return true if it succeeds, false if it fails.
*/
static bool scriptinternalbptoggle(int line) //internal breakpoint
{
if(!line or line > (int)linemap.size()) //invalid line
@ -287,6 +382,16 @@ static bool scriptinternalbptoggle(int line) //internal breakpoint
return true;
}
/**
@fn static bool scriptisruncommand(const char* cmdlist)
@brief Scriptisruncommands the given cmdlist.
@param cmdlist The cmdlist.
@return true if it succeeds, false if it fails.
*/
static bool scriptisruncommand(const char* cmdlist)
{
if(arraycontains(cmdlist, "run"))
@ -310,6 +415,17 @@ static bool scriptisruncommand(const char* cmdlist)
return false;
}
/**
@fn static bool scriptisinternalcommand(const char* text, const char* cmd)
@brief Scriptisinternalcommands.
@param text The text.
@param cmd The command.
@return true if it succeeds, false if it fails.
*/
static bool scriptisinternalcommand(const char* text, const char* cmd)
{
int len = (int)strlen(text);
@ -323,6 +439,16 @@ static bool scriptisinternalcommand(const char* text, const char* cmd)
return false;
}
/**
@fn static CMDRESULT scriptinternalcmdexec(const char* cmd)
@brief Scriptinternalcmdexecs the given command.
@param cmd The command.
@return A CMDRESULT.
*/
static CMDRESULT scriptinternalcmdexec(const char* cmd)
{
if(scriptisinternalcommand(cmd, "ret")) //script finished
@ -359,6 +485,16 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
return res;
}
/**
@fn static bool scriptinternalbranch(SCRIPTBRANCHTYPE type)
@brief Scriptinternalbranches the given type.
@param type The type.
@return true if it succeeds, false if it fails.
*/
static bool scriptinternalbranch(SCRIPTBRANCHTYPE type) //determine if we should jump
{
uint ezflag = 0;
@ -403,6 +539,14 @@ static bool scriptinternalbranch(SCRIPTBRANCHTYPE type) //determine if we should
return bJump;
}
/**
@fn static bool scriptinternalcmd()
@brief Scriptinternalcmds this object.
@return true if it succeeds, false if it fails.
*/
static bool scriptinternalcmd()
{
bool bContinue = true;
@ -439,6 +583,16 @@ static bool scriptinternalcmd()
return bContinue;
}
/**
@fn static DWORD WINAPI scriptRunThread(void* arg)
@brief Script run thread.
@param [in,out] arg If non-null, the argument.
@return A WINAPI.
*/
static DWORD WINAPI scriptRunThread(void* arg)
{
int destline = (int)(uint)arg;
@ -474,6 +628,16 @@ static DWORD WINAPI scriptRunThread(void* arg)
return 0;
}
/**
@fn static DWORD WINAPI scriptLoadThread(void* filename)
@brief Script load thread.
@param [in,out] filename If non-null, filename of the file.
@return A WINAPI.
*/
static DWORD WINAPI scriptLoadThread(void* filename)
{
GuiScriptClear();
@ -494,6 +658,14 @@ static DWORD WINAPI scriptLoadThread(void* filename)
return 0;
}
/**
@fn void scriptload(const char* filename)
@brief Scriptloads the given file.
@param filename Filename of the file.
*/
void scriptload(const char* filename)
{
static char filename_[MAX_PATH] = "";
@ -501,6 +673,12 @@ void scriptload(const char* filename)
CloseHandle(CreateThread(0, 0, scriptLoadThread, filename_, 0, 0));
}
/**
@fn void scriptunload()
@brief Scriptunloads this object.
*/
void scriptunload()
{
GuiScriptClear();
@ -509,6 +687,14 @@ void scriptunload()
bAbort = false;
}
/**
@fn void scriptrun(int destline)
@brief Scriptruns.
@param destline The destline.
*/
void scriptrun(int destline)
{
if(DbgIsDebugging() && !waitislocked(WAITID_RUN))
@ -522,6 +708,16 @@ void scriptrun(int destline)
CloseHandle(CreateThread(0, 0, scriptRunThread, (void*)(uint)destline, 0, 0));
}
/**
@fn DWORD WINAPI scriptStepThread(void* param)
@brief Script step thread.
@param [in,out] param If non-null, the parameter.
@return A WINAPI.
*/
DWORD WINAPI scriptStepThread(void* param)
{
if(bIsRunning) //already running
@ -536,11 +732,27 @@ DWORD WINAPI scriptStepThread(void* param)
return 0;
}
/**
@fn void scriptstep()
@brief Scriptsteps this object.
*/
void scriptstep()
{
CloseHandle(CreateThread(0, 0, scriptStepThread, 0, 0, 0));
}
/**
@fn bool scriptbptoggle(int line)
@brief Scriptbptoggles.
@param line The line.
@return true if it succeeds, false if it fails.
*/
bool scriptbptoggle(int line)
{
if(!line or line > (int)linemap.size()) //invalid line
@ -566,6 +778,16 @@ bool scriptbptoggle(int line)
return true;
}
/**
@fn bool scriptbpget(int line)
@brief Scriptbpgets.
@param line The line.
@return true if it succeeds, false if it fails.
*/
bool scriptbpget(int line)
{
int bpcount = (int)scriptbplist.size();
@ -575,6 +797,16 @@ bool scriptbpget(int line)
return false;
}
/**
@fn bool scriptcmdexec(const char* command)
@brief Scriptcmdexecs the given command.
@param command The command.
@return true if it succeeds, false if it fails.
*/
bool scriptcmdexec(const char* command)
{
switch(scriptinternalcmdexec(command))
@ -593,6 +825,12 @@ bool scriptcmdexec(const char* command)
return true;
}
/**
@fn void scriptabort()
@brief Scriptaborts this object.
*/
void scriptabort()
{
if(bIsRunning)
@ -605,6 +843,16 @@ void scriptabort()
scriptsetip(0);
}
/**
@fn SCRIPTLINETYPE scriptgetlinetype(int line)
@brief Scriptgetlinetypes.
@param line The line.
@return A SCRIPTLINETYPE.
*/
SCRIPTLINETYPE scriptgetlinetype(int line)
{
if(line > (int)linemap.size())
@ -612,6 +860,14 @@ SCRIPTLINETYPE scriptgetlinetype(int line)
return linemap.at(line - 1).type;
}
/**
@fn void scriptsetip(int line)
@brief Scriptsetips.
@param line The line.
*/
void scriptsetip(int line)
{
if(line)
@ -620,6 +876,12 @@ void scriptsetip(int line)
GuiScriptSetIp(scriptIp);
}
/**
@fn void scriptreset()
@brief Scriptresets this object.
*/
void scriptreset()
{
while(bIsRunning)
@ -631,6 +893,17 @@ void scriptreset()
scriptsetip(0);
}
/**
@fn bool scriptgetbranchinfo(int line, SCRIPTBRANCH* info)
@brief Scriptgetbranchinfoes.
@param line The line.
@param [in,out] info If non-null, the information.
@return true if it succeeds, false if it fails.
*/
bool scriptgetbranchinfo(int line, SCRIPTBRANCH* info)
{
if(!info or !line or line > (int)linemap.size()) //invalid line
@ -641,6 +914,17 @@ bool scriptgetbranchinfo(int line, SCRIPTBRANCH* info)
return true;
}
/**
@fn CMDRESULT cbScriptLoad(int argc, char* argv[])
@brief Script load.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbScriptLoad(int argc, char* argv[])
{
if(argc < 2)
@ -649,6 +933,17 @@ CMDRESULT cbScriptLoad(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbScriptMsg(int argc, char* argv[])
@brief Script message.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbScriptMsg(int argc, char* argv[])
{
if(argc < 2)
@ -660,6 +955,17 @@ CMDRESULT cbScriptMsg(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn CMDRESULT cbScriptMsgyn(int argc, char* argv[])
@brief Script msgyn.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
CMDRESULT cbScriptMsgyn(int argc, char* argv[])
{
if(argc < 2)

View File

@ -1,3 +1,9 @@
/**
@file stackinfo.cpp
@brief Implements the stackinfo class.
*/
#include "stackinfo.h"
#include "debugger.h"
#include "memory.h"
@ -7,6 +13,17 @@
#include "addrinfo.h"
#include "_exports.h"
/**
@fn bool stackcommentget(uint addr, STACK_COMMENT* comment)
@brief Stackcommentgets.
@param addr The address.
@param [in,out] comment If non-null, the comment.
@return true if it succeeds, false if it fails.
*/
bool stackcommentget(uint addr, STACK_COMMENT* comment)
{
uint data = 0;
@ -112,6 +129,16 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
return false;
}
#include "console.h"
/**
@fn void stackgetcallstack(uint csp, CALLSTACK* callstack)
@brief Stackgetcallstacks.
@param csp The csp.
@param [in,out] callstack If non-null, the callstack.
*/
void stackgetcallstack(uint csp, CALLSTACK* callstack)
{
callstack->total = 0;

View File

@ -1,14 +1,47 @@
/**
@file symbolinfo.cpp
@brief Implements the symbolinfo class.
*/
#include "symbolinfo.h"
#include "debugger.h"
#include "addrinfo.h"
#include "console.h"
/**
@struct SYMBOLCBDATA
@brief A symbolcbdata.
*/
struct SYMBOLCBDATA
{
/**
@brief The symbol enum.
*/
CBSYMBOLENUM cbSymbolEnum;
/**
@brief The user.
*/
void* user;
};
/**
@fn static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
@brief Enum symbols.
@param pSymInfo Information describing the symbol.
@param SymbolSize Size of the symbol.
@param UserContext Context for the user.
@return A CALLBACK.
*/
static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
int len = (int)strlen(pSymInfo->Name);
@ -39,6 +72,16 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID
return TRUE;
}
/**
@fn void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user)
@brief Symenums.
@param base The base.
@param cbSymbolEnum The symbol enum.
@param [in,out] user If non-null, the user.
*/
void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user)
{
SYMBOLCBDATA symbolCbData;
@ -49,8 +92,34 @@ void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user)
}
#ifdef _WIN64
/**
@fn static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) #else static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID UserContext) #endif
@brief Enum modules.
@param ModuleName Name of the module.
@param BaseOfDll The base of DLL.
@param UserContext Context for the user.
@return A CALLBACK.
*/
static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext)
#else
/**
@fn static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID UserContext) #endif
@brief Enum modules.
@param ModuleName Name of the module.
@param BaseOfDll The base of DLL.
@param UserContext Context for the user.
@return A CALLBACK.
*/
static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID UserContext)
#endif //_WIN64
{
@ -62,6 +131,12 @@ static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID User
return TRUE;
}
/**
@fn void symupdatemodulelist()
@brief Symupdatemodulelists this object.
*/
void symupdatemodulelist()
{
std::vector<SYMBOLMODULEINFO> modList;
@ -74,6 +149,14 @@ void symupdatemodulelist()
GuiSymbolUpdateModuleList(modcount, modListBridge);
}
/**
@fn void symdownloadallsymbols(const char* szSymbolStore)
@brief Symdownloadallsymbols the given size symbol store.
@param szSymbolStore The symbol store.
*/
void symdownloadallsymbols(const char* szSymbolStore)
{
if(!szSymbolStore)
@ -124,6 +207,17 @@ void symdownloadallsymbols(const char* szSymbolStore)
}
}
/**
@fn bool symfromname(const char* name, uint* addr)
@brief Symfromnames.
@param name The name.
@param [in,out] addr If non-null, the address.
@return true if it succeeds, false if it fails.
*/
bool symfromname(const char* name, uint* addr)
{
if(!name or !strlen(name) or !addr or !_strnicmp(name, "ordinal", 7)) //skip 'OrdinalXXX'
@ -138,6 +232,16 @@ bool symfromname(const char* name, uint* addr)
return true;
}
/**
@fn const char* symgetsymbolicname(uint addr)
@brief Symgetsymbolicnames the given address.
@param addr The address.
@return null if it fails, else a char*.
*/
const char* symgetsymbolicname(uint addr)
{
//[modname.]symbolname

View File

@ -1,12 +1,40 @@
/**
@file thread.cpp
@brief Implements the thread class.
*/
#include "thread.h"
#include "console.h"
#include "undocumented.h"
#include "memory.h"
/**
@brief List of threads.
*/
static std::vector<THREADINFO> threadList;
/**
@brief The thread number.
*/
static int threadNum;
/**
@brief The current thread.
*/
static int currentThread;
/**
@fn void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
@brief Threadcreates the given create thread.
@param [in,out] CreateThread If non-null, the create thread.
*/
void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
{
THREADINFO curInfo;
@ -23,6 +51,14 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
GuiUpdateThreadView();
}
/**
@fn void threadexit(DWORD dwThreadId)
@brief Threadexits the given double-word thread identifier.
@param dwThreadId Identifier for the thread.
*/
void threadexit(DWORD dwThreadId)
{
for(unsigned int i = 0; i < threadList.size(); i++)
@ -34,6 +70,12 @@ void threadexit(DWORD dwThreadId)
GuiUpdateThreadView();
}
/**
@fn void threadclear()
@brief Threadclears this object.
*/
void threadclear()
{
threadNum = 0;
@ -41,11 +83,31 @@ void threadclear()
GuiUpdateThreadView();
}
/**
@fn static THREADWAITREASON GetThreadWaitReason(DWORD dwThreadId)
@brief Gets thread wait reason.
@param dwThreadId Identifier for the thread.
@return The thread wait reason.
*/
static THREADWAITREASON GetThreadWaitReason(DWORD dwThreadId)
{
return _Executive;
}
/**
@fn static DWORD GetThreadLastError(uint tebAddress)
@brief Gets thread last error.
@param tebAddress The teb address.
@return The thread last error.
*/
static DWORD GetThreadLastError(uint tebAddress)
{
TEB teb;
@ -55,6 +117,14 @@ static DWORD GetThreadLastError(uint tebAddress)
return teb.LastErrorValue;
}
/**
@fn void threadgetlist(THREADLIST* list)
@brief Threadgetlists the given list.
@param [in,out] list If non-null, the list.
*/
void threadgetlist(THREADLIST* list)
{
int count = (int)threadList.size();
@ -79,6 +149,16 @@ void threadgetlist(THREADLIST* list)
list->CurrentThread = currentThread;
}
/**
@fn bool threadisvalid(DWORD dwThreadId)
@brief Threadisvalids the given double-word thread identifier.
@param dwThreadId Identifier for the thread.
@return true if it succeeds, false if it fails.
*/
bool threadisvalid(DWORD dwThreadId)
{
for(unsigned int i = 0; i < threadList.size(); i++)
@ -87,6 +167,17 @@ bool threadisvalid(DWORD dwThreadId)
return false;
}
/**
@fn bool threadsetname(DWORD dwThreadId, const char* name)
@brief Threadsetnames.
@param dwThreadId Identifier for the thread.
@param name The name.
@return true if it succeeds, false if it fails.
*/
bool threadsetname(DWORD dwThreadId, const char* name)
{
for(unsigned int i = 0; i < threadList.size(); i++)
@ -100,6 +191,16 @@ bool threadsetname(DWORD dwThreadId, const char* name)
return false;
}
/**
@fn HANDLE threadgethandle(DWORD dwThreadId)
@brief Threadgethandles the given double-word thread identifier.
@param dwThreadId Identifier for the thread.
@return The handle of the.
*/
HANDLE threadgethandle(DWORD dwThreadId)
{
for(unsigned int i = 0; i < threadList.size(); i++)
@ -108,6 +209,16 @@ HANDLE threadgethandle(DWORD dwThreadId)
return 0;
}
/**
@fn DWORD threadgetid(HANDLE hThread)
@brief Threadgetids the given h thread.
@param hThread Handle of the thread.
@return A DWORD.
*/
DWORD threadgetid(HANDLE hThread)
{
for(unsigned int i = 0; i < threadList.size(); i++)

View File

@ -1,36 +1,105 @@
/**
@file threading.cpp
@brief Implements the threading class.
*/
#include "threading.h"
/**
@property static volatile bool waitarray[16]
@brief Gets a value indicating whether the waitarray[ 16].
@return true if waitarray[ 16], false if not.
*/
static volatile bool waitarray[16];
/**
@fn void waitclear()
@brief Waitclears this object.
*/
void waitclear()
{
memset((void*)waitarray, 0, sizeof(waitarray));
}
/**
@fn void wait(WAIT_ID id)
@brief Waits the given identifier.
@param id The identifier.
*/
void wait(WAIT_ID id)
{
while(waitarray[id]) //1=locked, 0=unlocked
Sleep(1);
}
/**
@fn void lock(WAIT_ID id)
@brief Locks the given identifier.
@param id The identifier.
*/
void lock(WAIT_ID id)
{
waitarray[id] = true;
}
/**
@fn void unlock(WAIT_ID id)
@brief Unlocks the given identifier.
@param id The identifier.
*/
void unlock(WAIT_ID id)
{
waitarray[id] = false;
}
/**
@fn bool waitislocked(WAIT_ID id)
@brief Waitislocked the given identifier.
@param id The identifier.
@return true if it succeeds, false if it fails.
*/
bool waitislocked(WAIT_ID id)
{
return waitarray[id];
}
/**
@brief The locks[ lock last].
*/
static CRITICAL_SECTION locks[LockLast] = {};
/**
@brief The initialise done.
*/
static bool bInitDone = false;
/**
@fn static void CriticalSectionInitializeLocks()
@brief Critical section initialize locks.
*/
static void CriticalSectionInitializeLocks()
{
if(bInitDone)
@ -40,6 +109,12 @@ static void CriticalSectionInitializeLocks()
bInitDone = true;
}
/**
@fn void CriticalSectionDeleteLocks()
@brief Critical section delete locks.
*/
void CriticalSectionDeleteLocks()
{
if(!bInitDone)
@ -49,6 +124,14 @@ void CriticalSectionDeleteLocks()
bInitDone = false;
}
/**
@fn CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
@brief Constructor.
@param lock The lock.
*/
CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
{
CriticalSectionInitializeLocks(); //initialize critical sections
@ -56,16 +139,34 @@ CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
EnterCriticalSection(&locks[gLock]);
}
/**
@fn CriticalSectionLocker::~CriticalSectionLocker()
@brief Destructor.
*/
CriticalSectionLocker::~CriticalSectionLocker()
{
LeaveCriticalSection(&locks[gLock]);
}
/**
@fn void CriticalSectionLocker::unlock()
@brief Unlocks this object.
*/
void CriticalSectionLocker::unlock()
{
LeaveCriticalSection(&locks[gLock]);
}
/**
@fn void CriticalSectionLocker::relock()
@brief Relocks this object.
*/
void CriticalSectionLocker::relock()
{
EnterCriticalSection(&locks[gLock]);

View File

@ -1,3 +1,9 @@
/**
@file value.cpp
@brief Implements the value class.
*/
#include "value.h"
#include "variable.h"
#include "debugger.h"
@ -8,18 +14,48 @@
#include "symbolinfo.h"
#include <psapi.h>
/**
@brief The dosignedcalc.
*/
static bool dosignedcalc = false;
/**
@fn bool valuesignedcalc()
@brief Valuesignedcalcs this object.
@return true if it succeeds, false if it fails.
*/
bool valuesignedcalc()
{
return dosignedcalc;
}
/**
@fn void valuesetsignedcalc(bool a)
@brief Valuesetsignedcalcs.
@param a true to a.
*/
void valuesetsignedcalc(bool a)
{
dosignedcalc = a;
}
/**
@fn static bool isflag(const char* string)
@brief Query if 'string' isflag.
@param string The string.
@return true if it succeeds, false if it fails.
*/
static bool isflag(const char* string)
{
if(scmp(string, "cf"))
@ -55,6 +91,16 @@ static bool isflag(const char* string)
return false;
}
/**
@fn static bool isregister(const char* string)
@brief Query if 'string' isregister.
@param string The string.
@return true if it succeeds, false if it fails.
*/
static bool isregister(const char* string)
{
if(scmp(string, "eax"))
@ -257,6 +303,17 @@ static bool isregister(const char* string)
return false;
}
/**
@fn bool valflagfromstring(uint eflags, const char* string)
@brief Valflagfromstrings.
@param eflags The eflags.
@param string The string.
@return true if it succeeds, false if it fails.
*/
bool valflagfromstring(uint eflags, const char* string)
{
if(scmp(string, "cf"))
@ -292,6 +349,17 @@ bool valflagfromstring(uint eflags, const char* string)
return false;
}
/**
@fn static bool setflag(const char* string, bool set)
@brief Setflags.
@param string The string.
@param set true to set.
@return true if it succeeds, false if it fails.
*/
static bool setflag(const char* string, bool set)
{
uint eflags = GetContextDataEx(hActiveThread, UE_CFLAGS);
@ -334,6 +402,17 @@ static bool setflag(const char* string, bool set)
return SetContextDataEx(hActiveThread, UE_CFLAGS, eflags ^ xorval);
}
/**
@fn static uint getregister(int* size, const char* string)
@brief Getregisters.
@param [in,out] size If non-null, the size.
@param string The string.
@return An uint.
*/
static uint getregister(int* size, const char* string)
{
if(size)
@ -772,6 +851,17 @@ static uint getregister(int* size, const char* string)
return 0;
}
/**
@fn static bool setregister(const char* string, uint value)
@brief Setregisters.
@param string The string.
@param value The value.
@return true if it succeeds, false if it fails.
*/
static bool setregister(const char* string, uint value)
{
if(scmp(string, "eax"))
@ -976,6 +1066,21 @@ static bool setregister(const char* string, uint value)
return false;
}
/**
@fn bool valapifromstring(const char* name, uint* value, int* value_size, bool printall, bool silent, bool* hexonly)
@brief Valapifromstrings.
@param name The name.
@param [in,out] value If non-null, the value.
@param [in,out] value_size If non-null, size of the value.
@param printall true to printall.
@param silent true to silent.
@param [in,out] hexonly If non-null, the hexonly.
@return true if it succeeds, false if it fails.
*/
bool valapifromstring(const char* name, uint* value, int* value_size, bool printall, bool silent, bool* hexonly)
{
if(!value or !DbgIsDebugging())
@ -1114,6 +1219,17 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
/*
check whether a string is a valid dec number
*/
/**
@fn static bool isdecnumber(const char* string)
@brief Query if 'string' isdecnumber.
@param string The string.
@return true if it succeeds, false if it fails.
*/
static bool isdecnumber(const char* string)
{
if(*string != '.' or !string[1]) //dec indicator/no number
@ -1135,6 +1251,17 @@ static bool isdecnumber(const char* string)
/*
check whether a string is a valid hex number
*/
/**
@fn static bool ishexnumber(const char* string)
@brief Query if 'string' ishexnumber.
@param string The string.
@return true if it succeeds, false if it fails.
*/
static bool ishexnumber(const char* string)
{
int add = 0;
@ -1151,6 +1278,22 @@ static bool ishexnumber(const char* string)
return true;
}
/**
@fn bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar, bool* hexonly)
@brief Valfromstrings.
@param string The string.
@param [in,out] value If non-null, the value.
@param silent true to silent.
@param baseonly true to baseonly.
@param [in,out] value_size If non-null, size of the value.
@param [in,out] isvar If non-null, the isvar.
@param [in,out] hexonly If non-null, the hexonly.
@return true if it succeeds, false if it fails.
*/
bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar, bool* hexonly)
{
if(!value or !string)
@ -1345,21 +1488,69 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
return false; //nothing was OK
}
/**
@fn bool valfromstring(const char* string, uint* value, bool silent, bool baseonly)
@brief Valfromstrings.
@param string The string.
@param [in,out] value If non-null, the value.
@param silent true to silent.
@param baseonly true to baseonly.
@return true if it succeeds, false if it fails.
*/
bool valfromstring(const char* string, uint* value, bool silent, bool baseonly)
{
return valfromstring(string, value, silent, baseonly, 0, 0, 0);
}
/**
@fn bool valfromstring(const char* string, uint* value, bool silent)
@brief Valfromstrings.
@param string The string.
@param [in,out] value If non-null, the value.
@param silent true to silent.
@return true if it succeeds, false if it fails.
*/
bool valfromstring(const char* string, uint* value, bool silent)
{
return valfromstring(string, value, silent, false);
}
/**
@fn bool valfromstring(const char* string, uint* value)
@brief Valfromstrings.
@param string The string.
@param [in,out] value If non-null, the value.
@return true if it succeeds, false if it fails.
*/
bool valfromstring(const char* string, uint* value)
{
return valfromstring(string, value, true);
}
/**
@fn bool valtostring(const char* string, uint* value, bool silent)
@brief Valtostrings.
@param string The string.
@param [in,out] value If non-null, the value.
@param silent true to silent.
@return true if it succeeds, false if it fails.
*/
bool valtostring(const char* string, uint* value, bool silent)
{
if(!*string or !value)

View File

@ -1,8 +1,32 @@
/**
@file variable.cpp
@brief Implements the variable class.
*/
#include "variable.h"
/**
@brief The variables.
*/
static VariableMap variables;
/**
@brief The variables.
*/
static VAR* vars;
/**
@fn static void varsetvalue(VAR* var, VAR_VALUE* value)
@brief Varsetvalues.
@param [in,out] var If non-null, the variable.
@param [in,out] value If non-null, the value.
*/
static void varsetvalue(VAR* var, VAR_VALUE* value)
{
switch(var->value.type)
@ -17,6 +41,18 @@ static void varsetvalue(VAR* var, VAR_VALUE* value)
memcpy(&var->value, value, sizeof(VAR_VALUE));
}
/**
@fn static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
@brief Varsets.
@param name The name.
@param [in,out] value If non-null, the value.
@param setreadonly true to setreadonly.
@return true if it succeeds, false if it fails.
*/
static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
{
std::string name_;
@ -34,6 +70,12 @@ static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
return true;
}
/**
@fn void varinit()
@brief Varinits this object.
*/
void varinit()
{
variables.clear();
@ -54,11 +96,25 @@ void varinit()
varnew("$_BS_FLAG", 0, VAR_READONLY); //bigger/smaller flag for internal use (1=bigger, 0=smaller)
}
/**
@fn void varfree()
@brief Varfrees this object.
*/
void varfree()
{
variables.clear();
}
/**
@fn VAR* vargetptr()
@brief Gets the vargetptr.
@return null if it fails, else a VAR*.
*/
VAR* vargetptr()
{
return 0;
@ -67,6 +123,18 @@ VAR* vargetptr()
#include <iostream>
#include <sstream>
/**
@fn std::vector<std::string> & split(const std::string & s, char delim, std::vector<std::string> & elems)
@brief Splits.
@param s The const std::string &amp; to process.
@param delim The delimiter.
@param [in,out] elems The elements.
@return A std::vector&lt;std::string&gt;&amp;
*/
std::vector<std::string> & split(const std::string & s, char delim, std::vector<std::string> & elems)
{
std::stringstream ss(s);
@ -80,6 +148,17 @@ std::vector<std::string> & split(const std::string & s, char delim, std::vector<
return elems;
}
/**
@fn std::vector<std::string> split(const std::string & s, char delim)
@brief Splits.
@param s The const std::string &amp; to process.
@param delim The delimiter.
@return A std::vector&lt;std::string&gt;
*/
std::vector<std::string> split(const std::string & s, char delim)
{
std::vector<std::string> elems;
@ -87,6 +166,18 @@ std::vector<std::string> split(const std::string & s, char delim)
return elems;
}
/**
@fn bool varnew(const char* name, uint value, VAR_TYPE type)
@brief Varnews.
@param name The name.
@param value The value.
@param type The type.
@return true if it succeeds, false if it fails.
*/
bool varnew(const char* name, uint value, VAR_TYPE type)
{
if(!name)
@ -117,6 +208,19 @@ bool varnew(const char* name, uint value, VAR_TYPE type)
return true;
}
/**
@fn static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type)
@brief Vargets.
@param name The name.
@param [in,out] value If non-null, the value.
@param [in,out] size If non-null, the size.
@param [in,out] type If non-null, the type.
@return true if it succeeds, false if it fails.
*/
static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type)
{
std::string name_;
@ -137,6 +241,19 @@ static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type
return true;
}
/**
@fn bool varget(const char* name, uint* value, int* size, VAR_TYPE* type)
@brief Vargets.
@param name The name.
@param [in,out] value If non-null, the value.
@param [in,out] size If non-null, the size.
@param [in,out] type If non-null, the type.
@return true if it succeeds, false if it fails.
*/
bool varget(const char* name, uint* value, int* size, VAR_TYPE* type)
{
VAR_VALUE varvalue;
@ -155,6 +272,19 @@ bool varget(const char* name, uint* value, int* size, VAR_TYPE* type)
return true;
}
/**
@fn bool varget(const char* name, char* string, int* size, VAR_TYPE* type)
@brief Vargets.
@param name The name.
@param [in,out] string If non-null, the string.
@param [in,out] size If non-null, the size.
@param [in,out] type If non-null, the type.
@return true if it succeeds, false if it fails.
*/
bool varget(const char* name, char* string, int* size, VAR_TYPE* type)
{
VAR_VALUE varvalue;
@ -173,6 +303,18 @@ bool varget(const char* name, char* string, int* size, VAR_TYPE* type)
return true;
}
/**
@fn bool varset(const char* name, uint value, bool setreadonly)
@brief Varsets.
@param name The name.
@param value The value.
@param setreadonly true to setreadonly.
@return true if it succeeds, false if it fails.
*/
bool varset(const char* name, uint value, bool setreadonly)
{
VAR_VALUE varvalue;
@ -182,6 +324,18 @@ bool varset(const char* name, uint value, bool setreadonly)
return varset(name, &varvalue, setreadonly);
}
/**
@fn bool varset(const char* name, const char* string, bool setreadonly)
@brief Varsets.
@param name The name.
@param string The string.
@param setreadonly true to setreadonly.
@return true if it succeeds, false if it fails.
*/
bool varset(const char* name, const char* string, bool setreadonly)
{
VAR_VALUE varvalue;
@ -200,6 +354,17 @@ bool varset(const char* name, const char* string, bool setreadonly)
return true;
}
/**
@fn bool vardel(const char* name, bool delsystem)
@brief Vardels.
@param name The name.
@param delsystem true to delsystem.
@return true if it succeeds, false if it fails.
*/
bool vardel(const char* name, bool delsystem)
{
std::string name_;
@ -224,6 +389,18 @@ bool vardel(const char* name, bool delsystem)
return true;
}
/**
@fn bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
@brief Vargettypes.
@param name The name.
@param [in,out] type If non-null, the type.
@param [in,out] valtype If non-null, the valtype.
@return true if it succeeds, false if it fails.
*/
bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
{
std::string name_;
@ -242,6 +419,17 @@ bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
return true;
}
/**
@fn bool varenum(VAR* entries, size_t* cbsize)
@brief Varenums.
@param [in,out] entries If non-null, the entries.
@param [in,out] cbsize If non-null, the cbsize.
@return true if it succeeds, false if it fails.
*/
bool varenum(VAR* entries, size_t* cbsize)
{
if(!entries && !cbsize || !variables.size())

View File

@ -1,3 +1,9 @@
/**
@file x64_dbg.cpp
@brief Implements the 64 debug class.
*/
#include "_global.h"
#include "argument.h"
#include "command.h"
@ -17,12 +23,40 @@
#include "_dbgfunctions.h"
#include "debugger_commands.h"
/**
@brief Stack of messages.
*/
static MESSAGE_STACK* gMsgStack = 0;
/**
@brief List of commands.
*/
static COMMAND* command_list = 0;
/**
@brief The command loop thread.
*/
static HANDLE hCommandLoopThread = 0;
/**
@brief The alloctrace[ maximum path].
*/
static char alloctrace[MAX_PATH] = "";
//Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-Simple-Win32-CommandLine-Parser.htm
/**
@fn static void commandlinefree(int argc, char** argv)
@brief Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-
Simple-Win32-CommandLine-Parser.htm.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
*/
static void commandlinefree(int argc, char** argv)
{
for(int i = 0; i < argc; i++)
@ -30,6 +64,16 @@ static void commandlinefree(int argc, char** argv)
efree(argv);
}
/**
@fn static char** commandlineparse(int* argc)
@brief Commandlineparses the given argc.
@param [in,out] argc If non-null, the argc.
@return null if it fails, else a char**.
*/
static char** commandlineparse(int* argc)
{
if(!argc)
@ -47,6 +91,17 @@ static char** commandlineparse(int* argc)
return argv;
}
/**
@fn static CMDRESULT cbStrLen(int argc, char* argv[])
@brief String length.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
static CMDRESULT cbStrLen(int argc, char* argv[])
{
if(argc < 2)
@ -58,12 +113,34 @@ static CMDRESULT cbStrLen(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn static CMDRESULT cbCls(int argc, char* argv[])
@brief Cls.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
static CMDRESULT cbCls(int argc, char* argv[])
{
GuiLogClear();
return STATUS_CONTINUE;
}
/**
@fn static CMDRESULT cbPrintf(int argc, char* argv[])
@brief Printfs.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
@return A CMDRESULT.
*/
static CMDRESULT cbPrintf(int argc, char* argv[])
{
if(argc < 2)
@ -73,6 +150,12 @@ static CMDRESULT cbPrintf(int argc, char* argv[])
return STATUS_CONTINUE;
}
/**
@fn static void registercommands()
@brief Registercommands this object.
*/
static void registercommands()
{
COMMAND* cmd = command_list = cmdinit();
@ -212,6 +295,17 @@ static void registercommands()
dbgcmdnew("looplist", cbInstrLoopList, true); //list loops
}
/**
@fn static bool cbCommandProvider(char* cmd, int maxlen)
@brief Command provider.
@param [in,out] cmd If non-null, the command.
@param maxlen The maxlen.
@return true if it succeeds, false if it fails.
*/
static bool cbCommandProvider(char* cmd, int maxlen)
{
MESSAGE msg;
@ -227,6 +321,16 @@ static bool cbCommandProvider(char* cmd, int maxlen)
return true;
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
@brief Debug dbgcmdexec.
@param cmd The command.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
{
int len = (int)strlen(cmd);
@ -235,22 +339,58 @@ extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
return msgsend(gMsgStack, 0, (uint)newcmd, 0);
}
/**
@fn static DWORD WINAPI DbgCommandLoopThread(void* a)
@brief Debug command loop thread.
@param [in,out] a If non-null, the void* to process.
@return A WINAPI.
*/
static DWORD WINAPI DbgCommandLoopThread(void* a)
{
cmdloop(command_list, cbBadCmd, cbCommandProvider, cmdfindmain, false);
return 0;
}
/**
@fn static void* emalloc_json(size_t size)
@brief Emalloc JSON.
@param size The size.
@return null if it fails, else a void*.
*/
static void* emalloc_json(size_t size)
{
return emalloc(size, "json:ptr");
}
/**
@fn static void efree_json(void* ptr)
@brief Efree JSON.
@param [in,out] ptr If non-null, the pointer.
*/
static void efree_json(void* ptr)
{
efree(ptr, "json:ptr");
}
/**
@fn extern "C" DLL_EXPORT const char* _dbg_dbginit()
@brief Debug dbginit.
@return null if it fails, else a char*.
*/
extern "C" DLL_EXPORT const char* _dbg_dbginit()
{
dbginit();
@ -310,6 +450,12 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
return 0;
}
/**
@fn extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
@brief Debug dbgexitsignal.
*/
extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
{
cbStopDebug(0, 0);
@ -332,6 +478,16 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
CriticalSectionDeleteLocks();
}
/**
@fn extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd)
@brief Debug dbgcmddirectexec.
@param cmd The command.
@return true if it succeeds, false if it fails.
*/
extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd)
{
if(cmddirectexec(command_list, cmd) == STATUS_ERROR)
@ -339,6 +495,14 @@ extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd)
return true;
}
/**
@fn COMMAND* dbggetcommandlist()
@brief Gets the dbggetcommandlist.
@return null if it fails, else a COMMAND*.
*/
COMMAND* dbggetcommandlist()
{
return command_list;

View File

@ -1,7 +1,26 @@
/**
@file x64_dbg_exe.cpp
@brief Implements the 64 debug executable class.
*/
#include <stdio.h>
#include <windows.h>
#include "..\x64_dbg_bridge\bridgemain.h"
/**
@fn int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
@brief Window main.
@param hInstance The instance.
@param hPrevInstance The previous instance.
@param lpCmdLine The command line.
@param nShowCmd The show command.
@return An APIENTRY.
*/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
const char* errormsg = BridgeInit();

View File

@ -1,22 +1,85 @@
/**
@file x64_dbg_launcher.cpp
@brief Implements the 64 debug launcher class.
*/
#include <stdio.h>
#include <windows.h>
#include <string>
#include <shlwapi.h>
/**
@enum arch
@brief Values that represent arch.
*/
enum arch
{
/**
@property notfound, invalid, x32, x64 }
@brief Gets the.
@return The.
*/
notfound,
/**
@property invalid, x32, x64 }
@brief Gets the.
@return The.
*/
invalid,
/**
@property x32, x64 }
@brief Gets the.
@return The.
*/
x32,
/**
@brief .
*/
x64
};
/**
@fn static bool FileExists(const char* file)
@brief Queries if a given file exists.
@param file The file.
@return true if it succeeds, false if it fails.
*/
static bool FileExists(const char* file)
{
DWORD attrib = GetFileAttributes(file);
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
}
/**
@fn static arch GetFileArchitecture(const char* szFileName)
@brief Gets file architecture.
@param szFileName Filename of the file.
@return The file architecture.
*/
static arch GetFileArchitecture(const char* szFileName)
{
arch retval = notfound;
@ -50,7 +113,16 @@ static arch GetFileArchitecture(const char* szFileName)
return retval;
}
//Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-Simple-Win32-CommandLine-Parser.htm
/**
@fn static void commandlinefree(int argc, char** argv)
@brief Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-
Simple-Win32-CommandLine-Parser.htm.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
*/
static void commandlinefree(int argc, char** argv)
{
for(int i = 0; i < argc; i++)
@ -58,6 +130,16 @@ static void commandlinefree(int argc, char** argv)
free(argv);
}
/**
@fn static char** commandlineparse(int* argc)
@brief Commandlineparses the given argc.
@param [in,out] argc If non-null, the argc.
@return null if it fails, else a char**.
*/
static char** commandlineparse(int* argc)
{
if(!argc)
@ -75,6 +157,21 @@ static char** commandlineparse(int* argc)
return argv;
}
/**
@fn static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, char* filename, int filename_size, const char* init_dir)
@brief Queries if a given browse file open.
@param owner Handle of the owner.
@param filter Specifies the filter.
@param defext The defext.
@param [in,out] filename If non-null, filename of the file.
@param filename_size Size of the filename.
@param init_dir The initialise dir.
@return true if it succeeds, false if it fails.
*/
static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, char* filename, int filename_size, const char* init_dir)
{
OPENFILENAME ofstruct;
@ -91,9 +188,31 @@ static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, c
return !!GetOpenFileNameA(&ofstruct);
}
/**
@def SHELLEXT_EXE_KEY
@brief A macro that defines shellext executable key.
*/
#define SHELLEXT_EXE_KEY "exefile\\shell\\Debug with x64_dbg\\Command"
/**
@def SHELLEXT_DLL_KEY
@brief A macro that defines shellext DLL key.
*/
#define SHELLEXT_DLL_KEY "dllfile\\shell\\Debug with x64_dbg\\Command"
/**
@fn void RegisterShellExtension(const char* key, const char* command)
@brief Registers the shell extension.
@param key The key.
@param command The command.
*/
void RegisterShellExtension(const char* key, const char* command)
{
HKEY hKey;
@ -107,6 +226,19 @@ void RegisterShellExtension(const char* key, const char* command)
RegCloseKey(hKey);
}
/**
@fn int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
@brief Window main.
@param hInstance The instance.
@param hPrevInstance The previous instance.
@param lpCmdLine The command line.
@param nShowCmd The show command.
@return An APIENTRY.
*/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
CoInitialize(NULL); //fixed some crash