如何在 CreateEvent 的 SDDL 字符串中添加同步权

Oli*_*ier 5 windows service acl dacl

我的 Windows 服务使用 CreateEvent 创建 2 个事件,以便与用户应用程序进行通信。该服务和用户应用程序不在同一用户帐户下运行。用户应用程序打开事件并将其设置为有信号,不会出现错误。但该服务从未收到该事件。另一个事件的作用方向相反。所以我认为这些事件错​​过了同步权利。

服务:

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 
            );
Run Code Online (Sandbox Code Playgroud)

互动应用程序:

HANDLE EvtCreateNewUserSession = OpenEventW( 
EVENT_MODIFY_STATE | SYNCHRONIZE,       // default security attributes
FALSE,      // initial state is not signaled
L"Global\\MyEvent"      // object name 
;
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助,

奥利维尔

Kry*_*gaj 5

使用 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
Run Code Online (Sandbox Code Playgroud)

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. 
...
Run Code Online (Sandbox Code Playgroud)