From bff390aada1aa07f14f84dbbc59ffd3825b1492f Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 18 Dec 2018 17:28:17 +0100 Subject: [PATCH] Update NC.cs Code Refactor --- Navicat_Keygen_Patch_By_DFoX/NC.cs | 38 ++++++++++++------------------ 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/Navicat_Keygen_Patch_By_DFoX/NC.cs b/Navicat_Keygen_Patch_By_DFoX/NC.cs index 544c488..6e95488 100644 --- a/Navicat_Keygen_Patch_By_DFoX/NC.cs +++ b/Navicat_Keygen_Patch_By_DFoX/NC.cs @@ -1,4 +1,4 @@ -using Microsoft.Win32; +using Microsoft.Win32; using Navicat_Keygen_Patch_By_DFoX.Properties; using Newtonsoft.Json; using Org.BouncyCastle.Crypto; @@ -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 = { @@ -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) { @@ -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 { @@ -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) { @@ -1038,8 +1038,6 @@ private void PatchewNV(string file) } finale(libcc, filearrlibcc); } - //Fine - //} byte[] filearr = File.ReadAllBytes(file); if (controlloBackup.Checked == true) { @@ -1047,16 +1045,11 @@ private void PatchewNV(string file) 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 @@ -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; @@ -1503,4 +1495,4 @@ public static byte[] StringToByteArray(string hex) .ToArray(); } } -} \ No newline at end of file +}