--- Daodan/src/Daodan_Patch.c 2009/03/17 09:06:00 272 +++ Daodan/src/Daodan_Patch.c 2013/03/02 23:46:33 677 @@ -1,5 +1,7 @@ #include "Daodan_Patch.h" #include +#include +#include bool DDrPatch_MakeJump(void* from, void* to) { @@ -7,7 +9,8 @@ bool DDrPatch_MakeJump(void* from, void* if (VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &oldp)) { - *(char*)from++ = 0xe9; // jmp rel32 + *((char*)from) = 0xe9; // jmp rel32 + from = (char*)from + 1; *(int*)from = (unsigned int)to - (unsigned int)from - 4; VirtualProtect(from, 5, oldp, &oldp); return true; @@ -22,7 +25,8 @@ bool DDrPatch_MakeCall(void* from, void* if (VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &oldp)) { - *(char*)from++ = 0xe8; // call rel32 + *((char*)from) = 0xe8; // call rel32 + from = (char*)from + 1; *(int*)from = (unsigned int)to - (unsigned int)from - 4; VirtualProtect(from, 5, oldp, &oldp); return true; @@ -84,5 +88,33 @@ bool DDrPatch_Int16(short* dest, short v return true; } else + return false; +} + +bool DDrPatch__strdup(int* dest, const char* value) +{ + DWORD oldp; + + if (VirtualProtect(dest, 4, PAGE_EXECUTE_READWRITE, &oldp)) + { + *dest = (int)_strdup(value); + VirtualProtect(dest, 4, oldp, &oldp); + return true; + } + else + return false; +} + +bool DDrPatch_NOOP(char* dest, unsigned int length) +{ + DWORD oldp; + + if (VirtualProtect(dest, length, PAGE_EXECUTE_READWRITE, &oldp)) + { + memset(dest, 0x90, length); + VirtualProtect(dest, length, oldp, &oldp); + return true; + } + else return false; }