Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Added --dll wildcard support for --mode proxy --action exports
Browse files Browse the repository at this point in the history
  • Loading branch information
sadreck committed Jul 16, 2023
1 parent 0c88de0 commit 0b01448
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions Spartacus/Modes/PROXY/ExportsGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Spartacus.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down
14 changes: 14 additions & 0 deletions Spartacus/Modes/PROXY/ModeProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ protected void SanitiseExportsGenerationRuntimeData()
}
else
{
// Export DLLs support wildcard paths, so you can add --dll "C:\Windows\System32\*.dll" and it will load all those DLLs.
List<string> wildcardPaths = RuntimeData.BatchDLLFiles.Where(dll => dll.ToLower().Contains("*.dll")).ToList();
foreach (string wildcardPath in wildcardPaths)
{
// First we remove the found path from the list.
RuntimeData.BatchDLLFiles.Remove(wildcardPath);
string dllPath = Path.GetDirectoryName(wildcardPath);

// Then we append the new results to the list.
RuntimeData.BatchDLLFiles.AddRange(Directory.EnumerateFiles(dllPath, "*.dll").ToList());

RuntimeData.BatchDLLFiles = RuntimeData.BatchDLLFiles.Distinct().ToList();
}

foreach (string dllFile in RuntimeData.BatchDLLFiles)
{
if (!File.Exists(dllFile))
Expand Down
3 changes: 2 additions & 1 deletion Spartacus/Utils/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public List<FileExport> GetExportFunctions(string DLL)
}
catch (Exception ex)
{
// Nothing.
Logger.Error("Could not get exports for file: " + DLL);
Logger.Error(ex.Message);
}

return exports;
Expand Down
4 changes: 2 additions & 2 deletions Spartacus/Utils/PEFileExports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ public List<FileExport> Extract(string dllFile)
}
finally
{
reader.Close();
stream.Close();
reader?.Close();
stream?.Close();
}
}

Expand Down

0 comments on commit 0b01448

Please sign in to comment.