Make those command tools use the console uilities library, aka. solve all those problems of wrong characters on the console...
Nitpickers may notice that at some places, the usage of a "Puts"-like function would be better than Printf. Don't worry, I'm on it, it's for another commit.
CORE-10504
CORE-11909 #resolve
svn path=/trunk/; revision=72928
-list(APPEND SOURCE cacls.c cacls.rc)
-add_executable(cacls ${SOURCE})
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
+
+add_executable(cacls cacls.c cacls.rc)
set_module_type(cacls win32cui UNICODE)
+target_link_libraries(cacls conutils ${PSEH_LIB})
add_importlibs(cacls advapi32 user32 shell32 msvcrt kernel32)
add_cd_file(TARGET cacls DESTINATION reactos/system32 FOR all)
static
-INT
-LengthOfStrResource(IN HINSTANCE hInst,
- IN UINT uID)
+VOID PrintError(DWORD dwError)
{
- HRSRC hrSrc;
- HGLOBAL hRes;
- LPWSTR lpName, lpStr;
+ if (dwError == ERROR_SUCCESS)
+ return;
- if (hInst == NULL)
- {
- hInst = GetModuleHandle(NULL);
- }
-
- /* There are always blocks of 16 strings */
- lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
-
- /* Find the string table block */
- hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING);
- if (hrSrc)
- {
- hRes = LoadResource(hInst, hrSrc);
- if (hRes)
- {
- lpStr = LockResource(hRes);
- if (lpStr)
- {
- UINT x;
-
- /* Find the string we're looking for */
- uID &= 0xF; /* position in the block, same as % 16 */
- for (x = 0; x < uID; x++)
- {
- lpStr += (*lpStr) + 1;
- }
-
- /* Found the string */
- return (int)(*lpStr);
- }
- }
- }
- return -1;
-}
-
-
-static
-INT
-AllocAndLoadString(OUT LPTSTR *lpTarget,
- IN HINSTANCE hInst,
- IN UINT uID)
-{
- INT ln;
-
- ln = LengthOfStrResource(hInst,
- uID);
- if (ln++ > 0)
- {
- (*lpTarget) = (LPTSTR)HeapAlloc(GetProcessHeap(),
- 0,
- ln * sizeof(TCHAR));
- if ((*lpTarget) != NULL)
- {
- INT Ret;
- Ret = LoadString(hInst,
- uID,
- *lpTarget,
- ln);
- if (!Ret)
- {
- HeapFree(GetProcessHeap(),
- 0,
- *lpTarget);
- }
- return Ret;
- }
- }
- return 0;
-}
-
-
-static
-VOID
-PrintHelp(VOID)
-{
- LPTSTR szHelp;
-
- if (AllocAndLoadString(&szHelp,
- NULL,
- IDS_HELP) != 0)
- {
- _tprintf(_T("%s"),
- szHelp);
-
- HeapFree(GetProcessHeap(),
- 0,
- szHelp);
- }
+ ConMsgPrintf(StdErr,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dwError, LANG_USER_DEFAULT);
}
-
-static
-VOID
-PrintErrorMessage(IN DWORD dwError)
-{
- LPTSTR szError;
-
- if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_IGNORE_INSERTS |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- dwError,
- MAKELANGID(LANG_NEUTRAL,
- SUBLANG_DEFAULT),
- (LPTSTR)&szError,
- 0,
- NULL) != 0)
- {
- _tprintf(_T("%s"),
- szError);
- LocalFree((HLOCAL)szError);
- }
-}
-
-
-static
-DWORD
-LoadAndPrintString(IN HINSTANCE hInst,
- IN UINT uID)
-{
- TCHAR szTemp[255];
- DWORD Len;
-
- Len = (DWORD)LoadString(hInst,
- uID,
- szTemp,
- sizeof(szTemp) / sizeof(szTemp[0]));
-
- if (Len != 0)
- {
- _tprintf(_T("%s"),
- szTemp);
- }
-
- return Len;
-}
-
-
static
BOOL
PrintFileDacl(IN LPTSTR FilePath,
/* print the ACE Flags */
if (Ace->Header.AceFlags & CONTAINER_INHERIT_ACE)
{
- IndentAccess += LoadAndPrintString(NULL,
- IDS_ABBR_CI);
+ IndentAccess += PrintResourceString(IDS_ABBR_CI);
}
if (Ace->Header.AceFlags & OBJECT_INHERIT_ACE)
{
- IndentAccess += LoadAndPrintString(NULL,
- IDS_ABBR_OI);
+ IndentAccess += PrintResourceString(IDS_ABBR_OI);
}
if (Ace->Header.AceFlags & INHERIT_ONLY_ACE)
{
- IndentAccess += LoadAndPrintString(NULL,
- IDS_ABBR_IO);
+ IndentAccess += PrintResourceString(IDS_ABBR_IO);
}
IndentAccess += 2;
{
if (AccessMask == FILE_ALL_ACCESS)
{
- LoadAndPrintString(NULL,
- IDS_ABBR_NONE);
+ PrintResourceString(IDS_ABBR_NONE);
}
else
{
- LoadAndPrintString(NULL,
- IDS_DENY);
+ PrintResourceString(IDS_DENY);
goto PrintSpecialAccess;
}
}
{
if (AccessMask == FILE_ALL_ACCESS)
{
- LoadAndPrintString(NULL,
- IDS_ABBR_FULL);
+ PrintResourceString(IDS_ABBR_FULL);
}
else if (!(Ace->Mask & (GENERIC_READ | GENERIC_EXECUTE)) &&
AccessMask == (FILE_GENERIC_READ | FILE_EXECUTE))
{
- LoadAndPrintString(NULL,
- IDS_ABBR_READ);
+ PrintResourceString(IDS_ABBR_READ);
}
else if (AccessMask == (FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_EXECUTE | DELETE))
{
- LoadAndPrintString(NULL,
- IDS_ABBR_CHANGE);
+ PrintResourceString(IDS_ABBR_CHANGE);
}
else if (AccessMask == FILE_GENERIC_WRITE)
{
- LoadAndPrintString(NULL,
- IDS_ABBR_WRITE);
+ PrintResourceString(IDS_ABBR_WRITE);
}
else
{
{STANDARD_RIGHTS_ALL, IDS_STANDARD_RIGHTS_ALL},
};
- LoadAndPrintString(NULL,
- IDS_ALLOW);
+ PrintResourceString(IDS_ALLOW);
PrintSpecialAccess:
- LoadAndPrintString(NULL,
- IDS_SPECIAL_ACCESS);
+ PrintResourceString(IDS_SPECIAL_ACCESS);
/* print the special access rights */
- x = sizeof(AccessRights) / sizeof(AccessRights[0]);
+ x = ARRAYSIZE(AccessRights);
while (x-- != 0)
{
if ((Ace->Mask & AccessRights[x].Access) == AccessRights[x].Access)
_tprintf(_T(" "));
}
- LoadAndPrintString(NULL,
- AccessRights[x].uID);
+ PrintResourceString(AccessRights[x].uID);
}
}
*pch = 0;
if (!GetFullPathName(FilePath, MAX_PATH, FullPath, NULL))
{
- PrintErrorMessage(GetLastError());
+ PrintError(GetLastError());
return FALSE;
}
lstrcpyn(FilePath, FullPath, MAX_PATH);
attrs = GetFileAttributes(FilePath);
if (attrs == 0xFFFFFFFF || !(attrs & FILE_ATTRIBUTE_DIRECTORY))
{
- PrintErrorMessage(ERROR_DIRECTORY);
+ PrintError(ERROR_DIRECTORY);
return FALSE;
}
}
LastError = GetLastError();
if (LastError == ERROR_ACCESS_DENIED)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
if (!OptionC)
{
FindClose(hFind);
if (LastError != ERROR_NO_MORE_FILES)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
return FALSE;
}
LastError = GetLastError();
if (LastError == ERROR_ACCESS_DENIED)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
if (!OptionC)
{
FindClose(hFind);
if (LastError != ERROR_NO_MORE_FILES)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
return FALSE;
}
LastError = GetLastError();
if (LastError == ERROR_ACCESS_DENIED)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
if (!OptionC)
{
FindClose(hFind);
if (LastError != ERROR_NO_MORE_FILES)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
return FALSE;
}
LastError = GetLastError();
if (LastError == ERROR_ACCESS_DENIED)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
if (!OptionC)
{
FindClose(hFind);
if (LastError != ERROR_NO_MORE_FILES)
{
- PrintErrorMessage(LastError);
+ PrintError(LastError);
return FALSE;
}
return TRUE;
}
-int
-__cdecl
-_tmain(int argc, const TCHAR *argv[])
+int _tmain(int argc, const TCHAR *argv[])
{
INT i;
LPTSTR pch;
BOOL InvalidParameter = FALSE;
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
+
if (argc <= 1)
{
- PrintHelp();
+ PrintResourceString(IDS_HELP);
return 0;
}
if (InvalidParameter)
{
- PrintErrorMessage(ERROR_INVALID_PARAMETER);
- PrintHelp();
+ PrintError(ERROR_INVALID_PARAMETER);
+ PrintResourceString(IDS_HELP);
return 1;
}
#define _CACLS_PRECOMP_H
#include <stdarg.h>
+#include <tchar.h>
+
#include <windef.h>
#include <winbase.h>
-#include <winuser.h>
+#include <winuser.h> // For CharPrev
#include <sddl.h>
-#include <tchar.h>
+
+#include <conutils.h>
#include "resource.h"
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
+
add_executable(clip clip.c clip.rc)
set_module_type(clip win32cui UNICODE)
-add_importlibs(clip user32 msvcrt kernel32 advapi32)
+target_link_libraries(clip conutils ${PSEH_LIB})
+add_importlibs(clip advapi32 user32 msvcrt kernel32)
add_cd_file(TARGET clip DESTINATION reactos/system32 FOR all)
#include <winbase.h>
#include <winuser.h>
+#include <conutils.h>
+
#include "resource.h"
-static void PrintError(void)
+VOID PrintError(DWORD dwError)
{
- DWORD dwError;
- LPWSTR lpMsgBuf = NULL;
-
- dwError = GetLastError();
- if (dwError == NO_ERROR)
+ if (dwError == ERROR_SUCCESS)
return;
- FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, dwError, 0, (LPWSTR)&lpMsgBuf, 0, NULL);
- wprintf(L"%s", lpMsgBuf);
- LocalFree(lpMsgBuf);
-}
-
-static void PrintResourceString(UINT uID)
-{
- WCHAR buff[500];
-
- if (LoadStringW(GetModuleHandle(NULL), uID, buff, ARRAYSIZE(buff)))
- {
- wprintf(L"%s", buff);
- }
+ ConMsgPrintf(StdErr,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dwError, LANG_USER_DEFAULT);
}
static BOOL IsDataUnicode(HGLOBAL hGlobal)
LPBYTE lpBuffer;
SIZE_T dwSize = 0;
+ /* Initialize the Console Standard Streams */
hInput = GetStdHandle(STD_INPUT_HANDLE);
+ ConInitStdStreams();
/* Check for usage */
if (argc > 1 && wcsncmp(argv[1], L"/?", 2) == 0)
{
- PrintResourceString(IDS_HELP);
+ ConResPrintf(StdOut, IDS_HELP);
return 0;
}
if (GetFileType(hInput) == FILE_TYPE_CHAR)
{
- PrintResourceString(IDS_USAGE);
+ ConResPrintf(StdOut, IDS_USAGE);
return 0;
}
/* Initialize a growable buffer for holding clipboard data */
hBuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 4096);
if (!hBuffer)
- {
- PrintError();
- return -1;
- }
+ goto Failure;
/*
* Read data from the input stream by chunks of 4096 bytes
{
lpBuffer = GlobalLock(hBuffer);
if (!lpBuffer)
- goto cleanup;
+ goto Failure;
bStatus = ReadFile(hInput, lpBuffer + dwSize, 4096, &dwBytesRead, NULL);
dwSize += dwBytesRead;
hTemp = GlobalReAlloc(hBuffer, GlobalSize(hBuffer) + 4096, GMEM_ZEROINIT);
if (!hTemp)
- goto cleanup;
+ goto Failure;
hBuffer = hTemp;
}
/* Attempt to open the clipboard */
if (!OpenClipboard(NULL))
- goto cleanup;
+ goto Failure;
/* Empty it, copy our data, then close it */
CloseClipboard();
return 0;
-cleanup:
- GlobalFree(hBuffer);
- PrintError();
+Failure:
+ if (hBuffer) GlobalFree(hBuffer);
+ PrintError(GetLastError());
return -1;
}
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
+
add_executable(comp comp.c comp.rc)
set_module_type(comp win32cui UNICODE)
-add_importlibs(comp user32 msvcrt kernel32)
+target_link_libraries(comp conutils ${PSEH_LIB})
+add_importlibs(comp msvcrt kernel32)
add_cd_file(TARGET comp DESTINATION reactos/system32 FOR all)
-/*\r
- * ReactOS Win32 Applications\r
- * Copyright (C) 2005 ReactOS Team\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- */\r
-/*\r
- * PROJECT: ReactOS Comp utility\r
- * COPYRIGHT: See COPYING in the top level directory\r
- * FILE: base/applications/cmdutils/comp/comp.c\r
- * PURPOSE: Compares the contents of two files\r
- * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-// #include <string.h>\r
-// #include <wchar.h>\r
-#include <assert.h>\r
-\r
-#define WIN32_NO_STATUS\r
-#include <windef.h>\r
-#include <winbase.h>\r
-#include <winuser.h>\r
-\r
-#include "resource.h"\r
-\r
-#define STRBUF 1024\r
-\r
-VOID PrintResourceString(INT resID, ...)\r
-{\r
- WCHAR bufSrc[RC_STRING_MAX_SIZE];\r
- WCHAR bufFormatted[RC_STRING_MAX_SIZE];\r
- CHAR bufFormattedOem[RC_STRING_MAX_SIZE];\r
-\r
- va_list args;\r
- va_start(args, resID);\r
-\r
- if (LoadStringW(GetModuleHandleW(NULL), resID, bufSrc, ARRAYSIZE(bufSrc)))\r
- vswprintf(bufFormatted, bufSrc, args);\r
- else\r
- swprintf(bufFormatted, L"Resource loading error!");\r
-\r
- CharToOemW(bufFormatted, bufFormattedOem);\r
- fputs(bufFormattedOem, stdout);\r
-\r
- va_end(args);\r
-}\r
-\r
-/* getline: read a line, return length */\r
-INT GetBuff(PBYTE buff, FILE* in)\r
-{\r
- return fread(buff, sizeof(BYTE), STRBUF, in);\r
-}\r
-\r
-INT FileSize(FILE* fd)\r
-{\r
- INT result = -1;\r
- if (fseek(fd, 0, SEEK_END) == 0 && (result = ftell(fd)) != -1)\r
- {\r
- /* Restoring file pointer */\r
- rewind(fd);\r
- }\r
- return result;\r
-}\r
-\r
-/* Print program usage */\r
-VOID Usage(VOID)\r
-{\r
- PrintResourceString(IDS_HELP);\r
-}\r
-\r
-\r
-int wmain (int argc, WCHAR* argv[])\r
-{\r
- INT i;\r
-\r
- /* File pointers */\r
- FILE *fp1 = NULL;\r
- FILE *fp2 = NULL;\r
-\r
- INT BufLen1, BufLen2;\r
- PBYTE Buff1 = NULL;\r
- PBYTE Buff2 = NULL;\r
- WCHAR File1[_MAX_PATH + 1], // File paths\r
- File2[_MAX_PATH + 1];\r
- BOOL bAscii = FALSE, // /A switch\r
- bLineNos = FALSE; // /L switch\r
- UINT LineNumber;\r
- UINT Offset;\r
- INT FileSizeFile1;\r
- INT FileSizeFile2;\r
- INT NumberOfOptions = 0;\r
- INT FilesOK = 1;\r
- INT Status = EXIT_SUCCESS;\r
-\r
- /* Parse command line for options */\r
- for (i = 1; i < argc; i++)\r
- {\r
- if (argv[i][0] == L'/')\r
- {\r
- switch (argv[i][1])\r
- {\r
- case L'A':\r
- bAscii = TRUE;\r
- NumberOfOptions++;\r
- break;\r
-\r
- case L'L':\r
- bLineNos = TRUE;\r
- NumberOfOptions++;\r
- break;\r
-\r
- case L'?':\r
- Usage();\r
- return EXIT_SUCCESS;\r
-\r
- default:\r
- PrintResourceString(IDS_INVALIDSWITCH, argv[i][1]);\r
- Usage();\r
- return EXIT_FAILURE;\r
- }\r
- }\r
- }\r
-\r
- if (argc - NumberOfOptions == 3)\r
- {\r
- wcsncpy(File1, argv[1 + NumberOfOptions], _MAX_PATH);\r
- wcsncpy(File2, argv[2 + NumberOfOptions], _MAX_PATH);\r
- }\r
- else\r
- {\r
- PrintResourceString(IDS_BADSYNTAX);\r
- return EXIT_FAILURE;\r
- }\r
-\r
- Buff1 = (PBYTE)malloc(STRBUF);\r
- if (Buff1 == NULL)\r
- {\r
- wprintf(L"Can't get free memory for Buff1\n");\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- Buff2 = (PBYTE)malloc(STRBUF);\r
- if (Buff2 == NULL)\r
- {\r
- wprintf(L"Can't get free memory for Buff2\n");\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- if ((fp1 = _wfopen(File1, L"rb")) == NULL)\r
- {\r
- PrintResourceString(IDS_FILEERROR, File1);\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
- if ((fp2 = _wfopen(File2, L"rb")) == NULL)\r
- {\r
- PrintResourceString(IDS_FILEERROR, File2);\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- PrintResourceString(IDS_COMPARING, File1, File2);\r
-\r
- FileSizeFile1 = FileSize(fp1);\r
- if (FileSizeFile1 == -1)\r
- {\r
- PrintResourceString(IDS_FILESIZEERROR, File1);\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- FileSizeFile2 = FileSize(fp2);\r
- if (FileSizeFile2 == -1)\r
- {\r
- PrintResourceString(IDS_FILESIZEERROR, File2);\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- if (FileSizeFile1 != FileSizeFile2)\r
- {\r
- PrintResourceString(IDS_SIZEDIFFERS);\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- LineNumber = 1;\r
- Offset = 0;\r
- while (1)\r
- {\r
- BufLen1 = GetBuff(Buff1, fp1);\r
- BufLen2 = GetBuff(Buff2, fp2);\r
-\r
- if (ferror(fp1) || ferror(fp2))\r
- {\r
- PrintResourceString(IDS_READERROR);\r
- Status = EXIT_FAILURE;\r
- goto Cleanup;\r
- }\r
-\r
- if (!BufLen1 && !BufLen2)\r
- break;\r
-\r
- assert(BufLen1 == BufLen2);\r
- for (i = 0; i < BufLen1; i++)\r
- {\r
- if (Buff1[i] != Buff2[i])\r
- {\r
- FilesOK = 0;\r
-\r
- /* Reporting here a mismatch */\r
- if (bLineNos)\r
- {\r
- PrintResourceString(IDS_MISMATCHLINE, LineNumber);\r
- }\r
- else\r
- {\r
- PrintResourceString(IDS_MISMATCHOFFSET, Offset);\r
- }\r
-\r
- if (bAscii)\r
- {\r
- PrintResourceString(IDS_ASCIIDIFF, 1, Buff1[i]);\r
- PrintResourceString(IDS_ASCIIDIFF, 2, Buff2[i]);\r
- }\r
- else\r
- {\r
- PrintResourceString(IDS_HEXADECIMALDIFF, 1, Buff1[i]);\r
- PrintResourceString(IDS_HEXADECIMALDIFF, 2, Buff2[i]);\r
- }\r
- }\r
-\r
- Offset++;\r
-\r
- if (Buff1[i] == '\n')\r
- LineNumber++;\r
- }\r
- }\r
-\r
- if (FilesOK)\r
- PrintResourceString(IDS_MATCH);\r
-\r
-Cleanup:\r
- if (fp2)\r
- fclose(fp2);\r
- if (fp1)\r
- fclose(fp1);\r
-\r
- if (Buff2)\r
- free(Buff2);\r
- if (Buff1)\r
- free(Buff1);\r
-\r
- return Status;\r
-}\r
-\r
-/* EOF */\r
+/*
+ * ReactOS Win32 Applications
+ * Copyright (C) 2005 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.
+ */
+/*
+ * PROJECT: ReactOS Comp utility
+ * COPYRIGHT: See COPYING in the top level directory
+ * FILE: base/applications/cmdutils/comp/comp.c
+ * PURPOSE: Compares the contents of two files
+ * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+// #include <string.h>
+// #include <wchar.h>
+#include <assert.h>
+
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <winbase.h>
+
+#include <conutils.h>
+
+#include "resource.h"
+
+#define STRBUF 1024
+
+/* getline: read a line, return length */
+INT GetBuff(PBYTE buff, FILE* in)
+{
+ return fread(buff, sizeof(BYTE), STRBUF, in);
+}
+
+INT FileSize(FILE* fd)
+{
+ INT result = -1;
+ if (fseek(fd, 0, SEEK_END) == 0 && (result = ftell(fd)) != -1)
+ {
+ /* Restoring file pointer */
+ rewind(fd);
+ }
+ return result;
+}
+
+
+int wmain (int argc, WCHAR* argv[])
+{
+ INT i;
+
+ /* File pointers */
+ FILE *fp1 = NULL;
+ FILE *fp2 = NULL;
+
+ INT BufLen1, BufLen2;
+ PBYTE Buff1 = NULL;
+ PBYTE Buff2 = NULL;
+ WCHAR File1[_MAX_PATH + 1], // File paths
+ File2[_MAX_PATH + 1];
+ BOOL bAscii = FALSE, // /A switch
+ bLineNos = FALSE; // /L switch
+ UINT LineNumber;
+ UINT Offset;
+ INT FileSizeFile1;
+ INT FileSizeFile2;
+ INT NumberOfOptions = 0;
+ INT FilesOK = 1;
+ INT Status = EXIT_SUCCESS;
+
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
+
+ /* Parse command line for options */
+ for (i = 1; i < argc; i++)
+ {
+ if (argv[i][0] == L'/')
+ {
+ switch (towlower(argv[i][1]))
+ {
+ case L'a':
+ bAscii = TRUE;
+ NumberOfOptions++;
+ break;
+
+ case L'l':
+ bLineNos = TRUE;
+ NumberOfOptions++;
+ break;
+
+ case L'?':
+ PrintResourceString(IDS_HELP);
+ return EXIT_SUCCESS;
+
+ default:
+ PrintResourceString(IDS_INVALIDSWITCH, argv[i][1]);
+ PrintResourceString(IDS_HELP);
+ return EXIT_FAILURE;
+ }
+ }
+ }
+
+ if (argc - NumberOfOptions == 3)
+ {
+ wcsncpy(File1, argv[1 + NumberOfOptions], _MAX_PATH);
+ wcsncpy(File2, argv[2 + NumberOfOptions], _MAX_PATH);
+ }
+ else
+ {
+ PrintResourceString(IDS_BADSYNTAX);
+ return EXIT_FAILURE;
+ }
+
+ Buff1 = (PBYTE)malloc(STRBUF);
+ if (Buff1 == NULL)
+ {
+ ConPrintf(StdErr, L"Can't get free memory for Buff1\n");
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ Buff2 = (PBYTE)malloc(STRBUF);
+ if (Buff2 == NULL)
+ {
+ ConPrintf(StdErr, L"Can't get free memory for Buff2\n");
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ if ((fp1 = _wfopen(File1, L"rb")) == NULL)
+ {
+ PrintResourceString(IDS_FILEERROR, File1);
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+ if ((fp2 = _wfopen(File2, L"rb")) == NULL)
+ {
+ PrintResourceString(IDS_FILEERROR, File2);
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ PrintResourceString(IDS_COMPARING, File1, File2);
+
+ FileSizeFile1 = FileSize(fp1);
+ if (FileSizeFile1 == -1)
+ {
+ PrintResourceString(IDS_FILESIZEERROR, File1);
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ FileSizeFile2 = FileSize(fp2);
+ if (FileSizeFile2 == -1)
+ {
+ PrintResourceString(IDS_FILESIZEERROR, File2);
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ if (FileSizeFile1 != FileSizeFile2)
+ {
+ PrintResourceString(IDS_SIZEDIFFERS);
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ LineNumber = 1;
+ Offset = 0;
+ while (1)
+ {
+ BufLen1 = GetBuff(Buff1, fp1);
+ BufLen2 = GetBuff(Buff2, fp2);
+
+ if (ferror(fp1) || ferror(fp2))
+ {
+ PrintResourceString(IDS_READERROR);
+ Status = EXIT_FAILURE;
+ goto Cleanup;
+ }
+
+ if (!BufLen1 && !BufLen2)
+ break;
+
+ assert(BufLen1 == BufLen2);
+ for (i = 0; i < BufLen1; i++)
+ {
+ if (Buff1[i] != Buff2[i])
+ {
+ FilesOK = 0;
+
+ /* Reporting here a mismatch */
+ if (bLineNos)
+ {
+ PrintResourceString(IDS_MISMATCHLINE, LineNumber);
+ }
+ else
+ {
+ PrintResourceString(IDS_MISMATCHOFFSET, Offset);
+ }
+
+ if (bAscii)
+ {
+ PrintResourceString(IDS_ASCIIDIFF, 1, Buff1[i]);
+ PrintResourceString(IDS_ASCIIDIFF, 2, Buff2[i]);
+ }
+ else
+ {
+ PrintResourceString(IDS_HEXADECIMALDIFF, 1, Buff1[i]);
+ PrintResourceString(IDS_HEXADECIMALDIFF, 2, Buff2[i]);
+ }
+ }
+
+ Offset++;
+
+ if (Buff1[i] == '\n')
+ LineNumber++;
+ }
+ }
+
+ if (FilesOK)
+ PrintResourceString(IDS_MATCH);
+
+Cleanup:
+ if (fp2)
+ fclose(fp2);
+ if (fp1)
+ fclose(fp1);
+
+ if (Buff2)
+ free(Buff2);
+ if (Buff1)
+ free(Buff1);
+
+ return Status;
+}
+
+/* EOF */
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
+
add_executable(cmd_help help.c help.rc)
set_module_type(cmd_help win32cui UNICODE)
-add_importlibs(cmd_help user32 msvcrt kernel32)
+target_link_libraries(cmd_help conutils ${PSEH_LIB})
+add_importlibs(cmd_help msvcrt kernel32)
set_target_properties(cmd_help PROPERTIES OUTPUT_NAME "help")
add_cd_file(TARGET cmd_help DESTINATION reactos/system32 FOR all)
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
-#include <winuser.h>
-#include <wincon.h>
+
#include <strsafe.h>
+#include <conutils.h>
+
#include "help.h"
#include "resource.h"
-VOID PrintResourceString(INT resID, ...)
-{
- WCHAR bufSrc[RC_STRING_MAX_SIZE];
- WCHAR bufFormatted[RC_STRING_MAX_SIZE];
- CHAR bufFormattedOem[RC_STRING_MAX_SIZE];
-
- va_list args;
- va_start(args, resID);
-
- LoadStringW(GetModuleHandleW(NULL), resID, bufSrc, ARRAYSIZE(bufSrc));
- vswprintf(bufFormatted, bufSrc, args);
- CharToOemW(bufFormatted, bufFormattedOem);
- fputs(bufFormattedOem, stdout);
-
- va_end(args);
-}
-
BOOL IsInternalCommand(LPCWSTR Cmd)
{
size_t i;
{
WCHAR CmdLine[CMDLINE_LENGTH];
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
+
/*
* If the user hasn't asked for specific help,
* then print out the list of available commands.
* Run "<command> /?" in the current command processor.
*/
StringCbPrintfW(CmdLine, sizeof(CmdLine), L"%ls /?", argv[1]);
-
+
_flushall();
return _wsystem(CmdLine);
}
-list(APPEND SOURCE
- misc.c
- logoff.c
- precomp.h)
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
-add_executable(logoff ${SOURCE} logoff.rc)
-set_module_type(logoff win32cui)
+add_executable(logoff logoff.c logoff.rc)
+set_module_type(logoff win32cui UNICODE)
+target_link_libraries(logoff conutils ${PSEH_LIB})
add_importlibs(logoff advapi32 user32 msvcrt kernel32)
-add_pch(logoff precomp.h SOURCE)
add_cd_file(TARGET logoff DESTINATION reactos/system32 FOR all)
* with Windows' system32\logoff.exe commandline application.
*/
-#include "precomp.h"
-
#include <stdio.h>
-#include <tchar.h>
-//Commandline argument switches
-LPTSTR szRemoteServerName = NULL;
-BOOL bVerbose;
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
-//----------------------------------------------------------------------
-//
-//Retrieve resource string and output the Usage to the console
-//
-//----------------------------------------------------------------------
-static void PrintUsage() {
- LPTSTR lpUsage = NULL;
+#include <conutils.h>
- if (AllocAndLoadString(&lpUsage, GetModuleHandle(NULL), IDS_USAGE)) {
- _putts(lpUsage);
- LocalFree(lpUsage);
- }
+#include "resource.h"
-}
+// Commandline argument switches
+LPWSTR szRemoteServerName = NULL;
+BOOL bVerbose;
//----------------------------------------------------------------------
//
// Writes the last error as both text and error code to the console.
//
//----------------------------------------------------------------------
-void DisplayLastError()
+VOID DisplayError(DWORD dwError)
{
- int errorCode = GetLastError();
- LPTSTR lpMsgBuf;
-
- // Display the error message to the user
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errorCode,
- LANG_USER_DEFAULT,
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL);
-
- _ftprintf(stderr, lpMsgBuf);
- _ftprintf(stderr, _T("Error code: %d\n"), errorCode);
-
- LocalFree(lpMsgBuf);
+ ConMsgPrintf(StdErr,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dwError, LANG_USER_DEFAULT);
+ ConPrintf(StdErr, L"Error code: %lu\n", dwError);
}
//----------------------------------------------------------------------
//
-//Sets flags based on commandline arguments
+// Sets flags based on commandline arguments
//
//----------------------------------------------------------------------
-BOOL ParseCommandLine(int argc, TCHAR *argv[])
+BOOL ParseCommandLine(int argc, WCHAR *argv[])
{
int i;
- LPTSTR lpIllegalMsg;
//FIXME: Add handling of commandline arguments to select the session number and name, and also name of remote machine
//Example: logoff.exe 4 /SERVER:Master should logoff session number 4 on remote machine called Master.
for (i = 1; i < argc; i++) {
switch(argv[i][0]){
- case '-':
- case '/':
+ case L'-':
+ case L'/':
// -v (verbose)
- if (argv[i][1] == 'v') {
+ if (argv[i][1] == L'v') {
bVerbose = TRUE;
break; //continue parsing the arguments
}
// -? (usage)
- else if(argv[i][1] == '?') {
+ else if(argv[i][1] == L'?') {
return FALSE; //display the Usage
}
default:
//Invalid parameter detected
- if (AllocAndLoadString(&lpIllegalMsg, GetModuleHandle(NULL), IDS_ILLEGAL_PARAM)) {
- _putts(lpIllegalMsg);
- LocalFree(lpIllegalMsg);
- }
+ ConResPrintf(StdErr, IDS_ILLEGAL_PARAM);
return FALSE;
}
}
//----------------------------------------------------------------------
//
-//Main entry for program
+// Main entry for program
//
//----------------------------------------------------------------------
-int _tmain(int argc, TCHAR *argv[])
+int wmain(int argc, WCHAR *argv[])
{
- LPTSTR lpLogoffRemote, lpLogoffLocal;
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
//
// Parse command line
//
if (!ParseCommandLine(argc, argv)) {
- PrintUsage();
+ ConResPrintf(StdOut, IDS_USAGE);
return 1;
}
//
- //Should we log off session on remote server?
+ // Should we log off session on remote server?
//
if (szRemoteServerName) {
if (bVerbose) {
- if (AllocAndLoadString(&lpLogoffRemote, GetModuleHandle(NULL), IDS_LOGOFF_REMOTE))
- _putts(lpLogoffRemote);
+ ConResPrintf(StdOut, IDS_LOGOFF_REMOTE);
}
- //FIXME: Add Remote Procedure Call to logoff user on a remote machine
- _ftprintf(stderr, "Remote Procedure Call in logoff.exe has not been implemented");
+ // FIXME: Add Remote Procedure Call to logoff user on a remote machine
+ ConPrintf(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented");
}
//
- //Perform logoff of current session on local machine instead
+ // Perform logoff of current session on local machine instead
//
else {
if (bVerbose) {
- //Get resource string, and print it.
- if (AllocAndLoadString(&lpLogoffLocal, GetModuleHandle(NULL), IDS_LOGOFF_LOCAL))
- _putts(lpLogoffLocal);
+ // Get resource string, and print it.
+ ConResPrintf(StdOut, IDS_LOGOFF_LOCAL);
}
- //Actual logoff
- if (!ExitWindows(NULL, NULL)) {
- DisplayLastError();
+ // Actual logoff
+ if (!ExitWindowsEx(EWX_LOGOFF, 0)) {
+ DisplayError(GetLastError());
return 1;
}
}
+++ /dev/null
-#include "precomp.h"
-
-static INT
-LengthOfStrResource(IN HINSTANCE hInst,
- IN UINT uID)
-{
- HRSRC hrSrc;
- HGLOBAL hRes;
- LPWSTR lpName, lpStr;
-
- if (hInst == NULL)
- {
- return -1;
- }
-
- /* There are always blocks of 16 strings */
- lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
-
- /* Find the string table block */
- if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
- (hRes = LoadResource(hInst, hrSrc)) &&
- (lpStr = (WCHAR*) LockResource(hRes)))
- {
- UINT x;
-
- /* Find the string we're looking for */
- uID &= 0xF; /* position in the block, same as % 16 */
- for (x = 0; x < uID; x++)
- {
- lpStr += (*lpStr) + 1;
- }
-
- /* Found the string */
- return (int)(*lpStr);
- }
- return -1;
-}
-
-INT
-AllocAndLoadString(OUT LPTSTR *lpTarget,
- IN HINSTANCE hInst,
- IN UINT uID)
-{
- INT ln;
-
- ln = LengthOfStrResource(hInst,
- uID);
- if (ln++ > 0)
- {
- (*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
- ln * sizeof(TCHAR));
- if ((*lpTarget) != NULL)
- {
- INT Ret;
- if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
- {
- LocalFree((HLOCAL)(*lpTarget));
- }
- return Ret;
- }
- }
- return 0;
-}
+++ /dev/null
-#ifndef __SHUTDOWN_PRECOMP_H
-#define __SHUTDOWN_PRECOMP_H
-
-#include <stdarg.h>
-
-#include <windef.h>
-#include <winbase.h>
-#include <winuser.h>
-
-#include "resource.h"
-
-/* misc.c */
-INT AllocAndLoadString(OUT LPTSTR *lpTarget,
- IN HINSTANCE hInst,
- IN UINT uID);
-
-#endif /* __SHUTDOWN_PRECOMP_H */
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
+
list(APPEND SOURCE
gui.c
misc.c
add_executable(shutdown ${SOURCE} shutdown.rc)
set_module_type(shutdown win32cui UNICODE)
+target_link_libraries(shutdown conutils ${PSEH_LIB})
add_importlibs(shutdown advapi32 user32 powrprof msvcrt kernel32)
add_pch(shutdown precomp.h SOURCE)
add_cd_file(TARGET shutdown DESTINATION reactos/system32 FOR all)
/* Writes the last error as both text and error code to the console */
VOID DisplayError(DWORD dwError)
{
- LPWSTR lpMsgBuf = NULL;
- DWORD errLength; /* Error message length */
- LPSTR resMsg; /* For error message in OEM symbols */
-
- /* Grabs the length of the error message */
- errLength = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- dwError,
- LANG_USER_DEFAULT,
- (LPWSTR)&lpMsgBuf,
- 0,
- NULL) + 1;
-
- /* Gets the error message ready for output */
- resMsg = (LPSTR)LocalAlloc(LPTR, errLength * sizeof(WCHAR));
- CharToOemBuffW(lpMsgBuf, resMsg, errLength);
-
- /* Prints out the error message to the user */
- fprintf(stderr, resMsg);
- fwprintf(stderr, L"Error code: %lu\n", dwError);
-
- LocalFree(lpMsgBuf);
- LocalFree(resMsg);
+ ConMsgPrintf(StdErr,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dwError, LANG_USER_DEFAULT);
+ ConPrintf(StdErr, L"Error code: %lu\n", dwError);
}
/* EOF */
#include <winreg.h>
#include <winuser.h>
+#include <conutils.h>
+
#include "resource.h"
/* DEFINES *******************************************************************/
+
#define MAX_MESSAGE_SIZE 512
#define MAX_MAJOR_CODE 256
#define MAX_MINOR_CODE 65536
#define MAX_TIMEOUT 315360000
-#define MAX_BUFFER_SIZE 5024
/* Reason Code List */
typedef struct _REASON
#include <tchar.h>
#include <powrprof.h>
-/*
- * This takes strings from a resource stringtable
- * and outputs it to the console.
- */
-VOID PrintResourceString(INT resID, ...)
-{
- WCHAR tmpBuffer[MAX_BUFFER_SIZE];
- va_list arg_ptr;
-
- va_start(arg_ptr, resID);
- LoadStringW(GetModuleHandle(NULL), resID, tmpBuffer, MAX_BUFFER_SIZE);
- vfwprintf(stdout, tmpBuffer, arg_ptr);
- va_end(arg_ptr);
-}
-
/*
* Takes the commandline arguments, and creates a
* struct which matches the arguments supplied.
DWORD error = ERROR_SUCCESS;
struct CommandLineOptions opts;
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
+
if (argc == 1) /* i.e. no commandline arguments given */
{
PrintResourceString(IDS_USAGE);
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/fmifs)
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(chkdsk chkdsk.c chkdsk.rc)
set_module_type(chkdsk win32cui UNICODE)
+target_link_libraries(chkdsk conutils ${PSEH_LIB})
add_importlibs(chkdsk fmifs msvcrt kernel32 ntdll)
add_cd_file(TARGET chkdsk DESTINATION reactos/system32 FOR all)
#include <winbase.h>
#include <wincon.h>
+#include <conutils.h>
+
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
//
BOOL Error = FALSE;
-// switches
+// Switches
BOOL FixErrors = FALSE;
BOOL SkipClean = FALSE;
BOOL ScanSectors = FALSE;
//----------------------------------------------------------------------
static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode)
{
- LPWSTR lpMsgBuf;
-
- FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, ErrorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&lpMsgBuf, 0, NULL);
-
- wprintf(L"%s: %s\n", Message, lpMsgBuf);
- LocalFree(lpMsgBuf);
+ ConPrintf(StdErr, L"%s: ", Message);
+ ConMsgPrintf(StdErr,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, ErrorCode, LANG_USER_DEFAULT);
+ ConPrintf(StdErr, L"\n");
}
static VOID
Usage(PWCHAR ProgramName)
{
- wprintf(L"Usage: %s [drive:] [-F] [-V] [-R] [-C]\n\n"
- L"[drive:] Specifies the drive to check.\n"
- L"-F Fixes errors on the disk.\n"
- L"-V Displays the full path of every file on the disk.\n"
- L"-R Locates bad sectors and recovers readable information.\n"
- L"-C Checks the drive only if it is dirty.\n\n",
- ProgramName);
+ ConPrintf(StdOut,
+ L"Usage: %s [drive:] [-F] [-V] [-R] [-C]\n\n"
+ L"[drive:] Specifies the drive to check.\n"
+ L"-F Fixes errors on the disk.\n"
+ L"-V Displays the full path of every file on the disk.\n"
+ L"-R Locates bad sectors and recovers readable information.\n"
+ L"-C Checks the drive only if it is dirty.\n\n",
+ ProgramName);
}
switch (Command)
{
case UNKNOWN2:
- wprintf(L"UNKNOWN2\r");
+ ConPrintf(StdOut, L"UNKNOWN2\r");
break;
case UNKNOWN3:
- wprintf(L"UNKNOWN3\n");
+ ConPrintf(StdOut, L"UNKNOWN3\n");
break;
case UNKNOWN4:
- wprintf(L"UNKNOWN4\n");
+ ConPrintf(StdOut, L"UNKNOWN4\n");
break;
case UNKNOWN5:
- wprintf(L"UNKNOWN5\n");
+ ConPrintf(StdOut, L"UNKNOWN5\n");
break;
case FSNOTSUPPORTED:
- wprintf(L"FSNOTSUPPORTED\n");
+ ConPrintf(StdOut, L"FSNOTSUPPORTED\n");
break;
case VOLUMEINUSE:
- wprintf(L"VOLUMEINUSE\n");
+ ConPrintf(StdOut, L"VOLUMEINUSE\n");
break;
case UNKNOWN9:
- wprintf(L"UNKNOWN9\n");
+ ConPrintf(StdOut, L"UNKNOWN9\n");
break;
case UNKNOWNA:
- wprintf(L"UNKNOWNA\n");
+ ConPrintf(StdOut, L"UNKNOWNA\n");
break;
case UNKNOWNC:
- wprintf(L"UNKNOWNC\n");
+ ConPrintf(StdOut, L"UNKNOWNC\n");
break;
case UNKNOWND:
- wprintf(L"UNKNOWND\n");
+ ConPrintf(StdOut, L"UNKNOWND\n");
break;
case INSUFFICIENTRIGHTS:
- wprintf(L"INSUFFICIENTRIGHTS\n");
+ ConPrintf(StdOut, L"INSUFFICIENTRIGHTS\n");
break;
case STRUCTUREPROGRESS:
- wprintf(L"STRUCTUREPROGRESS\n");
+ ConPrintf(StdOut, L"STRUCTUREPROGRESS\n");
break;
case DONEWITHSTRUCTURE:
- wprintf(L"DONEWITHSTRUCTURE\n");
+ ConPrintf(StdOut, L"DONEWITHSTRUCTURE\n");
break;
case CLUSTERSIZETOOSMALL:
- wprintf(L"CLUSTERSIZETOOSMALL\n");
+ ConPrintf(StdOut, L"CLUSTERSIZETOOSMALL\n");
break;
case PROGRESS:
percent = (PDWORD)Argument;
- wprintf(L"%d percent completed.\r", *percent);
+ ConPrintf(StdOut, L"%d percent completed.\r", *percent);
break;
case OUTPUT:
output = (PTEXTOUTPUT)Argument;
- wprintf(L"%S", output->Output);
+ ConPrintf(StdOut, L"%S", output->Output);
break;
case DONE:
status = (PBOOLEAN)Argument;
if (*status == FALSE)
{
- wprintf(L"Chkdsk was unable to complete successfully.\n\n");
+ ConPrintf(StdOut, L"Chkdsk was unable to complete successfully.\n\n");
Error = TRUE;
}
break;
wmain(int argc, WCHAR *argv[])
{
int badArg;
- HANDLE volumeHandle;
- WCHAR fileSystem[1024];
- WCHAR volumeName[1024];
- DWORD serialNumber;
- DWORD flags, maxComponent;
+ HANDLE volumeHandle;
+ WCHAR fileSystem[1024];
+ WCHAR volumeName[1024];
+ DWORD serialNumber;
+ DWORD flags, maxComponent;
+
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
- wprintf(L"\n"
- L"Chkdskx v1.0.1 by Mark Russinovich\n"
- L"Systems Internals - http://www.sysinternals.com\n"
- L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n");
+ ConPrintf(StdOut,
+ L"\n"
+ L"Chkdskx v1.0.1 by Mark Russinovich\n"
+ L"Systems Internals - http://www.sysinternals.com\n"
+ L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n");
#ifndef FMIFS_IMPORT_DLL
//
//
if (!LoadFMIFSEntryPoints())
{
- wprintf(L"Could not located FMIFS entry points.\n\n");
+ ConPrintf(StdErr, L"Could not located FMIFS entry points.\n\n");
return -1;
}
#endif
badArg = ParseCommandLine(argc, argv);
if (badArg)
{
- wprintf(L"Unknown argument: %s\n", argv[badArg]);
+ ConPrintf(StdOut, L"Unknown argument: %s\n", argv[badArg]);
Usage(argv[0]);
return -1;
}
0);
if (volumeHandle == INVALID_HANDLE_VALUE)
{
- wprintf(L"Chdskx cannot run because the volume is in use by another process.\n\n");
+ ConPrintf(StdErr, L"Chkdsk cannot run because the volume is in use by another process.\n\n");
return -1;
}
CloseHandle(volumeHandle);
//
// Just do it
//
- wprintf(L"The type of file system is %s.\n", fileSystem);
+ ConPrintf(StdOut, L"The type of file system is %s.\n", fileSystem);
Chkdsk(Drive,
fileSystem,
FixErrors,
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/fmifs)
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(format format.c format.rc)
set_module_type(format win32cui UNICODE)
+target_link_libraries(format conutils ${PSEH_LIB})
+add_importlibs(format fmifs msvcrt kernel32 ntdll)
set_target_properties(format PROPERTIES SUFFIX ".com")
-add_importlibs(format user32 fmifs msvcrt kernel32 ntdll)
add_cd_file(TARGET format DESTINATION reactos/system32 FOR all)
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
-#include <winnls.h>
-#include <winuser.h>
+
+#include <conutils.h>
#define NTOS_MODE_USER
#include <ndk/rtlfuncs.h>
// Globals
BOOL Error = FALSE;
-// switches
+// Switches
BOOL QuickFormat = FALSE;
DWORD ClusterSize = 0;
BOOL CompressDrive = FALSE;
};
-VOID PrintStringV(LPWSTR szStr, va_list args)
-{
- WCHAR bufFormatted[RC_STRING_MAX_SIZE];
- CHAR bufFormattedOem[RC_STRING_MAX_SIZE];
-
- _vsnwprintf(bufFormatted, ARRAYSIZE(bufFormatted), szStr, args);
-
- CharToOemW(bufFormatted, bufFormattedOem);
- puts(bufFormattedOem);
-}
-
-VOID PrintString(LPWSTR szStr, ...)
-{
- va_list args;
-
- va_start(args, szStr);
- PrintStringV(szStr, args);
- va_end(args);
-}
-
-VOID PrintResourceString(UINT uID, ...)
-{
- WCHAR bufSrc[RC_STRING_MAX_SIZE];
- va_list args;
-
- LoadStringW(GetModuleHandleW(NULL), uID, bufSrc, ARRAYSIZE(bufSrc));
-
- va_start(args, uID);
- PrintStringV(bufSrc, args);
- va_end(args);
-}
-
-
//----------------------------------------------------------------------
//
// PrintWin32Error
//----------------------------------------------------------------------
static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode)
{
- LPWSTR lpMsgBuf;
-
- FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, ErrorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&lpMsgBuf, 0, NULL);
-
- PrintString(L"%s: %s\n", Message, lpMsgBuf);
- LocalFree(lpMsgBuf);
+ ConPrintf(StdErr, L"%s: ", Message);
+ ConMsgPrintf(StdErr,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, ErrorCode, LANG_USER_DEFAULT);
+ ConPrintf(StdErr, L"\n");
}
{
case PROGRESS:
percent = (PDWORD)Argument;
- PrintResourceString(STRING_COMPLETE, *percent);
+ ConResPrintf(StdOut, STRING_COMPLETE, *percent);
break;
case OUTPUT:
output = (PTEXTOUTPUT)Argument;
- wprintf(L"%S", output->Output);
+ ConPrintf(StdOut, L"%S\n", output->Output);
break;
case DONE:
status = (PBOOLEAN)Argument;
if (*status == FALSE)
{
- PrintResourceString(STRING_FORMAT_FAIL);
+ ConResPrintf(StdOut, STRING_FORMAT_FAIL);
Error = TRUE;
}
break;
case UNKNOWND:
case STRUCTUREPROGRESS:
case CLUSTERSIZETOOSMALL:
- PrintResourceString(STRING_NO_SUPPORT);
+ ConResPrintf(StdOut, STRING_NO_SUPPORT);
return FALSE;
}
return TRUE;
BYTE dummy;
BOOLEAN latestVersion;
- LoadStringW(GetModuleHandle(NULL), STRING_HELP, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_HELP, szMsg, ARRAYSIZE(szMsg));
#ifndef FMIFS_IMPORT_DLL
if (!LoadFMIFSEntryPoints())
{
- PrintString(szMsg, ProgramName, L"");
+ ConPrintf(StdOut, szMsg, ProgramName, L"");
return;
}
#endif
wcscat(szFormats, szFormatW);
}
- PrintString(szMsg, ProgramName, szFormats);
+ ConPrintf(StdOut, szMsg, ProgramName, szFormats);
}
ULARGE_INTEGER freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes;
WCHAR szMsg[RC_STRING_MAX_SIZE];
- wprintf(L"\n"
- L"Formatx v1.0 by Mark Russinovich\n"
- L"Systems Internals - http://www.sysinternals.com\n"
- L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n");
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
+
+ ConPrintf(StdOut,
+ L"\n"
+ L"Formatx v1.0 by Mark Russinovich\n"
+ L"Systems Internals - http://www.sysinternals.com\n"
+ L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n");
#ifndef FMIFS_IMPORT_DLL
//
//
if (!LoadFMIFSEntryPoints())
{
- PrintResourceString(STRING_FMIFS_FAIL);
+ ConResPrintf(StdErr, STRING_FMIFS_FAIL);
return -1;
}
#endif
badArg = ParseCommandLine(argc, argv);
if (badArg)
{
- PrintResourceString(STRING_UNKNOW_ARG, argv[badArg]);
+ ConResPrintf(StdOut, STRING_UNKNOW_ARG, argv[badArg]);
Usage(argv[0]);
return -1;
}
//
if (!Drive)
{
- PrintResourceString(STRING_DRIVE_PARM);
+ ConResPrintf(StdOut, STRING_DRIVE_PARM);
Usage(argv[0]);
return -1;
}
switch (driveType)
{
case DRIVE_UNKNOWN :
- LoadStringW(GetModuleHandle(NULL), STRING_ERROR_DRIVE_TYPE, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_ERROR_DRIVE_TYPE, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
case DRIVE_REMOTE:
case DRIVE_CDROM:
- PrintResourceString(STRING_NO_SUPPORT);
+ ConResPrintf(StdOut, STRING_NO_SUPPORT);
return -1;
case DRIVE_NO_ROOT_DIR:
- LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
case DRIVE_REMOVABLE:
- PrintResourceString(STRING_INSERT_DISK, RootDirectory[0]);
+ ConResPrintf(StdOut, STRING_INSERT_DISK, RootDirectory[0]);
fgetws(input, ARRAYSIZE(input), stdin);
media = FMIFS_FLOPPY;
break;
if (towlower(path[0]) == towlower(Drive[0]))
{
// todo: report "Cannot format system drive"
- PrintResourceString(STRING_NO_SUPPORT);
+ ConResPrintf(StdOut, STRING_NO_SUPPORT);
return -1;
}
}
&serialNumber, &maxComponent, &flags,
fileSystem, ARRAYSIZE(fileSystem)))
{
- LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
}
&totalNumberOfBytes,
&totalNumberOfFreeBytes))
{
- LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
}
- PrintResourceString(STRING_FILESYSTEM, fileSystem);
+ ConResPrintf(StdOut, STRING_FILESYSTEM, fileSystem);
//
// Make sure they want to do this
{
while (TRUE)
{
- PrintResourceString(STRING_LABEL_NAME_EDIT, RootDirectory[0]);
+ ConResPrintf(StdOut, STRING_LABEL_NAME_EDIT, RootDirectory[0]);
fgetws(input, ARRAYSIZE(input), stdin);
input[wcslen(input) - 1] = 0;
if (!wcsicmp(input, volumeName))
break;
- PrintResourceString(STRING_ERROR_LABEL);
+ ConResPrintf(StdOut, STRING_ERROR_LABEL);
}
}
- PrintResourceString(STRING_YN_FORMAT, RootDirectory[0]);
+ ConResPrintf(StdOut, STRING_YN_FORMAT, RootDirectory[0]);
- LoadStringW(GetModuleHandle(NULL), STRING_YES_NO_FAQ, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_YES_NO_FAQ, szMsg, ARRAYSIZE(szMsg));
while (TRUE)
{
fgetws(input, ARRAYSIZE(input), stdin);
if (_wcsnicmp(&input[0], &szMsg[0], 1) == 0) break;
if (_wcsnicmp(&input[0], &szMsg[1], 1) == 0)
{
- wprintf(L"\n");
+ ConPrintf(StdOut, L"\n");
return 0;
}
}
//
if (!QuickFormat)
{
- LoadStringW(GetModuleHandle(NULL), STRING_VERIFYING, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_VERIFYING, szMsg, ARRAYSIZE(szMsg));
if (totalNumberOfBytes.QuadPart > 1024*1024*10)
{
- PrintString(L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024)));
+ ConPrintf(StdOut, L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024)));
}
else
{
- PrintString(L"%s %.1fM\n", szMsg,
+ ConPrintf(StdOut, L"%s %.1fM\n", szMsg,
((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0));
}
}
else
{
- LoadStringW(GetModuleHandle(NULL), STRING_FAST_FMT, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_FAST_FMT, szMsg, ARRAYSIZE(szMsg));
if (totalNumberOfBytes.QuadPart > 1024*1024*10)
{
- PrintString(L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024)));
+ ConPrintf(StdOut, L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024)));
}
else
{
- PrintString(L"%s %.2fM\n", szMsg,
+ ConPrintf(StdOut, L"%s %.2fM\n", szMsg,
((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0));
}
- PrintResourceString(STRING_CREATE_FSYS);
+ ConResPrintf(StdOut, STRING_CREATE_FSYS);
}
//
FormatEx(RootDirectory, media, FileSystem, Label, QuickFormat,
ClusterSize, FormatExCallback);
if (Error) return -1;
- PrintResourceString(STRING_FMT_COMPLETE);
+ ConResPrintf(StdOut, STRING_FMT_COMPLETE);
//
// Enable compression if desired
if (CompressDrive)
{
if (!EnableVolumeCompression(RootDirectory, TRUE))
- PrintResourceString(STRING_VOL_COMPRESS);
+ ConResPrintf(StdOut, STRING_VOL_COMPRESS);
}
//
//
if (!GotALabel)
{
- PrintResourceString(STRING_ENTER_LABEL);
+ ConResPrintf(StdOut, STRING_ENTER_LABEL);
fgetws(input, ARRAYSIZE(LabelString), stdin);
input[wcslen(input) - 1] = 0;
if (!SetVolumeLabelW(RootDirectory, input))
{
- LoadStringW(GetModuleHandle(NULL), STRING_NO_LABEL, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_LABEL, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
}
&serialNumber, &maxComponent, &flags,
fileSystem, ARRAYSIZE(fileSystem)))
{
- LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
}
&totalNumberOfBytes,
&totalNumberOfFreeBytes))
{
- LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
}
- PrintResourceString(STRING_FREE_SPACE, totalNumberOfBytes.QuadPart,
- totalNumberOfFreeBytes.QuadPart);
+ ConResPrintf(StdOut, STRING_FREE_SPACE, totalNumberOfBytes.QuadPart,
+ totalNumberOfFreeBytes.QuadPart);
//
// Get the drive's serial number
&serialNumber, &maxComponent, &flags,
fileSystem, ARRAYSIZE(fileSystem)))
{
- LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
+ K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg));
PrintWin32Error(szMsg, GetLastError());
return -1;
}
- PrintResourceString(STRING_SERIAL_NUMBER,
- (unsigned int)(serialNumber >> 16),
- (unsigned int)(serialNumber & 0xFFFF));
+ ConResPrintf(StdOut, STRING_SERIAL_NUMBER,
+ (unsigned int)(serialNumber >> 16),
+ (unsigned int)(serialNumber & 0xFFFF));
return 0;
}
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
+
add_executable(subst subst.c subst.rc)
set_module_type(subst win32cui UNICODE)
-add_importlibs(subst msvcrt kernel32 user32 ntdll)
+target_link_libraries(subst conutils ${PSEH_LIB})
+add_importlibs(subst msvcrt kernel32 ntdll)
add_cd_file(TARGET subst DESTINATION reactos/system32 FOR all)
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
-#include <winuser.h>
+
+#include <conutils.h>
#include "resource.h"
VOID PrintError(IN DWORD ErrCode)
{
- WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0};
- PWSTR buffer, msg = NULL;
+ DWORD dwLength = 0;
+ PWSTR pMsgBuf = NULL;
- buffer = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2048 * sizeof(WCHAR));
- if (!buffer)
+#if 0
+ if (ErrCode == ERROR_SUCCESS)
return;
+#endif
- FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- ErrCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (PWSTR)&msg,
- 0,
- NULL);
- if (msg)
+ /* Retrieve the message string without appending extra newlines */
+ dwLength = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
+ NULL,
+ ErrCode,
+ LANG_USER_DEFAULT,
+ (PWSTR)&pMsgBuf,
+ 0, NULL);
+ if (pMsgBuf /* && dwLength */)
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_FAILED_WITH_ERRORCODE,
- szFmtString,
- ARRAYSIZE(szFmtString));
- _snwprintf(buffer,
- 2048,
- szFmtString,
- ErrCode,
- msg);
- wprintf(L"%s", buffer);
-
- LocalFree(msg);
+ ConResPrintf(StdErr, IDS_FAILED_WITH_ERRORCODE,
+ ErrCode, pMsgBuf);
+ LocalFree(pMsgBuf);
}
-
- HeapFree(GetProcessHeap(), 0, buffer);
-}
-
-VOID DisplaySubstUsage(VOID)
-{
- WCHAR szHelp[RC_STRING_MAX_SIZE] = {0};
-
- LoadStringW(GetModuleHandleW(NULL),
- IDS_USAGE,
- szHelp,
- ARRAYSIZE(szHelp));
- wprintf(L"%s", szHelp);
}
ULONG QuerySubstedDrive(IN WCHAR DriveLetter,
DriveLetter = L'A' + i;
if (QuerySubstedDrive(DriveLetter, &lpTargetPath, &dwSize) == ERROR_IS_SUBSTED)
{
- wprintf(L"%c:\\: => %s\n", DriveLetter, lpTargetPath + 4);
+ ConPrintf(StdOut, L"%c:\\: => %s\n", DriveLetter, lpTargetPath + 4);
}
i++;
INT DeleteSubst(IN PWSTR Drive)
{
DWORD dwResult;
- WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0};
if ((wcslen(Drive) != 2) || (Drive[1] != L':'))
{
// case ERROR_INVALID_DRIVE:
case ERROR_INVALID_PARAMETER:
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_INVALID_PARAMETER2,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, Drive);
+ ConResPrintf(StdErr, IDS_INVALID_PARAMETER2, Drive);
return 1;
}
case ERROR_ACCESS_DENIED:
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_ACCESS_DENIED,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, Drive);
+ ConResPrintf(StdErr, IDS_ACCESS_DENIED, Drive);
return 1;
}
INT AddSubst(IN PWSTR Drive, IN PWSTR Path)
{
DWORD dwResult, dwPathAttr;
- WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0};
if ((wcslen(Drive) != 2) || (Drive[1] != L':'))
{
case ERROR_INVALID_DRIVE:
case ERROR_INVALID_PARAMETER:
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_INVALID_PARAMETER2,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, Drive);
+ ConResPrintf(StdErr, IDS_INVALID_PARAMETER2, Drive);
return 1;
}
case ERROR_IS_SUBSTED:
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_DRIVE_ALREADY_SUBSTED,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString);
+ ConResPrintf(StdErr, IDS_DRIVE_ALREADY_SUBSTED);
return 1;
}
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_PATH_NOT_FOUND,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, Path);
+ ConResPrintf(StdErr, IDS_PATH_NOT_FOUND, Path);
return 1;
}
case ERROR_ACCESS_DENIED:
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_ACCESS_DENIED,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, Path);
+ ConResPrintf(StdErr, IDS_ACCESS_DENIED, Path);
return 1;
}
int wmain(int argc, WCHAR* argv[])
{
INT i;
- WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0};
+
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
for (i = 0; i < argc; i++)
{
if (!_wcsicmp(argv[i], L"/?"))
{
- DisplaySubstUsage();
+ ConResPrintf(StdOut, IDS_USAGE);
return 0;
}
}
{
if (argc >= 2)
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_INVALID_PARAMETER,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, argv[1]);
+ ConResPrintf(StdErr, IDS_INVALID_PARAMETER, argv[1]);
return 1;
}
DumpSubstedDrives();
if (argc > 3)
{
- LoadStringW(GetModuleHandleW(NULL),
- IDS_INCORRECT_PARAMETER_COUNT,
- szFmtString,
- ARRAYSIZE(szFmtString));
- wprintf(szFmtString, argv[3]);
+ ConResPrintf(StdErr, IDS_INCORRECT_PARAMETER_COUNT, argv[3]);
return 1;
}