diff --git a/reactos/subsys/system/sm/En.rc b/reactos/subsys/system/sm/En.rc index e9f3338ecdd..35e67057163 100644 --- a/reactos/subsys/system/sm/En.rc +++ b/reactos/subsys/system/sm/En.rc @@ -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" diff --git a/reactos/subsys/system/sm/resource.h b/reactos/subsys/system/sm/resource.h index 81630929f67..fbee6a60314 100644 --- a/reactos/subsys/system/sm/resource.h +++ b/reactos/subsys/system/sm/resource.h @@ -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 */ diff --git a/reactos/subsys/system/sm/sm.c b/reactos/subsys/system/sm/sm.c index 1238763497b..5cb8db369a5 100644 --- a/reactos/subsys/system/sm/sm.c +++ b/reactos/subsys/system/sm/sm.c @@ -35,12 +35,21 @@ #include +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) diff --git a/reactos/subsys/system/sm/sm.xml b/reactos/subsys/system/sm/sm.xml index 34a5fc4d4f2..5340cdb7078 100644 --- a/reactos/subsys/system/sm/sm.xml +++ b/reactos/subsys/system/sm/sm.xml @@ -6,5 +6,6 @@ ntdll kernel32 sm.c + win32err.c sm.rc diff --git a/reactos/subsys/system/sm/win32err.c b/reactos/subsys/system/sm/win32err.c new file mode 100644 index 00000000000..83dd10ad9ab --- /dev/null +++ b/reactos/subsys/system/sm/win32err.c @@ -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 +#include + +//---------------------------------------------------------------------- +// +// 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 */