C++部分类型定义:
typedef struct _SID_AND_ATTRIBUTES_HASH {
DWORD SidCount;
PSID_AND_ATTRIBUTES SidAttr;
SID_HASH_ENTRY Hash[SID_HASH_SIZE];
} SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
typedef struct _LUID {
DWORD LowPart;
LONG HighPart;
} LUID, *PLUID;
typedef enum _TOKEN_TYPE {
TokenPrimary = 1,
TokenImpersonation
} TOKEN_TYPE;
typedef TOKEN_TYPE *PTOKEN_TYPE;
typedef enum _SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation
} SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
typedef PVOID PSID;
///
C++要转换的类型:
struct TOKEN_ACCESS_INFORMATION {
PTOKEN_PRIVILEGES Privileges; //结构体指针
LUID AuthenticationId; //结构体
TOKEN_TYPE TokenType; //枚举类型enum
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; //枚举类型enum
DWORD Flags;
DWORD AppContainerNumber;
PSID PackageSid;
PSID TrustLevelSid;
};
///
C#对应的类型:
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct TOKEN_ACCESS_INFORMATION {
/// PTOKEN_PRIVILEGES->_TOKEN_PRIVILEGES*
public System.IntPtr Privileges;
/// LUID->_LUID
public LUID AuthenticationId;
/// TOKEN_TYPE->_TOKEN_TYPE
public TOKEN_TYPE TokenType;
/// SECURITY_IMPERSONATION_LEVEL->_SECURITY_IMPERSONATION_LEVEL
public SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
/// DWORD->unsigned int
public uint Flags;
/// DWORD->unsigned int
public uint AppContainerNumber;
/// PSID->PVOID->void*
public System.IntPtr PackageSid;
/// PSID->PVOID->void*
public System.IntPtr TrustLevelSid;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct LUID {
/// DWORD->unsigned int
public uint LowPart;
/// LONG->int
public int HighPart;
}
public enum TOKEN_TYPE {
/// TokenPrimary -> 1
TokenPrimary = 1,
TokenImpersonation,
}
public enum SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation,
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct TOKEN_PRIVILEGES {
/// DWORD->unsigned int
public uint PrivilegeCount;
/// LUID_AND_ATTRIBUTES[1]
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1, ArraySubType=System.Runtime.InteropServices.UnmanagedType.Struct)]
public LUID_AND_ATTRIBUTES[] Privileges;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct LUID_AND_ATTRIBUTES {
/// LUID->_LUID
public LUID Luid;
/// DWORD->unsigned int
public uint Attributes;
}