简体   繁体   English

EnumProcessModules在32位win7上失败,错误299

[英]EnumProcessModules failed with error 299 on 32bit win7

My code is running on win7 32bit, but when I use EnumProcessModules , it returned false and getlasterror() return error code 299, which declare that the program is 32bit and this statement can not be running on 64bit system. 我的代码在win7 32bit上运行,但是当我使用EnumProcessModules ,它返回false并且getlasterror()返回错误代码299,它声明程序是32位且该语句不能在64位系统上运行。

I wonder why this happens, and why the system thinks that I am running on a 64bit OS? 我想知道为什么会这样,为什么系统认为我在64位操作系统上运行?

The code I use: 我使用的代码:

         HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPid);
         if (hProcess)
         {
            HMODULE hMod = NULL;
            DWORD cbNeeded = 0;
            if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
            {
              //do something here...
            }
         }

dwPid is the id of the process I want to manipulate. dwPid是我想要操作的进程的id。

PS.This error just happen on one of my test machine, others are fine. PS。这个错误只发生在我的一台测试机上,其他的都很好。 So This problem may be related to that specific machine or system configration? 那么这个问题可能与特定的机器或系统配置有关?

Though It has been a while since you posted this question.But I thought of giving it a try . 虽然你发布这个问题已经有一段时间了。但我想试一试。

Reason might be because You are using CreateProcessA in your code.. and suddenly calling EnumProcessModules.Thus windows is not able to create ModuleInfo by that time.And it returns error 299(Thinking its a 64 bit system.. as it fails to read the memory). 原因可能是因为您在代码中使用了CreateProcessA ..并突然调用EnumProcessModules.Thus窗口无法在那时创建ModuleInfo。它返回错误299(认为它是64位系统..因为它无法读取记忆)。

Actually I was stuck at this too and figured it out..after looking at your post. 实际上我也被困在这里,并在看完你的帖子后想出来了。 Thanks 谢谢

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx CreatProcess Remarks.. It ask to call WaitforInput Idle before proceeding.;-) http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx CreatProcess备注..它要求在继续之前调用WaitforInput空闲。;-)

The calling thread can use the WaitForInputIdle function to wait until the new process has finished its initialization and is waiting for user input with no input pending. 调用线程可以使用WaitForInputIdle函数等待新进程完成初始化并等待没有输入挂起的用户输入。 This can be useful for synchronization between parent and child processes, because CreateProcess returns without waiting for the new process to finish its initialization. 这对于父进程和子进程之间的同步很有用,因为CreateProcess在不等待新进程完成初始化的情况下返回。 For example, the creating process would use WaitForInputIdle before trying to find a window associated with the new process. 例如,在尝试查找与新进程关联的窗口之前,创建进程将使用WaitForInputIdle。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行msi会在32位win7中导致“模块注册失败”,但在64位win7中有效 - Running msi causes “module failed to register” in 32bit win7,but works in 64bit win7 C ++ Windows Shell扩展-Win7 32位-64位兼容性问题 - C++ Windows Shell Extensions - Win7 32bit - 64bit compatibility issues Python C-Api 32位PyDict_Check访问冲突,Win7,Python 2.66 - Python C-Api 32bit PyDict_Check Access Violation, Win7, Python 2.66 在Win7 64bit上崩溃未处理的第一次机会异常(在XP 32bit,Linux 64bit上没有问题) - Crash over unhandled first chance exception on Win7 64bit (no issue on XP 32bit, Linux 64bit) win7 32位下如何用C++ api通过TBBUTTONINFO结构体的iImage成员提取系统托盘上的图标? - How to extract the icon on system tray through the iImage member of TBBUTTONINFO structure with C++ api under win7 32bit? 为Win 7开发设置为32位 - Developing for Win 7 set to 32bit 为什么 EnumProcessModules 返回 FALSE 值和 299 代码错误? - Why EnumProcessModules is return FALSE value and 299 code error? LoadLibrary在Win7 32位上失败,在Win XP 32位上成功 - LoadLibrary failing on Win7 32 bit, succeeding on Win XP 32 bit 是否可以在intel / 64-bit win7上的32位应用程序中使用64位指令 - Is it possible to use 64-bit instruction in a 32-bit application on intel/64-bit win7 CreateRemoteThread在win7 64位上返回ERROR_ACCESS_DENIED(5) - CreateRemoteThread returns ERROR_ACCESS_DENIED (5) on win7 64 bit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM