DLL 共享内存问题与不同的会话、服务和用户会话 [英] DLL shared memory problems with different session, service and user session

查看:50
本文介绍了DLL 共享内存问题与不同的会话、服务和用户会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,感谢您阅读本文:)

first, Thank you read this :)

我使用 DLL 共享内存并使用互锁~函数.(赢7)

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

服务 exe 和用户应用 exe 加载的 DLL.

DLL loaded by service exe and user app exe.

你知道,服务会话是 0,用户会话是 1,所以不同.

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

如果用户应用程序 exe 更改了 DLL 的共享内存值,则不会反映服务的 DLL 共享内存值.

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

有没有办法同步服务和用户应用程序的 DLL 共享内存?

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

推荐答案

共享部分不再跨会话边界工作.如果没记错的话,微软认为这是一个安全问题,并在很久以前故意破坏了该功能.我相信每个会话现在都会看到该部分的私有副本.

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.

但是内存映射文件 (MMF) 工作正常,我现在用它代替共享部分.唯一的缺点是全局可用的 MMF 必须以高权限创建,所以我使用一个服务来创建 MMF.

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.

这篇关于DLL 共享内存问题与不同的会话、服务和用户会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆