2013-09-27 25 views
3

我的Windows服務使用CreateEvent創建2個事件,以便與用戶應用程序進行通信。 該服務和用戶應用程序不在同一用戶帳戶下運行。 用戶應用程序打開該事件並將其設置爲無錯信號。但該服務從未收到該活動。另一個事件的方向相反。 所以我認爲這些事件錯​​過了同步化權利。如何在CreateEvent的SDDL字符串中添加同步權

服務:

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 
; 

感謝您的幫助,

奧利維爾

回答

3

而不是使用 '字符串SDDL權利'(如GA)使用0xXXXXXXXX格式(您可以組合標誌,然後將它們轉換爲十六進制字符串)。

例如,這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 - 場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. 
... 
+0

是的,你說得對。由於syncronization權限不存在SDDL字符串,唯一的解決方案是使用全局十六進制字符串。 – Olivier