diff --git a/dlls/user/resource.c b/dlls/user/resource.c index 29ce970bc67..8c66431a5de 100644 --- a/dlls/user/resource.c +++ b/dlls/user/resource.c @@ -364,14 +364,11 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id, int string_num; int i; - if (HIWORD(resource_id)==0xFFFF) /* netscape 3 passes this */ - resource_id = (UINT)(-((INT)resource_id)); TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n", instance, resource_id, buffer, buflen); - /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out - * 20 - 31. */ - hrsrc = FindResourceW( instance, MAKEINTRESOURCEW(((resource_id>>4)&0xffff)+1), + /* Use loword (incremented by 1) as resourceid */ + hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), (LPWSTR)RT_STRING ); if (!hrsrc) return 0; hmem = LoadResource( instance, hrsrc ); @@ -394,9 +391,6 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id, buffer[0] = (WCHAR) 0; return 0; } -#if 0 - WARN("Don't know why caller gave buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1); -#endif } TRACE("%s loaded !\n", debugstr_w(buffer)); diff --git a/dlls/user/tests/resource.c b/dlls/user/tests/resource.c index dc879315467..30ee4afe2ac 100644 --- a/dlls/user/tests/resource.c +++ b/dlls/user/tests/resource.c @@ -46,6 +46,7 @@ static void test_LoadStringA (void) {sizeof str, sizeof str - 1}, {sizeof str - 1, sizeof str - 2}}; unsigned int i; + int ret; assert (sizeof str < sizeof buf); for (i = 0; i < sizeof tests / sizeof tests[0]; i++) { @@ -61,6 +62,20 @@ static void test_LoadStringA (void) ok (buf[len] == 0, "bufsiz=%d: NUL termination missing\n", bufsiz); } + + ret = LoadStringA(hInst, 1, buf, sizeof(buf) ); + ok( ret > 0, "LoadString failed: ret %d err %ld\n", ret, GetLastError()); + ok( LoadStringA( hInst, MAKELONG( 1, 0x8000 ), buf, sizeof(buf)) == ret, + "LoadString failed: ret %d err %ld\n", ret, GetLastError()); + ok( LoadStringA( hInst, MAKELONG( 1, 0xffff ), buf, sizeof(buf)) == ret, + "LoadString failed: ret %d err %ld\n", ret, GetLastError()); + + ret = LoadStringA(hInst, 65534, buf, sizeof(buf) ); + ok( ret > 0, "LoadString failed: ret %d err %ld\n", ret, GetLastError()); + ok( LoadStringA( hInst, MAKELONG( 65534, 0x8000 ), buf, sizeof(buf)) == ret, + "LoadString failed: ret %d err %ld\n", ret, GetLastError()); + ok( LoadStringA( hInst, MAKELONG( 65534, 0xffff ), buf, sizeof(buf)) == ret, + "LoadString failed: ret %d err %ld\n", ret, GetLastError()); } static void test_accel1(void) diff --git a/dlls/user/tests/resource.rc b/dlls/user/tests/resource.rc index 305b06a5e9a..e8827283078 100644 --- a/dlls/user/tests/resource.rc +++ b/dlls/user/tests/resource.rc @@ -40,6 +40,8 @@ STRINGTABLE { 0 "String resource" + 1 "Another string resource" + 65534 "Test high id" } TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30