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