*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <k32.h>
*/
/**********************************************************************
- * load_messageA (internal)
+ * load_messageW (internal)
*/
-
-static LPSTR load_messageA( HMODULE module, UINT id, WORD lang )
+static LPWSTR load_messageW( HMODULE module, UINT id, WORD lang )
{
PRTL_MESSAGE_RESOURCE_ENTRY mre;
- char *buffer;
+ 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 );
+ Status = RtlFindMessage( module, (ULONG_PTR) RT_MESSAGETABLE, lang, id, &mre );
if (!NT_SUCCESS(Status))
+ {
+ SetLastError( RtlNtStatusToDosError(Status) );
return NULL;
+ }
if (mre->Flags & MESSAGE_RESOURCE_UNICODE)
{
- int len = WideCharToMultiByte( CP_ACP, 0, (const WCHAR *)mre->Text, -1, NULL, 0, NULL, NULL );
+ int len = (strlenW( (const WCHAR *)mre->Text ) + 1) * sizeof(WCHAR);
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
- WideCharToMultiByte( CP_ACP, 0, (const WCHAR *)mre->Text, -1, buffer, len, NULL, NULL );
+ memcpy( buffer, mre->Text, len );
}
else
{
- int len = strlen((const char*)mre->Text) + 1;
- if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
- memcpy( buffer, mre->Text, len );
+ 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_a(buffer));
+ //TRACE("returning %s\n", wine_dbgstr_w(buffer));
return buffer;
}
+/**********************************************************************
+ * load_messageA (internal)
+ */
-static LPWSTR load_messageW( HMODULE module, UINT id, WORD lang )
+static LPSTR load_messageA( HMODULE module, UINT id, WORD lang )
{
PRTL_MESSAGE_RESOURCE_ENTRY mre;
- WCHAR *buffer;
+ char *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 );
+ Status = RtlFindMessage( module, (ULONG_PTR) 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);
+ int len = WideCharToMultiByte( CP_ACP, 0, (const WCHAR *)mre->Text, -1, NULL, 0, NULL, NULL );
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
- memcpy( buffer, mre->Text, len );
+ WideCharToMultiByte( CP_ACP, 0, (const WCHAR *)mre->Text, -1, buffer, len, NULL, NULL );
}
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 );
+ int len = strlen((const char*)mre->Text) + 1;
+ if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
+ memcpy( buffer, mre->Text, len );
}
- //TRACE("returning %s\n", wine_dbgstr_w(buffer));
+ //TRACE("returning %s\n", wine_dbgstr_a(buffer));
return buffer;
}
+
/***********************************************************************
* FormatMessageA (KERNEL32.@)
* FIXME: missing wrap,
if (!from)
{
- SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND);
return 0;
}
}
if (!from)
{
- SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND);
return 0;
}
}
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);