reactos/lib/kernel32/file
diff -u -r1.50 -r1.51
--- dir.c 7 Oct 2004 21:05:36 -0000 1.50
+++ dir.c 9 Dec 2004 17:28:10 -0000 1.51
@@ -1,4 +1,4 @@
-/* $Id: dir.c,v 1.50 2004/10/07 21:05:36 gvg Exp $
+/* $Id: dir.c,v 1.51 2004/12/09 17:28:10 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -20,6 +20,7 @@
#define NDEBUG
#include "../include/debug.h"
+UNICODE_STRING DllDirectory = {0, 0, NULL};
/* FUNCTIONS *****************************************************************/
@@ -878,4 +879,184 @@
return retCode / sizeof(WCHAR);
}
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+SetDllDirectoryW(
+ LPCWSTR lpPathName
+ )
+{
+ UNICODE_STRING PathName;
+
+ RtlInitUnicodeString(&PathName, lpPathName);
+
+ RtlEnterCriticalSection(&DllLock);
+ if(PathName.Length > 0)
+ {
+ if(PathName.Length + sizeof(WCHAR) <= DllDirectory.MaximumLength)
+ {
+ RtlCopyUnicodeString(&DllDirectory, &PathName);
+ }
+ else
+ {
+ RtlFreeUnicodeString(&DllDirectory);
+ if(!(DllDirectory.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(),
+ 0,
+ PathName.Length + sizeof(WCHAR))))
+ {
+ RtlLeaveCriticalSection(&DllLock);
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+ DllDirectory.Length = 0;
+ DllDirectory.MaximumLength = PathName.Length + sizeof(WCHAR);
+
+ RtlCopyUnicodeString(&DllDirectory, &PathName);
+ }
+ }
+ else
+ {
+ RtlFreeUnicodeString(&DllDirectory);
+ }
+ RtlLeaveCriticalSection(&DllLock);
+
+ return TRUE;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+SetDllDirectoryA(
+ LPCSTR lpPathName
+ )
+{
+ UNICODE_STRING PathNameU;
+ ANSI_STRING PathNameA;
+ BOOL Ret;
+
+ if(lpPathName != NULL)
+ {
+ RtlInitAnsiString(&PathNameA, lpPathName);
+ if(bIsFileApiAnsi)
+ {
+ RtlAnsiStringToUnicodeString(&PathNameU, &PathNameA, TRUE);
+ }
+ else
+ {
+ RtlOemStringToUnicodeString(&PathNameU, &PathNameA, TRUE);
+ }
+ }
+ else
+ {
+ PathNameU.Buffer = NULL;
+ }
+
+ Ret = SetDllDirectoryW(PathNameU.Buffer);
+
+ if(lpPathName != NULL)
+ {
+ RtlFreeUnicodeString(&PathNameU);
+ }
+
+ return Ret;
+}
+
+/*
+ * @implemented
+ */
+DWORD
+STDCALL
+GetDllDirectoryW(
+ DWORD nBufferLength,
+ LPWSTR lpBuffer
+ )
+{
+ DWORD Ret;
+
+ RtlEnterCriticalSection(&DllLock);
+ if(nBufferLength > 0)
+ {
+ Ret = DllDirectory.Length / sizeof(WCHAR);
+ if(Ret > nBufferLength - 1)
+ {
+ Ret = nBufferLength - 1;
+ }
+
+ if(Ret > 0)
+ {
+ RtlCopyMemory(lpBuffer, DllDirectory.Buffer, Ret * sizeof(WCHAR));
+ }
+ lpBuffer[Ret] = L'\0';
+ }
+ else
+ {
+ /* include termination character, even if the string is empty! */
+ Ret = (DllDirectory.Length / sizeof(WCHAR)) + 1;
+ }
+ RtlLeaveCriticalSection(&DllLock);
+
+ return Ret;
+}
+
+/*
+ * @implemented
+ */
+DWORD
+STDCALL
+GetDllDirectoryA(
+ DWORD nBufferLength,
+ LPSTR lpBuffer
+ )
+{
+ UNICODE_STRING PathNameU;
+ ANSI_STRING PathNameA;
+ DWORD Ret;
+
+ if(nBufferLength > 0)
+ {
+ if(!(PathNameU.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(),
+ 0,
+ nBufferLength * sizeof(WCHAR))))
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+ PathNameU.Length = 0;
+ PathNameU.MaximumLength = nBufferLength * sizeof(WCHAR);
+ }
+
+ Ret = GetDllDirectoryW(nBufferLength,
+ ((nBufferLength > 0) ? PathNameU.Buffer : NULL));
+
+ if(nBufferLength > 0)
+ {
+ PathNameU.Length = Ret * sizeof(WCHAR);
+
+ PathNameA.Length = 0;
+ PathNameA.MaximumLength = nBufferLength;
+ PathNameA.Buffer = lpBuffer;
+
+ if(Ret > 0)
+ {
+ if(bIsFileApiAnsi)
+ {
+ RtlUnicodeStringToAnsiString(&PathNameA, &PathNameU, FALSE);
+ }
+ else
+ {
+ RtlUnicodeStringToOemString(&PathNameA, &PathNameU, FALSE);
+ }
+ }
+ lpBuffer[Ret] = '\0';
+
+ RtlFreeHeap(RtlGetProcessHeap(), 0, PathNameU.Buffer);
+ }
+
+ return Ret;
+}
+
/* EOF */
reactos/lib/kernel32/include
diff -u -r1.6 -r1.7
--- kernel32.h 26 Jun 2004 20:06:25 -0000 1.6
+++ kernel32.h 9 Dec 2004 17:28:10 -0000 1.7
@@ -41,6 +41,8 @@
extern CRITICAL_SECTION DllLock;
+extern UNICODE_STRING DllDirectory;
+
/* FUNCTION PROTOTYPES *******************************************************/
BOOL STDCALL IsConsoleHandle(HANDLE Handle);
reactos/lib/kernel32/misc
diff -u -r1.98 -r1.99
--- stubs.c 7 Dec 2004 20:18:49 -0000 1.98
+++ stubs.c 9 Dec 2004 17:28:10 -0000 1.99
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.98 2004/12/07 20:18:49 royce Exp $
+/* $Id: stubs.c,v 1.99 2004/12/09 17:28:10 weiden Exp $
*
* KERNEL32.DLL stubs (STUB functions)
* Remove from this file, if you implement them.
@@ -1159,20 +1159,6 @@
*/
DWORD
STDCALL
-GetDllDirectoryW(
- DWORD nBufferLength,
- LPWSTR lpBuffer
- )
-{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
GetFirmwareEnvironmentVariableW(
LPCWSTR lpName,
LPCWSTR lpGuid,
@@ -1311,19 +1297,6 @@
*/
BOOL
STDCALL
-SetDllDirectoryW(
- LPCWSTR lpPathName
- )
-{
- STUB;
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
SetFirmwareEnvironmentVariableW(
LPCWSTR lpName,
LPCWSTR lpGuid,
@@ -1473,20 +1446,6 @@
*/
DWORD
STDCALL
-GetDllDirectoryA(
- DWORD nBufferLength,
- LPSTR lpBuffer
- )
-{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
GetFirmwareEnvironmentVariableA(
LPCSTR lpName,
LPCSTR lpGuid,
@@ -1625,19 +1584,6 @@
*/
BOOL
STDCALL
-SetDllDirectoryA(
- LPCSTR lpPathName
- )
-{
- STUB;
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
SetFirmwareEnvironmentVariableA(
LPCSTR lpName,
LPCSTR lpGuid,