Good day to All.
Internet searches reveal that the fine folks in this forum have attempted to answer the question before, as well as to probe as to the questioner’s purpose/intentions. I don’t know why the questioners didn’t respond.
I am interested in kernel-mode LoadLibrary() and GetProcAddress() counterparts because I’d like to compile my driver into just two build types: x86 and x64 (maybe IA-64 as a third).
I’d like to aim for linking against, let’s say, Windows 2000, but to activate certain additional features if I detect a newer OS. This way, the same binary “works” for all OS versions with the same architecture; it’d just have a more limited feature-set where dependencies could not be satisfied.
A specific example (but only an example) would be the absence of PsDereferencePrimaryToken() from Windows 2000. I could have #if-#endif spaghetti and lots of different builds, or I could have a wrapper check for availability at run-time and memoize the result, with a single build.
Similarly, I could audit my driver’s code for functions which deprecate with newer OS versions and wrap them appropriately… It’d be nice to be able to determine, “it’s so deprecated that it’s not even exported with this kernel version,” for instance.
Is this a silly approach? Has anyone some nice open source code that could help, or some code samples as tips? I’d read about hand-coding PE image routines, but wouldn’t like to re-invent any wheels.
Thank you for your attention.