Revert, thx Thomas, wasnt sure.
[reactos.git] / reactos / subsys / system / sm / sm.c
index 1238763..e694242 100644 (file)
 #include <tchar.h>
 #include "resource.h"
 
+#define WIN32_NO_STATUS
 #include <windows.h>
 #define NTOS_MODE_USER
 #include <ndk/ntndk.h>
 
 #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];
@@ -89,7 +99,7 @@ PSM_CMD_DESCRIPTOR LookupCommand (const TCHAR * CommandName)
        {
                LoadString( GetModuleHandle(NULL), IDS_Unknown, (LPTSTR) UsageMessage,RC_STRING_MAX_SIZE);
 
-               _ftprintf(stderr, _T("%s '%s'.\n"), UsageMessage, CommandName);
+               _ftprintf(stderr, UsageMessage, CommandName);
                return NULL;
        }
        return & Command [i];
@@ -117,9 +127,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 +205,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)