Page MenuHomeFeedback Tracker

Game does cannot load multiple DLLs in single extension addon, leading to crash
Closed, ResolvedPublic

Description

The callExtension scripting command allows mod makers to call a method in an external DLL.

However, if that DLL itself has a dependency on another DLL, the game does correctly search for it within the current path.

{F18190}

Details

Legacy ID
4240842368
Severity
Crash
Resolution
Open
Reproducibility
Always
Category
Modding
Steps To Reproduce

Extract both dlls from the attached archive into

   ...\Documents\Arma 3 Alpha\Arma3TestExtension1

Start arma3 using "-mod=Arma3TestExtension1"

Create a new mission in the editor and in init.sqf place the command

   "Arma3TestExtension1" callExtension "an arbitrary command string";

You should see the game crash

Additional Information

It's clear from the output of ProcMon (edited) that the current path is not being searched. Instead the dependency is assumed to live in its own folder in the main game installation folder...

16:46:27.7771128 arma3.exe 10892 Load Image D:\Users\user\Documents\Arma 3 Alpha\Arma3TestExtension1\Arma3TestExtension1.dll SUCCESS Image Base: 0x16440000, Image Size: 0xb000
...
16:46:27.8619788 arma3.exe 10892 QueryOpen D:\Program Files (x86)\Steam\steamapps\common\Arma 3\netStuff.dll NAME NOT FOUND
16:46:27.8620583 arma3.exe 10892 QueryOpen D:\Program Files (x86)\Steam\steamapps\common\Arma 3\netstuff\netStuff.dll NAME NOT FOUND
16:46:27.8621299 arma3.exe 10892 QueryOpen D:\Program Files (x86)\Steam\steamapps\common\Arma 3\netStuff.exe NAME NOT FOUND
16:46:27.8622006 arma3.exe 10892 QueryOpen D:\Program Files (x86)\Steam\steamapps\common\Arma 3\netstuff\netStuff.exe NAME NOT FOUND

Event Timeline

sbsmac edited Steps To Reproduce. (Show Details)Mar 17 2013, 5:50 PM
sbsmac edited Additional Information. (Show Details)
sbsmac set Category to Modding.
sbsmac set Reproducibility to Always.
sbsmac set Severity to Crash.
sbsmac set Resolution to Open.
sbsmac set Legacy ID to 4240842368.May 7 2016, 12:49 PM
MaHuJa added a subscriber: MaHuJa.May 7 2016, 12:49 PM

Workarounds

  1. Static compilation. This isn't always feasible, but it sure makes it simple when it is.
  1. Make sure the dependencies are delay loaded, call a win32 function that allows you to set a dll search path (it gets searched before the normal ones) before you immediately call something from each dll. (other things could set that dll search path elsewhere later)

I believe you can find the path of your dll from other win32 functions using the hmodule passed into the winmain.

  1. Put the dependencies in the main arma 3 directory; this obviously won't happen automatically with most installers.
dedmen added a subscriber: dedmen.May 7 2016, 12:49 PM

Not BIs fault.. Thats just the behaviour of windows LoadLibrary (I suppose Linux does the same)
But LoadLibrary is searching in the working directory for files to load so if you change the working directory as soon as your dll gets attached (Not sure if thats possible) LoadLibrary will find your dependencys.

Also if a DLL dependency cannot be loaded LoadLibrary fails to load your extension. It shouldn't crash. Didn't try to reproduce.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686203(v=vs.85).aspx

dedmen closed this task as Resolved.May 18 2020, 11:13 AM