【发布时间】:2012-11-08 12:50:20
【问题描述】:
所以我现在正在尝试操作几个 pinvoke 函数,但我不知道在哪里可以找到 SECURITY_INFORMATION 中每个标志的值?
这里是link
我已经访问过 PInvoke 站点,它对 SECURITY_INFORMATION 的定义似乎不正确。 Here
我认为它不正确的原因是因为我在尝试调用 ConvertSecurityDescriptorToStringSecurityDescriptor 方法时抛出了以下错误。
A call to PInvoke function 'ConvertSecurityDescriptorToStringSecurityDescriptor'
has unbalanced the stack. This is likely because the managed PInvoke signature
does not match the unmanaged target signature. Check that the calling
convention and parameters of the PInvoke signature match the target
unmanaged signature.
但我再次有兴趣弄清楚如何找到我提供的 MSDN 文章中列出的每个标志的十六进制值。就好像人们只是神奇地生成了这些值并且它们是正确的,即使在那篇文章中没有任何记录它们的迹象。
编辑 1
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool ConvertSecurityDescriptorToStringSecurityDescriptor(IntPtr SecurityDescriptor,
uint RequestedStringSDRevision,
SECURITY_INFORMATION SecurityInformation,
out IntPtr StringSecurityDescriptor,
out int StringSecurityDescriptorLen);
[Flags]
public enum SECURITY_INFORMATION {
OWNER_SECURITY_INFORMATION = 0x00000001,
GROUP_SECURITY_INFORMATION = 0x00000002,
DACL_SECURITY_INFORMATION = 0x00000004,
SACL_SECURITY_INFORMATION = 0x00000008,
UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000,
UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000,
PROTECTED_SACL_SECURITY_INFORMATION = 0x40000000
}
【问题讨论】:
-
为什么在调用 ConvertStringSecurityDescriptorToSecurityDescriptor 时使用 SECURITY_INFORMATION 标志?
-
因为我没有调用 ConvertStringSecurityDescriptorToSecurityDescriptor 我正在调用 ConvertSecurityDescriptorToStringSecurityDescriptor。
-
噢!是的,那会更有意义。您可以发布用于函数调用的 PInvoke 签名吗?
-
有签名和标志,但我的问题是它们如何为枚举生成这些值。十六进制值。