Call DLLfunction from DLL in app Folder

50 views
Skip to first unread message

Grey Serg

unread,
May 31, 2022, 7:39:04 AM5/31/22
to innosetup
Hello
I want to call dll function from dll, which
 should lie in app folder (temporary folder
not suitable).
When I write
procedure MyDllFuncSetup(hWnd: Integer; lpText, lpCaption: AnsiString; uType: Cardinal);
external 'MyDllFunc@{app}\MyDll.dll stdcall';
On start I got error "An attempt was made to expand the app constant  before it was initialized".

'files:' prefix is not suitable, because It call function in dll in temporary folder, and my function failed (dll must lie in app folder).

How can I call function from dll in my app folder ?

 

Grey Serg

unread,
May 31, 2022, 10:53:00 AM5/31/22
to innosetup
Sorry, 'files:' prefix is now suitable.
I figured out that my function need system dll, which it search only in SysWow64 folder (with help of Process monitor from Sysinternals), nowhere else.
My old installer (not inno setup) search this system dll (when I called function from mydll) not only in SysWow64 folder, but first in folder where setup.exe located.
Why Is Inno Setup search dependent DLLs only in SysWow64 folder ?

вторник, 31 мая 2022 г. в 14:39:04 UTC+3, Grey Serg:

Gavin Lambert

unread,
May 31, 2022, 7:03:51 PM5/31/22
to inno...@googlegroups.com
On 31/05/2022 23:39, Grey Serg wrote:
> I want to call dll function from dll, which
>  should lie in app folder (temporary folder
> not suitable).
> When I write
> /procedure MyDllFuncSetup(hWnd: Integer; lpText, lpCaption: AnsiString;
> uType: Cardinal);
> external 'MyDllFunc@{app}\MyDll.dll stdcall';/
> On start I got error "/An attempt was made to expand the app constant
> before it was initialized/".
>
> '/files:/' prefix is not suitable, because It call function in dll in
> temporary folder, and my function failed (dll must lie in app folder).

Add the 'delayload' tag after 'stdcall', and avoid calling the function
until after [Files] are installed.

Gavin Lambert

unread,
May 31, 2022, 8:49:44 PM5/31/22
to inno...@googlegroups.com
On 1/06/2022 02:53, Grey Serg wrote:
> Sorry, '/files:/' prefix is now suitable.
> I figured out that my function need system dll, which it search only in
> SysWow64 folder (with help of Process monitor from Sysinternals),
> nowhere else.
> My old installer (not inno setup) search this system dll (when I called
> function from mydll) not only in SysWow64 folder, but first in folder
> where setup.exe located.
> Why Is Inno Setup search dependent DLLs only in SysWow64 folder ?

Because it's a huge security risk to load DLLs from the location of the
setup.exe -- that's frequently a "Downloads" or temp folder that can
contain untrustworthy files, which might include malware DLLs hoping to
get loaded accidentally.

And Inno is a 32-bit app, so it will only search 32-bit DLL search paths
(regardless of installation mode).

https://jrsoftware.org/ishelp/topic_scriptdll.htm
Reply all
Reply to author
Forward
0 new messages