Announcement

Collapse
No announcement yet.

DLL.CallFunction() Quesions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DLL.CallFunction() Quesions

    I have the following questions regarding the DLL.CallFunction(), which are not mentioned in the documenttion:
    1. Does Setup Factory take ownership of a string retuned from a dll when using the DLL.CallFunction() and specifying the return type as "DLL_RETURN_TYPE_STRING"?
    2. Is the DLL loaded and then immediately unloaded when called or when does the DLL get unloaded?

    Regarding 1)
    Functions in our C++ DLL returns results in the form of a dynamically created "char*". Now the question is, who need to take responsibility for the memory allocated that is returned.
    Does Setup Factory take ownership or is the responsibility of the DLL to keep track of the data and free it?
    I accept that a memory leak is not really a problem since the memory will be cleaned up during the unload, but a 'double free' or 'reference after free' will be an issue if SetupFactory takes ownership.

    Regarding 2)
    For some reason our DLL does not get unloaded and after the install completes we still have a process called irsetup.exe in the task manager. We can see that the dll was not deleted and the irsetup.exe has a handle open to the DLL. We are suspecting an issue in our dll but just want to ensure that we are not doing anything wrong.

  • #2
    I asked the people how Setup Factory works, here is what I received back:

    Everything is passed by value, not reference. We call the function in the DLL and return. It is not kept around. The DLL must release all memory and other resources before returning. If not, there will be application corruption. So, the user should not be passing back a return value by reference.
    I hope this helps.

    Ulrich

    Comment


    • #3
      Hi Ulrich,

      Do you have any information on Question 2, when does the DLL get unloaded?

      We solved the issue with irsetup.exe not releasing the DLL handle.

      The problem we have now is that we have a DLL as a primer file.
      Setup Factory calls functions in the DLL using DLL.CallFunction()
      Now in the install log we see ERROR: Delete primer file: ....*.dll (5)

      Can this be a sequence/timing issue that the DLL is not unloaded by Setup Factory and then the script tries to delete the DLL before it is unloaded?

      Comment


      • #4
        I Removed the "Delete On Exit" flag for these primer files and added the following to the "On Shutdown" Action and the dlls are removed without issue:
        Code:
        File.Delete( SessionVar.Expand("%TempLaunchFolder%").."\\<dllname>.dll" );

        Comment


        • #5
          It seems like the "On Shutdown" is not a complete solution.
          If the user exits the installer at any time during the install by pressings "Cancel" button the "On Shutdown" action is not execution and the files are left behind.

          I also doubt that deleting the files on each "On Cancel" action for every screen will not be possible since it depends again on when the DLL is unloaded.

          Comment


          • #6
            The DLL is unloaded immediately after DLL.CallFunction() finishes. I just tested this with one of my DLLs, where I was able to call a function successfully, and then deleted the DLL from the temporary folder (...AppData\Local\Temp\_ir_sf_temp_0) while the Setup Factory runtime was still running. The file was not locked, in use, etc.

            Ulrich

            Comment

            Working...
            X