mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Emit Win32 error messages on failure.
svn path=/trunk/; revision=17281
This commit is contained in:
parent
97ffde7504
commit
f83c14b3fc
5 changed files with 86 additions and 12 deletions
|
@ -32,8 +32,6 @@ IDS_shutdown_msg, "shutdown an optional environment subsystem;"
|
|||
|
||||
IDS_Unknown, "Unknown command '%s'.\n"
|
||||
|
||||
IDS_Status, "Status 0x%08lx\n"
|
||||
|
||||
IDS_SM1, "SM SubSystem Directory\n\n\
|
||||
SSID PID Flags\n\
|
||||
---- -------- ------------\n"
|
||||
|
|
|
@ -14,14 +14,13 @@
|
|||
#define IDS_shutdown_msg 209
|
||||
|
||||
#define IDS_Unknown 300
|
||||
#define IDS_Not_Imp 301
|
||||
#define IDS_Not_Imp 301
|
||||
#define IDS_ID 302
|
||||
#define IDS_SM2 303
|
||||
#define IDS_SM1 304
|
||||
#define IDS_Status 305
|
||||
#define IDS_Mangers 306
|
||||
#define IDS_USING 307
|
||||
#define IDS_FAILS_MNG 308
|
||||
#define IDS_Mangers 305
|
||||
#define IDS_USING 306
|
||||
#define IDS_FAILS_MNG 307
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -35,12 +35,21 @@
|
|||
|
||||
#include <sm/helper.h>
|
||||
|
||||
VOID PrintWin32Error(PWCHAR,DWORD); /* win32err.c */
|
||||
|
||||
#define SM_CMD(n) cmd_##n
|
||||
#define SM_CMD_DECL(n) int SM_CMD(n)(int argc, char * argv[])
|
||||
#define SM_CMD_CALL(n,c,v) SM_CMD(n)((c),(v))
|
||||
|
||||
HANDLE hSmApiPort = (HANDLE) 0;
|
||||
|
||||
VOID STDCALL PrintStatusError (NTSTATUS Status)
|
||||
{
|
||||
DWORD Win32Error = RtlNtStatusToDosError (Status);
|
||||
|
||||
PrintWin32Error (L"sm", Win32Error);
|
||||
}
|
||||
|
||||
typedef struct _SM_CMD_DESCRIPTOR
|
||||
{
|
||||
TCHAR Name[RC_STRING_MAX_SIZE];
|
||||
|
@ -117,9 +126,7 @@ SM_CMD_DECL(boot)
|
|||
#endif
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
LoadString( GetModuleHandle(NULL), IDS_Status, (LPTSTR) UsageMessage,RC_STRING_MAX_SIZE);
|
||||
|
||||
_tprintf(UsageMessage, Status);
|
||||
PrintStatusError (Status);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -197,8 +204,7 @@ SM_CMD_DECL(info)
|
|||
& ReturnDataLength);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
LoadString( GetModuleHandle(NULL), IDS_Status, (LPTSTR) UsageMessage,RC_STRING_MAX_SIZE);
|
||||
_tprintf(UsageMessage, Status);
|
||||
PrintStatusError (Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
switch (argc)
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
<library>ntdll</library>
|
||||
<library>kernel32</library>
|
||||
<file>sm.c</file>
|
||||
<file>win32err.c</file>
|
||||
<file>sm.rc</file>
|
||||
</module>
|
||||
|
|
70
reactos/subsys/system/sm/win32err.c
Normal file
70
reactos/subsys/system/sm/win32err.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* $Id: win32err.c 16861 2005-07-29 13:46:03Z ea $
|
||||
*
|
||||
* win32err.c
|
||||
*
|
||||
* Copyright (c) 1998 Mark Russinovich
|
||||
* Systems Internals
|
||||
* http://www.sysinternals.com/
|
||||
*
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* This software is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This software 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this software; see the file COPYING.LIB. If
|
||||
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
* Cambridge, MA 02139, USA.
|
||||
*
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* Print a Win32 error.
|
||||
*
|
||||
* 1999 February (Emanuele Aliberti)
|
||||
* Taken from chkdskx.c and formatx.c by Mark Russinovich
|
||||
* to be used in all sysutils.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// PrintWin32Error
|
||||
//
|
||||
// Takes the win32 error code and prints the text version.
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
void
|
||||
PrintWin32Error(
|
||||
PWCHAR Message,
|
||||
DWORD ErrorCode
|
||||
)
|
||||
{
|
||||
PVOID 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 );
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
Loading…
Reference in a new issue