-/* $Id: misc.c,v 1.5 2004/07/12 10:33:04 weiden Exp $
+/*
+ * ReactOS kernel
+ * Copyright (C) 2004 ReactOS Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* PROGRAMMER: Eric Kohl
*/
-#include <ntos.h>
-#include <windows.h>
-#include <string.h>
+#include <precomp.h>
-#include "internal.h"
+#define NDEBUG
+#include <debug.h>
/* FUNCTIONS ***************************************************************/
GetUserSidFromToken (HANDLE hToken,
PUNICODE_STRING SidString)
{
- PSID_AND_ATTRIBUTES SidBuffer;
+ PSID_AND_ATTRIBUTES SidBuffer, nsb;
ULONG Length;
NTSTATUS Status;
Length = 256;
- SidBuffer = LocalAlloc (0,
+ SidBuffer = LocalAlloc (LMEM_FIXED,
Length);
if (SidBuffer == NULL)
return FALSE;
&Length);
if (Status == STATUS_BUFFER_TOO_SMALL)
{
- SidBuffer = LocalReAlloc (SidBuffer,
- Length,
- 0);
- if (SidBuffer == NULL)
- return FALSE;
-
+ nsb = LocalReAlloc (SidBuffer,
+ Length,
+ LMEM_MOVEABLE);
+ if (nsb == NULL)
+ {
+ LocalFree((HLOCAL)SidBuffer);
+ return FALSE;
+ }
+
+ SidBuffer = nsb;
Status = NtQueryInformationToken (hToken,
TokenUser,
(PVOID)SidBuffer,
if (!NT_SUCCESS (Status))
{
- LocalFree (SidBuffer);
+ LocalFree ((HLOCAL)SidBuffer);
+ SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
}
SidBuffer[0].Sid,
TRUE);
- LocalFree (SidBuffer);
+ LocalFree ((HLOCAL)SidBuffer);
if (!NT_SUCCESS (Status))
- return FALSE;
+ {
+ SetLastError (RtlNtStatusToDosError (Status));
+ return FALSE;
+ }
DPRINT ("SidString.Length: %lu\n", SidString->Length);
DPRINT ("SidString.MaximumLength: %lu\n", SidString->MaximumLength);
return TRUE;
}
+PVOID
+CreateDefaultSD(VOID)
+{
+ /* FIXME - create a default security descriptor */
+ return NULL;
+}
+
/* Dynamic DLL loading interface **********************************************/
/* OLE32.DLL import table */
-DYN_MODULE DynOle32 =
+DYN_MODULE DynOle32 =
{
L"ole32.dll",
{
}
};
-/*
- Use this function to load functions from other modules. We cannot statically
- link to e.g. ole32.dll because those dlls would get loaded on startup with
- winlogon and they may try to register classes etc when not even a window station
- has been created!
-*/
+/*
+ * Use this function to load functions from other modules. We cannot statically
+ * link to e.g. ole32.dll because those dlls would get loaded on startup with
+ * winlogon and they may try to register classes etc when not even a window station
+ * has been created!
+ */
BOOL
LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
{
LPSTR *fname;
PVOID *fn;
-
+
ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
-
+
DynFuncs->hModule = LoadLibraryW(Module->Library);
- if(!DynFuncs->hModule)
- {
- return FALSE;
- }
-
+ if (!DynFuncs->hModule)
+ {
+ return FALSE;
+ }
+
fn = &DynFuncs->fn.foo;
-
+
/* load the imports */
- for(fname = Module->Functions; *fname != NULL; fname++)
- {
- *fn = GetProcAddress(DynFuncs->hModule, *fname);
- if(*fn == NULL)
+ for (fname = Module->Functions; *fname != NULL; fname++)
{
- FreeLibrary(DynFuncs->hModule);
- DynFuncs->hModule = (HMODULE)0;
- return FALSE;
+ *fn = GetProcAddress(DynFuncs->hModule, *fname);
+ if (*fn == NULL)
+ {
+ FreeLibrary(DynFuncs->hModule);
+ DynFuncs->hModule = (HMODULE)0;
+
+ return FALSE;
+ }
+
+ fn++;
}
- fn++;
- }
-
+
return TRUE;
}
+
VOID
UnloadDynamicImports(PDYN_FUNCS DynFuncs)
{
- if(DynFuncs->hModule)
- {
- FreeLibrary(DynFuncs->hModule);
- DynFuncs->hModule = (HMODULE)0;
- }
+ if (DynFuncs->hModule)
+ {
+ FreeLibrary(DynFuncs->hModule);
+ DynFuncs->hModule = (HMODULE)0;
+ }
}
/* EOF */