| 41 |  | void* DDrPatch_MakeDetour(void* from, void* to) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 |  | int len = 0; | 
 
 
 
 
 
 
 
 | 44 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 |  | /* | 
 
 
 
 
 
 
 
 
 
 
 | 46 | < | DISASM MyDisasm; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | < | int i = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | < | memset (&MyDisasm, 0, sizeof(DISASM)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | < | MyDisasm.EIP = (UIntPtr) from; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | < | i = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 | < | STARTUPMESSAGE("Orig before @ 0x%06x", from); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 | < | while (i<10){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 55 | < | len = Disasm(&MyDisasm); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 | < | if (len != UNKNOWN_OPCODE) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | < | STARTUPMESSAGE("%s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | < | STARTUPMESSAGE("    Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number ); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 | < | MyDisasm.EIP += (UIntPtr)len; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 60 | < | i++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | < | }; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 | 46 | > | STARTUPMESSAGE("Orig before", 0); | 
 
 
 
 
 | 47 | > | DDrPatch_PrintDisasm(from, 10, 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 |  | */ | 
 
 
 
 
 
 
 
 
 | 65 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 |  | DISASM disasm; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 |  | memset(&disasm, 0, sizeof(DISASM)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 |  | disasm.EIP = (UIntPtr) from; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 157 |  | return (void*)-1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 158 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 159 |  | DDrPatch_MakeJump(from, to); | 
 
 
 
 
 
 
 
 | 160 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 |  | /* | 
 
 
 
 
 
 
 
 
 
 
 | 162 | < | memset (&MyDisasm, 0, sizeof(DISASM)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 163 | < | MyDisasm.EIP = (UIntPtr) trampoline; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 164 | < | i = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 165 | < | STARTUPMESSAGE("Trampoline @ 0x%06x", trampoline); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 166 | < | while (i<10){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 183 | < | len = Disasm(&MyDisasm); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 184 | < | if (len != UNKNOWN_OPCODE) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 185 | < | STARTUPMESSAGE("%s", MyDisasm.CompleteInstr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 186 | < | MyDisasm.EIP += (UIntPtr)len; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 187 | < | i++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 188 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 189 | < | }; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 190 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 191 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 192 | < | memset (&MyDisasm, 0, sizeof(DISASM)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 193 | < | MyDisasm.EIP = disasm.EIP; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 194 | < | i = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 195 | < | STARTUPMESSAGE("Orig after @ 0x%06x", disasm.EIP); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 196 | < | while (i<7){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 197 | < | len = Disasm(&MyDisasm); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 198 | < | if (len != UNKNOWN_OPCODE) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 199 | < | STARTUPMESSAGE("%s", MyDisasm.CompleteInstr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 200 | < | MyDisasm.EIP += (UIntPtr)len; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 201 | < | i++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 202 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 203 | < | }; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 204 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 205 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 206 | < | memset (&MyDisasm, 0, sizeof(DISASM)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 207 | < | MyDisasm.EIP = (UIntPtr) from; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 208 | < | i = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 209 | < | STARTUPMESSAGE("Orig start after @ 0x%06x", from); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 210 | < | while (i<3){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 211 | < | len = Disasm(&MyDisasm); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 212 | < | if (len != UNKNOWN_OPCODE) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 213 | < | STARTUPMESSAGE("%s", MyDisasm.CompleteInstr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 214 | < | MyDisasm.EIP += (UIntPtr)len; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 215 | < | i++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 216 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 217 | < | }; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 218 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 219 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 220 | < | STARTUPMESSAGE("", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 221 | < | */ | 
 
 
 
 
 
 
 
 
 | 162 | > | STARTUPMESSAGE("Trampoline", 0); | 
 
 
 
 
 | 163 | > | DDrPatch_PrintDisasm(trampoline, 10, 6); | 
 
 
 
 
 | 164 | > |  | 
 
 
 
 
 | 165 | > | STARTUPMESSAGE("Orig after", 0); | 
 
 
 
 
 | 166 | > | DDrPatch_PrintDisasm(disasm.EIP, 7, 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 167 |  |  | 
 
 
 
 
 
 
 
 | 168 | + | STARTUPMESSAGE("Orig start after", 0); | 
 
 
 
 
 
 
 
 | 169 | + | DDrPatch_PrintDisasm(from, 3, 6); | 
 
 
 
 
 
 
 
 | 170 | + | */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 |  | return trampoline; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 |  |  |