Skip to content

Instantly share code, notes, and snippets.

@alastorid
Created December 10, 2024 19:06
Show Gist options
  • Save alastorid/73d37505c7875055d67ac684138a8dae to your computer and use it in GitHub Desktop.
Save alastorid/73d37505c7875055d67ac684138a8dae to your computer and use it in GitHub Desktop.
api-ms-win-core-file-l1-2-2.dll is not found... WTF?

What is api-ms-XXX

A stub dll acts as a pointer to the actual dll that does the work.

Without the stub:
  Your program: I need ReadConsoleW from kernel32.dll
  kernel32.dll: I'm here.
Your program works.
-------
With the stub:
  Your program: I need ReadConsoleW from ...no, from api-ms-bla-blabla...
  OS: Too bad, not found. Maybe it's too old or something.
  Your program: Nothing found, I'm out.
Your program breaks.

How to make broken program work again?

Go fix the import table of your broken program. You'll need:

  1. CFF Explorer VIII - To view and edit import table. Edit the import dll name from api-xxx-xxx.dll to the one actually contains the functions to be imported.
  2. ripgrep - To that one. For example: kernel32.dll for ReadConsoleW
  3. Dependency Walker - Shows what's missing

Note:

  1. Backup everything.
  2. At your own risk.

Tip:

ripgrep

 rg -uuu --glob '\*.dll' GetTempFileNameA

I fixed my issue by changing api-ms-win-core-file-l1-2-2.dll to kernel32.dll in import table. Use ripgrep to find the right DLL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment