diff --git a/reactos/base/applications/cmdutils/whoami/CMakeLists.txt b/reactos/base/applications/cmdutils/whoami/CMakeLists.txt index 60094134b38..b94bc1498cd 100644 --- a/reactos/base/applications/cmdutils/whoami/CMakeLists.txt +++ b/reactos/base/applications/cmdutils/whoami/CMakeLists.txt @@ -1,5 +1,8 @@ +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) + add_executable(whoami whoami.c whoami.rc) set_module_type(whoami win32cui UNICODE) +target_link_libraries(whoami conutils ${PSEH_LIB}) add_importlibs(whoami user32 secur32 advapi32 msvcrt kernel32) add_cd_file(TARGET whoami DESTINATION reactos/system32 FOR all) diff --git a/reactos/base/applications/cmdutils/whoami/whoami.c b/reactos/base/applications/cmdutils/whoami/whoami.c index 485fb084b6d..8d8f7e14a4e 100644 --- a/reactos/base/applications/cmdutils/whoami/whoami.c +++ b/reactos/base/applications/cmdutils/whoami/whoami.c @@ -6,69 +6,16 @@ * PROGRAMMERS: Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com) */ - #define SECURITY_WIN32 #include #include - #include +#include + #include "resource.h" - -/* Unicode (W) to ANSI OEM wrapper function, as console and Unicode don't mix well, sigh */ -static void WhoamiOemConversion_printf(const WCHAR *lpSourceFormatW, ...) -{ - CHAR *lpBufferA = NULL; - WCHAR *lpBufferW = NULL; - - UINT Size; - va_list Args; - - /* first let's find out the final output'ed length of the wprintf routine */ - va_start(Args, lpSourceFormatW); - - Size = _vscwprintf(lpSourceFormatW, Args); - - va_end(Args); - - /* allocate a proportional memory chunk taking into account the char width */ - lpBufferW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (Size + 1) * sizeof(WCHAR)); - - if (!lpBufferW) - return; - - /* do wprintf to this newly allocated buffer of ours */ - va_start(Args, lpSourceFormatW); - - _vsnwprintf(lpBufferW, Size, lpSourceFormatW, Args); - - va_end(Args); - - /* allocate a similarly sized buffer for the ANSI/OEM version of our string */ - lpBufferA = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (Size + 1) * sizeof(CHAR)); - - if (!lpBufferA) - { - HeapFree(GetProcessHeap(), 0, lpBufferW); - return; - } - - /* convert our Unicode/Wide char string into a proper ANSI/OEM - string that our console may understand, at least in theory */ - CharToOemBuffW(lpBufferW, - lpBufferA, - Size); - - /* print the converted OEM string into the console's output and call it a day */ - printf("%s", lpBufferA); - - /* clean everything up */ - HeapFree(GetProcessHeap(), 0, lpBufferW); - HeapFree(GetProcessHeap(), 0, lpBufferA); -} - -#define wprintf WhoamiOemConversion_printf +#define wprintf(...) ConPrintf(StdOut, ##__VA_ARGS__) BOOL NoHeader = FALSE; UINT NoHeaderArgCount = 0; @@ -194,7 +141,6 @@ void WhoamiPrintHeader(int HeaderId) while (Length--) wprintf(L"-"); - /* _putws seems to be broken in ReactOS' CRT ??? */ wprintf(L"\n\n"); } @@ -718,13 +664,16 @@ int WhoamiPriv(void) int wmain(int argc, WCHAR* argv[]) { - INT i; - BYTE WamBit = 0; - #define WAM_USER 1<<0 #define WAM_GROUPS 1<<1 #define WAM_PRIV 1<<2 + INT i; + BYTE WamBit = 0; + + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + /* * * * * * * * * * * * * * * * * A: no parameters whatsoever */