What exactly means ERROR_INVALID_ORDINAL?

巧了我就是萌 提交于 2019-12-22 08:06:41

问题


The LoadLibrary function is returning to me the error code 182. From MSDN:

ERROR_INVALID_ORDINAL: "The operating system cannot run %1"

Does anyone have a better description of what this error is?


回答1:


Very obscure error. The term "ordinal" is however strongly associated with a DLL. A DLL contains a list of exported functions as well as a list of imported functions. Other DLLs that it has a dependency on. These exports and imports usually have a name, but that's not required. They always have a number, the number is the "ordinal".

To start diagnosing this, use the SDK's Dumpbin.exe tool. Run this first:

Dumpbin /exports Blah.dll

and look at the list of exports. You should see the ordinal as well as the name. If that all checks out, run

Dumpbin /imports Blah.dll

to get a list of the dependencies. Odds are good that it has a dependency on a function in another DLL by number that this DLL doesn't have. Something like that anyway. You can probably make it less laborious by using the DependencyWalker tool. If the first step fails then something went drastically wrong when the DLL was built. If the second step fails then you're probably looking at some kind of DLL Hell problem.




回答2:


Are you sure that this error is coming from LoadLibrary? Windows DLLs allow you to specify exports by name and ordinal value. That is, each function can be identified by a number. If you call GetProcAddress and specify an invalid ordinal, then you'll get this error.

My best guess is that the DLL that you're loading is calling GetProcAddress in its DllMain and specifying an invalid ordinal. This causes it to fail, and when you call GetLastError, you get ERROR_INVALID_ORDINAL since that's the last error that occurred.



来源:https://stackoverflow.com/questions/3497301/what-exactly-means-error-invalid-ordinal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!