user32: Make LoadStringW pass tests.
This commit is contained in:
parent
17bf0d9164
commit
9978cc9c56
|
@ -1402,8 +1402,9 @@ static void init_oid_info(HINSTANCE hinst)
|
|||
}
|
||||
else
|
||||
{
|
||||
LPCWSTR stringresource;
|
||||
int len = LoadStringW(hinst, (UINT_PTR)oidInfoConstructors[i].pwszName,
|
||||
NULL, 0);
|
||||
(LPWSTR)&stringresource, 0);
|
||||
|
||||
if (len)
|
||||
{
|
||||
|
@ -1415,12 +1416,11 @@ static void init_oid_info(HINSTANCE hinst)
|
|||
memset(info, 0, sizeof(*info));
|
||||
info->info.cbSize = sizeof(CRYPT_OID_INFO);
|
||||
info->info.pszOID = oidInfoConstructors[i].pszOID;
|
||||
info->info.pwszName =
|
||||
(LPWSTR)((LPBYTE)info + sizeof(struct OIDInfo));
|
||||
info->info.pwszName = (LPWSTR)(info + 1);
|
||||
info->info.dwGroupId = oidInfoConstructors[i].dwGroupId;
|
||||
info->info.u.Algid = oidInfoConstructors[i].Algid;
|
||||
LoadStringW(hinst, (UINT_PTR)oidInfoConstructors[i].pwszName,
|
||||
(LPWSTR)info->info.pwszName, len + 1);
|
||||
memcpy(info + 1, stringresource, len*sizeof(WCHAR));
|
||||
((LPWSTR)(info + 1))[len] = 0;
|
||||
if (oidInfoConstructors[i].blob)
|
||||
{
|
||||
info->info.ExtraInfo.cbData =
|
||||
|
|
|
@ -51,13 +51,14 @@ static const WCHAR szEmpty[] = {0};
|
|||
static LPWSTR HH_LoadString(DWORD dwID)
|
||||
{
|
||||
LPWSTR string = NULL;
|
||||
LPCWSTR stringresource;
|
||||
int iSize;
|
||||
|
||||
iSize = LoadStringW(hhctrl_hinstance, dwID, NULL, 0);
|
||||
iSize += 2; /* some strings (tab text) needs double-null termination */
|
||||
iSize = LoadStringW(hhctrl_hinstance, dwID, (LPWSTR)&stringresource, 0);
|
||||
|
||||
string = heap_alloc(iSize * sizeof(WCHAR));
|
||||
LoadStringW(hhctrl_hinstance, dwID, string, iSize);
|
||||
string = heap_alloc((iSize + 2) * sizeof(WCHAR)); /* some strings (tab text) needs double-null termination */
|
||||
memcpy(string, stringresource, iSize*sizeof(WCHAR));
|
||||
string[iSize] = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
|
|
@ -279,16 +279,18 @@ void wnetInit(HINSTANCE hInstDll)
|
|||
{
|
||||
PWSTR ptrPrev;
|
||||
int entireNetworkLen;
|
||||
LPCWSTR stringresource;
|
||||
|
||||
entireNetworkLen = LoadStringW(hInstDll,
|
||||
IDS_ENTIRENETWORK, NULL, 0);
|
||||
IDS_ENTIRENETWORK, (LPWSTR)&stringresource, 0);
|
||||
providerTable->entireNetwork = HeapAlloc(
|
||||
GetProcessHeap(), 0, (entireNetworkLen + 1) *
|
||||
sizeof(WCHAR));
|
||||
if (providerTable->entireNetwork)
|
||||
LoadStringW(hInstDll, IDS_ENTIRENETWORK,
|
||||
providerTable->entireNetwork,
|
||||
entireNetworkLen + 1);
|
||||
{
|
||||
memcpy(providerTable->entireNetwork, stringresource, entireNetworkLen*sizeof(WCHAR));
|
||||
providerTable->entireNetwork[entireNetworkLen] = 0;
|
||||
}
|
||||
providerTable->numAllocated = numToAllocate;
|
||||
for (ptr = providers; ptr; )
|
||||
{
|
||||
|
|
|
@ -368,6 +368,9 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
|
|||
TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n",
|
||||
instance, resource_id, buffer, buflen);
|
||||
|
||||
if(buffer == NULL)
|
||||
return 0;
|
||||
|
||||
/* Use loword (incremented by 1) as resourceid */
|
||||
hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1),
|
||||
(LPWSTR)RT_STRING );
|
||||
|
@ -382,7 +385,14 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
|
|||
|
||||
TRACE("strlen = %d\n", (int)*p );
|
||||
|
||||
if (buffer == NULL) return *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 *) */
|
||||
if(buflen == 0)
|
||||
{
|
||||
*((LPWSTR *)buffer) = p + 1;
|
||||
return *p;
|
||||
}
|
||||
|
||||
i = min(buflen - 1, *p);
|
||||
if (i > 0) {
|
||||
memcpy(buffer, p + 1, i * sizeof (WCHAR));
|
||||
|
|
|
@ -43,13 +43,10 @@ static void test_LoadStringW(void)
|
|||
length1 = LoadStringW(hInst, 2, (WCHAR *) &resourcepointer, 0); /* get pointer to resource. */
|
||||
length2 = LoadStringW(hInst, 2, returnedstringw, sizeof(returnedstringw) /sizeof(WCHAR)); /* get resource string */
|
||||
ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d\n", length2, GetLastError());
|
||||
todo_wine
|
||||
{
|
||||
ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n",
|
||||
length1, length2);
|
||||
ok(length1 > 0 && resourcepointer != NULL, "LoadStringW failed to get pointer to resource 2, ret %d, err %d\n",
|
||||
length1, GetLastError());
|
||||
}
|
||||
ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n",
|
||||
length1, length2);
|
||||
ok(length1 > 0 && resourcepointer != NULL, "LoadStringW failed to get pointer to resource 2, ret %d, err %d\n",
|
||||
length1, GetLastError());
|
||||
|
||||
/* Copy the resource since it is not '\0' terminated, and add '\0' to the end */
|
||||
if(resourcepointer != NULL) /* Check that the resource pointer was loaded to avoid access violation */
|
||||
|
@ -62,17 +59,13 @@ static void test_LoadStringW(void)
|
|||
ok(!memcmp(copiedstringw, returnedstringw, (length2 + 1)*sizeof(WCHAR)),
|
||||
"strings don't match: returnedstring = %s, copiedstring = %s\n", returnedstring, copiedstring);
|
||||
}
|
||||
todo_wine
|
||||
{
|
||||
/* check that calling LoadStringW with buffer = NULL returns zero */
|
||||
retvalue = LoadStringW(hInst, 2, NULL, 0);
|
||||
ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d\n",
|
||||
retvalue);
|
||||
/* check again, with a different buflen value, that calling LoadStringW with buffer = NULL returns zero */
|
||||
retvalue = LoadStringW(hInst, 2, NULL, 128);
|
||||
ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d\n",
|
||||
retvalue);
|
||||
}
|
||||
|
||||
/* check that calling LoadStringW with buffer = NULL returns zero */
|
||||
retvalue = LoadStringW(hInst, 2, NULL, 0);
|
||||
ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d\n", retvalue);
|
||||
/* check again, with a different buflen value, that calling LoadStringW with buffer = NULL returns zero */
|
||||
retvalue = LoadStringW(hInst, 2, NULL, 128);
|
||||
ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d\n", retvalue);
|
||||
}
|
||||
|
||||
static void test_LoadStringA (void)
|
||||
|
|
Loading…
Reference in New Issue