| 281 | } |
| 282 | |
| 283 | bool ProcessAccessHelp::disassembleMemory(BYTE * dataBuffer, SIZE_T bufferSize, DWORD_PTR startOffset) |
| 284 | { |
| 285 | // Holds the result of the decoding. |
| 286 | _DecodeResult res; |
| 287 | |
| 288 | // next is used for instruction's offset synchronization. |
| 289 | // decodedInstructionsCount holds the count of filled instructions' array by the decoder. |
| 290 | |
| 291 | decodedInstructionsCount = 0; |
| 292 | |
| 293 | _OffsetType offset = startOffset; |
| 294 | |
| 295 | res = distorm_decode(offset, dataBuffer, (int)bufferSize, dt, decodedInstructions, MAX_INSTRUCTIONS, &decodedInstructionsCount); |
| 296 | |
| 297 | /* for (unsigned int i = 0; i < decodedInstructionsCount; i++) { |
| 298 | #ifdef SUPPORT_64BIT_OFFSET |
| 299 | printf("%0*I64x (%02d) %-24s %s%s%s\n", dt != Decode64Bits ? 8 : 16, decodedInstructions[i].offset, decodedInstructions[i].size, (char*)decodedInstructions[i].instructionHex.p, (char*)decodedInstructions[i].mnemonic.p, decodedInstructions[i].operands.length != 0 ? " " : "", (char*)decodedInstructions[i].operands.p); |
| 300 | #else |
| 301 | printf("%08x (%02d) %-24s %s%s%s\n", decodedInstructions[i].offset, decodedInstructions[i].size, (char*)decodedInstructions[i].instructionHex.p, (char*)decodedInstructions[i].mnemonic.p, decodedInstructions[i].operands.length != 0 ? " " : "", (char*)decodedInstructions[i].operands.p); |
| 302 | #endif |
| 303 | |
| 304 | }*/ |
| 305 | |
| 306 | if (res == DECRES_INPUTERR) |
| 307 | { |
| 308 | #ifdef DEBUG_COMMENTS |
| 309 | Scylla::debugLog.log(L"disassembleMemory :: res == DECRES_INPUTERR"); |
| 310 | #endif |
| 311 | return false; |
| 312 | } |
| 313 | else if (res == DECRES_SUCCESS) |
| 314 | { |
| 315 | //printf("disassembleMemory :: res == DECRES_SUCCESS\n"); |
| 316 | return true; |
| 317 | } |
| 318 | else |
| 319 | { |
| 320 | #ifdef DEBUG_COMMENTS |
| 321 | Scylla::debugLog.log(L"disassembleMemory :: res == %d", res); |
| 322 | #endif |
| 323 | return true; //not all instructions fit in buffer |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | DWORD_PTR ProcessAccessHelp::findPattern(DWORD_PTR startOffset, DWORD size, BYTE * pattern, const char * mask) |
| 328 | { |