Skip to content

Commit

Permalink
Update NC.cs
Browse files Browse the repository at this point in the history
Code Refactor
  • Loading branch information
Paolo authored Dec 18, 2018
1 parent 3cf0cfe commit bff390a
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions Navicat_Keygen_Patch_By_DFoX/NC.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Win32;
using Microsoft.Win32;
using Navicat_Keygen_Patch_By_DFoX.Properties;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
Expand Down Expand Up @@ -910,14 +910,12 @@ private void PatchewNV(string file)
string pathdir = Path.GetDirectoryName(file);
bool is64bit = filea64bit(file);
string libcc = pathdir + @"\libcc.dll";
bool libccok1 = false;
bool libccok2 = false;
bool libccok1 = true;
bool libccok2 = true;
if (File.Exists(libcc))
{
bool is64bitlibcc = filea64bit(libcc);
byte[] filearrlibcc = File.ReadAllBytes(libcc);
int cntlibcc = 0;
int cntlibcc2 = 0;
int offsetHexlibcc = 0;
byte[][] libcc_c =
{
Expand All @@ -941,13 +939,15 @@ private void PatchewNV(string file)
offsetHexlibcc = cercaBytes(filearrlibcc, libcc_c[i], 0, filearrlibcc.Length);
if (offsetHexlibcc != -1)
{
cntlibcc++;
for (int p = 0; p < libcc_s[i].Length; p++)
filearrlibcc[offsetHexlibcc + p] = libcc_s[i][p];
}
else
{
libccok1 = false;
break;
}
}
if (cntlibcc == libcc_c.Length) //5 - Patcho il File
libccok1 = true;
offsetHexlibcc = 0;
if (is64bitlibcc)
{
Expand All @@ -961,20 +961,20 @@ private void PatchewNV(string file)
offsetHexlibcc = cercaBytes(filearrlibcc, tmpdfxc, offsetHexlibcc + 5, filearrlibcc.Length);
if (offsetHexlibcc != -1)
{
cntlibcc2++;
for (int p2 = 0; p2 < tmpdfxs.Length; p2++)
filearrlibcc[offsetHexlibcc + p2] = tmpdfxs[p2];
}
else
{
libccok2 = false;
break;
}
}
catch
{
//Nothing
}
}
if (cntlibcc2 == a2.Length) //391 - Patcho il File
libccok2 = true;
}
else
{
Expand Down Expand Up @@ -1006,20 +1006,20 @@ private void PatchewNV(string file)
offsetHexlibcc = cercaBytes(filearrlibcc, tmpdfxc, offsetHexlibcc + add, filearrlibcc.Length);
if (offsetHexlibcc != -1)
{
cntlibcc2++;
for (int p2 = 0; p2 < tmpdfxs.Length; p2++)
filearrlibcc[offsetHexlibcc + p2] = tmpdfxs[p2];
}
else
{
libccok2 = false;
break;
}
}
catch
{
//Nothing
}
}
if (cntlibcc2 == a2.Length) //391 - Patcho il File
libccok2 = true;
}
if (libccok1 || libccok2)
{
Expand All @@ -1038,25 +1038,18 @@ private void PatchewNV(string file)
}
finale(libcc, filearrlibcc);
}
//Fine
//}
byte[] filearr = File.ReadAllBytes(file);
if (controlloBackup.Checked == true)
{
if (File.Exists(file + ".BAK"))
File.Delete(file + ".BAK");
File.Copy(file, file + ".BAK");
}
int cnt = 0;
int offsetHex = cercaBytes(filearr, a, 0, filearr.Length);
if (offsetHex != -1)
{
cnt++;
for (int p = 0; p < b.Length; p++)
filearr[offsetHex + p] = b[p];
}
if (cnt > 0) // Patcho il File
{
finale(file, filearr);
}
else
Expand Down Expand Up @@ -1158,7 +1151,6 @@ public int cercaBytes(byte[] array, byte[] cosaCercare, int indiceDiPartenza, in
int indiceFine = contatore > 0 ? Math.Min(indiceDiPartenza + contatore, array.Length) : array.Length;
int dfx = 0;
int ultimoDfx = 0;

while (i < indiceFine)
{
ultimoDfx = dfx;
Expand Down Expand Up @@ -1503,4 +1495,4 @@ public static byte[] StringToByteArray(string hex)
.ToArray();
}
}
}
}

0 comments on commit bff390a

Please sign in to comment.