Commit dea8c6a9 authored by Alexandre Julliard's avatar Alexandre Julliard

user: Fix handling of high bits of resource id in LoadString, reported by Andrey Turkin.

parent b421b608
......@@ -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));
......
......@@ -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)
......
......@@ -40,6 +40,8 @@
STRINGTABLE
{
0 "String resource"
1 "Another string resource"
65534 "Test high id"
}
TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment