lucasg / Dependencies

A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues.
MIT License
9.05k stars 740 forks source link

Suggestions - path not found - use the windows search path algorithm #166

Open mediabuff opened 3 years ago

mediabuff commented 3 years ago

Suggest to use the windows search path algorithm to determine the depend DLLs. In the example below the dependent DLL (cpprestxx.dll) is in the same working directory as the chosen DLL (videodata.dll)

Or provide a mechanism to select or set the search path/directory.

image

akela1101 commented 3 years ago

Also, please check the following:

set PATH=c:\my_path;%PATH%
DependenciesGui.exe

In this case c:\my_path is not used in dll search, and so I see dlls not found.

But if I run my application from the same terminal, it can run. (without set PATH it did not)

lucasg commented 3 years ago

you can add folder to search in "Options/Customize Folders".

Example with C:\Windows\System32\ntoskrnl.exe :

image

Adding C:\Windows\System32\drivers as a valid folder :

image

Result :

image

All kext resolved to *.sys files have been correctly found

akela1101 commented 3 years ago

Thanks, I noticed that option, but was too lazy to enter around 10 additional paths I had from ROS.

Would be nice if both app path and current PATH were used automatically.

lucasg commented 3 years ago

hmm, weird I actually tried to look into PATH env var :

// 7. Find in PATH
string PATH = Environment.GetEnvironmentVariable("PATH");
List<String> PATHFolders = new List<string>(PATH.Split(';'));

// Filter out empty paths, since it resolve to the current working directory
// fix https://github.com/lucasg/Dependencies/issues/51
PATHFolders = PATHFolders.Where(path => path.Length != 0).ToList();

FoundPePath = FindPeFromPath(ModuleName, PATHFolders, ProcessorArch);

I'll look into it

jtwine commented 1 year ago

Using just the value of %PATH% in the incorrect order may not be the best way to do it. It might be better to follow the existing, established DLL search algorithm so that the same DLLs will be found in the same order as when the target application is launched normally.

This algorithm is documented here.

Peace!

-=- James.