How to make sure the function DLLPROC is called when your DLL is unloaded.

By: Kendall Sullivan

Abstract: This code change will ensure that DLLPROC is called when your DLL is unloaded.


Why isn't DLLPROC being called when my DLL is unloaded?


Due to RTL changes, the DLLProc was not being called appropriately. This change will fix the change that you may have noticed. Once you have completed the change, you will need to recompile the RTL and copy the new System.dcu into your project directory. Your project will use the newly created System.dcu with the fix included. In System.pas, navigate down to this method @@skipTLSproc.


        { Call any DllProc }

        PUSH    ECX
        MOV     ECX,[ESP+8]//Changed from 4 to 8.
        TEST    ECX,ECX
        JE      @@noDllProc
        MOV     EAX,[EBP+12]
        MOV     EDX,[EBP+16]
        CALL    ECX

Server Response from: ETNASC03