public static string GetConfigFile() { int nBufferSize = 260; char[] destination = new char[nBufferSize * 2]; IntPtr num1 = Marshal.AllocHGlobal(nBufferSize * 2); int num2 = RegHelper.QueryRegistryStringValue("SOFTWARE\\ViPER4Windows", "ConfigFile", num1, nBufferSize); Marshal.Copy(num1, destination, 0, nBufferSize * 2); Marshal.FreeHGlobal(num1); if (num2 == 0) { return(""); } string str1 = new string(destination); if (string.IsNullOrEmpty(str1)) { return(""); } char[] charArray = str1.ToCharArray(); int length = -1; for (int index = 0; index < charArray.Length; ++index) { if (charArray[index] == char.MinValue) { length = index; break; } } if (length == -1) { return(""); } char[] chArray = new char[length]; Array.Copy(charArray, chArray, length); string str2 = new string(chArray); return(string.IsNullOrEmpty(str2) ? "" : str2); }
public static bool CheckConfigRegister() { int nBufferSize = 260; char[] destination1 = new char[nBufferSize * 2]; char[] destination2 = new char[nBufferSize * 2]; IntPtr num1 = Marshal.AllocHGlobal(nBufferSize * 2); int num2 = RegHelper.QueryRegistryStringValue("SOFTWARE\\ViPER4Windows", "ConfigPath", num1, nBufferSize); Marshal.Copy(num1, destination1, 0, nBufferSize * 2); int num3 = RegHelper.QueryRegistryStringValue("SOFTWARE\\ViPER4Windows", "ConfigFile", num1, nBufferSize); Marshal.Copy(num1, destination2, 0, nBufferSize * 2); Marshal.FreeHGlobal(num1); if (num2 == 0 || num3 == 0) { return(false); } string str1 = new string(destination1); string str2 = new string(destination2); if (string.IsNullOrEmpty(str1) || string.IsNullOrEmpty(str2)) { return(false); } char[] charArray1 = str1.ToCharArray(); int length1 = -1; for (int index = 0; index < charArray1.Length; ++index) { if (charArray1[index] == char.MinValue) { length1 = index; break; } } if (length1 == -1) { return(false); } char[] chArray1 = new char[length1]; Array.Copy(charArray1, chArray1, length1); string str3 = new string(chArray1); char[] charArray2 = str2.ToCharArray(); int length2 = -1; for (int index = 0; index < charArray2.Length; ++index) { if (charArray2[index] == char.MinValue) { length2 = index; break; } } if (length2 == -1) { return(false); } char[] chArray2 = new char[length2]; Array.Copy(charArray2, chArray2, length2); string str4 = new string(chArray2); return(!string.IsNullOrEmpty(str3) && !string.IsNullOrEmpty(str4)); }