I've changed GetModuleHandle to LoadLibrary because when I compiled only tests/rebar.c as standalone, the comctl32 wasn't loaded and GetModuleHandle returned NULL. Are there advantages from using GetModuleHandle?
Mikołaj Zalewski
Mikołaj Zalewski wrote:
I've changed GetModuleHandle to LoadLibrary because when I compiled only tests/rebar.c as standalone, the comctl32 wasn't loaded and GetModuleHandle returned NULL. Are there advantages from using GetModuleHandle?
Mikołaj Zalewski
Well, I was checking whether LoadLibrary was accompanied by a FreeLibrary. In this case it wasn't and I thought GetModuleHandle does the trick as well. It did for the other stuff in the comctl32 tests.
I'm not in favor of LoadLibrary or GetModuleHandle. I think the general rule could be:
If dll is already imported use GetModuleHandle unless compilation excludes the dll because there are no reference to the dll.
Does that look a bit sane?
The question that remains is should the full <dll>-tests be able to be compiled and run or should we have this to be correct for every single test? I mean that are no issues if you compile the whole comctl32 "testsuite".
If LoadLibrary is indeed needed it should be accompanied with a FreeLibrary and we probably need a comment for the why as well.
If LoadLibrary is indeed needed it should be accompanied with a FreeLibrary and we probably need a comment for the why as well.
Does it matter if we call FreeLibrary on the library we are testing? I don't think we will be able to free it before the end of the tests when anyhow it will be unloaded by the process shutdown. But maybe I should care more about elegant code?
Mikolaj Zalewski
Mikołaj Zalewski wrote:
If LoadLibrary is indeed needed it should be accompanied with a FreeLibrary and we probably need a comment for the why as well.
Does it matter if we call FreeLibrary on the library we are testing? I don't think we will be able to free it before the end of the tests when anyhow it will be unloaded by the process shutdown. But maybe I should care more about elegant code?
Mikolaj Zalewski
Yeah, I wrote 'should' but it has more to do with style I guess. The same is true for HeapFree of course but I do think we should make the code as good/correct as possible.
Paul Vriens paul.vriens.wine@gmail.com writes:
The question that remains is should the full <dll>-tests be able to be compiled and run or should we have this to be correct for every single test? I mean that are no issues if you compile the whole comctl32 "testsuite".
It's a good idea to keep each C file as stand-alone as possible, so that it's possible to copy it over to Windows and quickly build a test exe without needing extra infrastructure.