"Building an Arm64X pure forwarder DLL": Consider recommending `/DEPENDENTLOADFLAG:0x100`

Open Beginner friendly
#6,205 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
documentation

Research direction

Start with landing/arm-docs/arm64x-build.md and read the “Building an Arm64X pure forwarder DLL” section. Check the linked /DEPENDENTLOADFLAG documentation and the reported Arm64 and x64 load-config behavior, then update the guidance to explain when the flag is needed and how it applies to both views. Done when the documented load behavior and recommendation address the reported cases.

Written by the indexing model from the issue text.

Description

Pri3
Type of issue

Missing information

Feedback

Page: https://learn.microsoft.com/en-us/windows/arm/arm64x-build#building-an-arm64x-pure-forwarder-dll
Source: landing/arm-docs/arm64x-build.md

Problem

The section "Building an Arm64X pure forwarder DLL" says:

When an Arm64 process loads foo.dll, the operating system immediately loads foo_arm64.dll in its place and any API calls are handled by foo_arm64.dll.

In practice the forward target is not loaded "in its place" when foo.dll is loaded. It is resolved when a forwarded export is looked up, for example by GetProcAddress. The target is named by bare module name (foo_arm64.MyAPI1), so the loader looks for it through the normal DLL search order. That order includes the forwarder's own directory only if the forwarder was loaded with LOAD_WITH_ALTERED_SEARCH_PATH or LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR.

So a pure forwarder built exactly as documented fails whenever it is loaded by full path without one of those flags. In that case LoadLibraryExW succeeds, but GetProcAddress fails with ERROR_PROC_NOT_FOUND (127).

This affects real products. A common use of an Arm64X pure forwarder is an in-proc COM server, such as a text input processor (TIP), that must load into both Arm64 and x64 processes. COM loads in-proc servers with LOAD_WITH_ALTERED_SEARCH_PATH in most processes, but we observed combase calling LoadLibraryExW(path, NULL, 0) in SystemSettings.exe. As a result, Japanese IMEs that use an Arm64X pure forwarder cannot be activated in Settings or in Start menu search (SearchHost.exe) on Arm64 Windows. See https://github.com/google/mozc/discussions/1623 for example.

Steps to reproduce

  1. Build foo.dll, foo_arm64.dll and foo_x64.dll by following the documented steps, and put them in the same directory.
  2. From a native Arm64 process whose executable is in a different directory, call:
    HMODULE h = LoadLibraryExW(L"C:\\path\\to\\foo.dll", nullptr, 0);
    FARPROC p = GetProcAddress(h, "MyAPI1");
    
  3. h is non-null, but p is null and GetLastError() returns 127. foo_arm64.dll is never loaded.

Results we observed on Windows 11 Arm64 (build 26300). An emulated x64 process gives the same results against foo_x64.dll.

LoadLibraryExW flags Result
0 fails (127)
LOAD_LIBRARY_SEARCH_SYSTEM32 fails (127)
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS fails (127)
LOAD_WITH_ALTERED_SEARCH_PATH OK

The same behavior reproduces with a plain x64 pure forwarder on x64 Windows, so it is a property of forwarded exports in general rather than of Arm64X.

Workaround and a toolchain gap

Linking the forwarder with /DEPENDENTLOADFLAG:0x100 (LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) makes the loader resolve forwarded exports from the forwarder's directory, regardless of the flags used to load the forwarder.

For an Arm64X pure forwarder, though, MSVC link.exe (14.51.36231, Visual Studio 2026) writes DependentLoadFlags only to the load config of the Arm64 view. The x64 (Arm64EC) view keeps 0. With the command below, Arm64 processes succeed with all four flags in the table above, but emulated x64 processes still fail with 0.

link /dll /noentry /machine:arm64x /dependentloadflag:0x100 /defArm64Native:foo_arm64.def /def:foo_x64.def empty_arm64.obj empty_x64.obj /out:foo.dll foo_arm64.lib foo_x64.lib

lld-link (20.1.1 and 23.1.5) sets the flag in both views, and with it both Arm64 and emulated x64 processes succeed with all four flags.

Suggested changes

  • Recommend /DEPENDENTLOADFLAG:0x100 for pure forwarders that may be loaded by a host the developer does not control, such as COM in-proc servers.
    • Mention that the flag also needs to reach the x64 view's load config. Alternatively, clarify whether MSVC link.exe is expected to apply /DEPENDENTLOADFLAG to both views of an Arm64X image.
  • (optional) Document that the forwarder and its target DLLs should normally be in the same directory, and that the target can be found only if the forwarder is loaded with LOAD_WITH_ALTERED_SEARCH_PATH / LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, or if the forwarder is linked with /DEPENDENTLOADFLAG:0x100.
  • (optional) Correct the sentence quoted above: the target DLL is resolved by bare name through the DLL search order when an export is looked up, not loaded "in place" of the forwarder.
Dominant language
C#
Stars
824
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MicrosoftDocs/windows-dev-docs

All issues in MicrosoftDocs/windows-dev-docs

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.