“The specified procedure could not be found” error

2019-04-16 07:34发布

We have a dll that has been running fine on Vista and Win7 for a while, but when running on XP we get the error "The specified procedure could not be found" when LoadLibrary() is called to load it.

I've tried running it through Dependency Walker with the Profile option, with Global Flags set to show loader snaps and the only seemingly useful information I can get out of it is:

LDR: Snapping imports for MyDll.dll from KERNEL32.dll
LDR: LdrGetProcedureAddress by NAME - RtlGetLastWin32Error
LDR: exception c0000139 thrown within function LdrpSnapIAT
Exception record: 0012E490
Context record: 0012E4A4
Context->Eip = 7C9673BE
Context->Ebp = 0012E7C0
Context->Esp = 0012E770
LDR: LdrpSnapIAT - caught exception c0000139 snapping thunks (#2)
LDR: LdrpWalkImportTable - LdrpSnapIAT #2 failed with status c0000139

I believe that exception c0000139 is 'Entry Point Not Found'.

We've taken care to ensure that there aren't any direct dependencies on post-XP APIs (there are a few, but these are dynamically loaded with LoadLibrary()). The dll was built with WINVER and _WIN32_WINNT set to 0x0501. The entry point of the library is visible in the exports shown in Dependency Monitor, and there are no obvious missing dependencies. The same application runs absolutely fine in Vista and Win7. An earlier version of the dll worked fine on XP (due to the nature of this component it's difficult to see which change caused things to break).

Edit: other things I think I've discounted:

  • Visual studio runtimes are installed
  • The manifest files from a working dll and one that doesn't are the same

Is there anything else obvious I'm missing?

标签: c windows dll
1条回答
唯我独甜
2楼-- · 2019-04-16 08:24

I've no idea if this will help you but I had the exact same issue today with loader snaps. It turned out that my problem was visible in depends.exe but I didn't know the significance of dlls being pink... I've only ever diagnosed export issues with depends, not import issues.

My issue was that I was using "RegGetValue" which is only available on Vista+. Unfortunately there's no proper error reporting if you use a Vista only API on Windows XP. Depends showed this in the import section like so:

enter image description here

I notice that your issue was with Kernel32.dll rather than Advapi.dll so check the imports with depends...

查看更多
登录 后发表回答