On 08/07/2018 08:45 PM, Fabian Maurer wrote:
+BOOL WINAPI SxsLookupClrGuid(DWORD dwFlags, LPGUID pClsid, HANDLE hActCtx, PVOID pvOutputBuffer, SIZE_T cbOutputBuffer, PSIZE_T pcbOutputBuffer)
Please fix argument type names.
- if (!FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, 0, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, pClsid, &guid_info))
- {
DWORD error = GetLastError();
if (error != ERROR_SXS_KEY_NOT_FOUND)
ERR("Failed to find guid: %d\n", error);
SetLastError(ERROR_NOT_FOUND);
return FALSE;
- }
This looks too complicated.
- QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex, AssemblyDetailedInformationInActivationContext, NULL, 0, &bytes_assembly_info);
- assembly_info = heap_alloc(bytes_assembly_info);
- if (!QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
AssemblyDetailedInformationInActivationContext, assembly_info, bytes_assembly_info, &bytes_assembly_info))
First call should also be checked for failure.
- len_identity = (lstrlenW(ptr_identity) + 1) * sizeof(WCHAR);
- len_name = (lstrlenW(ptr_name) + 1) * sizeof(WCHAR);
- if (class_data->version_len > 0)
len_version = (lstrlenW(ptr_version) + 1) * sizeof(WCHAR);
You already have lengths of all three fields at this point.
+#define copy_str(target, ptr, len) \
target = len ? (void *)ret_strings : NULL; \
memcpy(ret_strings, ptr, len); \
ret_strings += len;
- copy_str(ret->pcwszAssemblyIdentity, ptr_identity, len_identity);
- copy_str(ret->pcwszTypeName , ptr_name, len_name);
- copy_str(ret->pcwszRuntimeVersion, ptr_version, len_version);
+#undef copy_str
Could you add a test for this layout? And probably remove a macro too.