From 459d72e610dc6de2cd213c5acd641da17a9a1249 Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Sat, 14 Feb 2004 23:13:58 +0000 Subject: [PATCH] Implemented LsaFreeMemory and changed a few stubs to match WINE so Msys will load. svn path=/trunk/; revision=8176 --- reactos/lib/advapi32/sec/lsa.c | 169 +++++++++++++++++++++++++-------- 1 file changed, 131 insertions(+), 38 deletions(-) diff --git a/reactos/lib/advapi32/sec/lsa.c b/reactos/lib/advapi32/sec/lsa.c index 9240ee6a36a..46b94efad38 100644 --- a/reactos/lib/advapi32/sec/lsa.c +++ b/reactos/lib/advapi32/sec/lsa.c @@ -1,4 +1,4 @@ -/* $Id: lsa.c,v 1.7 2004/01/20 01:40:19 ekohl Exp $ +/* $Id: lsa.c,v 1.8 2004/02/14 23:13:58 sedwards Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -9,40 +9,132 @@ * 19990322 EA created * 19990515 EA stubs * 20030202 KJK compressed stubs + * */ #include #include #include +#include -/* +/****************************************************************************** + * LsaOpenPolicy [ADVAPI32.@] + * + * PARAMS + * x1 [] + * x2 [] + * x3 [] + * x4 [] + * * @unimplemented */ NTSTATUS STDCALL LsaOpenPolicy(PLSA_UNICODE_STRING lsaucs,PLSA_OBJECT_ATTRIBUTES lsaoa,ACCESS_MASK access,PLSA_HANDLE lsah) { - return(FALSE); + DPRINT1("LsaOpenPolicy - stub\n"); + return STATUS_SUCCESS; } /* * @unimplemented */ +#define SID_REVISION (1) /* Current revision - winnt.h */ + NTSTATUS STDCALL -LsaQueryInformationPolicy(LSA_HANDLE lsah,POLICY_INFORMATION_CLASS pic,PVOID* pv) +LsaQueryInformationPolicy(LSA_HANDLE lsah,POLICY_INFORMATION_CLASS pic,PVOID* Buffer) { - return(FALSE); + DPRINT1("(%p,0x%08x,%p):LsaQueryInformationPolicy stub\n", + lsah, pic, Buffer); + + if(!Buffer) return FALSE; + switch (pic) + { + case PolicyAuditEventsInformation: /* 2 */ + { + PPOLICY_AUDIT_EVENTS_INFO p = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO)); + p->AuditingMode = FALSE; /* no auditing */ + *Buffer = p; + } + break; + case PolicyPrimaryDomainInformation: /* 3 */ + case PolicyAccountDomainInformation: /* 5 */ + { + struct di + { POLICY_PRIMARY_DOMAIN_INFO ppdi; + SID sid; + }; + SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY}; + + struct di * xdi = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi)); + HKEY key; + BOOL useDefault = TRUE; + LONG ret; + + if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0, + KEY_READ, &key)) == ERROR_SUCCESS) + { + DWORD size = 0; + WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 }; + + ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size); + if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS) + { + xdi->ppdi.Name.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, size); + if ((ret = RegQueryValueExW(key, wg, NULL, NULL, + (LPBYTE)xdi->ppdi.Name.Buffer, &size)) == ERROR_SUCCESS) + { + xdi->ppdi.Name.Length = (USHORT)size; + useDefault = FALSE; + } + else + { + RtlFreeHeap(RtlGetProcessHeap(), 0, xdi->ppdi.Name.Buffer); + xdi->ppdi.Name.Buffer = NULL; + } + } + RegCloseKey(key); + } + if (useDefault) + RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN"); + DPRINT1("setting domain to \n"); + + xdi->ppdi.Sid = &(xdi->sid); + xdi->sid.Revision = SID_REVISION; + xdi->sid.SubAuthorityCount = 1; + xdi->sid.IdentifierAuthority = localSidAuthority; + xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID; + *Buffer = xdi; + } + break; + case PolicyAuditLogInformation: + case PolicyPdAccountInformation: + case PolicyLsaServerRoleInformation: + case PolicyReplicaSourceInformation: + case PolicyDefaultQuotaInformation: + case PolicyModificationInformation: + case PolicyAuditFullSetInformation: + case PolicyAuditFullQueryInformation: + case PolicyDnsDomainInformation: + { + DPRINT1("category not implemented\n"); + return FALSE; + } + } + return TRUE; } /* - * @unimplemented + * @implemented */ NTSTATUS STDCALL LsaFreeMemory(PVOID pv) { - return(FALSE); + return RtlFreeHeap(RtlGetProcessHeap(), 0, pv); } /* @@ -52,7 +144,8 @@ NTSTATUS STDCALL LsaClose(LSA_HANDLE ObjectHandle) { - return(FALSE); + DPRINT1("(%p):LsaClose stub\n",ObjectHandle); + return 0xc0000000; } /* @@ -61,7 +154,7 @@ LsaClose(LSA_HANDLE ObjectHandle) NTSTATUS STDCALL LsaAddAccountRights( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PSID AccountSid, PLSA_UNICODE_STRING UserRights, ULONG CountOfRights @@ -76,7 +169,7 @@ LsaAddAccountRights( NTSTATUS STDCALL LsaCreateTrustedDomainEx( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PTRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation, PTRUSTED_DOMAIN_AUTH_INFORMATION AuthenticationInformation, ACCESS_MASK DesiredAccess, @@ -92,7 +185,7 @@ LsaCreateTrustedDomainEx( NTSTATUS STDCALL LsaDeleteTrustedDomain( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PSID TrustedDomainSid ) { @@ -105,7 +198,7 @@ LsaDeleteTrustedDomain( NTSTATUS STDCALL LsaEnumerateAccountRights( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PSID AccountSid, PLSA_UNICODE_STRING *UserRights, PULONG CountOfRights @@ -120,7 +213,7 @@ LsaEnumerateAccountRights( NTSTATUS STDCALL LsaEnumerateAccountsWithUserRight( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, OPTIONAL PLSA_UNICODE_STRING UserRights, PVOID *EnumerationBuffer, PULONG CountReturned @@ -135,7 +228,7 @@ LsaEnumerateAccountsWithUserRight( NTSTATUS STDCALL LsaEnumerateTrustedDomains( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_ENUMERATION_HANDLE EnumerationContext, PVOID *Buffer, ULONG PreferedMaximumLength, @@ -151,7 +244,7 @@ LsaEnumerateTrustedDomains( NTSTATUS STDCALL LsaEnumerateTrustedDomainsEx( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_ENUMERATION_HANDLE EnumerationContext, PVOID *Buffer, ULONG PreferedMaximumLength, @@ -167,7 +260,7 @@ LsaEnumerateTrustedDomainsEx( NTSTATUS STDCALL LsaLookupNames( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, ULONG Count, PLSA_UNICODE_STRING Names, PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains, @@ -183,7 +276,7 @@ LsaLookupNames( NTSTATUS STDCALL LsaLookupNames2( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, ULONG Flags, ULONG Count, PLSA_UNICODE_STRING Names, @@ -200,7 +293,7 @@ LsaLookupNames2( NTSTATUS STDCALL LsaLookupSids( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, ULONG Count, PSID *Sids, PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains, @@ -216,7 +309,7 @@ LsaLookupSids( NTSTATUS STDCALL LsaOpenTrustedDomainByName( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING TrustedDomainName, ACCESS_MASK DesiredAccess, PLSA_HANDLE TrustedDomainHandle @@ -231,8 +324,8 @@ LsaOpenTrustedDomainByName( NTSTATUS STDCALL LsaQueryDomainInformationPolicy( - LSA_HANDLE PolicyHandle, - POLICY_DOMAIN_INFORMATION_CLASS InformationClass, + LSA_HANDLE lsah, + POLICY_DOMAIN_INFORMATION_CLASS pic, PVOID *Buffer ) { @@ -245,7 +338,7 @@ LsaQueryDomainInformationPolicy( NTSTATUS STDCALL LsaQueryForestTrustInformation( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING TrustedDomainName, PLSA_FOREST_TRUST_INFORMATION * ForestTrustInfo ) @@ -259,9 +352,9 @@ LsaQueryForestTrustInformation( NTSTATUS STDCALL LsaQueryTrustedDomainInfoByName( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING TrustedDomainName, - TRUSTED_INFORMATION_CLASS InformationClass, + TRUSTED_INFORMATION_CLASS pic, PVOID *Buffer ) { @@ -274,9 +367,9 @@ LsaQueryTrustedDomainInfoByName( NTSTATUS STDCALL LsaQueryTrustedDomainInfo( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PSID TrustedDomainSid, - TRUSTED_INFORMATION_CLASS InformationClass, + TRUSTED_INFORMATION_CLASS pic, PVOID *Buffer ) { @@ -289,7 +382,7 @@ LsaQueryTrustedDomainInfo( NTSTATUS STDCALL LsaRemoveAccountRights( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PSID AccountSid, BOOL AllRights, PLSA_UNICODE_STRING UserRights, @@ -305,7 +398,7 @@ LsaRemoveAccountRights( NTSTATUS STDCALL LsaRetrievePrivateData( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING KeyName, PLSA_UNICODE_STRING * PrivateData ) @@ -319,8 +412,8 @@ LsaRetrievePrivateData( NTSTATUS STDCALL LsaSetDomainInformationPolicy( - LSA_HANDLE PolicyHandle, - POLICY_DOMAIN_INFORMATION_CLASS InformationClass, + LSA_HANDLE lsah, + POLICY_DOMAIN_INFORMATION_CLASS pic, PVOID Buffer ) { @@ -333,8 +426,8 @@ LsaSetDomainInformationPolicy( NTSTATUS STDCALL LsaSetInformationPolicy( - LSA_HANDLE PolicyHandle, - POLICY_INFORMATION_CLASS InformationClass, + LSA_HANDLE lsah, + POLICY_INFORMATION_CLASS pic, PVOID Buffer ) { @@ -347,7 +440,7 @@ LsaSetInformationPolicy( NTSTATUS STDCALL LsaSetForestTrustInformation( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING TrustedDomainName, PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo, BOOL CheckOnly, @@ -363,9 +456,9 @@ LsaSetForestTrustInformation( NTSTATUS STDCALL LsaSetTrustedDomainInfoByName( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING TrustedDomainName, - TRUSTED_INFORMATION_CLASS InformationClass, + TRUSTED_INFORMATION_CLASS pic, PVOID Buffer ) { @@ -378,9 +471,9 @@ LsaSetTrustedDomainInfoByName( NTSTATUS STDCALL LsaSetTrustedDomainInformation( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PSID TrustedDomainSid, - TRUSTED_INFORMATION_CLASS InformationClass, + TRUSTED_INFORMATION_CLASS pic, PVOID Buffer ) { @@ -393,7 +486,7 @@ LsaSetTrustedDomainInformation( NTSTATUS STDCALL LsaStorePrivateData( - LSA_HANDLE PolicyHandle, + LSA_HANDLE lsah, PLSA_UNICODE_STRING KeyName, PLSA_UNICODE_STRING PrivateData )