DLL shared memory problems with different session, service and user session

∥☆過路亽.° 提交于 2019-12-06 15:07:48

问题


first, Thank you read this :)

I use DLL shared Memory and using interlocked~ functions. (Win 7)

DLL loaded by service exe and user app exe.

you know, service session is 0, user session is 1 so different.

if DLL's shared memory value changed by user app exe, not reflected service's DLL shared memory value.

is there a way to sync service and user app's DLL shared memory?


回答1:


Shared sections don't work across session boundaries any more. Microsoft considered this a security problem and deliberately broke the feature, quite some time ago if memory serves. I believe each session now sees its own private copy of the section.

However memory mapped files (MMFs) work fine, and I use this in place of shared sections now. The only downer is that globally-available MMFs have to be created with high privilege, so I use a service to create the MMF.




回答2:


Try using global shared memory. Microsoft's documentation says:

Prefixing the file mapping object names with "Global\" allows processes to communicate with each other even if they are in different terminal server sessions.




回答3:


Don't forget that the credentials also plays a role when sharing memory accross sessions.

This requires that the first process must have the SeCreateGlobalPrivilege privilege



来源:https://stackoverflow.com/questions/10827743/dll-shared-memory-problems-with-different-session-service-and-user-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!