Index: trunk/src/kernel32/Fileio.cpp
===================================================================
--- trunk/src/kernel32/Fileio.cpp	(revision 3587)
+++ trunk/src/kernel32/Fileio.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: Fileio.cpp,v 1.32 2000-05-09 19:27:44 sandervl Exp $ */
+/* $Id: Fileio.cpp,v 1.33 2000-05-22 19:07:53 sandervl Exp $ */
 
 /*
@@ -241,4 +241,10 @@
 //******************************************************************************
 //******************************************************************************
+ODINFUNCTION4(BOOL, GetFileTime, HANDLE, hFile, LPFILETIME, arg2, LPFILETIME, arg3, LPFILETIME, arg4)
+{
+    return HMGetFileTime(hFile, arg2, arg3, arg4);
+}
+//******************************************************************************
+//******************************************************************************
 ODINFUNCTION3(BOOL, CopyFileA,
               LPCSTR, arg1,
@@ -280,7 +286,16 @@
               LPCSTR, lpszFile)
 {
-  dprintf(("DeleteFileA %s", lpszFile));
-  return O32_DeleteFile(lpszFile);
-//  return TRUE;
+ BOOL rc;
+
+  rc = O32_DeleteFile(lpszFile);
+  if(!rc) {
+  	dprintf(("DeleteFileA %s returned FALSE; last error %x", lpszFile, GetLastError()));
+	if(GetLastError() == 20) {
+		return TRUE;
+	}
+  } 
+  else  dprintf(("DeleteFileA %s", lpszFile));
+
+  return rc;
 }
 //******************************************************************************
@@ -431,4 +446,9 @@
 	}
     }
+    //SvL: Open32 returns FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_NORMAL for
+    //     directories whereas NT 4 (SP6) only returns FILE_ATTRIBUTE_DIRECTORY
+    if(rc != -1 && (rc & FILE_ATTRIBUTE_DIRECTORY)) {
+	rc = FILE_ATTRIBUTE_DIRECTORY;
+    }
 
 #if 0 // need more tests, maybe there is also a better way to hide simulated b:
Index: trunk/src/kernel32/HandleManager.cpp
===================================================================
--- trunk/src/kernel32/HandleManager.cpp	(revision 3587)
+++ trunk/src/kernel32/HandleManager.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: HandleManager.cpp,v 1.38 2000-03-24 23:14:59 sandervl Exp $ */
+/* $Id: HandleManager.cpp,v 1.39 2000-05-22 19:07:52 sandervl Exp $ */
 
 /*
@@ -1346,4 +1346,42 @@
 }
 
+/*****************************************************************************
+ * Name      : HMDeviceHandler::GetFileTime
+ * Purpose   : router function for SetFileTime
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    :
+ *
+ * Author    : SvL
+ *****************************************************************************/
+
+BOOL HMGetFileTime (HANDLE         hFile,
+                    const FILETIME *pFT1,
+                    const FILETIME *pFT2,
+                    const FILETIME *pFT3)
+{
+  int       iIndex;                           /* index into the handle table */
+  BOOL      bResult;                 /* result from the device handler's API */
+  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
+
+                                                          /* validate handle */
+  iIndex = _HMHandleQuery(hFile);                           /* get the index */
+  if (-1 == iIndex)                                               /* error ? */
+  {
+    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
+    return FALSE;                         /* signal failure */
+  }
+
+  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
+  bResult = pHMHandle->pDeviceHandler->GetFileTime(&pHMHandle->hmHandleData,
+                                                   (LPFILETIME)pFT1,
+                                                   (LPFILETIME)pFT2,
+                                                   (LPFILETIME)pFT3);
+
+  return (bResult);                                   /* deliver return code */
+}
+
 
 /*****************************************************************************
Index: trunk/src/kernel32/hmdevice.cpp
===================================================================
--- trunk/src/kernel32/hmdevice.cpp	(revision 3587)
+++ trunk/src/kernel32/hmdevice.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.cpp,v 1.18 2000-03-17 16:08:39 sandervl Exp $ */
+/* $Id: hmdevice.cpp,v 1.19 2000-05-22 19:07:54 sandervl Exp $ */
 
 /*
@@ -350,4 +350,28 @@
            pFT3));
 
+  return(ERROR_INVALID_FUNCTION);
+}
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceHandler::GetFileTime
+ * Purpose   : get file time
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             PFILETIME     pFT1
+ *             PFILETIME     pFT2
+ *             PFILETIME     pFT3
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : SvL
+ *****************************************************************************/
+
+BOOL HMDeviceHandler::GetFileTime(PHMHANDLEDATA pHMHandleData,
+                                      LPFILETIME pFT1,
+                                      LPFILETIME pFT2,
+                                      LPFILETIME pFT3)
+{
+  DebugInt3();
   return(ERROR_INVALID_FUNCTION);
 }
Index: trunk/src/kernel32/hmdevice.h
===================================================================
--- trunk/src/kernel32/hmdevice.h	(revision 3587)
+++ trunk/src/kernel32/hmdevice.h	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.h,v 1.17 2000-03-17 16:08:39 sandervl Exp $ */
+/* $Id: hmdevice.h,v 1.18 2000-05-22 19:07:55 sandervl Exp $ */
 
 /*
@@ -132,4 +132,10 @@
                       /* this is a handler method for calls to SetFileTime() */
   virtual BOOL  SetFileTime (PHMHANDLEDATA pHMHandleData,
+                             LPFILETIME    pFT1,
+                             LPFILETIME    pFT2,
+                             LPFILETIME    pFT3);
+
+                      /* this is a handler method for calls to GetFileTime() */
+  virtual BOOL  GetFileTime (PHMHANDLEDATA pHMHandleData,
                              LPFILETIME    pFT1,
                              LPFILETIME    pFT2,
Index: trunk/src/kernel32/hmopen32.cpp
===================================================================
--- trunk/src/kernel32/hmopen32.cpp	(revision 3587)
+++ trunk/src/kernel32/hmopen32.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: hmopen32.cpp,v 1.21 2000-05-09 18:56:08 sandervl Exp $ */
+/* $Id: hmopen32.cpp,v 1.22 2000-05-22 19:07:56 sandervl Exp $ */
 
 /*
@@ -185,9 +185,11 @@
   if (hFile != INVALID_HANDLE_ERROR)
   {
-     pHMHandleData->hHMHandle = hFile;
-     return (NO_ERROR);
-  }
-  else
-    return(O32_GetLastError());
+     	pHMHandleData->hHMHandle = hFile;
+     	return (NO_ERROR);
+  }
+  else {
+	dprintf(("CreateFile failed; error %x", O32_GetLastError()));
+    	return(O32_GetLastError());
+  }
 #else
 
@@ -516,4 +518,30 @@
 }
 
+/*****************************************************************************
+ * Name      : BOOL HMDeviceOpen32Class::GetFileTime
+ * Purpose   : get file time
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             PFILETIME     pFT1
+ *             PFILETIME     pFT2
+ *             PFILETIME     pFT3
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : SvL
+ *****************************************************************************/
+
+BOOL HMDeviceOpen32Class::GetFileTime(PHMHANDLEDATA pHMHandleData,
+                                      LPFILETIME pFT1,
+                                      LPFILETIME pFT2,
+                                      LPFILETIME pFT3)
+{
+  return O32_GetFileTime(pHMHandleData->hHMHandle,
+                         pFT1,
+                         pFT2,
+                         pFT3);
+}
+
 
 /*****************************************************************************
@@ -758,8 +786,8 @@
     pHMHandleData->hHMHandle = hFile;
 
-    GetFileTime(hFile,
-                NULL,
-                NULL,
-                &filetime );
+    ::GetFileTime(hFile,
+                  NULL,
+                  NULL,
+                  &filetime );
     FileTimeToDosDateTime(&filetime,
                           &filedatetime[0],
Index: trunk/src/kernel32/hmopen32.h
===================================================================
--- trunk/src/kernel32/hmopen32.h	(revision 3587)
+++ trunk/src/kernel32/hmopen32.h	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: hmopen32.h,v 1.4 1999-12-09 19:08:29 sandervl Exp $ */
+/* $Id: hmopen32.h,v 1.5 2000-05-22 19:07:56 sandervl Exp $ */
 
 /*
@@ -95,4 +95,10 @@
                              LPFILETIME    pFT3);
 
+                      /* this is a handler method for calls to GetFileTime() */
+  virtual BOOL  GetFileTime (PHMHANDLEDATA pHMHandleData,
+                             LPFILETIME    pFT1,
+                             LPFILETIME    pFT2,
+                             LPFILETIME    pFT3);
+
                       /* this is a handler method for calls to GetFileSize() */
   virtual DWORD GetFileSize(PHMHANDLEDATA pHMHandleData,
Index: trunk/src/kernel32/lang.cpp
===================================================================
--- trunk/src/kernel32/lang.cpp	(revision 3587)
+++ trunk/src/kernel32/lang.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: lang.cpp,v 1.19 2000-05-09 18:56:09 sandervl Exp $ */
+/* $Id: lang.cpp,v 1.20 2000-05-22 19:07:57 sandervl Exp $ */
 /*
  * Win32 language API functions for OS/2
@@ -141,5 +141,5 @@
 {
   dprintf(("KERNEL32:  OS2GetUserDefaultLCID: returns %x", MAKELCID(GetLanguageId(), SORT_DEFAULT)));
-  return(MAKELCID(GetLanguageId(), SORT_DEFAULT));        //US English
+  return(MAKELCID(GetLanguageId(), SORT_DEFAULT));
 }
 //******************************************************************************
Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 3587)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.cpp,v 1.26 2000-04-09 15:08:25 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.27 2000-05-22 19:07:58 sandervl Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
@@ -420,4 +420,10 @@
 //******************************************************************************
 //******************************************************************************
+DWORD OSLibDosDelete(char *lpszFileName)
+{
+  return DosDelete(lpszFileName);
+}
+//******************************************************************************
+//******************************************************************************
 BOOL pmDateTimeToFileTime(FDATE *pDate,FTIME *pTime,FILETIME *pFT)
 {
Index: trunk/src/kernel32/oslibdos.h
===================================================================
--- trunk/src/kernel32/oslibdos.h	(revision 3587)
+++ trunk/src/kernel32/oslibdos.h	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.h,v 1.13 2000-03-29 15:17:29 cbratschi Exp $ */
+/* $Id: oslibdos.h,v 1.14 2000-05-22 19:07:59 sandervl Exp $ */
 
 /*
@@ -71,4 +71,5 @@
 DWORD OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead);
 DWORD OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten);
+DWORD OSLibDosDelete(char *lpszFileName);
 
 #define OSLIB_SETPTR_FILE_CURRENT       1
Index: trunk/src/kernel32/time.cpp
===================================================================
--- trunk/src/kernel32/time.cpp	(revision 3587)
+++ trunk/src/kernel32/time.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: time.cpp,v 1.7 2000-02-16 14:23:12 sandervl Exp $ */
+/* $Id: time.cpp,v 1.8 2000-05-22 19:07:59 sandervl Exp $ */
 
 /*
@@ -114,11 +114,4 @@
     dprintf(("KERNEL32:  DosDateTimeToFileTime\n"));
     return O32_DosDateTimeToFileTime(arg1, arg2, arg3);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL WIN32API GetFileTime( HANDLE arg1, LPFILETIME arg2, LPFILETIME arg3, LPFILETIME  arg4)
-{
-    dprintf(("KERNEL32:  GetFileTime\n"));
-    return O32_GetFileTime(arg1, arg2, arg3, arg4);
 }
 //******************************************************************************
Index: trunk/src/kernel32/winimagebase.h
===================================================================
--- trunk/src/kernel32/winimagebase.h	(revision 3587)
+++ trunk/src/kernel32/winimagebase.h	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: winimagebase.h,v 1.7 2000-05-02 20:53:14 sandervl Exp $ */
+/* $Id: winimagebase.h,v 1.8 2000-05-22 19:08:00 sandervl Exp $ */
 
 /*
@@ -136,7 +136,7 @@
         ULONG getPEResourceSize(ULONG id, ULONG type, ULONG lang = LANG_GETFIRST);
 
-        PIMAGE_RESOURCE_DATA_ENTRY getPEResourceEntry(ULONG id, ULONG type, ULONG lang = LANG_GETFIRST);
+        PIMAGE_RESOURCE_DATA_ENTRY getPEResourceEntry(ULONG id, ULONG type, ULONG lang, int *error);
         PIMAGE_RESOURCE_DATA_ENTRY ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
-                                                    ULONG *nodeData, int level);
+                                                    ULONG *nodeData, int level, int *error);
         PIMAGE_RESOURCE_DIRECTORY  getResSubDirW(PIMAGE_RESOURCE_DIRECTORY pResDir, LPCWSTR lpszName);
         PIMAGE_RESOURCE_DIRECTORY  getResSubDirA(PIMAGE_RESOURCE_DIRECTORY pResDir, LPCTSTR lpszName);
Index: trunk/src/kernel32/winimgres.cpp
===================================================================
--- trunk/src/kernel32/winimgres.cpp	(revision 3587)
+++ trunk/src/kernel32/winimgres.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: winimgres.cpp,v 1.36 2000-05-18 09:08:38 sandervl Exp $ */
+/* $Id: winimgres.cpp,v 1.37 2000-05-22 19:08:00 sandervl Exp $ */
 
 /*
@@ -35,4 +35,9 @@
 #define BITMAP_TYPENAME2    "DIB"
 
+#define RESERR_SUCCESS          0
+#define RESERR_IDNOTFOUND	1
+#define RESERR_TYPENOTFOUND     2
+#define RESERR_LANGNOTFOUND     3
+
 //******************************************************************************
 //Assuming names are case insensitive
@@ -40,5 +45,5 @@
 //******************************************************************************
 PIMAGE_RESOURCE_DATA_ENTRY
- Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
+ Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang, int *error)
 {
  PIMAGE_RESOURCE_DIRECTORY       prdType;
@@ -48,4 +53,6 @@
  ULONG  nodeData[3], i, j, nameOffset;
  BOOL  fFound = FALSE, fNumType;
+
+  *error = RESERR_TYPENOTFOUND;
 
   //PH: our system LX DLLs might not have a resource segment
@@ -120,5 +127,5 @@
     if(fFound) {
         if((ULONG)prdType & 0x80000000) {//subdirectory?
-            pData = ProcessResSubDir(prdType, &nodeData[0], 2);
+            pData = ProcessResSubDir(prdType, &nodeData[0], 2, error);
         }
         else {
@@ -131,4 +138,7 @@
     prde++;
   }
+  if(pData) {
+	*error = RESERR_SUCCESS; //found it
+  }
   return pData;
 }
@@ -139,5 +149,5 @@
 PIMAGE_RESOURCE_DATA_ENTRY
     Win32ImageBase::ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
-                                     ULONG *nodeData, int level)
+                                     ULONG *nodeData, int level, int *error)
 {
  PIMAGE_RESOURCE_DIRECTORY       prdType2;
@@ -158,4 +168,10 @@
   prde    = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((DWORD)prdType + sizeof(IMAGE_RESOURCE_DIRECTORY));
 
+  if(level == 2) {
+	*error = RESERR_IDNOTFOUND;
+  }
+  else {
+	*error = RESERR_LANGNOTFOUND;
+  }
   //level 2 (id)   -> get first id?
   //level 3 (lang) -> get first language?
@@ -204,5 +220,5 @@
         if(fFound) {
             if((ULONG)prdType2 & 0x80000000) {//subdirectory?
-                    return ProcessResSubDir(prdType2, nodeData+1, 3);
+                    return ProcessResSubDir(prdType2, nodeData+1, 3, error);
             }
             else {
@@ -222,5 +238,6 @@
 ULONG Win32ImageBase::getPEResourceSize(ULONG id, ULONG type, ULONG lang)
 {
- PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
+ PIMAGE_RESOURCE_DATA_ENTRY pData = NULL;
+ int                        error;
 
     switch(lang) {
@@ -237,5 +254,5 @@
     }
 
-    pData = getPEResourceEntry(id, type, lang);
+    pData = getPEResourceEntry(id, type, lang, &error);
     if(pData == NULL) {
         dprintf(("Win32ImageBase::getPEResourceSize: couldn't find resource %d (type %d, lang %x)", id, type, lang));
@@ -246,5 +263,5 @@
 //******************************************************************************
 //******************************************************************************
-HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
+HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG langid)
 {
  PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
@@ -252,6 +269,6 @@
  BOOL   fNumType;
  char  *winres = NULL;
- ULONG  id, type;
- int    i, j;
+ ULONG  id, type, lang;
+ int    i, j, error;
 
     fNumType = TRUE;    //assume numeric
@@ -275,5 +292,5 @@
     else  type = (ULONG)lpszType;
 
-    switch(lang) {
+    switch(langid) {
     case LOCALE_SYSTEM_DEFAULT:
 	lang = GetSystemDefaultLangID();
@@ -285,15 +302,31 @@
 	//TODO: Not correct; should take language associated with current thread
 	lang = IDLANG_GETFIRST;
-	break;    
+	break; 
+    case IDLANG_GETFIRST:
+        lang = GetUserDefaultLangID();
+        break;   
     }
     id = (ULONG)lpszName;
 
-    pData = getPEResourceEntry(id, type, lang);
+    pData = getPEResourceEntry(id, type, lang, &error);
     if(pData == NULL) {
-        if(HIWORD(id)) {
-                dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %s (type %d, lang %x)", szModule, id, type, lang));
-        }
-        else    dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %d (type %d, lang %x)", szModule, id, type, lang));
-        return 0;
+        //TODO: Optimize this; check if language wasn't found
+        //try system default language
+	if(error == RESERR_LANGNOTFOUND) {
+	    	pData = getPEResourceEntry(id, type, GetSystemDefaultLangID(), &error);
+	}
+	if(pData == NULL) {
+        	//finally try first available language
+		if(error == RESERR_LANGNOTFOUND) {
+    			pData = getPEResourceEntry(id, type, IDLANG_GETFIRST, &error);
+		}
+		if(pData == NULL) {
+		        if(HIWORD(id)) {
+		                dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %s (type %d, lang %x)", szModule, id, type, lang));
+		        }
+		        else    dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %d (type %d, lang %x)", szModule, id, type, lang));
+		       	return 0;
+		}
+	}
     }
     if(HIWORD(id)) {
@@ -374,4 +407,5 @@
 {
  PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
+ int                             error;
 
     if(verstruct == NULL || bufLength == 0) {
@@ -379,5 +413,5 @@
         return FALSE;
     }
-    pData = getPEResourceEntry(ID_GETFIRST, NTRT_VERSION);
+    pData = getPEResourceEntry(ID_GETFIRST, NTRT_VERSION, IDLANG_GETFIRST, &error);
     if(pData == NULL) {
         dprintf(("Win32PeLdrImage::getVersionStruct: couldn't find version resource!"));
Index: trunk/src/kernel32/wprocess.cpp
===================================================================
--- trunk/src/kernel32/wprocess.cpp	(revision 3587)
+++ trunk/src/kernel32/wprocess.cpp	(revision 3588)
@@ -1,3 +1,3 @@
-/* $Id: wprocess.cpp,v 1.80 2000-05-02 20:53:15 sandervl Exp $ */
+/* $Id: wprocess.cpp,v 1.81 2000-05-22 19:08:01 sandervl Exp $ */
 
 /*
@@ -62,4 +62,18 @@
 static THDB     *threadList = 0;
 static VMutex    threadListMutex;
+
+//TODO: This should not be here: (need to rearrange NTDLL; kernel32 can't depend on ntdll)
+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);
+static HINSTANCE hInstNTDll = 0;
 //******************************************************************************
 //******************************************************************************
@@ -202,4 +216,29 @@
     }
     else thdb->flags      = 0;  //todo textmode
+
+    //Initialize thread security objects (TODO: Not complete)
+    if(hInstNTDll == 0) {
+	hInstNTDll = LoadLibraryA("NTDLL.DLL");
+	*(ULONG *)&RtlAllocateAndInitializeSid = (ULONG)GetProcAddress(hInstNTDll, "RtlAllocateAndInitializeSid");
+	if(RtlAllocateAndInitializeSid == NULL) {
+		DebugInt3();
+	}
+    }
+    SID_IDENTIFIER_AUTHORITY sidIdAuth = {0};
+    thdb->threadinfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED;
+    RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &thdb->threadinfo.SidUser.User.Sid);
+    thdb->threadinfo.SidUser.User.Attributes = 0; //?????????
+ 
+    thdb->threadinfo.pTokenGroups = (TOKEN_GROUPS*)malloc(sizeof(TOKEN_GROUPS));
+    thdb->threadinfo.pTokenGroups->GroupCount = 1;
+    RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &thdb->threadinfo.PrimaryGroup.PrimaryGroup);
+    thdb->threadinfo.pTokenGroups->Groups[0].Sid = thdb->threadinfo.PrimaryGroup.PrimaryGroup;
+    thdb->threadinfo.pTokenGroups->Groups[0].Attributes = 0; //????
+//        pPrivilegeSet   = NULL;
+//        pTokenPrivileges= NULL;
+//        TokenOwner      = {0};
+//        DefaultDACL     = {0};
+//        TokenSource     = {0};
+    thdb->threadinfo.TokenType = TokenPrimary;
 
     if(fMainThread)
