Browse Source

Updated patcher to optionally update reference instead of replacing it and hoping for the best (which wasn't working)

Fix for #2
piracy-check 3.9.1
Anairkoen Schno 6 years ago
parent
commit
87a84d5163
1 changed files with 25 additions and 13 deletions
  1. +25
    -13
      IPA/Patcher/Patcher.cs

+ 25
- 13
IPA/Patcher/Patcher.cs View File

@ -62,10 +62,11 @@ namespace IPA.Patcher
public void Patch(Version v)
{
// First, let's add the reference
var nameReference = new AssemblyNameReference("IPA.Injector", Program.Version);
var nameReference = new AssemblyNameReference("IPA.Injector", v);
var injectorPath = Path.Combine(_File.DirectoryName, "IPA.Injector.dll");
var injector = ModuleDefinition.ReadModule(injectorPath);
bool hasIPAInjector = false;
for (int i = 0; i < _Module.AssemblyReferences.Count; i++)
{
if (_Module.AssemblyReferences[i].Name == "IllusionInjector")
@ -73,26 +74,37 @@ namespace IPA.Patcher
if (_Module.AssemblyReferences[i].Name == "IllusionPlugin")
_Module.AssemblyReferences.RemoveAt(i--);
if (_Module.AssemblyReferences[i].Name == "IPA.Injector")
_Module.AssemblyReferences.RemoveAt(i--);
{
hasIPAInjector = true;
_Module.AssemblyReferences[i].Version = v;
}
}
_Module.AssemblyReferences.Add(nameReference);
int patched = 0;
foreach(var type in FindEntryTypes())
if (!hasIPAInjector)
{
if(PatchType(type, injector))
_Module.AssemblyReferences.Add(nameReference);
int patched = 0;
foreach (var type in FindEntryTypes())
{
if (PatchType(type, injector))
{
patched++;
}
}
if (patched > 0)
{
_Module.Write(_File.FullName);
}
else
{
patched++;
throw new Exception("Could not find any entry type!");
}
}
if(patched > 0)
else
{
_Module.Write(_File.FullName);
} else
{
throw new Exception("Could not find any entry type!");
}
}


Loading…
Cancel
Save