| 9 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 10 |  | if (VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &oldp)) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 11 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 12 | < | *(char*)from++ = 0xe9; // jmp rel32 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 | > | *((char*)from) = 0xe9; // jmp rel32 | 
 
 
 
 
 | 13 | > | from = (char*)from + 1; | 
 
 
 
 
 
 
 
 
 
 
 | 14 |  | *(int*)from = (unsigned int)to - (unsigned int)from - 4; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 |  | VirtualProtect(from, 5, oldp, &oldp); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 |  | return true; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 25 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 26 |  | if (VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &oldp)) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 27 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 28 | < | *(char*)from++ = 0xe8; // call rel32 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 28 | > | *((char*)from) = 0xe8; // call rel32 | 
 
 
 
 
 | 29 | > | from = (char*)from + 1; | 
 
 
 
 
 
 
 
 
 
 
 | 30 |  | *(int*)from = (unsigned int)to - (unsigned int)from - 4; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 |  | VirtualProtect(from, 5, oldp, &oldp); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 |  | return true; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 91 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 94 | < | bool DDrPatch_StrDup(int* dest, const char* value) | 
 
 
 
 
 
 
 
 
 | 94 | > | bool DDrPatch__strdup(int* dest, const char* value) | 
 
 
 
 
 
 
 
 
 
 
 | 95 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 96 |  | DWORD oldp; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 |  | if (VirtualProtect(dest, 4, PAGE_EXECUTE_READWRITE, &oldp)) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 100 | < | *dest = (int)strdup(value); | 
 
 
 
 
 
 
 
 
 | 100 | > | *dest = (int)_strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 | 101 |  | VirtualProtect(dest, 4, oldp, &oldp); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 102 |  | return true; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 103 |  | } |