1 /* 2 * PROJECT: Authentication Package DLL 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: dll/win32/msv1_0/msv1_0.h 5 * PURPOSE: Common header file 6 * COPYRIGHT: Copyright 2013 Eric Kohl 7 */ 8 9 #define FIXUP_POINTER(Pointer, Offset) ((Pointer != NULL) ? ((PWSTR)((ULONG_PTR)Pointer + Offset)) : NULL) 10 11 12 typedef struct _RPC_SID 13 { 14 UCHAR Revision; 15 UCHAR SubAuthorityCount; 16 SID_IDENTIFIER_AUTHORITY IdentifierAuthority; 17 DWORD SubAuthority[]; 18 } RPC_SID, *PRPC_SID; 19 20 typedef struct _RPC_UNICODE_STRING 21 { 22 unsigned short Length; 23 unsigned short MaximumLength; 24 wchar_t *Buffer; 25 } RPC_UNICODE_STRING, *PRPC_UNICODE_STRING; 26 27 typedef wchar_t *PSAMPR_SERVER_NAME; 28 typedef void *SAMPR_HANDLE; 29 30 typedef struct _OLD_LARGE_INTEGER 31 { 32 unsigned long LowPart; 33 long HighPart; 34 } OLD_LARGE_INTEGER, *POLD_LARGE_INTEGER; 35 36 typedef struct RPC_SHORT_BLOB 37 { 38 unsigned short Length; 39 unsigned short MaximumLength; 40 unsigned short *Buffer; 41 } RPC_SHORT_BLOB, *PRPC_SHORT_BLOB; 42 43 typedef struct _SAMPR_SR_SECURITY_DESCRIPTOR 44 { 45 unsigned long Length; 46 unsigned char *SecurityDescriptor; 47 } SAMPR_SR_SECURITY_DESCRIPTOR, *PSAMPR_SR_SECURITY_DESCRIPTOR; 48 49 typedef struct _ENCRYPTED_LM_OWF_PASSWORD 50 { 51 char data[16]; 52 } ENCRYPTED_LM_OWF_PASSWORD, *PENCRYPTED_LM_OWF_PASSWORD, ENCRYPTED_NT_OWF_PASSWORD, *PENCRYPTED_NT_OWF_PASSWORD; 53 54 typedef struct _SAMPR_ULONG_ARRAY 55 { 56 ULONG Count; 57 PULONG Element; 58 } SAMPR_ULONG_ARRAY, *PSAMPR_ULONG_ARRAY; 59 60 typedef struct _SAMPR_LOGON_HOURS 61 { 62 unsigned short UnitsPerWeek; 63 unsigned char *LogonHours; 64 } SAMPR_LOGON_HOURS, *PSAMPR_LOGON_HOURS; 65 66 #define USER_LOGON_BAD_PASSWORD 0x08000000 67 #define USER_LOGON_SUCCESS 0x10000000 68 69 typedef struct _SAMPR_USER_INTERNAL2_INFORMATION 70 { 71 unsigned long Flags; 72 OLD_LARGE_INTEGER LastLogon; 73 OLD_LARGE_INTEGER LastLogoff; 74 unsigned short BadPasswordCount; 75 unsigned short LogonCount; 76 } SAMPR_USER_INTERNAL2_INFORMATION, *PSAMPR_USER_INTERNAL2_INFORMATION; 77 78 typedef struct _SAMPR_USER_ALL_INFORMATION 79 { 80 OLD_LARGE_INTEGER LastLogon; 81 OLD_LARGE_INTEGER LastLogoff; 82 OLD_LARGE_INTEGER PasswordLastSet; 83 OLD_LARGE_INTEGER AccountExpires; 84 OLD_LARGE_INTEGER PasswordCanChange; 85 OLD_LARGE_INTEGER PasswordMustChange; 86 RPC_UNICODE_STRING UserName; 87 RPC_UNICODE_STRING FullName; 88 RPC_UNICODE_STRING HomeDirectory; 89 RPC_UNICODE_STRING HomeDirectoryDrive; 90 RPC_UNICODE_STRING ScriptPath; 91 RPC_UNICODE_STRING ProfilePath; 92 RPC_UNICODE_STRING AdminComment; 93 RPC_UNICODE_STRING WorkStations; 94 RPC_UNICODE_STRING UserComment; 95 RPC_UNICODE_STRING Parameters; 96 RPC_SHORT_BLOB LmOwfPassword; 97 RPC_SHORT_BLOB NtOwfPassword; 98 RPC_UNICODE_STRING PrivateData; 99 SAMPR_SR_SECURITY_DESCRIPTOR SecurityDescriptor; 100 unsigned long UserId; 101 unsigned long PrimaryGroupId; 102 unsigned long UserAccountControl; 103 unsigned long WhichFields; 104 SAMPR_LOGON_HOURS LogonHours; 105 unsigned short BadPasswordCount; 106 unsigned short LogonCount; 107 unsigned short CountryCode; 108 unsigned short CodePage; 109 unsigned char LmPasswordPresent; 110 unsigned char NtPasswordPresent; 111 unsigned char PasswordExpired; 112 unsigned char PrivateDataSensitive; 113 } SAMPR_USER_ALL_INFORMATION, *PSAMPR_USER_ALL_INFORMATION; 114 115 typedef union _SAMPR_USER_INFO_BUFFER 116 { 117 #if 0 118 SAMPR_USER_GENERAL_INFORMATION General; 119 SAMPR_USER_PREFERENCES_INFORMATION Preferences; 120 SAMPR_USER_LOGON_INFORMATION Logon; 121 SAMPR_USER_LOGON_HOURS_INFORMATION LogonHours; 122 SAMPR_USER_ACCOUNT_INFORMATION Account; 123 SAMPR_USER_NAME_INFORMATION Name; 124 SAMPR_USER_A_NAME_INFORMATION AccountName; 125 SAMPR_USER_F_NAME_INFORMATION FullName; 126 USER_PRIMARY_GROUP_INFORMATION PrimaryGroup; 127 SAMPR_USER_HOME_INFORMATION Home; 128 SAMPR_USER_SCRIPT_INFORMATION Script; 129 SAMPR_USER_PROFILE_INFORMATION Profile; 130 SAMPR_USER_ADMIN_COMMENT_INFORMATION AdminComment; 131 SAMPR_USER_WORKSTATIONS_INFORMATION WorkStations; 132 SAMPR_USER_SET_PASSWORD_INFORMATION SetPassword; 133 USER_CONTROL_INFORMATION Control; 134 USER_EXPIRES_INFORMATION Expires; 135 SAMPR_USER_INTERNAL1_INFORMATION Internal1; 136 #endif 137 SAMPR_USER_INTERNAL2_INFORMATION Internal2; 138 #if 0 139 SAMPR_USER_PARAMETERS_INFORMATION Parameters; 140 #endif 141 SAMPR_USER_ALL_INFORMATION All; 142 #if 0 143 SAMPR_USER_INTERNAL4_INFORMATION Internal4; 144 SAMPR_USER_INTERNAL5_INFORMATION Internal5; 145 SAMPR_USER_INTERNAL4_INFORMATION_NEW Internal4New; 146 SAMPR_USER_INTERNAL5_INFORMATION_NEW Internal5New; 147 #endif 148 } SAMPR_USER_INFO_BUFFER, *PSAMPR_USER_INFO_BUFFER; 149 150 151 NTSTATUS 152 NTAPI 153 SamIConnect(IN PSAMPR_SERVER_NAME ServerName, 154 OUT SAMPR_HANDLE *ServerHandle, 155 IN ACCESS_MASK DesiredAccess, 156 IN BOOLEAN Trusted); 157 158 VOID 159 NTAPI 160 SamIFreeVoid(PVOID Ptr); 161 162 VOID 163 NTAPI 164 SamIFree_SAMPR_ULONG_ARRAY(PSAMPR_ULONG_ARRAY Ptr); 165 166 VOID 167 NTAPI 168 SamIFree_SAMPR_USER_INFO_BUFFER(PSAMPR_USER_INFO_BUFFER Ptr, 169 USER_INFORMATION_CLASS InformationClass); 170 171 NTSTATUS 172 NTAPI 173 SamrChangePasswordUser(IN SAMPR_HANDLE UserHandle, 174 IN unsigned char LmPresent, 175 IN PENCRYPTED_LM_OWF_PASSWORD OldLmEncryptedWithNewLm, 176 IN PENCRYPTED_LM_OWF_PASSWORD NewLmEncryptedWithOldLm, 177 IN unsigned char NtPresent, 178 IN PENCRYPTED_NT_OWF_PASSWORD OldNtEncryptedWithNewNt, 179 IN PENCRYPTED_NT_OWF_PASSWORD NewNtEncryptedWithOldNt, 180 IN unsigned char NtCrossEncryptionPresent, 181 IN PENCRYPTED_NT_OWF_PASSWORD NewNtEncryptedWithNewLm, 182 IN unsigned char LmCrossEncryptionPresent, 183 IN PENCRYPTED_LM_OWF_PASSWORD NewLmEncryptedWithNewNt); 184 185 NTSTATUS 186 NTAPI 187 SamrCloseHandle(IN OUT SAMPR_HANDLE *SamHandle); 188 189 NTSTATUS 190 NTAPI 191 SamrLookupDomainInSamServer(IN SAMPR_HANDLE ServerHandle, 192 IN PRPC_UNICODE_STRING Name, 193 OUT PRPC_SID *DomainId); 194 195 NTSTATUS 196 NTAPI 197 SamrLookupNamesInDomain(IN SAMPR_HANDLE DomainHandle, 198 IN ULONG Count, 199 IN RPC_UNICODE_STRING Names[], 200 OUT PSAMPR_ULONG_ARRAY RelativeIds, 201 OUT PSAMPR_ULONG_ARRAY Use); 202 203 NTSTATUS 204 NTAPI 205 SamrOpenDomain(IN SAMPR_HANDLE ServerHandle, 206 IN ACCESS_MASK DesiredAccess, 207 IN PRPC_SID DomainId, 208 OUT SAMPR_HANDLE *DomainHandle); 209 210 NTSTATUS 211 NTAPI 212 SamrOpenUser(IN SAMPR_HANDLE DomainHandle, 213 IN ACCESS_MASK DesiredAccess, 214 IN ULONG UserId, 215 OUT SAMPR_HANDLE *UserHandle); 216 217 NTSTATUS 218 NTAPI 219 SamrQueryInformationUser(IN SAMPR_HANDLE UserHandle, 220 IN USER_INFORMATION_CLASS UserInformationClass, 221 OUT PSAMPR_USER_INFO_BUFFER *Buffer); 222 223 NTSTATUS 224 NTAPI 225 SamrSetInformationUser(IN SAMPR_HANDLE UserHandle, 226 IN USER_INFORMATION_CLASS UserInformationClass, 227 IN PSAMPR_USER_INFO_BUFFER Buffer); 228 229 typedef PVOID LSAPR_HANDLE; 230 231 typedef struct _LSAPR_POLICY_AUDIT_EVENTS_INFO 232 { 233 BOOLEAN AuditingMode; 234 DWORD *EventAuditingOptions; 235 DWORD MaximumAuditEventCount; 236 } LSAPR_POLICY_AUDIT_EVENTS_INFO, *PLSAPR_POLICY_AUDIT_EVENTS_INFO; 237 238 typedef struct _LSAPR_POLICY_PRIMARY_DOM_INFO 239 { 240 RPC_UNICODE_STRING Name; 241 PRPC_SID Sid; 242 } LSAPR_POLICY_PRIMARY_DOM_INFO, *PLSAPR_POLICY_PRIMARY_DOM_INFO; 243 244 typedef struct _LSAPR_POLICY_ACCOUNT_DOM_INFO 245 { 246 RPC_UNICODE_STRING DomainName; 247 PRPC_SID Sid; 248 } LSAPR_POLICY_ACCOUNT_DOM_INFO, *PLSAPR_POLICY_ACCOUNT_DOM_INFO; 249 250 typedef struct _LSAPR_POLICY_PD_ACCOUNT_INFO 251 { 252 RPC_UNICODE_STRING Name; 253 } LSAPR_POLICY_PD_ACCOUNT_INFO, *PLSAPR_POLICY_PD_ACCOUNT_INFO; 254 255 typedef struct _POLICY_LSA_REPLICA_SRCE_INFO 256 { 257 RPC_UNICODE_STRING ReplicaSource; 258 RPC_UNICODE_STRING ReplicaAccountName; 259 } POLICY_LSA_REPLICA_SRCE_INFO, *PPOLICY_LSA_REPLICA_SRCE_INFO; 260 261 typedef struct _LSAPR_POLICY_DNS_DOMAIN_INFO 262 { 263 RPC_UNICODE_STRING Name; 264 RPC_UNICODE_STRING DnsDomainName; 265 RPC_UNICODE_STRING DnsForestName; 266 GUID DomainGuid; 267 PRPC_SID Sid; 268 } LSAPR_POLICY_DNS_DOMAIN_INFO, *PLSAPR_POLICY_DNS_DOMAIN_INFO; 269 270 typedef union _LSAPR_POLICY_INFORMATION 271 { 272 POLICY_AUDIT_LOG_INFO PolicyAuditLogInfo; 273 LSAPR_POLICY_AUDIT_EVENTS_INFO PolicyAuditEventsInfo; 274 LSAPR_POLICY_PRIMARY_DOM_INFO PolicyPrimaryDomInfo; 275 LSAPR_POLICY_PD_ACCOUNT_INFO PolicyPdAccountInfo; 276 LSAPR_POLICY_ACCOUNT_DOM_INFO PolicyAccountDomainInfo; 277 POLICY_LSA_SERVER_ROLE_INFO PolicyServerRoleInfo; 278 POLICY_LSA_REPLICA_SRCE_INFO PolicyReplicaSourceInfo; 279 POLICY_DEFAULT_QUOTA_INFO PolicyDefaultQuotaInfo; 280 POLICY_MODIFICATION_INFO PolicyModificationInfo; 281 POLICY_AUDIT_FULL_SET_INFO PolicyAuditFullSetInfo; 282 POLICY_AUDIT_FULL_QUERY_INFO PolicyAuditFullQueryInfo; 283 LSAPR_POLICY_DNS_DOMAIN_INFO PolicyDnsDomainInfo; 284 LSAPR_POLICY_DNS_DOMAIN_INFO PolicyDnsDomainInfoInt; 285 LSAPR_POLICY_ACCOUNT_DOM_INFO PolicyLocalAccountDomainInfo; 286 } LSAPR_POLICY_INFORMATION, *PLSAPR_POLICY_INFORMATION; 287 288 VOID 289 NTAPI 290 LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass, 291 IN PLSAPR_POLICY_INFORMATION PolicyInformation); 292 293 NTSTATUS 294 WINAPI 295 LsaIOpenPolicyTrusted(OUT LSAPR_HANDLE *PolicyHandle); 296 297 NTSTATUS 298 WINAPI 299 LsarClose(IN OUT LSAPR_HANDLE *ObjectHandle); 300 301 NTSTATUS 302 WINAPI 303 LsarLookupPrivilegeValue(IN LSAPR_HANDLE PolicyHandle, 304 IN PRPC_UNICODE_STRING Name, 305 OUT PLUID Value); 306 307 NTSTATUS 308 WINAPI 309 LsarQueryInformationPolicy(IN LSAPR_HANDLE PolicyHandle, 310 IN POLICY_INFORMATION_CLASS InformationClass, 311 OUT PLSAPR_POLICY_INFORMATION *PolicyInformation); 312 313 NTSTATUS 314 WINAPI 315 SystemFunction006(LPCSTR password, 316 LPSTR hash); 317 318 NTSTATUS 319 WINAPI 320 SystemFunction007(PUNICODE_STRING string, 321 LPBYTE hash); 322 323 NTSTATUS 324 WINAPI 325 SystemFunction012(const BYTE *in, 326 const BYTE *key, 327 LPBYTE out); 328 329 /* EOF */ 330