diff --git a/reactos/lib/kernel32/file/move.c b/reactos/lib/kernel32/file/move.c index a9fe1ca2d1e..f7ad25d1880 100644 --- a/reactos/lib/kernel32/file/move.c +++ b/reactos/lib/kernel32/file/move.c @@ -1,4 +1,4 @@ -/* $Id: move.c,v 1.15 2004/12/04 15:38:22 hbirr Exp $ +/* $Id: move.c,v 1.16 2004/12/18 13:26:57 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -18,14 +18,6 @@ /* GLOBALS *****************************************************************/ -#if defined(__GNUC__) -void * alloca(size_t size); -#elif defined(_MSC_VER) -void* _alloca(size_t size); -#else -#error Unknown compiler for alloca intrinsic stack allocation "function" -#endif - /* FUNCTIONS ****************************************************************/ static BOOL diff --git a/reactos/lib/kernel32/k32.h b/reactos/lib/kernel32/k32.h index 85e8c65340b..e985b983c26 100755 --- a/reactos/lib/kernel32/k32.h +++ b/reactos/lib/kernel32/k32.h @@ -36,3 +36,5 @@ #include #include "include/kernel32.h" + +#include diff --git a/reactos/lib/kernel32/misc/console.c b/reactos/lib/kernel32/misc/console.c index 230407f5935..54710bb3a5b 100644 --- a/reactos/lib/kernel32/misc/console.c +++ b/reactos/lib/kernel32/misc/console.c @@ -1,4 +1,4 @@ -/* $Id: console.c,v 1.85 2004/12/18 00:28:16 gdalsnes Exp $ +/* $Id: console.c,v 1.86 2004/12/18 13:26:57 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -31,6 +31,7 @@ static BOOL IgnoreCtrlEvents = FALSE; static PHANDLER_ROUTINE* CtrlHandlers = NULL; static ULONG NrCtrlHandlers = 0; +static WCHAR InputExeName[MAX_PATH + 1] = L""; /* Default Console Control Handler *******************************************/ @@ -3412,4 +3413,160 @@ BOOL STDCALL SetConsoleIcon(HICON hicon) return NT_SUCCESS(Status); } + +/*-------------------------------------------------------------- + * SetConsoleInputExeNameW + * + * @implemented + */ +BOOL STDCALL +SetConsoleInputExeNameW(LPCWSTR lpInputExeName) +{ + int lenName = lstrlenW(lpInputExeName); + + if(lenName < 1 || + lenName > (sizeof(InputExeName) / sizeof(InputExeName[0])) - 1) + { + /* Fail if string is empty or too long */ + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + RtlEnterCriticalSection(&ConsoleLock); + RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR)); + InputExeName[lenName] = L'\0'; + RtlLeaveCriticalSection(&ConsoleLock); + + return TRUE; +} + + +/*-------------------------------------------------------------- + * SetConsoleInputExeNameA + * + * @implemented + */ +BOOL STDCALL +SetConsoleInputExeNameA(LPCSTR lpInputExeName) +{ + ANSI_STRING InputExeNameA; + UNICODE_STRING InputExeNameU; + NTSTATUS Status; + BOOL Ret; + + RtlInitAnsiString(&InputExeNameA, lpInputExeName); + + if(InputExeNameA.Length < sizeof(InputExeNameA.Buffer[0]) || + InputExeNameA.Length >= (sizeof(InputExeName) / sizeof(InputExeName[0])) - 1) + { + /* Fail if string is empty or too long */ + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + Status = RtlAnsiStringToUnicodeString(&InputExeNameU, &InputExeNameA, TRUE); + if(NT_SUCCESS(Status)) + { + Ret = SetConsoleInputExeNameW(InputExeNameU.Buffer); + RtlFreeUnicodeString(&InputExeNameU); + } + else + { + SetLastErrorByStatus(Status); + Ret = FALSE; + } + + return Ret; +} + + +/*-------------------------------------------------------------- + * GetConsoleInputExeNameW + * + * @implemented + */ +DWORD STDCALL +GetConsoleInputExeNameW(DWORD nBufferLength, LPWSTR lpBuffer) +{ + int lenName; + + RtlEnterCriticalSection(&ConsoleLock); + + lenName = lstrlenW(InputExeName); + if(lenName >= nBufferLength) + { + /* buffer is not large enough, return the required size */ + RtlLeaveCriticalSection(&ConsoleLock); + return lenName + 1; + } + + /* wrap copying into SEH as we may copy to invalid buffer and in case of an + exception the console lock would've never been released, which would cause + further calls (if the exception was handled by the caller) to recursively + acquire the lock... */ + _SEH_TRY + { + RtlCopyMemory(lpBuffer, InputExeName, (lenName + 1) * sizeof(WCHAR)); + } + _SEH_HANDLE + { + lenName = 0; + SetLastErrorByStatus(_SEH_GetExceptionCode()); + } + _SEH_END; + + RtlLeaveCriticalSection(&ConsoleLock); + + return lenName; +} + + +/*-------------------------------------------------------------- + * GetConsoleInputExeNameA + * + * @implemented + */ +DWORD STDCALL +GetConsoleInputExeNameA(DWORD nBufferLength, LPSTR lpBuffer) +{ + WCHAR *Buffer; + DWORD Ret; + + if(nBufferLength > 0) + { + Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, nBufferLength * sizeof(WCHAR)); + if(Buffer == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + } + else + { + Buffer = NULL; + } + + Ret = GetConsoleInputExeNameW(nBufferLength, Buffer); + if(nBufferLength > 0) + { + if(Ret > 0) + { + UNICODE_STRING BufferU; + ANSI_STRING BufferA; + + RtlInitUnicodeString(&BufferU, Buffer); + + BufferA.Length = 0; + BufferA.MaximumLength = nBufferLength; + BufferA.Buffer = lpBuffer; + + RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE); + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + } + + return Ret; +} + /* EOF */ diff --git a/reactos/lib/kernel32/misc/ldr.c b/reactos/lib/kernel32/misc/ldr.c index 7ae5282964f..80bd86ba8f5 100644 --- a/reactos/lib/kernel32/misc/ldr.c +++ b/reactos/lib/kernel32/misc/ldr.c @@ -1,4 +1,4 @@ -/* $Id: ldr.c,v 1.21 2004/06/13 20:04:56 navaraf Exp $ +/* $Id: ldr.c,v 1.22 2004/12/18 13:26:57 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT : ReactOS user mode libraries @@ -72,6 +72,8 @@ LoadLibraryExA ( NTSTATUS Status; (void)hFile; + + DbgPrint("LoadLibraryExA: 0x%x (=%s) 0x%x, 0x%x\n", lpLibFileName, lpLibFileName ? lpLibFileName : "NULL", hFile, dwFlags); RtlInitAnsiString (&LibFileName, (LPSTR)lpLibFileName); diff --git a/reactos/lib/kernel32/misc/stubs.c b/reactos/lib/kernel32/misc/stubs.c index b5ecba33f29..1d36ce3413f 100644 --- a/reactos/lib/kernel32/misc/stubs.c +++ b/reactos/lib/kernel32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.100 2004/12/09 19:11:07 weiden Exp $ +/* $Id: stubs.c,v 1.101 2004/12/18 13:26:57 weiden Exp $ * * KERNEL32.DLL stubs (STUB functions) * Remove from this file, if you implement them. @@ -1670,24 +1670,6 @@ BOOL STDCALL SetHandleContext(HANDLE hnd,DWORD context) return 0; } -/* - * @unimplemented - */ -BOOL STDCALL SetConsoleInputExeNameA(LPCSTR name) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL STDCALL SetConsoleInputExeNameW(LPCWSTR name) -{ - STUB; - return 0; -} - /* * @unimplemented */ @@ -1730,24 +1712,6 @@ NTSTATUS STDCALL CreateNlsSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescri return 0; } -/* - * @unimplemented - */ -BOOL STDCALL GetConsoleInputExeNameA(ULONG length,LPCSTR name) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL STDCALL GetConsoleInputExeNameW(ULONG length,LPCWSTR name) -{ - STUB; - return 0; -} - /* * @unimplemented */ diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index dc481d17ab6..0fdef2dea88 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.90 2004/12/13 13:32:24 navaraf Exp $ +/* $Id: create.c,v 1.91 2004/12/18 13:26:57 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -12,7 +12,6 @@ /* INCLUDES ****************************************************************/ #include -#include #define NDEBUG #include "../include/debug.h" diff --git a/reactos/lib/kernel32/thread/thread.c b/reactos/lib/kernel32/thread/thread.c index 6e8d868faff..67623e01ca9 100644 --- a/reactos/lib/kernel32/thread/thread.c +++ b/reactos/lib/kernel32/thread/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.59 2004/12/13 13:32:24 navaraf Exp $ +/* $Id: thread.c,v 1.60 2004/12/18 13:26:57 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -14,7 +14,6 @@ /* INCLUDES ******************************************************************/ #include -#include #define NDEBUG #include "../include/debug.h"