forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisassembleCode.cpp
More file actions
29 lines (24 loc) · 799 Bytes
/
Copy pathDisassembleCode.cpp
File metadata and controls
29 lines (24 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <vector>
#include <cstdint>
#include <beaengine/BeaEngine.h>
#include "NativeCore.hpp"
extern "C" bool DisassembleCode(RC_Pointer address, RC_Size length, RC_Pointer virtualAddress, InstructionData* instruction)
{
DISASM disasm = {};
disasm.Options = NasmSyntax;
#ifdef RECLASSNET64
disasm.Archi = 64;
#endif
disasm.VirtualAddr = reinterpret_cast<UInt64>(virtualAddress);
disasm.EIP = reinterpret_cast<UIntPtr>(address);
disasm.SecurityBlock = static_cast<UInt32>(length);
auto disamLength = Disasm(&disasm);
if (disamLength == OUT_OF_BLOCK || disamLength == UNKNOWN_OPCODE)
{
return false;
}
instruction->Length = disamLength;
std::memcpy(instruction->Data, address, disamLength);
MultiByteToUnicode(disasm.CompleteInstr, instruction->Instruction, 64);
return true;
}