winapi - 创建 tagSECURITY_ATTRIBUTES 对象

标签 winapi autoit

使用 _WinAPI_CreateFileMapping() 我想让同一台机器上的不同用户通过 _WinAPI_OpenFileMapping() 接收消息。当我尝试打开文件映射时收到错误消息(无效句柄错误 #6),这可能是安全设置的原因。

我找到了 this post关于文件映射和允许跨用户访问。解决方案是创建一个 NULL 安全标识符(不传递 NULL,而是传递一个有效的安全标识符,包含 NULL):

SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.NullSid, null);

如何在 AutoIt 中创建它并将其传递给 _WinAPI_CreateFileMapping()

发送端脚本(以本地用户身份运行):

Local $sid = _Security__StringSidToSid("S-1-0")     ; also tried S-1-1
$hMapping = _WinAPI_CreateFileMapping(-1, 2048, 'MyFileMapping',0x0004,$sid)  ;it seems to accept the sid
DllStructSetData($tData, 1, "IDL")  ; if($hMapping)  send the message...

接收服务脚本(以系统账户运行):

$hMapping = _WinAPI_OpenFileMapping('MyFileMapping')

还尝试通过只读。 0x0004 返回 0x0000 文件句柄/0 错误 0 扩展。一旦出现 1305 错误代码(无法复制)。

;  if($hMapping) ... this is how I am trying to receive the message:
$pAddress = _WinAPI_MapViewOfFile($hMapping)
$tData = DllStructCreate('wchar[1024]', $pAddress)
$Text = DllStructGetData($tData, 1)
DllStructSetData($tData, 1, '')

最佳答案

尝试使用 S-1-0-0 而不是 S-1-0

Source

关于winapi - 创建 tagSECURITY_ATTRIBUTES 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22919518/

相关文章:

delphi - 图像从 TWebBrowser 到 TPicture

windows - 如何使用 GDI 即时创建带 alpha channel 的位图?

android - 远程 AutoIt 鼠标控制脚本未执行

linux - Ubuntu 上的 Autoit key 重新映射(Ubuntu 上的第 2 天)?

windows - 如何使用 autoit 在特殊程序中打开文件?

testing - AutoIt 中的组合键

c++ - GDI+位图保存问题

WNDCLASSEX的概念,良好的编程习惯和系统类的WndProc

windows - IsAppThemed 和 IsThemeActive 有什么区别?

c++ - WinKill() 源代码