问题
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