News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

LoadLibrary, GetProcAddress, FreeLibrary

Started by dedndave, November 06, 2015, 05:20:09 AM

Previous topic - Next topic

dedndave

i think this is the code i want to use - no FreeLibrary call until exit
now, to devise a test to see if there's a leak in the event they don't clean-up   :redface:

    INVOKE  GetModuleHandleA,offset __szKernel32
    .if !eax
        INVOKE  LoadLibraryA,offset __szKernel32
        mov     __hKernel32Free,eax
    .endif

    .if eax
        ;get proc addresses, here
    .else
        dec     eax
        ;set proc address pointers to -1, signifying initialized, unsupported
    .endif

TouEnMasm


The GetModuleHandle retrieve the loaded module without the loadlibrary.
The getprocadress work.
You use that at your own risk,because the getprocadress failed if the module is unloaded by the module
using it.
This is shown by a test dll loaded only once.
If there is a poor chance to unload the kernel32.dll,it is not the same for other.
Fa is a musical note to play with CL