Skip to content

Commit

Permalink
Fix Debugger Issues
Browse files Browse the repository at this point in the history
-Detect Steam Stub
-Fix Nekopara vol.3
  • Loading branch information
marcussacana committed Jan 12, 2019
1 parent a26aec2 commit 8495b6c
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions CatSystemDebugger/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ static void Main(string[] args) {
0xC3, 0xD5, 0x8C, 0xD7, 0xB3, 0xDD, 0xF5, 0xF1, 0x8A, 0x77, 0xE2, 0xBD, 0x3F, 0xD2, 0x4F,
0xC9, 0x66, 0x0E, 0xFA };

static readonly byte[] Validation = new byte[] { 0x75, 0x75, 0x8D, 0x4C };
static readonly byte[] Validation = new byte[] { 0x75, 0x75, 0x8D, 0x4C };
static readonly byte[] Validation2 = new byte[] { 0x74, 0x2D, 0x6A, 0x00, 0x68 };
private static void DebugPatch(string EXE, string CFG, string KeyPath) {
File.Move(EXE, EXE + ".bak");
byte[] Executable = File.ReadAllBytes(EXE + ".bak");
Expand All @@ -73,11 +74,16 @@ private static void DebugPatch(string EXE, string CFG, string KeyPath) {
File.WriteAllBytes(KeyPath, DBGKEY);
Log("Debug Key Generated...");

if (!Patch(ref Executable, Validation, new byte[] { 0xEB }, "BYPASS")) {
File.Move(EXE + ".bak", EXE);
File.Delete(EXE + ".tmp");
Log("Failed to Patch, Unsupported Engine Version");
return;
if (!Patch(ref Executable, Validation, new byte[] { 0xEB }, "BYPASS V1")) {
if (!Patch(ref Executable, Validation2, new byte[] { 0xEB }, "BYPASS V2")) {
File.Move(EXE + ".bak", EXE);
File.Delete(EXE + ".tmp");
if (SteamStubPresent(ref Executable))
Log("Failed to Patch, Steam Stub Present in the executable, Remove it before.");
else
Log("Failed to Patch, Unsupported Engine Version");
return;
}
}
File.WriteAllBytes(EXE, Executable);

Expand Down Expand Up @@ -115,6 +121,16 @@ private static bool Patch(ref byte[] Data, byte[] Ori, byte[] Patch, string Name
return Patched;
}

private static bool SteamStubPresent(ref byte[] Data) {
byte[] Sig = Encoding.ASCII.GetBytes(".bind");
for (uint i = 0; i < Data.LongLength; i++) {
if (EqualsAt(Data, Sig, i)) {
return true;
}
}
return false;
}

private static bool EqualsAt(byte[] Data, byte[] DataToCompare, uint Pos) {
if (DataToCompare.Length + Pos > Data.Length)
return false;
Expand Down

0 comments on commit 8495b6c

Please sign in to comment.