ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Daodan_Patch.c
(Generate patch)

Comparing Daodan/src/Daodan_Patch.c (file contents):
Revision 993 by alloc, Sun Apr 6 17:06:02 2014 UTC vs.
Revision 994 by alloc, Mon Apr 7 10:33:27 2014 UTC

# Line 1 | Line 1
1   #include "Daodan_Patch.h"
2 < #include "Daodan_Utility.h"
2 > #include "Patches/Utility.h"
3   #include <beaengine/BeaEngine.h>
4  
5   #include <windows.h>
# Line 279 | Line 279 | bool DDrPatch_Int16(short* dest, unsigne
279                  return false;
280   }
281  
282 bool DDrPatch__strdup(int* dest, const char* value)
283 {
284        DWORD oldp;
285        
286        if (VirtualProtect(dest, 4, PAGE_EXECUTE_READWRITE, &oldp))
287        {
288                *dest = (int)_strdup(value);
289                VirtualProtect(dest, 4, oldp, &oldp);
290                return true;
291        }
292        else
293                return false;
294 }
295
282   bool DDrPatch_NOOP(char* dest, unsigned int length)
283   {
284          DWORD oldp;
# Line 306 | Line 292 | bool DDrPatch_NOOP(char* dest, unsigned
292          else
293                  return false;
294   }
295 +
296 +
297 + void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit)
298 + {
299 +        DISASM MyDisasm;
300 +        int len = 0;
301 +        int size = 0;
302 +        int i = 0;
303 +
304 +        memset(&MyDisasm, 0, sizeof(DISASM));
305 +
306 +        MyDisasm.EIP = (UIntPtr) addr;
307 +
308 +        STARTUPMESSAGE("", 0);
309 +        STARTUPMESSAGE("Disassembly @ 0x%06x", addr);
310 +
311 +        if (sizeLimit <= 0)
312 +                sizeLimit = 20 * instLimit;
313 +
314 +        while ((i < instLimit) && (size < sizeLimit)) {
315 +                len = Disasm(&MyDisasm);
316 +                if (len != UNKNOWN_OPCODE) {
317 +                        size += len;
318 +                        STARTUPMESSAGE("    %s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue);
319 +                        STARTUPMESSAGE("          Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number );
320 +
321 +                        MyDisasm.EIP += (UIntPtr)len;
322 +                        i++;
323 +                }
324 +        };
325 +
326 +        STARTUPMESSAGE("", 0);
327 + }
328 +

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)