您好我有一个执行以下操作的来源。
int[] context = new int[179];
context[0] = 65538; //context integer
GetThreadContext(PI.hThread, context); //from kernel32
ReadProcessMemory(PI.hProcess, context[41]+ 8, ref BaseAddress, 4, ref ReadWrite)
在谷歌搜索后,上下文[41]指的是EBX。知道为什么吗? PInvokes.net显示以下内容。
[StructLayout(LayoutKind.Sequential)]
public struct CONTEXT
{
public uint ContextFlags; //set this to an appropriate value
// Retrieved by CONTEXT_DEBUG_REGISTERS
public uint Dr0;
public uint Dr1;
public uint Dr2;
public uint Dr3;
public uint Dr6;
public uint Dr7;
// Retrieved by CONTEXT_FLOATING_POINT
public FLOATING_SAVE_AREA FloatSave;
// Retrieved by CONTEXT_SEGMENTS
public uint SegGs;
public uint SegFs;
public uint SegEs;
public uint SegDs;
// Retrieved by CONTEXT_INTEGER
public uint Edi;
public uint Esi;
public uint Ebx;
public uint Edx;
public uint Ecx;
public uint Eax;
// Retrieved by CONTEXT_CONTROL
public uint Ebp;
public uint Eip;
public uint SegCs;
public uint EFlags;
public uint Esp;
public uint SegSs;
// Retrieved by CONTEXT_EXTENDED_REGISTERS
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public byte[] ExtendedRegisters;
}
另外,为什么我们必须使用ebx + 8来获取lpbaseaddress?
答案 0 :(得分:1)
CONTEXT结构在winnt.h中定义。请注意,它具有基于处理器体系结构的不同定义。使用此结构定义来访问ebx寄存器而不是特定的开始偏移量。 EBX寄存器指向进程的PEB(进程环境块),其中Ldr指针包含基址。所有这些都用于称为'Dynamic Forking'的技术,以在另一个进程的上下文中运行进程。例如,用于恶意软件应用程序。