Skip to content

Commit

Permalink
Fixed Executable Handler using file name to get executable data
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkhist committed Apr 9, 2017
1 parent 9a67762 commit ac93d10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 2 additions & 4 deletions Pathfinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,10 @@
<Compile Include="Pathfinder\Daemon\Instance.cs" />
<Compile Include="Pathfinder\Daemon\Interface.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Pathfinder\Executable\" />
<Folder Include="Pathfinder\Command\" />
<Folder Include="Pathfinder\Daemon\" />
<Folder Include="Pathfinder\Computer\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
Expand Down
12 changes: 7 additions & 5 deletions Pathfinder/Executable/Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ public static bool AddExecutable(string exeName, Interface inter)

internal static void ExecutableListener(ExecutableExecuteEvent e)
{
Interface i;
if (interfaces.TryGetValue(e.ExecutableName, out i)
&& e.ExecutableData.Equals(i.FileData))
foreach(Interface i in interfaces.Values)
{
e.OsInstance.addExe(new Instance(e.Location, e.OsInstance, e.Parameters, i));
e.IsCancelled = true;
if (e.ExecutableData.Equals(i.FileData))
{
e.OsInstance.addExe(new Instance(e.Location, e.OsInstance, e.Parameters, i));
e.IsCancelled = true;
break;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions PathfinderPatcher/Pathfinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ internal static void Main(string[] args)
flags: InjectFlags.PassInvokingInstance | InjectFlags.ModifyReturn
);

// SENSIBLE CODE, CHANGE OFFSET IF NEEDED
ad.MainModule.GetType("Hacknet.OS").GetMethod("launchExecutable").InjectWith(
hooks.GetMethod("onExecutableExecute"),
48,
flags: InjectFlags.PassInvokingInstance | InjectFlags.PassParametersRef | InjectFlags.ModifyReturn | InjectFlags.PassLocals,
localsID: new int[] { 2 }
);

// SENSIBLE CODE, CHANGE OFFSET IF NEEDED
var mainMenu = ad.MainModule.GetType("Hacknet.MainMenu");
mainMenu.GetMethod("DrawBackgroundAndTitle").InjectWith(
hooks.GetMethod("onDrawMainMenuTitles"),
Expand Down

0 comments on commit ac93d10

Please sign in to comment.