Ignore:
Timestamp:
Aug 26, 2014, 1:21:09 AM (10 years ago)
Author:
alloc
Message:

Daodan 3.9: Added AI awareness patch (fixes #36)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Daodan/src/Daodan_Patch.c

    r995 r1008  
    242242}
    243243
     244void* DDrPatch_ExecutableASM(char* from, char* nextInst, const unsigned char* code, int length)
     245{
     246        char* newCode = malloc(length+5);
     247        if (!DDrPatch_NOOP(newCode, length+5))
     248                return (void*)-1;
     249
     250        memcpy(newCode, code, length);
     251        if (!DDrPatch_MakeJump(&newCode[length], nextInst))
     252                return (void*)-1;
     253
     254        DWORD oldp;
     255        if (!VirtualProtect(newCode, length+5, PAGE_EXECUTE_READWRITE, &oldp)) {
     256                STARTUPMESSAGE("ExecASM: Could not mark page for new code as executable: from address 0x%08x", from);
     257                return (void*)-1;
     258        }
     259       
     260        if (!DDrPatch_MakeJump(from, newCode))
     261                return (void*)-1;
     262
     263        return newCode;
     264}
    244265
    245266void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit)
Note: See TracChangeset for help on using the changeset viewer.