Index: trunk/src/NTDLL/ntdll.def
===================================================================
--- trunk/src/NTDLL/ntdll.def	(revision 7981)
+++ trunk/src/NTDLL/ntdll.def	(revision 7983)
@@ -1,3 +1,3 @@
-; $Id: ntdll.def,v 1.41 2001-10-29 02:26:38 bird Exp $
+; $Id: ntdll.def,v 1.42 2002-02-21 22:52:42 sandervl Exp $
 
 ;
@@ -64,5 +64,5 @@
 ;   NlsMbOemCodePageTag                             @53
     NtAcceptConnectPort           = _NtAcceptConnectPort@24     @54
-;   NtAccessCheck                                   @55
+    NtAccessCheck                 = _NtAccessCheck@32            @55
 ;   NtAccessCheckAndAuditAlarm                      @56
 ;   NtAddAtom                                   @57
@@ -244,5 +244,5 @@
 ;   NtSetLowWaitHighEventPair                       @231
 ;   NtSetLowWaitHighThread                      @232
-;   NtSetSecurityObject                         @233
+    NtSetSecurityObject           = _NtSetSecurityObject@12             @233
 ;   NtSetSystemEnvironmentValue                     @234
 ;   NtSetSystemInformation                      @235
@@ -430,5 +430,5 @@
 ;   RtlGetCallersAddress                        @414
 ;   RtlGetCompressionWorkSpaceSize                  @415
-;   RtlGetControlSecurityDescriptor                 @416
+    RtlGetControlSecurityDescriptor = _RtlGetControlSecurityDescriptor@12 @416
 ;   RtlGetCurrentDirectory_U                        @417
     RtlGetDaclSecurityDescriptor  = _RtlGetDaclSecurityDescriptor@16    @418
@@ -449,5 +449,5 @@
 ;   RtlImageRvaToSection                        @433
 ;   RtlImageRvaToVa                         @434
-;   RtlImpersonateSelf                          @435
+    RtlImpersonateSelf            = _RtlImpersonateSelf@4               @435
     RtlInitAnsiString             = _RtlInitAnsiString@8                @436
 ;   RtlInitCodePageTable                        @437
@@ -490,5 +490,5 @@
 ;   RtlLookupAtomInAtomTable                        @474
 ;   RtlLookupElementGenericTable                    @475
-;   RtlMakeSelfRelativeSD                       @476
+    RtlMakeSelfRelativeSD          = _RtlMakeSelfRelativeSD@12          @476
 ;   RtlMapGenericMask                           @477
     RtlMoveMemory                  = _RtlMoveMemory@12                  @478
Index: trunk/src/NTDLL/rtl.cpp
===================================================================
--- trunk/src/NTDLL/rtl.cpp	(revision 7981)
+++ trunk/src/NTDLL/rtl.cpp	(revision 7983)
@@ -1,3 +1,3 @@
-/* $Id: rtl.cpp,v 1.13 2001-07-20 15:39:47 sandervl Exp $ */
+/* $Id: rtl.cpp,v 1.14 2002-02-21 22:52:42 sandervl Exp $ */
 
 /*
@@ -29,5 +29,4 @@
 #include "stackframe.h"
 #include "ntddk.h"
-#include "imagehlp.h"
 #include "winreg.h"
 #include "heapstring.h"
@@ -334,5 +333,5 @@
  * FIXME: prototype guessed
  */
-BOOLEAN WINAPI RtlDestroyHeap(HANDLE Heap)
+HANDLE WINAPI RtlDestroyHeap( HANDLE Heap )
 {
   dprintf(("NTDLL: RtlDestroyHeap(%08xh)\n",
@@ -505,21 +504,9 @@
 
 
-/******************************************************************************
- * RtlEnlargedIntegerMultiply [NTDLL.341]
- * Note: This even works, since gcc returns 64bit values in eax/edx just like
- * the caller expects. However... The relay code won't grok this I think.
- *
- * @@@PH: Parameters are unknown
- */
-/* longlong in VAC++ ? */
-
-extern INT WINAPI RtlEnlargedIntegerMultiply(INT factor1,
-                                             INT factor2);
-
 
 /******************************************************************************
  *  RtlFormatCurrentUserKeyPath             [NTDLL.371]
  */
-DWORD WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING pustrKeyPath)
+NTSTATUS WINAPI RtlFormatCurrentUserKeyPath(IN OUT PUNICODE_STRING pustrKeyPath)
 {
   dprintf(("NTDLL: RtlFormatCurrentUserKeyPath(%08xh) not correctly implemented.\n",
Index: trunk/src/NTDLL/rtlstr.c
===================================================================
--- trunk/src/NTDLL/rtlstr.c	(revision 7981)
+++ trunk/src/NTDLL/rtlstr.c	(revision 7983)
@@ -606,5 +606,5 @@
  * including the terminating NULL.
  */
-UINT WINAPI RtlOemStringToUnicodeSize(PSTRING str)
+UINT WINAPI RtlOemStringToUnicodeSize( const STRING *str )
 {
     DWORD ret = MultiByteToWideChar( CP_OEMCP, 0, str->Buffer, str->Length, NULL, 0 );
@@ -619,5 +619,5 @@
  * including the terminating NULL.
  */
-DWORD WINAPI RtlAnsiStringToUnicodeSize(PSTRING str)
+DWORD WINAPI RtlAnsiStringToUnicodeSize( const STRING *str )
 {
     DWORD ret = MultiByteToWideChar( CP_ACP, 0, str->Buffer, str->Length, NULL, 0 );
Index: trunk/src/NTDLL/sec.cpp
===================================================================
--- trunk/src/NTDLL/sec.cpp	(revision 7981)
+++ trunk/src/NTDLL/sec.cpp	(revision 7983)
@@ -1,3 +1,3 @@
-/* $Id: sec.cpp,v 1.8 2001-04-22 10:38:59 sandervl Exp $ */
+/* $Id: sec.cpp,v 1.9 2002-02-21 22:52:43 sandervl Exp $ */
 
 /*
@@ -26,4 +26,5 @@
 #include "ntdll.h"
 
+#include <debugtools.h>
 
 ODINDEBUGCHANNEL(NTDLL-SEC)
@@ -807,2 +808,72 @@
 }
 
+
+/******************************************************************************
+ *  RtlImpersonateSelf		[NTDLL.@]
+ */
+BOOL WINAPI
+RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
+{
+	FIXME("(%08x), stub\n", ImpersonationLevel);
+	return TRUE;
+}
+
+/******************************************************************************
+ *  NtAccessCheck		[NTDLL.@]
+ */
+NTSTATUS WINAPI 
+NtAccessCheck(
+	IN PSECURITY_DESCRIPTOR SecurityDescriptor,
+	IN HANDLE ClientToken,
+	IN ACCESS_MASK DesiredAccess,
+	IN PGENERIC_MAPPING GenericMapping,
+	OUT PPRIVILEGE_SET PrivilegeSet,
+	OUT PULONG ReturnLength,
+	OUT PULONG GrantedAccess,
+	OUT PBOOLEAN AccessStatus)
+{
+	FIXME("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
+          SecurityDescriptor, ClientToken, DesiredAccess, GenericMapping, 
+          PrivilegeSet, ReturnLength, GrantedAccess, AccessStatus);
+	*AccessStatus = TRUE;
+	return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+ *  NtSetSecurityObject		[NTDLL.@]
+ */
+NTSTATUS WINAPI
+NtSetSecurityObject(
+        IN HANDLE Handle,
+        IN SECURITY_INFORMATION SecurityInformation,
+        IN PSECURITY_DESCRIPTOR SecurityDescriptor) 
+{
+	FIXME("0x%08x 0x%08lx %p\n", Handle, SecurityInformation, SecurityDescriptor);
+	return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+ * RtlGetControlSecurityDescriptor (NTDLL.@)
+ */
+
+NTSTATUS WINAPI RtlGetControlSecurityDescriptor(
+	PSECURITY_DESCRIPTOR  pSecurityDescriptor,
+	PSECURITY_DESCRIPTOR_CONTROL pControl,
+	LPDWORD lpdwRevision)
+{
+	FIXME("(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
+	return STATUS_SUCCESS;
+}		
+
+/**************************************************************************
+ *                 RtlMakeSelfRelativeSD		[NTDLL.@]
+ */
+NTSTATUS WINAPI RtlMakeSelfRelativeSD(
+	IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
+	IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
+	IN OUT LPDWORD lpdwBufferLength)
+{
+	FIXME("(%p,%p,%p(%lu))\n", pAbsoluteSecurityDescriptor,
+	pSelfRelativeSecurityDescriptor, lpdwBufferLength,*lpdwBufferLength);
+	return STATUS_SUCCESS;
+}
Index: trunk/src/advapi32/ADVAPI32.CPP
===================================================================
--- trunk/src/advapi32/ADVAPI32.CPP	(revision 7981)
+++ trunk/src/advapi32/ADVAPI32.CPP	(revision 7983)
@@ -1,3 +1,3 @@
-/* $Id: ADVAPI32.CPP,v 1.19 2001-08-10 19:31:19 sandervl Exp $ */
+/* $Id: ADVAPI32.CPP,v 1.20 2002-02-21 22:51:58 sandervl Exp $ */
 
 /*
@@ -1005,44 +1005,4 @@
 
 
-/*****************************************************************************
- * Name      : LookupAccountNameA
- * Purpose   : The LookupAccountName function accepts the name of a system and
- *             an account as input. It retrieves a security identifier (SID)
- *             for the account and the name of the domain on which the account was found.
- * Parameters: LPCSTR       lpSystemName           address of string for system name
- *             LPCSTR       lpAccountName          address of string for account name
- *             PSID          Sid                    address of security identifier
- *             LPDWORD       cbSid                  address of size of security identifier
- *             LPTSTR        ReferencedDomainName   address of string for referenced domain
- *             LPDWORD       cbReferencedDomainName address of size of domain string
- *             PSID_NAME_USE peUse                  address of SID-type indicator
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
- *****************************************************************************/
-
-BOOL WIN32API LookupAccountNameA(LPCSTR       lpSystemName,
-                                    LPCSTR       lpAccountName,
-                                    PSID          Sid,
-                                    LPDWORD       cbSid,
-                                    LPTSTR        ReferencedDomainName,
-                                    LPDWORD       cbReferencedDomainName,
-                                    PSID_NAME_USE peUse)
-{
-  dprintf(("ADVAPI32: LookupAccountNameA(%s,%s,%08xh,%08xh,%s,%08xh,%08xh) not implemented.\n",
-           lpSystemName,
-           lpAccountName,
-           Sid,
-           cbSid,
-           ReferencedDomainName,
-           cbReferencedDomainName,
-           peUse));
-
-  return (FALSE); /* signal failure */
-}
-
 
 /*****************************************************************************
@@ -1681,31 +1641,4 @@
 
 
-/*****************************************************************************
- * Name      : SetKernelObjectSecurity
- * Purpose   : The SetKernelObjectSecurity function sets the security of a kernel
- *             object. For example, this can be a process, thread, or event.
- * Parameters: HANDLE               hObject handle of object
- *             SECURITY_INFORMATION si      type of information to set
- *             PSECURITY_DESCRIPTOR psd     address of security descriptor
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
- *****************************************************************************/
-
-BOOL WIN32API SetKernelObjectSecurity(HANDLE               hObject,
-                                         SECURITY_INFORMATION si,
-                                         PSECURITY_DESCRIPTOR psd)
-{
-  dprintf(("ADVAPI32: SetKernelObjectSecurity(%08xh,%08xh,%08xh) not implemented.\n",
-           hObject,
-           si,
-           psd));
-
-  return (FALSE); /* signal failure */
-}
-
 
 /*****************************************************************************
Index: trunk/src/advapi32/lsa.cpp
===================================================================
--- trunk/src/advapi32/lsa.cpp	(revision 7981)
+++ trunk/src/advapi32/lsa.cpp	(revision 7983)
@@ -1,3 +1,3 @@
-/* $Id: lsa.cpp,v 1.6 2000-10-03 05:38:09 bird Exp $ */
+/* $Id: lsa.cpp,v 1.7 2002-02-21 22:51:59 sandervl Exp $ */
 
 /*
@@ -284,5 +284,4 @@
                                       ULONG                CountOfRights);
 
-NTSTATUS WIN32API LsaClose(LSA_HANDLE hLsaObject);
 
 NTSTATUS WIN32API LsaCreateTrustedDomainEx(LSA_HANDLE                       PolicyHandle,
@@ -317,5 +316,4 @@
                                                PULONG                   CountReturned);
 
-NTSTATUS WIN32API LsaFreeMemory(PVOID Buffer);
 
 NTSTATUS WIN32API LsaLookupNames(LSA_HANDLE                   PolicyHandle,
@@ -325,9 +323,4 @@
                                  PLSA_TRANSLATED_SID*         Sids);
 
-NTSTATUS WIN32API LsaLookupSids(LSA_HANDLE                   PolicyHandle,
-                                ULONG                        Count,
-                                PSID*                        Sids,
-                                PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains,
-                                PLSA_TRANSLATED_NAME*        Names);
 
 ULONG WIN32API LsaNtStatusToWinError(NTSTATUS Status);
@@ -343,7 +336,4 @@
                                              PLSA_HANDLE         TrustedDomainHandle);
 
-NTSTATUS WIN32API LsaQueryInformationPolicy(LSA_HANDLE               PolicyHandle,
-                                            POLICY_INFORMATION_CLASS InformationClass,
-                                            PVOID *                  Buffer);
 
 NTSTATUS WIN32API LsaQueryTrustedDomainInfo(LSA_HANDLE                 PolicyHandle,
@@ -420,21 +410,4 @@
 
 
-/*****************************************************************************
- * Name      : LsaClose
- * Purpose   : The LsaClose function closes a handle to an LSA policy object.
- * Parameters: LSA_HANDLE ObjectHandle
- * Variables :
- * Result    : NTSTATUS
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Thu, 1999/11/04 23:00]
- *****************************************************************************/
-
-ODINFUNCTION1(NTSTATUS,LsaClose,LSA_HANDLE,hLsaObject)
-{
-  dprintf(("ADVAPI32:Lsa: LsaClose not implemented.\n"));
-  return 0;
-}
 
 
@@ -608,27 +581,4 @@
 
 
-/*****************************************************************************
- * Name      : LsaFreeMemory
- * Purpose   : The LsaFreeMemory function frees memory allocated for
- *             an output buffer by an LSA function call. LSA functions that
- *             return variable-length output buffers always allocate the
- *             buffer on behalf of the caller. The caller must free this
- *             memory by passing the returned buffer pointer to
- *             LsaFreeMemory when the memory is no longer required.
- * Parameters: PVOID Buffer
- * Variables :
- * Result    : NTSTATUS
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Thu, 1999/11/04 23:00]
- *****************************************************************************/
-
-ODINFUNCTION1(NTSTATUS, LsaFreeMemory,
-              PVOID,    Buffer)
-{
-  dprintf(("ADVAPI32:Lsa: LsaFreeMemory not implemented.\n"));
-  return 0;
-}
 
 
@@ -663,33 +613,4 @@
 
 
-/*****************************************************************************
- * Name      : LsaLookupSids
- * Purpose   : The LsaLookupSids function looks up the names
- *             that corresponding to an array of SIDs. If a name can
- *             not be mapped to a SID, LsaLookupSids converts
- *             the SID to character form.
- * Parameters: LSA_HANDLE PolicyHandle,
- *             ULONG                       Count
- *             PSID                        *Sids
- *             PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains
- *             PLSA_TRANSLATED_NAME        *Names
- * Variables :
- * Result    : NTSTATUS
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Thu, 1999/11/04 23:00]
- *****************************************************************************/
-
-ODINFUNCTION5(NTSTATUS,                    LsaLookupSids,
-              LSA_HANDLE,                  PolicyHandle,
-              ULONG,                       Count,
-              PSID*,                       Sids,
-              PLSA_REFERENCED_DOMAIN_LIST*,ReferencedDomains,
-              PLSA_TRANSLATED_NAME*,       Names)
-{
-  dprintf(("ADVAPI32:Lsa: LsaLookupNames not implemented.\n"));
-  return 0;
-}
 
 
@@ -745,28 +666,4 @@
 }
 
-
-/*****************************************************************************
- * Name      : LsaQueryInformationPolicy
- * Purpose   : The LsaQueryInformationPolicy function
- *             retrieves information about an LSA policy object.
- * Parameters:  LSA_HANDLE PolicyHandle,
- *              POLICY_INFORMATION_CLASS InformationClass,
- *              PVOID *Buffer
- * Variables :
- * Result    : NTSTATUS
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Thu, 1999/11/04 23:00]
- *****************************************************************************/
-
-ODINFUNCTION3(NTSTATUS,                 LsaQueryInformationPolicy,
-              LSA_HANDLE,               PolicyHandle,
-              POLICY_INFORMATION_CLASS, InformationClass,
-              PVOID *,                  Buffer)
-{
-  dprintf(("ADVAPI32:Lsa: LsaQueryInformationPolicy not implemented.\n"));
-  return 0;
-}
 
 
Index: trunk/src/advapi32/makefile
===================================================================
--- trunk/src/advapi32/makefile	(revision 7981)
+++ trunk/src/advapi32/makefile	(revision 7983)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.29 2002-02-08 14:13:16 sandervl Exp $
+# $Id: makefile,v 1.30 2002-02-21 22:52:00 sandervl Exp $
 
 #
@@ -22,4 +22,5 @@
 $(OBJDIR)\lsa.obj \
 $(OBJDIR)\security.obj \
+$(OBJDIR)\security_odin.obj \
 $(OBJDIR)\systemfunction.obj \
 $(OBJDIR)\service.obj \
Index: trunk/src/advapi32/security.c
===================================================================
--- trunk/src/advapi32/security.c	(revision 7983)
+++ trunk/src/advapi32/security.c	(revision 7983)
@@ -0,0 +1,957 @@
+/*
+ * dlls/advapi32/security.c
+ *  FIXME: for all functions thunking down to Rtl* functions:  implement SetLastError()
+ */
+#include <string.h>
+
+#include "windef.h"
+#include "winerror.h"
+#include "heap.h"
+#include "ntddk.h"
+#include "ntsecapi.h"
+#include "debugtools.h"
+
+#ifdef __WIN32OS2__
+#include <heapstring.h>
+#endif
+
+DEFAULT_DEBUG_CHANNEL(advapi);
+
+#define CallWin32ToNt(func) \
+	{ NTSTATUS ret; \
+	  ret = (func); \
+	  if (ret !=STATUS_SUCCESS) \
+	  { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
+	  return TRUE; \
+	}
+
+static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa )
+{
+	if (oa)
+	{
+	  TRACE("\n\tlength=%lu, rootdir=0x%08x, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",
+		oa->Length, oa->RootDirectory,
+		oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
+     		oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService);
+	}
+}
+
+/*	##############################
+	######	TOKEN FUNCTIONS ######
+	##############################
+*/
+
+/******************************************************************************
+ * OpenProcessToken			[ADVAPI32.@]
+ * Opens the access token associated with a process
+ *
+ * PARAMS
+ *   ProcessHandle [I] Handle to process
+ *   DesiredAccess [I] Desired access to process
+ *   TokenHandle   [O] Pointer to handle of open access token
+ *
+ * RETURNS STD
+ */
+BOOL WINAPI
+OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess, 
+                  HANDLE *TokenHandle )
+{
+	CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
+}
+
+/******************************************************************************
+ * OpenThreadToken [ADVAPI32.@]
+ *
+ * PARAMS
+ *   thread        []
+ *   desiredaccess []
+ *   openasself    []
+ *   thandle       []
+ */
+BOOL WINAPI
+OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess, 
+		 BOOL OpenAsSelf, HANDLE *TokenHandle)
+{
+	CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
+}
+
+/******************************************************************************
+ * AdjustTokenPrivileges [ADVAPI32.@]
+ *
+ * PARAMS
+ *   TokenHandle          []
+ *   DisableAllPrivileges []
+ *   NewState             []
+ *   BufferLength         []
+ *   PreviousState        []
+ *   ReturnLength         []
+ */
+BOOL WINAPI
+AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
+                       LPVOID NewState, DWORD BufferLength, 
+                       LPVOID PreviousState, LPDWORD ReturnLength )
+{
+	CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
+}
+
+/******************************************************************************
+ * CheckTokenMembership [ADVAPI32.@]
+ *
+ * PARAMS
+ *   TokenHandle []
+ *   SidToCheck  []
+ *   IsMember    []
+ */
+BOOL WINAPI
+CheckTokenMembership( HANDLE TokenHandle, PSID SidToCheck,
+                      PBOOL IsMember )
+{
+  FIXME("(0x%08x %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
+
+  *IsMember = TRUE;
+  return(TRUE);
+}
+
+/******************************************************************************
+ * GetTokenInformation [ADVAPI32.@]
+ *
+ * PARAMS
+ *   token           []
+ *   tokeninfoclass  []
+ *   tokeninfo       []
+ *   tokeninfolength []
+ *   retlen          []
+ *
+ */
+BOOL WINAPI
+GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass, 
+		     LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
+{
+	CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
+}
+
+/*************************************************************************
+ * SetThreadToken [ADVAPI32.@]
+ *
+ * Assigns an "impersonation token" to a thread so it can assume the
+ * security privledges of another thread or process.  Can also remove
+ * a previously assigned token.  Only supported on NT - it's a stub 
+ * exactly like this one on Win9X.
+ *
+ */
+
+BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
+{
+#ifdef __WIN32OS2__
+
+    dprintf(("SetThreadToken %x %x NOT IMPLEMENTED (FAKED)", thread, token));
+    return TRUE; //pretend it succeeded
+#else
+    FIXME("(%p, %x): stub (NT impl. only)\n", thread, token);
+
+    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+
+    return FALSE;
+#endif
+}
+
+/*	##############################
+	######	SID FUNCTIONS	######
+	##############################
+*/
+
+/******************************************************************************
+ * AllocateAndInitializeSid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pIdentifierAuthority []
+ *   nSubAuthorityCount   []
+ *   nSubAuthority0       []
+ *   nSubAuthority1       []
+ *   nSubAuthority2       []
+ *   nSubAuthority3       []
+ *   nSubAuthority4       []
+ *   nSubAuthority5       []
+ *   nSubAuthority6       []
+ *   nSubAuthority7       []
+ *   pSid                 []
+ */
+BOOL WINAPI
+AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+                          BYTE nSubAuthorityCount,
+                          DWORD nSubAuthority0, DWORD nSubAuthority1,
+                          DWORD nSubAuthority2, DWORD nSubAuthority3,
+                          DWORD nSubAuthority4, DWORD nSubAuthority5,
+                          DWORD nSubAuthority6, DWORD nSubAuthority7,
+                          PSID *pSid )
+{
+	CallWin32ToNt (RtlAllocateAndInitializeSid(
+		pIdentifierAuthority, nSubAuthorityCount, 
+		nSubAuthority0, nSubAuthority1,	nSubAuthority2, nSubAuthority3,
+		nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
+		pSid ));
+}
+
+/******************************************************************************
+ * FreeSid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid []
+ */
+PVOID WINAPI
+FreeSid( PSID pSid )
+{
+    	RtlFreeSid(pSid); 
+	return NULL; /* is documented like this */
+}
+
+/******************************************************************************
+ * CopySid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   nDestinationSidLength []
+ *   pDestinationSid       []
+ *   pSourceSid            []
+ */
+BOOL WINAPI
+CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
+{
+	return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
+}
+
+/******************************************************************************
+ * IsValidSid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid []
+ */
+BOOL WINAPI
+IsValidSid( PSID pSid )
+{
+	return RtlValidSid( pSid );
+}
+
+/******************************************************************************
+ * EqualSid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid1 []
+ *   pSid2 []
+ */
+BOOL WINAPI
+EqualSid( PSID pSid1, PSID pSid2 )
+{
+	return RtlEqualSid( pSid1, pSid2 );
+}
+
+/******************************************************************************
+ * EqualPrefixSid [ADVAPI32.@]
+ */
+BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2) 
+{
+	return RtlEqualPrefixSid(pSid1, pSid2);
+}
+
+/******************************************************************************
+ * GetSidLengthRequired [ADVAPI32.@]
+ *
+ * PARAMS
+ *   nSubAuthorityCount []
+ */
+DWORD WINAPI
+GetSidLengthRequired( BYTE nSubAuthorityCount )
+{
+	return RtlLengthRequiredSid(nSubAuthorityCount);
+}
+
+/******************************************************************************
+ * InitializeSid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pIdentifierAuthority []
+ */
+BOOL WINAPI
+InitializeSid (
+	PSID pSid,
+	PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+	BYTE nSubAuthorityCount)
+{
+	return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
+}
+
+/******************************************************************************
+ * GetSidIdentifierAuthority [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid []
+ */
+PSID_IDENTIFIER_AUTHORITY WINAPI
+GetSidIdentifierAuthority( PSID pSid )
+{
+	return RtlIdentifierAuthoritySid(pSid);
+}
+
+/******************************************************************************
+ * GetSidSubAuthority [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid          []
+ *   nSubAuthority []
+ */
+PDWORD WINAPI
+GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
+{
+	return RtlSubAuthoritySid(pSid, nSubAuthority);
+}
+
+/******************************************************************************
+ * GetSidSubAuthorityCount [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid []
+ */
+PUCHAR WINAPI
+GetSidSubAuthorityCount (PSID pSid)
+{
+	return RtlSubAuthorityCountSid(pSid);
+}
+
+/******************************************************************************
+ * GetLengthSid [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pSid []
+ */
+DWORD WINAPI
+GetLengthSid (PSID pSid)
+{
+	return RtlLengthSid(pSid);
+}
+
+/*	##############################################
+	######	SECURITY DESCRIPTOR FUNCTIONS	######
+	##############################################
+*/
+	
+/******************************************************************************
+ * InitializeSecurityDescriptor [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pDescr   []
+ *   revision []
+ */
+BOOL WINAPI
+InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
+{
+	CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
+}
+
+/******************************************************************************
+ * GetSecurityDescriptorLength [ADVAPI32.@]
+ */
+DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
+{
+	return (RtlLengthSecurityDescriptor(pDescr));
+}
+
+/******************************************************************************
+ * GetSecurityDescriptorOwner [ADVAPI32.@]
+ *
+ * PARAMS
+ *   pOwner            []
+ *   lpbOwnerDefaulted []
+ */
+BOOL WINAPI
+GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
+			    LPBOOL lpbOwnerDefaulted )
+{
+	CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
+}
+
+/******************************************************************************
+ * SetSecurityDescriptorOwner [ADVAPI32.@]
+ *
+ * PARAMS
+ */
+BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor, 
+				   PSID pOwner, BOOL bOwnerDefaulted)
+{
+	CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
+}
+/******************************************************************************
+ * GetSecurityDescriptorGroup			[ADVAPI32.@]
+ */
+BOOL WINAPI GetSecurityDescriptorGroup(
+	PSECURITY_DESCRIPTOR SecurityDescriptor,
+	PSID *Group,
+	LPBOOL GroupDefaulted)
+{
+	CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
+}	
+/******************************************************************************
+ * SetSecurityDescriptorGroup [ADVAPI32.@]
+ */
+BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
+					   PSID Group, BOOL GroupDefaulted)
+{
+	CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
+}
+
+/******************************************************************************
+ * IsValidSecurityDescriptor [ADVAPI32.@]
+ *
+ * PARAMS
+ *   lpsecdesc []
+ */
+BOOL WINAPI
+IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
+{
+	CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
+}
+
+/******************************************************************************
+ *  GetSecurityDescriptorDacl			[ADVAPI32.@]
+ */
+BOOL WINAPI GetSecurityDescriptorDacl(
+	IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
+	OUT LPBOOL lpbDaclPresent,
+	OUT PACL *pDacl,
+	OUT LPBOOL lpbDaclDefaulted)
+{
+	CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
+					       pDacl, (PBOOLEAN)lpbDaclDefaulted));
+}	
+
+/******************************************************************************
+ *  SetSecurityDescriptorDacl			[ADVAPI32.@]
+ */
+BOOL WINAPI 
+SetSecurityDescriptorDacl (
+	PSECURITY_DESCRIPTOR lpsd,
+	BOOL daclpresent,
+	PACL dacl,
+	BOOL dacldefaulted )
+{
+	CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
+}
+/******************************************************************************
+ *  GetSecurityDescriptorSacl			[ADVAPI32.@]
+ */
+BOOL WINAPI GetSecurityDescriptorSacl(
+	IN PSECURITY_DESCRIPTOR lpsd,
+	OUT LPBOOL lpbSaclPresent,
+	OUT PACL *pSacl,
+	OUT LPBOOL lpbSaclDefaulted)
+{
+	CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd,
+	   (PBOOLEAN)lpbSaclPresent, pSacl, (PBOOLEAN)lpbSaclDefaulted));
+}	
+
+/**************************************************************************
+ * SetSecurityDescriptorSacl			[ADVAPI32.@]
+ */
+BOOL WINAPI SetSecurityDescriptorSacl (
+	PSECURITY_DESCRIPTOR lpsd,
+	BOOL saclpresent,
+	PACL lpsacl,
+	BOOL sacldefaulted)
+{
+	CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
+}
+/******************************************************************************
+ * MakeSelfRelativeSD [ADVAPI32.@]
+ *
+ * PARAMS
+ *   lpabssecdesc  []
+ *   lpselfsecdesc []
+ *   lpbuflen      []
+ */
+BOOL WINAPI
+MakeSelfRelativeSD(
+	IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
+	IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
+	IN OUT LPDWORD lpdwBufferLength)
+{
+	CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength));
+}
+
+/******************************************************************************
+ * GetSecurityDescriptorControl			[ADVAPI32.@]
+ */
+
+BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR  pSecurityDescriptor,
+		 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
+{
+	CallWin32ToNt (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
+}		
+
+/*	##############################
+	######	ACL FUNCTIONS	######
+	##############################
+*/
+
+/*************************************************************************
+ * InitializeAcl [ADVAPI32.@]
+ */
+DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
+{
+	CallWin32ToNt (RtlCreateAcl(acl, size, rev));
+}
+
+/*	##############################
+	######	MISC FUNCTIONS	######
+	##############################
+*/
+
+/******************************************************************************
+ * LookupPrivilegeValueW			[ADVAPI32.@]
+ * Retrieves LUID used on a system to represent the privilege name.
+ *
+ * NOTES
+ *   lpLuid should be PLUID
+ *
+ * PARAMS
+ *   lpSystemName [I] Address of string specifying the system
+ *   lpName       [I] Address of string specifying the privilege
+ *   lpLuid       [I] Address of locally unique identifier
+ *
+ * RETURNS STD
+ */
+BOOL WINAPI
+LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, LPVOID lpLuid )
+{
+    FIXME("(%s,%s,%p): stub\n",debugstr_w(lpSystemName), 
+        debugstr_w(lpName), lpLuid);
+    return TRUE;
+}
+
+/******************************************************************************
+ * LookupPrivilegeValueA			[ADVAPI32.@]
+ */
+BOOL WINAPI
+LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, LPVOID lpLuid )
+{
+    LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName);
+    LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName);
+    BOOL ret;
+
+    ret = LookupPrivilegeValueW( lpSystemNameW, lpNameW, lpLuid);
+    HeapFree(GetProcessHeap(), 0, lpNameW);
+    HeapFree(GetProcessHeap(), 0, lpSystemNameW);
+    return ret;
+}
+
+/******************************************************************************
+ * GetFileSecurityA [ADVAPI32.@]
+ *
+ * Obtains Specified information about the security of a file or directory
+ * The information obtained is constrained by the callers access rights and
+ * privileges
+ */
+BOOL WINAPI
+GetFileSecurityA( LPCSTR lpFileName, 
+                    SECURITY_INFORMATION RequestedInformation,
+                    PSECURITY_DESCRIPTOR pSecurityDescriptor,
+                    DWORD nLength, LPDWORD lpnLengthNeeded )
+{
+  FIXME("(%s) : stub\n", debugstr_a(lpFileName));
+  return TRUE;
+}
+
+/******************************************************************************
+ * GetFileSecurityW [ADVAPI32.@]
+ *
+ * Obtains Specified information about the security of a file or directory
+ * The information obtained is constrained by the callers access rights and
+ * privileges
+ *
+ * PARAMS
+ *   lpFileName           []
+ *   RequestedInformation []
+ *   pSecurityDescriptor  []
+ *   nLength              []
+ *   lpnLengthNeeded      []
+ */
+BOOL WINAPI
+GetFileSecurityW( LPCWSTR lpFileName, 
+                    SECURITY_INFORMATION RequestedInformation,
+                    PSECURITY_DESCRIPTOR pSecurityDescriptor,
+                    DWORD nLength, LPDWORD lpnLengthNeeded )
+{
+  FIXME("(%s) : stub\n", debugstr_w(lpFileName) ); 
+  return TRUE;
+}
+
+
+/******************************************************************************
+ * LookupAccountSidA [ADVAPI32.@]
+ */
+BOOL WINAPI
+LookupAccountSidA(
+	IN LPCSTR system,
+	IN PSID sid,
+	OUT LPSTR account,
+	IN OUT LPDWORD accountSize,
+	OUT LPSTR domain,
+	IN OUT LPDWORD domainSize,
+	OUT PSID_NAME_USE name_use )
+{
+	static const char ac[] = "Administrator";
+	static const char dm[] = "DOMAIN";
+	FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
+	      debugstr_a(system),sid,
+	      account,accountSize,accountSize?*accountSize:0,
+	      domain,domainSize,domainSize?*domainSize:0,
+	      name_use);
+
+	if (accountSize) *accountSize = strlen(ac)+1;
+	if (account && (*accountSize > strlen(ac)))
+	  strcpy(account, ac);
+
+	if (domainSize) *domainSize = strlen(dm)+1;
+	if (domain && (*domainSize > strlen(dm)))
+	  strcpy(domain,dm);
+
+	if (name_use) *name_use = SidTypeUser;
+	return TRUE;
+}
+
+/******************************************************************************
+ * LookupAccountSidW [ADVAPI32.@]
+ *
+ * PARAMS
+ *   system      []
+ *   sid         []
+ *   account     []
+ *   accountSize []
+ *   domain      []
+ *   domainSize  []
+ *   name_use    []
+ */
+BOOL WINAPI
+LookupAccountSidW(
+	IN LPCWSTR system,
+	IN PSID sid,
+	OUT LPWSTR account,
+	IN OUT LPDWORD accountSize,
+	OUT LPWSTR domain,
+	IN OUT LPDWORD domainSize,
+	OUT PSID_NAME_USE name_use )
+{
+    static const WCHAR ac[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
+    static const WCHAR dm[] = {'D','O','M','A','I','N',0};
+	FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
+	      debugstr_w(system),sid,
+	      account,accountSize,accountSize?*accountSize:0,
+	      domain,domainSize,domainSize?*domainSize:0,
+	      name_use);
+
+	if (accountSize) *accountSize = strlenW(ac)+1;
+	if (account && (*accountSize > strlenW(ac)))
+            strcpyW(account, ac);
+
+	if (domainSize) *domainSize = strlenW(dm)+1;
+	if (domain && (*domainSize > strlenW(dm)))
+            strcpyW(domain,dm);
+
+	if (name_use) *name_use = SidTypeUser;
+	return TRUE;
+}
+
+/******************************************************************************
+ * SetFileSecurityA [ADVAPI32.@]
+ * Sets the security of a file or directory
+ */
+BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
+                                SECURITY_INFORMATION RequestedInformation,
+                                PSECURITY_DESCRIPTOR pSecurityDescriptor)
+{
+  FIXME("(%s) : stub\n", debugstr_a(lpFileName));
+  return TRUE;
+}
+
+/******************************************************************************
+ * SetFileSecurityW [ADVAPI32.@]
+ * Sets the security of a file or directory
+ *
+ * PARAMS
+ *   lpFileName           []
+ *   RequestedInformation []
+ *   pSecurityDescriptor  []
+ */
+BOOL WINAPI
+SetFileSecurityW( LPCWSTR lpFileName, 
+                    SECURITY_INFORMATION RequestedInformation,
+                    PSECURITY_DESCRIPTOR pSecurityDescriptor )
+{
+  FIXME("(%s) : stub\n", debugstr_w(lpFileName) ); 
+  return TRUE;
+}
+
+/******************************************************************************
+ * QueryWindows31FilesMigration [ADVAPI32.@]
+ *
+ * PARAMS
+ *   x1 []
+ */
+BOOL WINAPI
+QueryWindows31FilesMigration( DWORD x1 )
+{
+	FIXME("(%ld):stub\n",x1);
+	return TRUE;
+}
+
+/******************************************************************************
+ * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
+ *
+ * PARAMS
+ *   x1 []
+ *   x2 []
+ *   x3 []
+ *   x4 []
+ */
+BOOL WINAPI
+SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
+                                               DWORD x4 )
+{
+	FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
+	return TRUE;
+}
+
+/******************************************************************************
+ * LsaOpenPolicy [ADVAPI32.@]
+ *
+ * PARAMS
+ *   x1 []
+ *   x2 []
+ *   x3 []
+ *   x4 []
+ */
+NTSTATUS WINAPI
+LsaOpenPolicy(
+	IN PLSA_UNICODE_STRING SystemName,
+	IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
+	IN ACCESS_MASK DesiredAccess,
+	IN OUT PLSA_HANDLE PolicyHandle)
+{
+	FIXME("(%s,%p,0x%08lx,%p):stub\n",
+              SystemName?debugstr_w(SystemName->Buffer):"null",
+	      ObjectAttributes, DesiredAccess, PolicyHandle);
+	dumpLsaAttributes(ObjectAttributes);
+	if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
+	return TRUE;
+}
+
+/******************************************************************************
+ * LsaQueryInformationPolicy [ADVAPI32.@]
+ */
+NTSTATUS WINAPI
+LsaQueryInformationPolicy( 
+	IN LSA_HANDLE PolicyHandle,
+        IN POLICY_INFORMATION_CLASS InformationClass,
+	OUT PVOID *Buffer)
+{
+	FIXME("(%p,0x%08x,%p):stub\n",
+              PolicyHandle, InformationClass, Buffer);
+
+	if(!Buffer) return FALSE;
+	switch (InformationClass)
+	{
+	  case PolicyAuditEventsInformation: /* 2 */
+	    {
+	      PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), 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 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
+	      RtlInitUnicodeString(&(xdi->ppdi.Name), HEAP_strdupAtoW(GetProcessHeap(),0,"DOMAIN"));
+	      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:
+	    {
+	      FIXME("category not implemented\n");
+	      return FALSE;
+	    }
+	}
+	return TRUE; 
+}			  
+
+/******************************************************************************
+ * LsaLookupSids [ADVAPI32.@]
+ */
+typedef struct
+{
+	SID_NAME_USE Use;
+	LSA_UNICODE_STRING Name;
+	LONG DomainIndex;
+} LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
+
+typedef struct 
+{
+	LSA_UNICODE_STRING Name;
+	PSID Sid;
+} LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
+
+typedef struct 
+{
+	ULONG Entries;
+	PLSA_TRUST_INFORMATION Domains;
+} LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
+
+NTSTATUS WINAPI
+LsaLookupSids(
+	IN LSA_HANDLE PolicyHandle,
+	IN ULONG Count,
+	IN PSID *Sids,
+	OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
+	OUT PLSA_TRANSLATED_NAME *Names )
+{
+	FIXME("%p %lu %p %p %p\n",
+	  PolicyHandle, Count, Sids, ReferencedDomains, Names);
+	return FALSE;
+}
+
+/******************************************************************************
+ * LsaFreeMemory [ADVAPI32.@]
+ */
+NTSTATUS WINAPI
+LsaFreeMemory(IN PVOID Buffer)
+{
+	TRACE("(%p)\n",Buffer);
+	return HeapFree(GetProcessHeap(), 0, Buffer);
+}
+/******************************************************************************
+ * LsaClose [ADVAPI32.@]
+ */
+NTSTATUS WINAPI
+LsaClose(IN LSA_HANDLE ObjectHandle)
+{
+	FIXME("(%p):stub\n",ObjectHandle);
+	return 0xc0000000;
+}
+/******************************************************************************
+ * NotifyBootConfigStatus [ADVAPI32.@]
+ *
+ * PARAMS
+ *   x1 []
+ */
+BOOL WINAPI
+NotifyBootConfigStatus( DWORD x1 )
+{
+	FIXME("(0x%08lx):stub\n",x1);
+	return 1;
+}
+
+/******************************************************************************
+ * RevertToSelf [ADVAPI32.@]
+ *
+ * PARAMS
+ *   void []
+ */
+BOOL WINAPI
+RevertToSelf( void )
+{
+	FIXME("(), stub\n");
+	return TRUE;
+}
+
+/******************************************************************************
+ * ImpersonateSelf [ADVAPI32.@]
+ */
+BOOL WINAPI
+ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
+{
+	return RtlImpersonateSelf(ImpersonationLevel);
+}
+
+/******************************************************************************
+ * AccessCheck [ADVAPI32.@]
+ *
+ * FIXME check cast LPBOOL to PBOOLEAN
+ */
+BOOL WINAPI
+AccessCheck(
+	PSECURITY_DESCRIPTOR SecurityDescriptor,
+	HANDLE ClientToken,
+	DWORD DesiredAccess,
+	PGENERIC_MAPPING GenericMapping,
+	PPRIVILEGE_SET PrivilegeSet,
+	LPDWORD PrivilegeSetLength,
+	LPDWORD GrantedAccess,
+	LPBOOL AccessStatus)
+{
+	CallWin32ToNt (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
+	  GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus));
+}
+
+/*************************************************************************
+ * SetKernelObjectSecurity [ADVAPI32.@]
+ */
+BOOL WINAPI SetKernelObjectSecurity (
+	IN HANDLE Handle,
+	IN SECURITY_INFORMATION SecurityInformation,
+	IN PSECURITY_DESCRIPTOR SecurityDescriptor )
+{
+	CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
+}
+
+/******************************************************************************
+ *  AddAccessAllowedAce [ADVAPI32.@]
+ */
+BOOL WINAPI AddAccessAllowedAce(
+        IN OUT PACL pAcl,
+        IN DWORD dwAceRevision,
+        IN DWORD AccessMask,
+        IN PSID pSid)
+{
+        return RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid);
+}
+
+/******************************************************************************
+ * LookupAccountNameA [ADVAPI32.@]
+ */
+BOOL WINAPI
+LookupAccountNameA(
+	IN LPCSTR system,
+	IN LPCSTR account,
+	OUT PSID sid,
+	OUT LPDWORD cbSid,
+	LPSTR ReferencedDomainName,
+	IN OUT LPDWORD cbReferencedDomainName,
+	OUT PSID_NAME_USE name_use )
+{
+    FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
+    return FALSE;
+}
+
+/******************************************************************************
+ * GetAce [ADVAPI32.@]
+ */
+BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
+{
+    CallWin32ToNt(RtlGetAce(pAcl, dwAceIndex, pAce));
+}
Index: trunk/src/advapi32/security.cpp
===================================================================
--- trunk/src/advapi32/security.cpp	(revision 7981)
+++ 	(revision )
@@ -1,822 +1,0 @@
-/* $Id: security.cpp,v 1.8 2001-04-22 10:39:27 sandervl Exp $ */
-/*
- * Win32 security API functions for OS/2
- *
- * Copyright 1998 Sander van Leeuwen (OS/2 Port)
- *
- * Based on Wine code (dlls\advapi32\security.c)
- *
- * Copyright original Wine author(s) (????)
- *
- * dlls/advapi32/security.c
- *  FIXME: for all functions thunking down to Rtl* functions:  implement SetLastError()
- */
-#ifdef __WIN32OS2__
-#include <os2win.h>
-#include <heapstring.h>
-#endif
-
-#include <string.h>
-
-#include "windef.h"
-#include "winerror.h"
-#include "heap.h"
-#include "ntddk.h"
-#include "ntsecapi.h"
-#include "debugtools.h"
-
-DECLARE_DEBUG_CHANNEL(advapi-security)
-
-static BOOL fInitSecurity = FALSE;
-static BOOL fHasSecurity = FALSE;
-
-static BOOL Wine_HasSecurity(void)
-{
-    //SvL: Let's not check this for every single call please...
-    if(!fInitSecurity) 
-    {
-    	OSVERSIONINFOA osi;
-    	osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); 
-    	GetVersionExA(&osi);
-    	if (osi.dwPlatformId == VER_PLATFORM_WIN32_NT) { 
-		fHasSecurity = TRUE;
-	}
-        fInitSecurity = TRUE;
-    }
-    if(!fHasSecurity) {
-       	SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 
-        return FALSE;
-    }
-    return TRUE;
-}  
-
-
-#define CallWin32ToNt(func) \
-	{ NTSTATUS ret; \
-	  ret = (func); \
-	  if (ret !=STATUS_SUCCESS) \
-	  { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
-	  return TRUE; \
-	}
-
-/*	##############################
-	######	TOKEN FUNCTIONS ######
-	##############################
-*/
-
-/******************************************************************************
- * OpenProcessToken			[ADVAPI32.109]
- * Opens the access token associated with a process
- *
- * PARAMS
- *   ProcessHandle [I] Handle to process
- *   DesiredAccess [I] Desired access to process
- *   TokenHandle   [O] Pointer to handle of open access token
- *
- * RETURNS STD
- */
-BOOL WINAPI
-OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess, 
-                  HANDLE *TokenHandle )
-{
-        if (!Wine_HasSecurity()) return FALSE;
-	CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
-}
-
-/******************************************************************************
- * OpenThreadToken [ADVAPI32.114]
- *
- * PARAMS
- *   thread        []
- *   desiredaccess []
- *   openasself    []
- *   thandle       []
- */
-BOOL WINAPI
-OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess, 
-		 BOOL OpenAsSelf, HANDLE *TokenHandle)
-{
-        if (!Wine_HasSecurity()) return FALSE;
-	CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
-}
-
-/*************************************************************************
- * SetThreadToken [ADVAPI32.231]
- *
- * Assigns an "impersonation token" to a thread so it can assume the
- * security privledges of another thread or process.  Can also remove
- * a previously assigned token.  Only supported on NT - it's a stub 
- * exactly like this one on Win9X.
- *
- */
-
-BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
-{
-#ifdef __WIN32OS2__
-
-    dprintf(("SetThreadToken %x %x NOT IMPLEMENTED (FAKED)", thread, token));
-
-    if (!Wine_HasSecurity()) return FALSE;
-    return TRUE; //pretend it succeeded
-#else
-    FIXME(__FUNCTION__"(%p, %x): stub\n", thread, token);
-
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-
-    return FALSE;
-#endif
-}
-
-/******************************************************************************
- * AdjustTokenPrivileges [ADVAPI32.10]
- *
- * PARAMS
- *   TokenHandle          []
- *   DisableAllPrivileges []
- *   NewState             []
- *   BufferLength         []
- *   PreviousState        []
- *   ReturnLength         []
- */
-BOOL WINAPI
-AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
-                       PTOKEN_PRIVILEGES NewState, DWORD BufferLength, 
-                       PTOKEN_PRIVILEGES PreviousState, LPDWORD ReturnLength )
-{
-	CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
-}
-
-/******************************************************************************
- * GetTokenInformation [ADVAPI32.66]
- *
- * PARAMS
- *   token           []
- *   tokeninfoclass  []
- *   tokeninfo       []
- *   tokeninfolength []
- *   retlen          []
- *
- */
-BOOL WINAPI
-GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass, 
-		     LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
-{
-	CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
-}
-
-/*	##############################
-	######	SID FUNCTIONS	######
-	##############################
-*/
-
-/******************************************************************************
- * AllocateAndInitializeSid [ADVAPI32.11]
- *
- * PARAMS
- *   pIdentifierAuthority []
- *   nSubAuthorityCount   []
- *   nSubAuthority0       []
- *   nSubAuthority1       []
- *   nSubAuthority2       []
- *   nSubAuthority3       []
- *   nSubAuthority4       []
- *   nSubAuthority5       []
- *   nSubAuthority6       []
- *   nSubAuthority7       []
- *   pSid                 []
- */
-BOOL WINAPI
-AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
-                          BYTE nSubAuthorityCount,
-                          DWORD nSubAuthority0, DWORD nSubAuthority1,
-                          DWORD nSubAuthority2, DWORD nSubAuthority3,
-                          DWORD nSubAuthority4, DWORD nSubAuthority5,
-                          DWORD nSubAuthority6, DWORD nSubAuthority7,
-                          PSID *pSid )
-{
-	return RtlAllocateAndInitializeSid(
-		pIdentifierAuthority, nSubAuthorityCount, 
-		nSubAuthority0, nSubAuthority1,	nSubAuthority2, nSubAuthority3,
-		nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
-		pSid );
-}
-
-/******************************************************************************
- * FreeSid [ADVAPI32.42]
- *
- * PARAMS
- *   pSid []
- */
-PVOID WINAPI
-FreeSid( PSID pSid )
-{
-    	RtlFreeSid(pSid); 
-	return NULL; /* is documented like this */
-}
-
-/******************************************************************************
- * CopySid [ADVAPI32.24]
- *
- * PARAMS
- *   nDestinationSidLength []
- *   pDestinationSid       []
- *   pSourceSid            []
- */
-BOOL WINAPI
-CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
-{
-	CallWin32ToNt (RtlCopySid( nDestinationSidLength, pDestinationSid, pSourceSid));
-}
-
-/******************************************************************************
- * IsValidSid [ADVAPI32.80]
- *
- * PARAMS
- *   pSid []
- */
-BOOL WINAPI
-IsValidSid( PSID pSid )
-{
-	CallWin32ToNt (RtlValidSid( pSid));
-}
-
-/******************************************************************************
- * EqualSid [ADVAPI32.40]
- *
- * PARAMS
- *   pSid1 []
- *   pSid2 []
- */
-BOOL WINAPI
-EqualSid( PSID pSid1, PSID pSid2 )
-{
-	CallWin32ToNt (RtlEqualSid( pSid1, pSid2));
-}
-
-/******************************************************************************
- * EqualPrefixSid [ADVAPI32.39]
- */
-BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2) 
-{
-	CallWin32ToNt (RtlEqualPrefixSid( pSid1, pSid2));
-}
-
-/******************************************************************************
- * InitializeSid [ADVAPI32.74]
- *
- * PARAMS
- *   pIdentifierAuthority []
- */
-BOOL WINAPI
-InitializeSid (PSID pSid, PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
-                    BYTE nSubAuthorityCount)
-{
-	CallWin32ToNt (RtlInitializeSid( pSid, pIdentifierAuthority, nSubAuthorityCount));
-}
-
-/*	##############################################
-	######	SECURITY DESCRIPTOR FUNCTIONS	######
-	##############################################
-*/
-	
-/******************************************************************************
- * InitializeSecurityDescriptor [ADVAPI32.73]
- *
- * PARAMS
- *   pDescr   []
- *   revision []
- */
-BOOL WINAPI
-InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
-{
-	CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
-}
-
-/******************************************************************************
- * GetSecurityDescriptorLength [ADVAPI32.55]
- */
-DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
-{
-	return (RtlLengthSecurityDescriptor(pDescr));
-}
-
-/******************************************************************************
- * GetSecurityDescriptorOwner [ADVAPI32.56]
- *
- * PARAMS
- *   pOwner            []
- *   lpbOwnerDefaulted []
- */
-BOOL WINAPI
-GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
-			    LPBOOL lpbOwnerDefaulted )
-{
-	CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
-}
-
-/******************************************************************************
- * SetSecurityDescriptorOwner [ADVAPI32]
- *
- * PARAMS
- */
-BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor, 
-				   PSID pOwner, BOOL bOwnerDefaulted)
-{
-	CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
-}
-/******************************************************************************
- * GetSecurityDescriptorGroup			[ADVAPI32.54]
- */
-BOOL WINAPI GetSecurityDescriptorGroup(
-	PSECURITY_DESCRIPTOR SecurityDescriptor,
-	PSID *Group,
-	LPBOOL GroupDefaulted)
-{
-	CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
-}	
-/******************************************************************************
- * SetSecurityDescriptorGroup
- */
-BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
-					   PSID Group, BOOL GroupDefaulted)
-{
-	CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
-}
-
-/******************************************************************************
- * IsValidSecurityDescriptor [ADVAPI32.79]
- *
- * PARAMS
- *   lpsecdesc []
- */
-BOOL WINAPI
-IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
-{
-	CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
-}
-
-/******************************************************************************
- *  GetSecurityDescriptorDacl			[ADVAPI.91]
- */
-BOOL WINAPI GetSecurityDescriptorDacl(
-	IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
-	OUT LPBOOL lpbDaclPresent,
-	OUT PACL *pDacl,
-	OUT LPBOOL lpbDaclDefaulted)
-{
-	CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
-					       pDacl, (PBOOLEAN)lpbDaclDefaulted));
-}	
-
-/******************************************************************************
- *  SetSecurityDescriptorDacl			[ADVAPI.224]
- */
-BOOL WINAPI 
-SetSecurityDescriptorDacl (
-	PSECURITY_DESCRIPTOR lpsd,
-	BOOL daclpresent,
-	PACL dacl,
-	BOOL dacldefaulted )
-{
-	CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
-}
-/******************************************************************************
- *  GetSecurityDescriptorSacl			[ADVAPI.]
- */
-BOOL WINAPI GetSecurityDescriptorSacl(
-	IN PSECURITY_DESCRIPTOR lpsd,
-	OUT LPBOOL lpbSaclPresent,
-	OUT PACL *pSacl,
-	OUT LPBOOL lpbSaclDefaulted)
-{
-	CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd, (PBOOLEAN)lpbSaclPresent,
-					       pSacl, (PBOOLEAN)lpbSaclDefaulted));
-}	
-
-/**************************************************************************
- * SetSecurityDescriptorSacl			[NTDLL.488]
- */
-BOOL  WINAPI SetSecurityDescriptorSacl (
-	PSECURITY_DESCRIPTOR lpsd,
-	BOOL saclpresent,
-	PACL lpsacl,
-	BOOL sacldefaulted)
-{
-	CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
-}
-/******************************************************************************
- * MakeSelfRelativeSD [ADVAPI32.95]
- *
- * PARAMS
- *   lpabssecdesc  []
- *   lpselfsecdesc []
- *   lpbuflen      []
- */
-BOOL WINAPI
-MakeSelfRelativeSD( PSECURITY_DESCRIPTOR lpabssecdesc,
-                    PSECURITY_DESCRIPTOR lpselfsecdesc, LPDWORD lpbuflen )
-{
-	FIXME(__FUNCTION__"(%p,%p,%p),stub!\n",lpabssecdesc,lpselfsecdesc,lpbuflen);
-	return TRUE;
-}
-
-/******************************************************************************
- * GetSecurityDescriptorControl32			[ADVAPI32]
- */
-
-BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR  pSecurityDescriptor,
-		 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
-{	FIXME(__FUNCTION__"(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
-	return 1;
-}		
-
-/*	##############################
-	######	MISC FUNCTIONS	######
-	##############################
-*/
-
-/******************************************************************************
- * LookupPrivilegeValue32W			[ADVAPI32.93]
- * Retrieves LUID used on a system to represent the privilege name.
- *
- * NOTES
- *   lpLuid should be PLUID
- *
- * PARAMS
- *   lpSystemName [I] Address of string specifying the system
- *   lpName       [I] Address of string specifying the privilege
- *   lpLuid       [I] Address of locally unique identifier
- *
- * RETURNS STD
- */
-BOOL WINAPI
-LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, LPVOID lpLuid )
-{
-    FIXME(__FUNCTION__"(%s,%s,%p): stub\n",debugstr_w(lpSystemName), 
-                  debugstr_w(lpName), lpLuid);
-    return TRUE;
-}
-
-/******************************************************************************
- * LookupPrivilegeValue32A			[ADVAPI32.92]
- */
-BOOL WINAPI
-LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, LPVOID lpLuid )
-{
-    dprintf(("LookupPrivilegeValueA %s %s %x NOT IMPLEMENTED", lpSystemName, lpName, lpLuid));
-    LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName);
-    LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName);
-    BOOL ret = LookupPrivilegeValueW( lpSystemNameW, lpNameW, lpLuid);
-    HeapFree(GetProcessHeap(), 0, lpNameW);
-    HeapFree(GetProcessHeap(), 0, lpSystemNameW);
-    return ret;
-}
-
-/******************************************************************************
- * GetFileSecurity32A [ADVAPI32.45]
- *
- * Obtains Specified information about the security of a file or directory
- * The information obtained is constrained by the callers access rights and
- * privileges
- */
-BOOL WINAPI
-GetFileSecurityA( LPCSTR lpFileName, 
-                    SECURITY_INFORMATION RequestedInformation,
-                    PSECURITY_DESCRIPTOR pSecurityDescriptor,
-                    DWORD nLength, LPDWORD lpnLengthNeeded )
-{
-  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_a(lpFileName));
-  return TRUE;
-}
-
-/******************************************************************************
- * GetFileSecurity32W [ADVAPI32.46]
- *
- * Obtains Specified information about the security of a file or directory
- * The information obtained is constrained by the callers access rights and
- * privileges
- *
- * PARAMS
- *   lpFileName           []
- *   RequestedInformation []
- *   pSecurityDescriptor  []
- *   nLength              []
- *   lpnLengthNeeded      []
- */
-BOOL WINAPI
-GetFileSecurityW( LPCWSTR lpFileName, 
-                    SECURITY_INFORMATION RequestedInformation,
-                    PSECURITY_DESCRIPTOR pSecurityDescriptor,
-                    DWORD nLength, LPDWORD lpnLengthNeeded )
-{
-  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_w(lpFileName) ); 
-  return TRUE;
-}
-
-/******************************************************************************
- * SetFileSecurity32A [ADVAPI32.182]
- * Sets the security of a file or directory
- */
-BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
-                                SECURITY_INFORMATION RequestedInformation,
-                                PSECURITY_DESCRIPTOR pSecurityDescriptor)
-{
-  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_a(lpFileName));
-  return TRUE;
-}
-
-/******************************************************************************
- * SetFileSecurity32W [ADVAPI32.183]
- * Sets the security of a file or directory
- *
- * PARAMS
- *   lpFileName           []
- *   RequestedInformation []
- *   pSecurityDescriptor  []
- */
-BOOL WINAPI
-SetFileSecurityW( LPCWSTR lpFileName, 
-                    SECURITY_INFORMATION RequestedInformation,
-                    PSECURITY_DESCRIPTOR pSecurityDescriptor )
-{
-  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_w(lpFileName) ); 
-  return TRUE;
-}
-
-/******************************************************************************
- * LookupAccountSid32A [ADVAPI32.86]
- */
-BOOL WINAPI
-LookupAccountSidA(
-	IN LPCSTR system,
-	IN PSID sid,
-	OUT LPSTR account,
-	IN OUT LPDWORD accountSize,
-	OUT LPSTR domain,
-	IN OUT LPDWORD domainSize,
-	OUT PSID_NAME_USE name_use )
-{
-	char * ac = "Administrator";
-	char * dm = "DOMAIN";
-	dprintf(("LookupAccountSidA(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub",
-	      sid,
-	      account,accountSize,accountSize?*accountSize:0,
-	      domain,domainSize,domainSize?*domainSize:0,
-	      name_use));
-
-	if (accountSize) *accountSize = strlen(ac)+1;
-	if (account && (*accountSize > strlen(ac)))
-	  strcpy(account, ac);
-
-	if (domainSize) *domainSize = strlen(dm)+1;
-	if (domain && (*domainSize > strlen(dm)))
-	  strcpy(domain,dm);
-
-	if (name_use) *name_use = SidTypeUser;
-	return TRUE;
-}
-
-/******************************************************************************
- * LookupAccountSid32W [ADVAPI32.87]
- *
- * PARAMS
- *   system      []
- *   sid         []
- *   account     []
- *   accountSize []
- *   domain      []
- *   domainSize  []
- *   name_use    []
- */
-BOOL WINAPI
-LookupAccountSidW(
-	IN LPCWSTR system,
-	IN PSID sid,
-	OUT LPWSTR account,
-	IN OUT LPDWORD accountSize,
-	OUT LPWSTR domain,
-	IN OUT LPDWORD domainSize,
-	OUT PSID_NAME_USE name_use )
-{
-	char * ac = "Administrator";
-	char * dm = "DOMAIN";
-	dprintf(("LookupAccountSidW(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub",
-	      sid,
-	      account,accountSize,accountSize?*accountSize:0,
-	      domain,domainSize,domainSize?*domainSize:0,
-	      name_use));
-
-	if (accountSize) *accountSize = strlen(ac)+1;
-	if (account && (*accountSize > strlen(ac)))
-	  lstrcpyAtoW(account, ac);
-
-	if (domainSize) *domainSize = strlen(dm)+1;
-	if (domain && (*domainSize > strlen(dm)))
-	  lstrcpyAtoW(domain,dm);
-
-	if (name_use) *name_use = SidTypeUser;
-	return TRUE;
-}
-
-/******************************************************************************
- * QueryWindows31FilesMigration [ADVAPI32.266]
- *
- * PARAMS
- *   x1 []
- */
-BOOL WINAPI
-QueryWindows31FilesMigration( DWORD x1 )
-{
-	FIXME(__FUNCTION__"(%ld):stub\n",x1);
-	return TRUE;
-}
-
-/******************************************************************************
- * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.265]
- *
- * PARAMS
- *   x1 []
- *   x2 []
- *   x3 []
- *   x4 []
- */
-BOOL WINAPI
-SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
-                                               DWORD x4 )
-{
-	FIXME(__FUNCTION__"(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
-	return TRUE;
-}
-
-/******************************************************************************
- * LsaOpenPolicy [ADVAPI32.200]
- *
- * PARAMS
- *   x1 []
- *   x2 []
- *   x3 []
- *   x4 []
- */
-NTSTATUS WINAPI
-LsaOpenPolicy(PLSA_UNICODE_STRING SystemName,
-	      PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
-	      ACCESS_MASK DesiredAccess,
-	      PLSA_HANDLE PolicyHandle)
-{
-	FIXME(__FUNCTION__"(%p,%p,0x%08lx,%p):stub\n",
-		       SystemName, ObjectAttributes,
-		       DesiredAccess, PolicyHandle);
-	return 0xc0000000; /* generic error */
-}
-
-/******************************************************************************
- * NotifyBootConfigStatus [ADVAPI32.97]
- *
- * PARAMS
- *   x1 []
- */
-BOOL WINAPI
-NotifyBootConfigStatus( DWORD x1 )
-{
-	FIXME(__FUNCTION__"(0x%08lx):stub\n",x1);
-	return 1;
-}
-
-/******************************************************************************
- * RevertToSelf [ADVAPI32.180]
- *
- * PARAMS
- *   void []
- */
-BOOL WINAPI
-RevertToSelf( void )
-{
-	FIXME(__FUNCTION__"(), stub\n");
-	return TRUE;
-}
-
-/******************************************************************************
- * ImpersonateSelf [ADVAPI32.71]
- */
-BOOL WINAPI
-ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
-{
-    FIXME(__FUNCTION__"(%08x), stub\n", ImpersonationLevel);
-    return TRUE;
-}
-
-/******************************************************************************
- * AccessCheck32 [ADVAPI32.71]
- */
-BOOL WINAPI
-AccessCheck(PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken,
-	    DWORD DesiredAccess, PGENERIC_MAPPING GenericMapping, PPRIVILEGE_SET PrivilegeSet,
-	    LPDWORD PrivilegeSetLength, LPDWORD GrantedAccess, LPBOOL AccessStatus)
-{
-    FIXME(__FUNCTION__"(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
-		   pSecurityDescriptor, ClientToken, DesiredAccess, GenericMapping, 
-		   PrivilegeSet, PrivilegeSetLength, GrantedAccess, AccessStatus);
-    *AccessStatus = TRUE;
-    return TRUE;
-}
-
-/*****************************************************************************
- * Name      : InitializeAcl
- * Purpose   : The InitializeAcl function creates a new ACL structure.
- *             An ACL is an access-control list.
- * Parameters: PACL  pAcl          address of access-control list
- *             DWORD nAclLength    size of access-control list
- *             DWORD dwAclRevision revision level of access-control list
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
- *****************************************************************************/
-
-BOOL WIN32API InitializeAcl(PACL  pAcl,
-                            DWORD nAclLength,
-                            DWORD dwAclRevision)
-{
-  dprintf(("ADVAPI32: InitializeAcl(%08xh,%08xh,%08xh)",
-           pAcl,
-           nAclLength,
-           dwAclRevision));
-
-  CallWin32ToNt (RtlCreateAcl(pAcl, nAclLength, dwAclRevision));
-}
-
-/*****************************************************************************
- * Name      : AddAce
- * Purpose   : The AddAce function adds one or more ACEs to a specified ACL.
- *             An ACE is an access-control entry. An ACL is an access-control list.
- * Parameters: PACL   pAcl               address of access-control list
- *             DWORD  dwAceRevision      ACL revision level
- *             DWORD  dwStartingAceIndex index of ACE position in ACL
- *             LPVOID pAceList           address of one or more ACEs
- *             DWORD  nAceListLength     size of buffer for ACEs
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
- *****************************************************************************/
-
-BOOL WIN32API AddAce(PACL   pAcl,
-                        DWORD  dwAceRevision,
-                        DWORD  dwStartingAceIndex,
-                        LPVOID pAceList,
-                        DWORD  nAceListLength)
-{
-  CallWin32ToNt (RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, (PACE_HEADER)pAceList, nAceListLength));
-}
-
-/*****************************************************************************
- * Name      : AddAccessAllowedAce
- * Purpose   : The AddAccessAllowedAce function adds an access-allowed ACE to
- *             an ACL. The access is granted to a specified SID. An ACE is an
- *             access-control entry. An ACL is an access-control list. A SID is
- *             a security identifier.
- * Parameters: PACL  pAcl           address of access-control list
- *             DWORD dwAceRevision  ACL revision level
- *             DWORD AccessMask     access mask
- *             PSID  pSid           address of security identifier
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
- *****************************************************************************/
-
-BOOL WIN32API AddAccessAllowedAce(PACL  pAcl,
-                                     DWORD dwAceRevision,
-                                     DWORD AccessMask,
-                                     PSID  pSid)
-{
-  CallWin32ToNt (RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
-}
-
-/*****************************************************************************
- * Name      : GetAce
- * Purpose   : The GetAce function obtains a pointer to an ACE in an ACL.
- *             An ACE is an access control entry. An ACL is an access control list.
- * Parameters: PACL   pAcl        address of access-control list
- *             DWORD  dwAceIndex  index of ACE to retrieve
- *             LPVOID *pAce       address of pointer to ACE
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
- *****************************************************************************/
-
-BOOL WIN32API GetAce(PACL   pAcl,
-                        DWORD  dwAceIndex,
-                        LPVOID *pAce)
-{
-  CallWin32ToNt (RtlGetAce(pAcl, dwAceIndex, pAce));
-}
Index: trunk/src/advapi32/security_odin.cpp
===================================================================
--- trunk/src/advapi32/security_odin.cpp	(revision 7983)
+++ trunk/src/advapi32/security_odin.cpp	(revision 7983)
@@ -0,0 +1,95 @@
+/* $Id: security_odin.cpp,v 1.1 2002-02-21 22:52:01 sandervl Exp $ */
+/*
+ * Win32 security API functions for OS/2
+ *
+ * Copyright 1998 Sander van Leeuwen (OS/2 Port)
+ *
+ * Based on Wine code (dlls\advapi32\security.c)
+ *
+ * Copyright original Wine author(s) (????)
+ *
+ * dlls/advapi32/security.c
+ *  FIXME: for all functions thunking down to Rtl* functions:  implement SetLastError()
+ */
+#ifdef __WIN32OS2__
+#include <os2win.h>
+#include <heapstring.h>
+#endif
+
+#include <string.h>
+
+#include "windef.h"
+#include "winerror.h"
+#include "heap.h"
+#include "ntddk.h"
+#include "ntsecapi.h"
+#include "debugtools.h"
+
+DECLARE_DEBUG_CHANNEL(advapi-security)
+
+static BOOL fInitSecurity = FALSE;
+static BOOL fHasSecurity = FALSE;
+
+BOOL Wine_HasSecurity(void)
+{
+    //SvL: Let's not check this for every single call please...
+    if(!fInitSecurity) 
+    {
+    	OSVERSIONINFOA osi;
+    	osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); 
+    	GetVersionExA(&osi);
+    	if (osi.dwPlatformId == VER_PLATFORM_WIN32_NT) { 
+		fHasSecurity = TRUE;
+	}
+        fInitSecurity = TRUE;
+    }
+    if(!fHasSecurity) {
+       	SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 
+        return FALSE;
+    }
+    return TRUE;
+}  
+
+
+#define CallWin32ToNt(func) \
+	{ NTSTATUS ret; \
+	  ret = (func); \
+	  if (ret !=STATUS_SUCCESS) \
+	  { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
+	  return TRUE; \
+	}
+
+/*	##############################
+	######	TOKEN FUNCTIONS ######
+	##############################
+*/
+
+
+
+/*****************************************************************************
+ * Name      : AddAce
+ * Purpose   : The AddAce function adds one or more ACEs to a specified ACL.
+ *             An ACE is an access-control entry. An ACL is an access-control list.
+ * Parameters: PACL   pAcl               address of access-control list
+ *             DWORD  dwAceRevision      ACL revision level
+ *             DWORD  dwStartingAceIndex index of ACE position in ACL
+ *             LPVOID pAceList           address of one or more ACEs
+ *             DWORD  nAceListLength     size of buffer for ACEs
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+BOOL WIN32API AddAce(PACL   pAcl,
+                        DWORD  dwAceRevision,
+                        DWORD  dwStartingAceIndex,
+                        LPVOID pAceList,
+                        DWORD  nAceListLength)
+{
+  CallWin32ToNt (RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, (PACE_HEADER)pAceList, nAceListLength));
+}
+
+
