Index: trunk/src/NTDLL/initterm.cpp
===================================================================
--- trunk/src/NTDLL/initterm.cpp	(revision 2115)
+++ trunk/src/NTDLL/initterm.cpp	(revision 2122)
@@ -1,3 +1,3 @@
-/* $Id: initterm.cpp,v 1.7 1999-09-15 23:26:05 sandervl Exp $ */
+/* $Id: initterm.cpp,v 1.8 1999-12-18 20:01:13 sandervl Exp $ */
 
 /*
@@ -50,4 +50,6 @@
 
 
+BOOL WINAPI NTDLL_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+
 /****************************************************************************/
 /* _DLL_InitTerm is the function that gets called by the operating system   */
@@ -81,5 +83,5 @@
          /*******************************************************************/
 
-	 if(RegisterLxDll(hModule, 0, 0) == FALSE) 
+	 if(RegisterLxDll(hModule, NTDLL_LibMain, 0) == FALSE) 
 		return 0UL;
 
Index: trunk/src/NTDLL/nt.cpp
===================================================================
--- trunk/src/NTDLL/nt.cpp	(revision 2115)
+++ trunk/src/NTDLL/nt.cpp	(revision 2122)
@@ -1,3 +1,3 @@
-/* $Id: nt.cpp,v 1.2 1999-06-10 17:06:45 phaller Exp $ */
+/* $Id: nt.cpp,v 1.3 1999-12-18 20:01:13 sandervl Exp $ */
 
 
@@ -331,13 +331,60 @@
   {
     case TokenGroups:                    /* 2 */
-      *ReturnLength = sizeof (TOKEN_GROUPS);
+      	*ReturnLength = sizeof (TOKEN_GROUPS);
+	if(TokenInformationLength < sizeof (TOKEN_GROUPS)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_GROUPS));
+	break;
+    case TokenUser:                     /* 1 */
+      	*ReturnLength = sizeof (TOKEN_USER);
+	if(TokenInformationLength < sizeof (TOKEN_USER)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_USER));
+	break;
+    case TokenPrivileges:
+      	*ReturnLength = sizeof (TOKEN_PRIVILEGES);
+	if(TokenInformationLength < sizeof (TOKEN_PRIVILEGES)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_PRIVILEGES));
+	break;
+    case TokenOwner:
+      	*ReturnLength = sizeof (TOKEN_OWNER);
+	if(TokenInformationLength < sizeof (TOKEN_OWNER)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_OWNER));
+	break;
+    case TokenPrimaryGroup:
+      	*ReturnLength = sizeof (TOKEN_PRIMARY_GROUP);
+	if(TokenInformationLength < sizeof (TOKEN_PRIMARY_GROUP)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_PRIMARY_GROUP));
+	break;
+    case TokenDefaultDacl:
+      	*ReturnLength = sizeof (TOKEN_DEFAULT_DACL);
+	if(TokenInformationLength < sizeof (TOKEN_DEFAULT_DACL)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_DEFAULT_DACL));
+	break;
+    case TokenSource:
+      	*ReturnLength = sizeof (TOKEN_SOURCE);
+	if(TokenInformationLength < sizeof (TOKEN_SOURCE)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_SOURCE));
+	break;
+    case TokenType:
+      	*ReturnLength = sizeof (TOKEN_TYPE);
+	if(TokenInformationLength < sizeof (TOKEN_TYPE)) {
+		return STATUS_BUFFER_TOO_SMALL;
+	}
+	memset(TokenInformation, 0, sizeof(TOKEN_TYPE));
+	break;
 #if 0
-    case TokenUser:                     /* 1 */
-    case TokenPrivileges:
-    case TokenOwner:
-    case TokenPrimaryGroup:
-    case TokenDefaultDacl:
-    case TokenSource:
-    case TokenType:
     case TokenImpersonationLevel:
     case TokenStatistics:
@@ -345,5 +392,5 @@
   }
 
-  return 0;
+  return STATUS_SUCCESS;
 }
 
Index: trunk/src/NTDLL/ntdll.cpp
===================================================================
--- trunk/src/NTDLL/ntdll.cpp	(revision 2115)
+++ trunk/src/NTDLL/ntdll.cpp	(revision 2122)
@@ -1,3 +1,3 @@
-/* $Id: ntdll.cpp,v 1.3 1999-11-09 09:30:20 phaller Exp $ */
+/* $Id: ntdll.cpp,v 1.4 1999-12-18 20:01:14 sandervl Exp $ */
 
 /*
@@ -50,4 +50,6 @@
 #define NTSTATUS DWORD
 
+//SvL: per process heap for NTDLL
+HANDLE NTDLL_hHeap = 0;
 
 /*****************************************************************************
@@ -77,2 +79,26 @@
   //@@@PH raise debug exception if running in debugger
 }
+
+
+BOOL WINAPI NTDLL_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    dprintf(("NTDLL_LibMain: 0x%x 0x%lx %p\n", hinstDLL, fdwReason, lpvReserved));
+
+    switch (fdwReason) {
+    case DLL_PROCESS_ATTACH:
+        NTDLL_hHeap = HeapCreate(0, 0x10000, 0);
+	break;
+    case DLL_PROCESS_DETACH:
+        HeapDestroy(NTDLL_hHeap);
+        NTDLL_hHeap = 0;
+	break;
+    case DLL_THREAD_ATTACH:
+	break;
+    case DLL_THREAD_DETACH:
+	break;
+    default:
+	break;
+    }
+    return TRUE;
+}
+
Index: trunk/src/NTDLL/ntdll.h
===================================================================
--- trunk/src/NTDLL/ntdll.h	(revision 2115)
+++ trunk/src/NTDLL/ntdll.h	(revision 2122)
@@ -1,3 +1,3 @@
-/* $Id: ntdll.h,v 1.7 1999-08-22 22:45:52 sandervl Exp $ */
+/* $Id: ntdll.h,v 1.8 1999-12-18 20:01:14 sandervl Exp $ */
 
 /*
@@ -45,4 +45,8 @@
 
 
+//SvL: Internal heap allocation definitions for NTDLL
+extern HANDLE NTDLL_hHeap;
+#define Heap_Alloc(a)	HeapAlloc(NTDLL_hHeap, HEAP_ZERO_MEMORY, a)
+#define Heap_Free(a)	HeapFree(NTDLL_hHeap, 0, (PVOID)a)
 
 typedef struct _IO_STATUS_BLOCK
@@ -367,19 +371,18 @@
  */
 
-BOOLEAN WINAPI RtlAllocateAndInitializeSid (
-   PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
-   DWORD nSubAuthorityCount,
-   DWORD x3,
-   DWORD x4,
-   DWORD x5,
-   DWORD x6,
-   DWORD x7,
-   DWORD x8,
-   DWORD x9,
-   DWORD x10,
-   PSID pSid);
-
-DWORD WINAPI RtlEqualSid(DWORD x1,DWORD x2);
-DWORD WINAPI RtlFreeSid(DWORD x1);
+BOOLEAN WINAPI RtlAllocateAndInitializeSid ( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+					     BYTE nSubAuthorityCount,
+					     DWORD nSubAuthority0,
+					     DWORD nSubAuthority1,
+					     DWORD nSubAuthority2,
+					     DWORD nSubAuthority3,
+					     DWORD nSubAuthority4,
+					     DWORD nSubAuthority5,
+					     DWORD nSubAuthority6,
+					     DWORD nSubAuthority7,
+					     PSID *pSid);
+	
+BOOL WINAPI RtlEqualSid(PSID pSid1, PSID pSid2);
+VOID* WINAPI RtlFreeSid(PSID pSid);
 DWORD WINAPI RtlLengthRequiredSid(DWORD nrofsubauths);
 DWORD WINAPI RtlLengthSid(PSID sid);
Index: trunk/src/NTDLL/sec.cpp
===================================================================
--- trunk/src/NTDLL/sec.cpp	(revision 2115)
+++ trunk/src/NTDLL/sec.cpp	(revision 2122)
@@ -1,3 +1,3 @@
-/* $Id: sec.cpp,v 1.3 1999-07-06 15:48:45 phaller Exp $ */
+/* $Id: sec.cpp,v 1.4 1999-12-18 20:01:14 sandervl Exp $ */
 
 /*
@@ -44,15 +44,15 @@
  *
  */
-BOOLEAN WINAPI RtlAllocateAndInitializeSid (PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
-                                            DWORD                     nSubAuthorityCount,
-                                            DWORD                     x3,
-                                            DWORD                     x4,
-                                            DWORD                     x5,
-                                            DWORD                     x6,
-                                            DWORD                     x7,
-                                            DWORD                     x8,
-                                            DWORD                     x9,
-                                            DWORD                     x10,
-                                            PSID                      pSid)
+BOOLEAN WINAPI RtlAllocateAndInitializeSid ( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+					     BYTE nSubAuthorityCount,
+					     DWORD nSubAuthority0,
+					     DWORD nSubAuthority1,
+					     DWORD nSubAuthority2,
+					     DWORD nSubAuthority3,
+					     DWORD nSubAuthority4,
+					     DWORD nSubAuthority5,
+					     DWORD nSubAuthority6,
+					     DWORD nSubAuthority7,
+					     PSID *pSid)
 {
   dprintf(("NTDLL: RtlAllocateAndInitializeSid(%08xh,%08xh,%08xh,"
@@ -60,15 +60,31 @@
            pIdentifierAuthority,
            nSubAuthorityCount,
-           x3,
-           x4,
-           x5,
-           x6,
-           x7,
-           x8,
-           x9,
-           x10,
+           nSubAuthority0,
+           nSubAuthority1,
+           nSubAuthority2,
+           nSubAuthority3,
+           nSubAuthority4,
+           nSubAuthority5,
+           nSubAuthority6,
+           nSubAuthority7,
            pSid));
 
-  return 0;
+  *pSid = (PSID)Heap_Alloc(sizeof(SID)+nSubAuthorityCount*sizeof(DWORD));
+  if(*pSid == NULL) {
+	SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+	return FALSE;
+  }
+  (*pSid)->Revision          = SID_REVISION;
+  (*pSid)->SubAuthorityCount = nSubAuthorityCount;
+  (*pSid)->SubAuthority[0]   = nSubAuthority0;
+  (*pSid)->SubAuthority[1]   = nSubAuthority1;
+  (*pSid)->SubAuthority[2]   = nSubAuthority2;
+  (*pSid)->SubAuthority[3]   = nSubAuthority3;
+  (*pSid)->SubAuthority[4]   = nSubAuthority4;
+  (*pSid)->SubAuthority[5]   = nSubAuthority5;
+  (*pSid)->SubAuthority[6]   = nSubAuthority6;
+  (*pSid)->SubAuthority[7]   = nSubAuthority7;
+  memcpy((PVOID)&(*pSid)->IdentifierAuthority, (PVOID)pIdentifierAuthority, sizeof(SID_IDENTIFIER_AUTHORITY));
+  return TRUE;
 }
 
@@ -78,10 +94,9 @@
  *
  */
-DWORD WINAPI RtlEqualSid(DWORD x1,
-                         DWORD x2)
+BOOL WINAPI RtlEqualSid(PSID pSid1, PSID pSid2)
 {
   dprintf(("NTDLL: RtlEqualSid(%08x, %08x) not implemented.\n",
-           x1,
-           x2));
+           pSid1,
+           pSid2));
 
   return TRUE;
@@ -92,10 +107,11 @@
  *  RtlFreeSid    [NTDLL.376]
  */
-DWORD WINAPI RtlFreeSid(DWORD x1)
+VOID* WINAPI RtlFreeSid(PSID pSid)
 {
   dprintf(("NTDLL: RtlFreeSid(%08xh) not implemented.\n",
-           x1));
-
-  return TRUE;
+           pSid));
+
+  Heap_Free(pSid);
+  return (VOID*)TRUE; //??????
 }
 
