"Building an Arm64X pure forwarder DLL": Consider recommending `/DEPENDENTLOADFLAG:0x100`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp
- Lĩnh vực
- documentation
Hướng nghiên cứu
Bắt đầu với landing/arm-docs/arm64x-build.md và đọc phần “Building an Arm64X pure forwarder DLL”. Kiểm tra tài liệu được liên kết về /DEPENDENTLOADFLAG và hành vi tải Arm64 và x64 đã được báo cáo, sau đó cập nhật hướng dẫn để giải thích khi nào cần cờ này và cách áp dụng cờ cho cả hai chế độ xem. Hoàn tất khi hành vi tải được tài liệu hóa và khuyến nghị giải quyết các trường hợp đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 loadsfoo_arm64.dllin its place and any API calls are handled byfoo_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
- Build
foo.dll,foo_arm64.dllandfoo_x64.dllby following the documented steps, and put them in the same directory. - 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"); his non-null, butpis null andGetLastError()returns 127.foo_arm64.dllis 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:0x100for 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.exeis expected to apply/DEPENDENTLOADFLAGto both views of an Arm64X image.
- Mention that the flag also needs to reach the x64 view's load config. Alternatively, clarify whether MSVC
- (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.
- Ngôn ngữ chính
- C#
- Star
- 824
- Fork
- 1.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MicrosoftDocs/windows-dev-docs
-
Pri3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
MicrosoftDocs/windows-dev-docs#6204 ·
-
no activa windows 10Đang mởPri3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
MicrosoftDocs/windows-dev-docs#6202 ·
-
PawlauxeSalesRecordingĐang mởPri3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 22/100
MicrosoftDocs/windows-dev-docs#6200 ·
-
Document offline Debugging Tools installation and the x64 CDB package for Windows SDK 10.0.26100.9457Có thể đã có người làm @hamza-usmani đã nhận 8 ngày trước. Đang mởPri3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 58/100
MicrosoftDocs/windows-dev-docs#6196 · 2 người được giao ·
Tất cả issue của MicrosoftDocs/windows-dev-docs
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/backend type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
umbraco/Umbraco-CMS#24668 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area-ai untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/extensions#7956 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
filiptrivan/spiderly#474 ·
Maintainer thường phản hồi trong vòng 2 ngày