Match Windows behavior when locating and retrieving the assembly manifest from a DLL.
Following is the explanation as to how this MR is sufficient for supporting isolation-aware DLLs and fixing #18889.
---
From Microsoft documentation, [Using Side-by-Side Assemblies as a Resource][sxs-rsrc] outlines the significance of each reserved manifest resource ID.
Further investigation reveals the following:
1. `CREATEPROCESS_MANIFEST_RESOURCE_ID` (value: `1`): This is used for process-wide initial (`NULL`) activation context.
- **Usage documentation**: [Enabling an Assembly in an Application Without Extensions](https://learn.microsoft.com/en-us/windows/win32/sbscs/enabling-…
- **Intended container module type**: EXE only.
- **Lifetime of the associated activation context**: Alive until the process is terminated. Owned by system (NTDLL).
- **Isolation-aware**: No.
2. `ISOLATIONAWARE_MANIFEST_RESOURCE_ID` (value: `2`): This is used to specify the assembly manifest that the loader (Ldr) uses to resolve static imports. Also, this is used by isolation-aware wrappers defined in `*.inl` files included in the Windows SDK (`include\um`) when the `ISOLATION_AWARE_ENABLED` macro is defined as a nonzero value.
- **Usage documentation**: [Enabling an Assembly in an Application Hosting a DLL, Extension, or Control Panel](https://learn.microsoft.com/en-us/windows/win32/sbscs/enabling-an-as…
- **Intended container module type**: EXE and DLL.
- **Lifetime of the associated activation context**: Alive until the module is unloaded (e.g., via `FreeLibrary`). Owned by system (NTDLL).
- **Isolation-aware**: Yes.
3. `ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID` (value: `3`): Ignored by the loader when resolving static imports. This is used by isolation-aware API wrappers defined in `*.inl` files included in the Windows SDK (`include\um`) when the `ISOLATION_AWARE_ENABLED` macro is defined as a nonzero value.
- **Usage documentation**: [IsolationAwareCleanup function][IsolationAwareCleanup]
- **Intended container module type**: EXE and DLL.
- **Lifetime of the associated activation context**: Alive until the application calls [`IsolationAwareCleanup`][IsolationAwareCleanup][^ia-cleanup-note]. Owned by the isolation-aware API wrapper library (part of the Windows SDK, rather than being a system DLL).
- **Isolation-aware**: Yes.
The `ISOLATION_AWARE_ENABLED` macro is documented in [Isolating Components][sxs-ic] as well as [Specifying a Default Activation Context][sxs-def-actctx]. When `ISOLATION_AWARE_ENABLED` macro is defined as a nonzero value, then the isolation-aware API wrapper library is enabled. The isolation-aware API wrapper library is responsible for:
- Creating (lazily) and destroying activation context (in `IsolationAwareCleanup`), if the manifest resource ID is `ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID`.[^actctx-lifetime-remark]
- Note: the isolation-aware API wrapper library does not manage the activation context's lifetime and delegates the responsibility to the system loader if the manifest resource ID is `ISOLATIONAWARE_MANIFEST_RESOURCE_ID`.
- Intercepting Win32 API calls for automatic activation context activation. Each API wrapper activates the "isolation-aware" activation context (obtaining one if it did not exist) before calling the original procedure, and deactivates it before returning.
The isolation-aware wrappers may be either be defined inline, or compiled into static libraries that are linked into the final application executable.
From the information above as well as the tests included in this merge request, we can infer the following:
1. Although side-by-side awareness is a cross-cutting concern, the *activation* of activation contexts itself is *not* usually performed automatically by the system for the application (with the sole exception of process-wide activation context associated with `CREATEPROCESS_MANIFEST_RESOURCE_ID`, and static import resolution).
2. `ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID` is treated like any other resource ID (from `0x0004` to `0xffff`) as far as the loader is concerned.
3. The resource ID of the manifest only concerns how the module containing the manifest intends to use the manifest. In fact, for DLLs that do not *statically* import symbols from side-by-side assemblies, the three resource IDs above are basically equivalent. A DLL can elect not to use manifest resources at all, and manage activation context and library loading by itself.
This is why I believe that this merge request is sufficient in completing the isolation-aware component support in Wine; the heavy lifting is done in the application side, not the system.
**EDIT**: Fix a few typos and unclear wording.
---
[^ia-cleanup-note]: According to the documentation, the application is presumably responsible for calling `IsolationAwareCleanup` from `DllMain` on `fdwReason = DLL_PROCESS_DETACH`.
[^actctx-lifetime-remark]: [IsolationAwareCleanup § Remarks](https://learn.microsoft.com/en-us/previous-versions/windows/deskto…, from Microsoft documentation.
[sxs-rsrc]: https://learn.microsoft.com/en-us/windows/win32/sbscs/using-side-by-side-as…
[IsolationAwareCleanup]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/…
[sxs-ic]: https://learn.microsoft.com/en-us/windows/win32/sbscs/isolating-components
[sxs-def-actctx]: https://learn.microsoft.com/en-us/windows/win32/sbscs/specifying-a-default-…
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=18889
--
v10: ntdll: Don't hard-code DLL manifest resource ID when looking up dependency assembly.
kernel32/tests: Test loading assembly manifest resource inside dependencies.
https://gitlab.winehq.org/wine/wine/-/merge_requests/2555
--
v5: vkd3d-shader/tpf: Write out comparison mode sampler declarations and corresponding sampling instruction.
vkd3d-shader/hlsl: Parse SampleCmp() method.
vkd3d-shader/hlsl: Parse SamplerComparisonState objects.
vkd3d-shader/hlsl: Use a function table for object methods handlers.
vkd3d-shader/hlsl: Move object type checks to methods handlers.
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/206
Some GStreamer plugins such as openh264 return spurious errors when
running the tests. They pass the tests successfull if we simply ignore
them.
It does not make much difference with returning the error, as they are
not supposed to happen anyway, and most of the time the MFT clients
don't expect or handle errors.
Split from https://gitlab.winehq.org/wine/wine/-/merge_requests/2893 as this is also orthogonal and only fixes the tests when running them with openh264, which is not the case on either the testbot or Gitlab.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2899
```c
dlls/wined3d/context_vk.c:2377:42: warning: ‘null_binding’ may be used uninitialized in this function [-Wmaybe-uninitialized]
2377 | *null_buffer_binding = b->binding = null_binding;
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
```
--
v3: wined3d: Fix uninitialized variable warning.
https://gitlab.winehq.org/wine/wine/-/merge_requests/2892
--
v4: wineoss: Use mmdevapi's AudioClient (4/4).
winecoreaudio: Use mmdevapi's AudioClient (4/4).
winealsa: Use mmdevapi's AudioClient (4/4).
winepulse: Move AudioClient into mmdevapi (4/4).
wineoss: Use mmdevapi's AudioClient (3/4).
winecoreaudio: Use mmdevapi's AudioClient (3/4).
winealsa: Use mmdevapi's AudioClient (3/4).
winepulse: Move AudioClient into mmdevapi (3/4).
wineoss: Use mmdevapi's AudioClient (2/4).
winecoreaudio: Use mmdevapi's AudioClient (2/4).
winealsa: Use mmdevapi's AudioClient (2/4).
winepulse: Move AudioClient into mmdevapi (2/4).
wineoss: Use mmdevapi's AudioClient (1/4).
winecoreaudio: Use mmdevapi's AudioClient (1/4).
winealsa: Use mmdevapi's AudioClient (1/4).
winepulse: Move AudioClient into mmdevapi (1/4).
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/2855