[ros-diffs] [cwittich] 44194: partial FormatMessage wine sync

cwittich at svn.reactos.org cwittich at svn.reactos.org
Mon Nov 16 02:37:12 CET 2009


Author: cwittich
Date: Mon Nov 16 02:37:12 2009
New Revision: 44194

URL: http://svn.reactos.org/svn/reactos?rev=44194&view=rev
Log:
partial FormatMessage wine sync

Modified:
    trunk/reactos/dll/win32/kernel32/misc/errormsg.c

Modified: trunk/reactos/dll/win32/kernel32/misc/errormsg.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/errormsg.c?rev=44194&r1=44193&r2=44194&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/errormsg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/errormsg.c [iso-8859-1] Mon Nov 16 02:37:12 2009
@@ -76,6 +76,42 @@
  */
 
 /**********************************************************************
+ *	load_messageW		(internal)
+ */
+static LPWSTR load_messageW( HMODULE module, UINT id, WORD lang )
+{
+    PRTL_MESSAGE_RESOURCE_ENTRY mre;
+    WCHAR *buffer;
+    NTSTATUS Status;
+
+    TRACE("module = %p, id = %08x\n", module, id );
+
+    if (!module) module = GetModuleHandleW( NULL );
+    Status = RtlFindMessage( module, (ULONG) RT_MESSAGETABLE, lang, id, &mre );
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastError( RtlNtStatusToDosError(Status) );
+        return NULL;
+    }
+
+    if (mre->Flags & MESSAGE_RESOURCE_UNICODE)
+    {
+        int len = (strlenW( (const WCHAR *)mre->Text ) + 1) * sizeof(WCHAR);
+        if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
+        memcpy( buffer, mre->Text, len );
+    }
+    else
+    {
+        int len = MultiByteToWideChar( CP_ACP, 0, (const char *)mre->Text, -1, NULL, 0 );
+        if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
+        MultiByteToWideChar( CP_ACP, 0, (const char*)mre->Text, -1, buffer, len );
+    }
+    //TRACE("returning %s\n", wine_dbgstr_w(buffer));
+    return buffer;
+}
+
+
+/**********************************************************************
  *      load_messageA           (internal)
  */
 
@@ -90,7 +126,10 @@
     if (!module) module = GetModuleHandleW( NULL );
     Status = RtlFindMessage( module, (ULONG) RT_MESSAGETABLE, lang, id, &mre );
     if (!NT_SUCCESS(Status))
+    {
+        SetLastError( RtlNtStatusToDosError(Status) );
         return NULL;
+    }
 
     if (mre->Flags & MESSAGE_RESOURCE_UNICODE)
     {
@@ -108,36 +147,6 @@
     return buffer;
 }
 
-
-
-static LPWSTR load_messageW( HMODULE module, UINT id, WORD lang )
-{
-    PRTL_MESSAGE_RESOURCE_ENTRY mre;
-    WCHAR *buffer;
-    NTSTATUS Status;
-
-    TRACE("module = %p, id = %08x\n", module, id );
-
-    if (!module) module = GetModuleHandleW( NULL );
-    Status = RtlFindMessage( module, (ULONG) RT_MESSAGETABLE, lang, id, &mre );
-    if (!NT_SUCCESS(Status))
-        return NULL;
-
-    if (mre->Flags & MESSAGE_RESOURCE_UNICODE)
-    {
-        int len = (strlenW( (const WCHAR *)mre->Text ) + 1) * sizeof(WCHAR);
-        if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
-        memcpy( buffer, mre->Text, len );
-    }
-    else
-    {
-        int len = MultiByteToWideChar( CP_ACP, 0, (const char *)mre->Text, -1, NULL, 0 );
-        if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
-        MultiByteToWideChar( CP_ACP, 0, (const char*)mre->Text, -1, buffer, len );
-    }
-    //TRACE("returning %s\n", wine_dbgstr_w(buffer));
-    return buffer;
-}
 
 /***********************************************************************
  *           FormatMessageA   (KERNEL32.@)
@@ -199,7 +208,6 @@
 
         if (!from)
         {
-            SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND);
             return 0;
         }
     }
@@ -457,7 +465,6 @@
 
         if (!from)
         {
-            SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND);
             return 0;
         }
     }
@@ -641,7 +648,7 @@
     if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
         /* nSize is the MINIMUM size */
         DWORD len = strlenW(target) + 1;
-        *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(LMEM_ZEROINIT,len*sizeof(WCHAR));
+        *((LPVOID*)lpBuffer) = LocalAlloc(LMEM_ZEROINIT,len*sizeof(WCHAR));
         strcpyW(*(LPWSTR*)lpBuffer, target);
     }
     else lstrcpynW(lpBuffer, target, nSize);




More information about the Ros-diffs mailing list