Can we hook APis using its Ordinal Number?
If yes then how can we achieve this?
http://msdn.microsoft.com/en-us/library ... 80%29.aspx
How to hook API using its Ordinal Number?
Re: How to hook API using its Ordinal Number?
Good question. I think you should be able to use GetProcAddress() to get the API address and then HookCode().
Re: How to hook API using its Ordinal Number?
Use the MAKEINTRESOURCE macro with the ordinal. ie GetProcAddress(hInstance, MAKEINTRESOURCE(2))
Re: How to hook API using its Ordinal Number?
not really, there are also delay loaded dlls which load after hook dll so at the hook time GetModuleHandle gives 0. As a temporary workaround I put LoadLibrary("target.dll") to make GetProcAddress work but it is actually illegal to call LoadLibrary in DllMain:madshi wrote:Good question. I think you should be able to use GetProcAddress() to get the API address and then HookCode().
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
"The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order. This can result in a DLL being used before the system has executed its initialization code."
So some HookOrdinal (in addition to HookCode and HookAPI) would be really nice!
Re: How to hook API using its Ordinal Number?
problem solved by installing a hook to LoadLibrary and waiting for the target dll being loaded
Re: How to hook API using its Ordinal Number?
I'll put this on my to do list, but it might take a while until I get to implementing it.