Skip to content

Commit 1721e1a

Browse files
committed
Added: Uninstall Hint to Loader Log
1 parent e9d256b commit 1721e1a

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

source/Reloaded.Mod.Loader.Bootstrapper/EntryPointParameter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
/* For C# source, see EntryPoint.cs */
4-
#define CURRENT_VERSION 7
4+
#define CURRENT_VERSION 8
55

66
enum EntryPointFlags : int
77
{
@@ -19,6 +19,7 @@ struct EntryPointParameters
1919
public:
2020
int version { CURRENT_VERSION };
2121
EntryPointFlags flags { None };
22+
LPWSTR dll_path { nullptr };
2223

2324
EntryPointParameters() = default;
2425
};

source/Reloaded.Mod.Loader.Bootstrapper/dllmain.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ bool load_reloaded(ReloadedPaths& reloadedPaths)
180180
throw std::exception("Failed to load .NET assembly.");
181181
}
182182

183+
// Set path to current dll
184+
// Using GetModuleFileNameW
185+
entryPointParameters.dll_path = new wchar_t[MAX_PATH];
186+
GetModuleFileNameW(thisProcessModule, entryPointParameters.dll_path, MAX_PATH);
183187
initialize(&entryPointParameters, sizeof(EntryPointParameters));
184188
return true;
185189
}

source/Reloaded.Mod.Loader/EntryPoint.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,18 @@ private static unsafe void SetupLoader2(EntryPointParameters* parameters)
9292

9393
var setupHooksTask = Task.Run(() => ExecuteTimed("Setting Up Hooks (Async)", () => SetupHooks(hooks)));
9494
InitialiseParameters(parameters);
95+
if (_parameters.SupportsDllPath && _parameters.DllPath != null)
96+
{
97+
var reloadedPath = Marshal.PtrToStringUni((nint)_parameters.DllPath);
98+
Logger!.LogWriteLineAsync($"Loaded via: {reloadedPath}", Logger.ColorInformation);
99+
if (reloadedPath!.EndsWith(".asi"))
100+
Logger!.LogWriteLineAsync($"Remove the above `.asi` file to uninstall. (Should be in your app/game folder)", Logger.ColorInformation);
101+
}
102+
95103
ExecuteTimed("Loading Mods (Total)", () => LoadMods(hooks));
96104

97105
setupHooksTask.Wait();
98-
Logger?.LogWriteLineAsync($"Total Loader Initialization Time: {_stopWatch.ElapsedMilliseconds}ms");
106+
Logger!.LogWriteLineAsync($"Total Loader Initialization Time: {_stopWatch.ElapsedMilliseconds}ms");
99107
_stopWatch.Reset();
100108
}
101109

source/Reloaded.Mod.Shared/EntryPointParameters.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Also update EntryPointParameter.h in bootstrapper accordingly.
1414
/// <summary>
1515
/// Current version of parameters.
1616
/// </summary>
17-
public const int CurrentVersion = 7;
17+
public const int CurrentVersion = 8;
1818

1919
// Version 1
2020
/// <summary>
@@ -30,6 +30,11 @@ Also update EntryPointParameter.h in bootstrapper accordingly.
3030
// Version 2
3131
// ...
3232

33+
/// <summary>
34+
/// Contains the path to the native DLL which loaded the loader.
35+
/// </summary>
36+
public unsafe char* DllPath;
37+
3338
/// <summary>
3439
/// Checks if struct is using latest version.
3540
/// </summary>
@@ -55,9 +60,19 @@ public static unsafe EntryPointParameters Copy(EntryPointParameters* pointer)
5560
result.Version = pointer->Version;
5661
result.Flags = pointer->Flags;
5762
}
63+
64+
if (pointer->Version >= 8)
65+
{
66+
result.DllPath = pointer->DllPath;
67+
}
5868

5969
return result;
6070
}
71+
72+
/// <summary>
73+
/// True if reading the DLL path is supported.
74+
/// </summary>
75+
public bool SupportsDllPath => Version >= 8;
6176
}
6277

6378
/// <summary>

0 commit comments

Comments
 (0)