DBG: fill with NOPs is working now
This commit is contained in:
parent
bacfcf498b
commit
afdcd0a7d5
|
|
@ -3,6 +3,8 @@
|
|||
#include "debugger.h"
|
||||
#include "XEDParse\XEDParse.h"
|
||||
#include "value.h"
|
||||
#include "disasm_helper.h"
|
||||
#include "console.h"
|
||||
|
||||
static bool cbUnknown(const char* text, ULONGLONG* value)
|
||||
{
|
||||
|
|
@ -35,6 +37,19 @@ bool assembleat(uint addr, const char* instruction, char* error, bool fillnop)
|
|||
strcpy(error, parse.error);
|
||||
return false;
|
||||
}
|
||||
bool ret=memwrite(fdProcessInfo->hProcess, (void*)addr, parse.dest, parse.dest_size, 0);
|
||||
return ret;
|
||||
|
||||
//calculate the number of NOPs to insert
|
||||
int destSize=parse.dest_size;
|
||||
int origLen=disasmgetsize(addr);
|
||||
while(origLen<destSize)
|
||||
origLen+=disasmgetsize(addr+origLen);
|
||||
int nopsize=origLen-destSize;
|
||||
unsigned char nops[16];
|
||||
memset(nops, 0x90, sizeof(nops));
|
||||
|
||||
bool ret=memwrite(fdProcessInfo->hProcess, (void*)addr, parse.dest, destSize, 0);
|
||||
if(ret && fillnop && nopsize)
|
||||
if(!memwrite(fdProcessInfo->hProcess, (void*)(addr+destSize), nops, nopsize, 0))
|
||||
ret=false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -419,3 +419,27 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
efree(data, "disasmgetstringat:data");
|
||||
return false;
|
||||
}
|
||||
|
||||
int disasmgetsize(uint addr, unsigned char* data)
|
||||
{
|
||||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(DISASM));
|
||||
disasm.Options=NoformatNumeral;
|
||||
#ifdef _WIN64
|
||||
disasm.Archi=64;
|
||||
#endif // _WIN64
|
||||
disasm.VirtualAddr=addr;
|
||||
disasm.EIP=(UIntPtr)data;
|
||||
int len=Disasm(&disasm);
|
||||
if(len==UNKNOWN_OPCODE)
|
||||
len=1;
|
||||
return len;
|
||||
}
|
||||
|
||||
int disasmgetsize(uint addr)
|
||||
{
|
||||
char data[16];
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data), 0))
|
||||
return 1;
|
||||
return disasmgetsize(addr, (unsigned char*)data);
|
||||
}
|
||||
|
|
@ -12,5 +12,7 @@ void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr);
|
|||
void disasmget(uint addr, DISASM_INSTR* instr);
|
||||
bool disasmispossiblestring(uint addr);
|
||||
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen);
|
||||
int disasmgetsize(uint addr, unsigned char* data);
|
||||
int disasmgetsize(uint addr);
|
||||
|
||||
#endif // _DISASM_HELPER_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue