我的 Windows 服务使用 CreateEvent 创建 2 个事件,以便与用户应用程序进行通信。
该服务和用户应用程序不在同一用户帐户下运行。
用户应用程序打开事件并将其设置为有信号,不会出现错误。但该服务从未收到该事件。另一个事件的作用方向相反。
所以我认为这些事件错过了同步权利。
Service:
SECURITY_ATTRIBUTES security;
ZeroMemory(&security, sizeof(security));
security.nLength = sizeof(security);
ConvertStringSecurityDescriptorToSecurityDescriptor(L"D:P(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GWGR;;;IU)", SDDL_REVISION_1, &security.lpSecurityDescriptor, NULL);
EvtCreateNewUserSession = CreateEventW(
&security, // security attributes
TRUE, // manual-reset event
FALSE, // initial state is not signaled
L"Global\\MyEvent" // object name
);
互动应用程序:
HANDLE EvtCreateNewUserSession = OpenEventW(
EVENT_MODIFY_STATE | SYNCHRONIZE, // default security attributes
FALSE, // initial state is not signaled
L"Global\\MyEvent" // object name
;
感谢您的帮助,
Olivier
使用 0xXXXXXXXX 格式而不是使用“字符串 SDDL 权限”(如 GA)(您可以组合标志,然后将它们转换为十六进制字符串)。
例如这个 SDDL:D:(A;;0x001F0003;;;BA)(A;;0x00100002;;;AU)
创建 DACL 用于:
- BA=Administrators, 0x001F0003=EVENT_ALL_ACCESS (LocalSystem and LocalService are in Administrators group, but NetworkService is not)
- AU=Authenticated Users, 0x00100002=SYNCHRONIZE | EVENT_MODIFY_STATE
http://msdn.microsoft.com/en-us/library/windows/desktop/aa374928(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/aa374928(v=vs.85).aspx- 场地rights
A string that indicates the access rights controlled by the ACE.
This string can be a hexadecimal string representation of the access rights,
such as "0x7800003F", or it can be a concatenation of the following strings.
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)