Browse Source

Fixed issue where updating with a backup would fail to update the fackup and prevent IPA from loading

pull/46/head
Anairkoen Schno 6 years ago
parent
commit
cf56d96239
2 changed files with 17 additions and 3 deletions
  1. +2
    -0
      IPA.Injector/Backups/BackupUnit.cs
  2. +15
    -3
      IPA.Injector/Injector.cs

+ 2
- 0
IPA.Injector/Backups/BackupUnit.cs View File

@ -79,6 +79,8 @@ namespace IPA.Injector.Backups
backupPath.Directory.Create();
if (file.Exists)
{
if (File.Exists(backupPath.FullName))
File.Delete(backupPath.FullName);
file.CopyTo(backupPath.FullName);
}
else


+ 15
- 3
IPA.Injector/Injector.cs View File

@ -102,10 +102,22 @@ namespace IPA.Injector
for (int i = 0; i < Math.Min(2, cctor.Body.Instructions.Count); i++)
{
var ins = cctor.Body.Instructions[i];
if (i == 0 && (ins.OpCode != OpCodes.Call || ins.Operand != cbs))
if (i == 0)
{
ilp.Replace(ins, ilp.Create(OpCodes.Call, cbs));
modified = true;
if (ins.OpCode != OpCodes.Call)
{
ilp.Replace(ins, ilp.Create(OpCodes.Call, cbs));
modified = true;
}
else
{
var mref = ins.Operand as MethodReference;
if (mref.FullName != cbs.FullName)
{
ilp.Replace(ins, ilp.Create(OpCodes.Call, cbs));
modified = true;
}
}
}
if (i == 1 && ins.OpCode != OpCodes.Ret)
{


Loading…
Cancel
Save