user32: LoadString should use only 16 bits of string id
Andrey Turkin
pancha at mail.nnov.ru
Thu Sep 21 21:54:16 CDT 2006
String resource id is unsigned short (16 bits), and tests show that
native implementation of LoadString treat it as such (that is, only 16
lowest bits are used). Wine's implementation used 20 bits; this patch
forces it to use 16 bits, and adds few tests for this case.
ChangeLog:
Use only 16 lowest bits of string id in LoadString
-------------- next part --------------
diff -aurp wine-0.9.21/dlls/user/resource.c wine-0.9.21-my/dlls/user/resource.c
--- wine-0.9.21/dlls/user/resource.c 2006-09-13 23:10:25.000000000 +0400
+++ wine-0.9.21-my/dlls/user/resource.c 2006-09-22 05:14:23.000000000 +0400
@@ -369,9 +369,9 @@ INT WINAPI LoadStringW( HINSTANCE instan
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 bits 4 - 15 (incremented by 1) as resourceid, mask out
+ * 16 - 31. */
+ hrsrc = FindResourceW( instance, MAKEINTRESOURCEW(((resource_id>>4)&0xfff)+1),
(LPWSTR)RT_STRING );
if (!hrsrc) return 0;
hmem = LoadResource( instance, hrsrc );
diff -aurp wine-0.9.21/dlls/user/tests/resource.c wine-0.9.21-my/dlls/user/tests/resource.c
--- wine-0.9.21/dlls/user/tests/resource.c 2006-09-13 23:10:25.000000000 +0400
+++ wine-0.9.21-my/dlls/user/tests/resource.c 2006-09-22 05:08:11.000000000 +0400
@@ -61,6 +61,11 @@ static void test_LoadStringA (void)
ok (buf[len] == 0, "bufsiz=%d: NUL termination missing\n",
bufsiz);
}
+
+ ok (LoadStringA (hInst, 0x00010000, buf, sizeof(buf)) > 0, "LoadString failed\n");
+ ok (LoadStringA (hInst, 0x80000000, buf, sizeof(buf)) > 0, "LoadString failed\n");
+ ok (LoadStringA (hInst, 0x80130000, buf, sizeof(buf)) > 0, "LoadString failed\n");
+ ok (LoadStringA (hInst, 0xFFFF0000, buf, sizeof(buf)) > 0, "LoadString failed\n");
}
static void test_accel1(void)
More information about the wine-patches
mailing list