MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / DisassembleBytes

Method DisassembleBytes

ReClass/CNodeFunctionPtr.cpp:192–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void CNodeFunctionPtr::DisassembleBytes( ULONG_PTR Address )
193{
194 UCHAR Code[2048] = { 0xCC }; // max function length
195 UIntPtr VirtualAddress = Address;
196
197 // Clear old disassembly info
198 m_pAssemblyWindow->SetReadOnly( FALSE );
199 m_pAssemblyWindow->Clear( );
200 m_pAssemblyWindow->SetReadOnly( TRUE );
201
202 m_Assembly.clear( );
203 m_nLongestLine = 0;
204
205 // Read in process bytes
206 if (ReClassReadMemory( (LPVOID)VirtualAddress, (LPVOID)&VirtualAddress, sizeof( UIntPtr ) ) &&
207 ReClassReadMemory( (LPVOID)VirtualAddress, (LPVOID)Code, 2048 ))
208 {
209 DISASM MyDisasm;
210 BOOL Error = FALSE;
211 UIntPtr EndCodeSection = (UIntPtr)(Code + 2048);
212
213 ZeroMemory( &MyDisasm, sizeof( DISASM ) );
214 MyDisasm.EIP = (UIntPtr)Code;
215 MyDisasm.VirtualAddr = (UInt64)VirtualAddress;
216 #ifdef _WIN64
217 MyDisasm.Archi = 64;
218 #else
219 MyDisasm.Archi = 0;
220 #endif
221 MyDisasm.Options = MasmSyntax | PrefixedNumeral | ShowSegmentRegs;
222
223 // Get assembly lines
224 while (Error == FALSE)
225 {
226 int disasmLen = 0;
227
228 MyDisasm.SecurityBlock = (UInt32)(EndCodeSection - MyDisasm.EIP);
229
230 disasmLen = Disasm( &MyDisasm );
231 if (disasmLen == OUT_OF_BLOCK || disasmLen == UNKNOWN_OPCODE)
232 {
233 Error = TRUE;
234 }
235 else
236 {
237 CHAR szInstruction[256] = { 0 };
238 CHAR szBytes[128] = { 0 };
239
240 // INT3 instruction usually indicates the end of a function
241 if (MyDisasm.Instruction.Opcode == 0xCC)
242 break;
243
244 // Generate instruction bytes
245 for (int i = 0; i < disasmLen; i++)
246 {
247 CHAR szByte[8];
248 sprintf_s( szByte, "%02X ", *(UCHAR*)(MyDisasm.EIP + i) );
249 strcat_s( szBytes, szByte );

Callers

nothing calls this directly

Calls 11

ReClassReadMemoryFunction · 0.85
DisasmClass · 0.85
clearMethod · 0.80
AppendTextMethod · 0.80
LineLengthMethod · 0.80
PointYFromPositionMethod · 0.80
PositionFromLineMethod · 0.80
SetReadOnlyMethod · 0.45
ClearMethod · 0.45
sizeMethod · 0.45
SetSelectionMethod · 0.45

Tested by

no test coverage detected