Skip to content

Commit eb5fd5d

Browse files
committed
Improve mm patch dll resolving
1 parent 52cc2bf commit eb5fd5d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -355,4 +355,6 @@ MigrationBackup/
355355
.idea
356356

357357
OTAPI.Client.Launcher/OTAPI.app/
358-
server/
358+
server/
359+
dependencies/
360+
terraria-server-*

OTAPI.Patcher/Targets/PatchTargets.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19+
using Mono.Cecil;
20+
using Mono.Cecil.Cil;
1921
using System;
2022
using System.Collections.Generic;
2123
using System.IO;
2224
using System.Linq;
2325
using System.Runtime.InteropServices;
24-
using Mono.Cecil;
25-
using Mono.Cecil.Cil;
2626

2727
namespace OTAPI.Patcher.Targets;
2828

@@ -47,7 +47,7 @@ public static IPatchTarget DeterminePatchTarget()
4747
if (!String.IsNullOrWhiteSpace(cli) && _targets.TryGetValue(cli[0], out IPatchTarget? match))
4848
return match;
4949

50-
if(Console.IsInputRedirected)
50+
if (Console.IsInputRedirected)
5151
return new PCServerTarget();
5252

5353
int attempts = 5;
@@ -82,7 +82,8 @@ public static IPatchTarget DeterminePatchTarget()
8282
/// </summary>
8383
public static void PatchMonoMod()
8484
{
85-
var bin = File.ReadAllBytes("MonoMod.dll");
85+
var dllPath = Path.Combine(AppContext.BaseDirectory, "MonoMod.dll");
86+
var bin = File.ReadAllBytes(dllPath);
8687
using MemoryStream ms = new(bin);
8788
var asm = AssemblyDefinition.ReadAssembly(ms);
8889
var modder = asm.MainModule.Types.Single(x => x.FullName == "MonoMod.MonoModder");
@@ -114,7 +115,7 @@ public static void PatchMonoMod()
114115
OpCodes.Ldc_I4, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 37 : 0
115116
));
116117

117-
asm.Write("MonoMod.dll");
118+
asm.Write(dllPath);
118119
}
119120
}
120121
}

0 commit comments

Comments
 (0)