Hello everyone,
1. Generally speaking using GetProcAddress through ordinal is faster than through name, right?
2. Why?
thanks in advance,
George
Hello everyone,
1. Generally speaking using GetProcAddress through ordinal is faster than through name, right?
2. Why?
thanks in advance,
George
Probably because using the ordinal number eliminates an intermediate step of doing a binary search on the names table.
For instance, using a function name, a binary search of the sorted names table would be done until it found the function name. Let's assume that the function name is the 4th entry in the names table. Now we have to read the 4th entry value from our ordinal table which is our ordinal value. Next, the ordinal value is used as an index into the address table to find the relative virtual address of the function which has to be converted to the actual address.
Now contrast this to using an ordinal number which would only require going directly to the address table. Thus eliminating the binary search.
But you (hopefully) only do this ONCE per function in the early part of the program - so it's unlikely that you will see any difference in the execution time of a real application.
If you have hundreds or thousands of DLL references that you look up by name or ordinal, then you are probably doing something wrong, particularly if you have to do it over and over again.
If that is really what you are worried about, then perhaps working out a way to have a single entry point that returns a struct/array of function pointers is the right way to do things. (Or, if it's C++, return a pointer to a class).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.