--- Daodan/src/Daodan_Patch.c 2014/04/09 00:10:18 995 +++ Daodan/src/Daodan_Patch.c 2014/08/25 23:21:09 1008 @@ -241,6 +241,27 @@ bool DDrPatch_NOOP(char* dest, unsigned return false; } +void* DDrPatch_ExecutableASM(char* from, char* nextInst, const unsigned char* code, int length) +{ + char* newCode = malloc(length+5); + if (!DDrPatch_NOOP(newCode, length+5)) + return (void*)-1; + + memcpy(newCode, code, length); + if (!DDrPatch_MakeJump(&newCode[length], nextInst)) + return (void*)-1; + + DWORD oldp; + if (!VirtualProtect(newCode, length+5, PAGE_EXECUTE_READWRITE, &oldp)) { + STARTUPMESSAGE("ExecASM: Could not mark page for new code as executable: from address 0x%08x", from); + return (void*)-1; + } + + if (!DDrPatch_MakeJump(from, newCode)) + return (void*)-1; + + return newCode; +} void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit) {