Commit 382b72d7 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

fusion: Support buffer size queries in IAssemblyName::GetName.

parent c5c71372
...@@ -369,19 +369,24 @@ static HRESULT WINAPI IAssemblyNameImpl_GetName(IAssemblyName *iface, ...@@ -369,19 +369,24 @@ static HRESULT WINAPI IAssemblyNameImpl_GetName(IAssemblyName *iface,
WCHAR *pwzName) WCHAR *pwzName)
{ {
IAssemblyNameImpl *name = impl_from_IAssemblyName(iface); IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
DWORD len;
TRACE("(%p, %p, %p)\n", iface, lpcwBuffer, pwzName); TRACE("(%p, %p, %p)\n", iface, lpcwBuffer, pwzName);
if (!name->name) if (name->name)
len = strlenW(name->name) + 1;
else
len = 0;
if (*lpcwBuffer < len)
{ {
*pwzName = '\0'; *lpcwBuffer = len;
*lpcwBuffer = 0; return E_NOT_SUFFICIENT_BUFFER;
return S_OK;
} }
if (!name->name) lpcwBuffer[0] = 0;
else strcpyW(pwzName, name->name);
lstrcpyW(pwzName, name->name); *lpcwBuffer = len;
*lpcwBuffer = lstrlenW(pwzName) + 1;
return S_OK; return S_OK;
} }
......
...@@ -421,12 +421,12 @@ static void test_CreateAssemblyNameObject(void) ...@@ -421,12 +421,12 @@ static void test_CreateAssemblyNameObject(void)
broken(hr == E_INVALIDARG), /* .NET 1.x */ broken(hr == E_INVALIDARG), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr); "Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
str[0] = 'a';
size = MAX_PATH; size = MAX_PATH;
str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str); hr = IAssemblyName_GetName(name, &size, str);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "got %08x\n", hr);
ok(!str[0], "Expected empty name\n"); ok(str[0] == 'a', "got %c\n", str[0]);
ok(size == 0, "Expected 0, got %d\n", size); ok(!size, "got %u\n", size);
hi = 0xbeefcace; hi = 0xbeefcace;
lo = 0xcafebabe; lo = 0xcafebabe;
...@@ -457,6 +457,26 @@ static void test_CreateAssemblyNameObject(void) ...@@ -457,6 +457,26 @@ static void test_CreateAssemblyNameObject(void)
broken(hr == S_OK), /* .NET 1.x */ broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr); "Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
size = 0;
hr = IAssemblyName_GetName(name, &size, NULL);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
ok(size == 1, "got %u\n", size);
if (0) /* crash */
{
str[0] = '\0';
hr = IAssemblyName_GetName(name, NULL, str);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
ok(!str[0], "got %c\n", str[0]);
}
size = 0;
str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
ok(!str[0], "got %c\n", str[0]);
ok(size == 1, "got %u\n", size);
size = MAX_PATH; size = MAX_PATH;
str[0] = '\0'; str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str); hr = IAssemblyName_GetName(name, &size, str);
...@@ -494,6 +514,13 @@ static void test_CreateAssemblyNameObject(void) ...@@ -494,6 +514,13 @@ static void test_CreateAssemblyNameObject(void)
ok_aw("wine", str); ok_aw("wine", str);
ok(size == 5, "Expected 5, got %d\n", size); ok(size == 5, "Expected 5, got %d\n", size);
size = 0;
str[0] = 0;
hr = IAssemblyName_GetName(name, &size, str);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
ok(!str[0], "got %c\n", str[0]);
ok(size == 5, "got %u\n", size);
size = MAX_PATH; size = MAX_PATH;
str[0] = '\0'; str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str); hr = IAssemblyName_GetName(name, &size, str);
......
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