所以我想操縱幾個pinvoke函數現在我無法弄清楚我在哪裏找到SECURITY_INFORMATION中每個標誌的值?如何確定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。 – meanbunny
Doh!是的,這會更有意義。你能發佈你正在使用的函數調用的PInvoke簽名嗎? –