From fd71c4cbecf3569d738af9693d3023ee96c5dcf2 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 27 Nov 2015 22:49:47 +0000 Subject: [PATCH] [USER32] Partially sync resources.c with Wine Staging 1.7.55. CORE-10536 svn path=/trunk/; revision=70169 --- reactos/media/doc/README.WINE | 2 +- reactos/win32ss/user/user32/misc/resources.c | 90 +++++++++++--------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 71c28eff88b..09c5cda876d 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -307,7 +307,7 @@ User32 - reactos/win32ss/user/user32/misc/ddeclient.c # Synced to WineStaging-1.7.37 reactos/win32ss/user/user32/misc/ddeserver.c # Synced to WineStaging-1.7.37 reactos/win32ss/user/user32/misc/exticon.c # Synced to Wine-1_1_22 - reactos/win32ss/user/user32/misc/resources.c # Forked? + reactos/win32ss/user/user32/misc/resources.c # Partially synced to WineStaging-1.7.55 reactos/win32ss/user/user32/misc/winhelp.c # Last sync date unknown reactos/win32ss/user/user32/misc/wsprintf.c # Synced to Wine-1_1_23 diff --git a/reactos/win32ss/user/user32/misc/resources.c b/reactos/win32ss/user/user32/misc/resources.c index bc7db00ed01..4f5107c0474 100644 --- a/reactos/win32ss/user/user32/misc/resources.c +++ b/reactos/win32ss/user/user32/misc/resources.c @@ -1,6 +1,7 @@ #include #include +WINE_DEFAULT_DEBUG_CHANNEL(resource); #ifndef _CFGMGR32_H_ #define CR_SUCCESS 0x00000000 @@ -20,43 +21,12 @@ typedef DWORD (WINAPI *CMP_UNREGNOTIFY) (ULONG ); static HINSTANCE hSetupApi = NULL; - -/* - * @implemented (Synced with Wine 08.01.2009) - */ -INT -WINAPI -LoadStringA(HINSTANCE instance, UINT resource_id, LPSTR buffer, INT buflen) -{ - HGLOBAL hmem; - HRSRC hrsrc; - DWORD retval = 0; - - if (!buflen) return -1; - - /* Use loword (incremented by 1) as resourceid */ - if ((hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), - (LPWSTR)RT_STRING )) && - (hmem = LoadResource( instance, hrsrc ))) - { - const WCHAR *p = LockResource(hmem); - unsigned int id = resource_id & 0x000f; - - while (id--) p += *p + 1; - - RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, (PWSTR)(p + 1), *p * sizeof(WCHAR) ); - } - buffer[retval] = 0; - return retval; -} - - -/* - * @implemented (Synced with Wine 08.01.2009) +/********************************************************************** + * LoadStringW (USER32.@) + * Synced with Wine Staging 1.7.55 */ -INT -WINAPI -LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen) +INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id, + LPWSTR buffer, INT buflen ) { HGLOBAL hmem; HRSRC hrsrc; @@ -64,6 +34,9 @@ LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen) int string_num; int i; + TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n", + instance, resource_id, buffer, buflen); + if(buffer == NULL) return 0; @@ -77,7 +50,9 @@ LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen) p = LockResource(hmem); string_num = resource_id & 0x000f; for (i = 0; i < string_num; i++) - p += *p + 1; + p += *p + 1; + + TRACE("strlen = %d\n", (int)*p ); /*if buflen == 0, then return a read-only pointer to the resource itself in buffer it is assumed that buffer is actually a (LPWSTR *) */ @@ -89,18 +64,51 @@ LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen) i = min(buflen - 1, *p); if (i > 0) { - memcpy(buffer, p + 1, i * sizeof (WCHAR)); + memcpy(buffer, p + 1, i * sizeof (WCHAR)); buffer[i] = 0; } else { - if (buflen > 1) { + if (buflen > 1) { buffer[0] = 0; - return 0; - } + return 0; + } } + TRACE("%s loaded !\n", debugstr_w(buffer)); return i; } +/********************************************************************** + * LoadStringA (USER32.@) + * Synced with Wine Staging 1.7.55 + */ +INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id, LPSTR buffer, INT buflen ) +{ + HGLOBAL hmem; + HRSRC hrsrc; + DWORD retval = 0; + + TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n", + instance, resource_id, buffer, buflen); + + if (!buflen) return -1; + + /* Use loword (incremented by 1) as resourceid */ + if ((hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), + (LPWSTR)RT_STRING )) && + (hmem = LoadResource( instance, hrsrc ))) + { + const WCHAR *p = LockResource(hmem); + unsigned int id = resource_id & 0x000f; + + while (id--) p += *p + 1; + + if (buflen != 1) + RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, (PWSTR)(p + 1), *p * sizeof(WCHAR) ); + } + buffer[retval] = 0; + TRACE("returning %s\n", debugstr_a(buffer)); + return retval; +} /* * @implemented -- 2.17.1