我试图使用与C++功能WscRegisterForChanges在Windows 7崩溃使用WscRegisterForChanges
文档位于:
http://msdn.microsoft.com/en-us/library/bb432507(v=VS.85).aspx
我的问题是,即使回调正确执行时,代码在回调执行结束时崩溃。
下面是有问题的代码。这是非常简单的,所以我不知道为什么它的崩溃:
#include #include #include void SecurityCenterChangeOccurred(void *param) { printf("Change occurred!\n"); } int main() { HRESULT result = S_OK; HANDLE callbackRegistration = NULL; result = WscRegisterForChanges( NULL, &callbackRegistration, (LPTHREAD_START_ROUTINE)SecurityCenterChangeOccurred, NULL); while(1) { Sleep(100); } return 0; }
我的调用堆栈看起来像这样,当发生崩溃:
> 00faf6e8() [email protected]() + 0x1293 bytes [email protected]@12() + 0x12 bytes [email protected]() + 0x27 bytes [email protected]() + 0x1b bytes
如果我添加了ExitThread(0);到SecurityCenterChangeOccurred年底,我得到一个错误,下面的跟踪(所以我不认为我应该使用了ExitThread):
Unhandled exception at 0x7799852b (ntdll.dll) in WscRegisterForChangesCrash.exe: 0xC000071C: An invalid thread, handle %p, is specified for this operation. Possibly, a threadpool worker thread was specified. [email protected]() + 0x3ca2f bytes [email protected]() + 0x30 bytes > WscRegisterForChangesCrash.exe!SecurityCenterChangeOccurred(void * param=0x00000000) Line 8 + 0xa bytes C++ wscapi.dll!WorkItemWrapper() + 0x19 bytes [email protected]() + 0xdf bytes [email protected]() + 0x1293 bytes [email protected]@12() + 0x12 bytes [email protected]() + 0x27 bytes [email protected]() + 0x1b bytes
有没有人有,为什么这可能发生的任何想法?
要触发崩溃运行程序并打开或关闭防火墙。