DynamoRIO / DynamoRIO/dynamorio
CRASH "library initializer failed" on Windows SDK 10.0.26100.0
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 30
Description
**Describe the bug**
On Windows, when compiled with Windows SDK **10.0.26100.0**, clients would crash with "library initializer failed". This occurred on multiple clients, including the "empty" sample client. This does not occur when compiled with older SDKs.
**To Reproduce**
Steps to reproduce the behavior:
1. Install Visual Studio 2022 with Windows SDK 10.0.26100.0
2. Create a CMake project.
3. Set the following values in `CMakePresets.json`:
```
{
"configurePresets": [
{
...
"generator": "Visual Studio 17 2022",
"cacheVariables": {
"DynamoRIO_DIR": ,
"CMAKE_GENERATOR_PLATFORM": "version=10.0.26100.0",
...
},
...
```
5. Write a simple client for the project.
6. Build the project.
7. Test the output DLL with `drrun.exe`
Please also answer these questions:
- What happens when you run without any client?
- No error.
- What happens when you run with debug build ("-debug" flag to drrun/drconfig/drinject)?
- Crashed with "library initializer failed"
**Screenshots or Pasted Text**
Command prompt output of injecting a simple client into `tasklist`:
```
>
\myclient.dll;0;' -client_lib64 '\myclient.dll;0;' -code_api -probe_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
```
Excerpts from log 0:
```
privload_call_entry for myclient.dll: reason=1 ASYNCH intercepted exception in thread 15100 at pc 0x00000000150ffec7 SYSLOG_ERROR: Application C:\Windows\system32\tasklist.exe (42524). Unable to load client library: myclient.dll: library initializer failed..
```
Excerpts from the app log:
```
loader_init_epilogue: calling entry points for myclient.dll privload_call_entry: calling myclient.dll entry 0x00007ff5b4fa1460 for 1 redirect_LoadLibraryW: api-ms-win-core-synch-l1-2-0 privload_map_name: mapped API-set dll api-ms-win-core-synch-l1-2-0.dll to kernelbase.dll redirect_GetProcAddress: 0x000001fb00140000InitializeCriticalSectionEx drwinapi_redirect_getprocaddr: InitializeCriticalSectionEx => 0x0000000015425840 redirect_RtlInitializeCriticalSectionEx: 0x00007ff5b4ff4210 redirect_LoadLibraryW: api-ms-win-core-fibers-l1-1-1 privload_map_name: mapped API-set dll api-ms-win-core-fibers-l1-1-1.dll to kernelbase.dll redirect_GetProcAddress: 0x000001fb00140000FlsAlloc drwinapi_redirect_getprocaddr: FlsAlloc => 0x000000001541fdb0 redirect_GetProcAddress: 0x000001fb00140000FlsSetValue drwinapi_redirect_getprocaddr: FlsSetValue => 0x000000001541ff70 Variable-size block: allocating 0x000001fb1e101fc0 (1040 bytes [1040 aligned] in 1376 block) privload_call_entry: myclient.dll init routine 0x00007ff5b4fa1460 crashed! privload_load_finalize: entry routine failed privload_unload: myclient.dll refcount => 0 privload_unload: unloading myclient.dll @ 0x00007ff5b4fa0000 privload_call_entry for myclient.dll: reason=0 privload_call_entry: calling myclient.dll entry 0x00007ff5b4fa1460 for 0 privload_unload: dynamorio.dll refcount => 1 privload_unload: KERNEL32.dll refcount => 9 in remove_vm_area 0x00007ff5b4fa0000 0x00007ff5b4ffd000 completely removing 0x00007ff5b4fa0000-0x00007ff5b4ffd000 removing dynamo vm area: 0x00007ff5b4fa0000-0x00007ff5b4ffd000 in remove_vm_area 0x00007ff5b4fa0000 0x00007ff5b4ffd000 SYSLOG_ERROR: Application C:\Windows\system32\tasklist.exe (42524). Unable to load client library: myclient.dll: library initializer failed..
```
**Versions**
- What version of DynamoRIO are you using?
- DynamoRIO version 10.93.19965, Windows release
- Does the latest build from https://github.com/DynamoRIO/dynamorio/releases solve the problem?
- No
- What operating system version are you running on? ("Windows 10" is *not* sufficient: give the release number.)
- Windows 11 Home, 23H2
- Is your application 32-bit or 64-bit?
- Tested on both.
Contributor guide
Assessment
This issue has not been assessed yet.