我的程序在 Windows Vista Ultimate 和 Windows 7 上完美运行,但在 Windows XP 上失败。
首先,我的应用程序创建一个系统文件的进程,它调用 GetThreadContext(remote_thread) 并将 LPVOID 值设置为值 context->Eip,然后检查从 VirtualQueryEx 设置的结构 MEMORY_BASIC_INFORMATION 中的值。
以下是 VirtualQueryEx 调用时返回的值:
视窗XP
- 0 - 分配基础
- 0 - 分配保护
- 2088828928 - 基址
- 1 - 保护
- 983040 - 区域大小
- 65536-状态
- 0 - type
Windows 7的
- 2003959808 - 分配基数
- 128 - 分配保护
- 2004025344 - 基址
- 32 - 保护
- 876544 - 区域大小
- 分段阅读_第 4096 章
- 16777216 - 类型
视窗Vista
- 2006122496 - 分配基数
- 128 - 分配保护
- 2006536192 - 基址
- 32 - 保护
- 389120 - 区域大小
- 分段阅读_第 4096 章
- 16777216 - 类型
为什么当我在 Windows XP 上运行我的应用程序时,它没有分配基础,没有分配保护,并且与 Windows 7 和 Windows Vista 的值完全不同。
我计划在地址(context->Eip)上使用VirtualProtectEx,所以如果这些是XP上的值,那么VirtualProtectEx将不可避免地失败,因为我将访问无法访问的内存。
这是我创建流程的方法:
if ( CreateProcessW(m_pwszContainerPath, NULL, NULL, NULL, FALSE, DETACHED_PROCESS | CREATE_SUSPENDED, NULL, NULL, &m_stStartInfo, &m_stProcessHandles) == TRUE )
{
// Get context of thread
m_stContext.ContextFlags = CONTEXT_FULL;
if ( GetThreadContext(m_stProcessHandles.hThread, &m_stContext) == FALSE )
goto _CLEANUP;
// Grab, Eip
m_pvLdrInitEip = (LPVOID)m_stContext.Eip;
}
事实是:这在 Windows 7 和 Windows Vista 上都能完美运行。
我在这里缺少什么吗?
感谢您的任何帮助。
编辑-这是一张图片:
Here is a picture of two instances of olly running the executable, one in the XP virtual machine, one outside. From what I notice, the XP picture (bottom one) has it's EIP set to ModuleEntryPoint while the Windows 7 Instance has it set to ntdll..
我进一步调查,发现 EIP 实际上位于 kernel32.dll 映像中(在 Windows XP 上),而不是应有的 ntdll.dll 中。