private static bool InternalCheckIsWow64() { if ((Environment.OSVersion.Version.Major != 5 || Environment.OSVersion.Version.Minor < 1) && Environment.OSVersion.Version.Major < 6) { return(false); } using (Process currentProcess = Process.GetCurrentProcess()) { bool wow64Process; return(FixUpOle.IsWow64Process(currentProcess.Handle, out wow64Process) && wow64Process); } }
public static void Main(string[] args) { BlueStacks.ComRegistrar.ComRegistrar.Init(); BlueStacks.ComRegistrar.ComRegistrar.sOpt.Parse(args); if (args.Length != 1 || !BlueStacks.ComRegistrar.ComRegistrar.sOpt.reg && !BlueStacks.ComRegistrar.ComRegistrar.sOpt.unreg) { Logger.Error("No/invalid arguments given. Exiting"); Environment.Exit(2); } if (!SystemUtils.IsAdministrator()) { Logger.Fatal("Not admin, exiting"); Environment.Exit(4); } if (ProcessUtils.CheckAlreadyRunningAndTakeLock("Global\\BlueStacks_UnRegRegCom_Lockbgp", out BlueStacks.ComRegistrar.ComRegistrar.sLock)) { Logger.Info("Another instance of ComRegistrar is already running"); Environment.Exit(1); } if (args.Length != 0) { Logger.Info("args: {0}", (object)string.Join(" ", args)); } if (BlueStacks.ComRegistrar.ComRegistrar.sOpt.reg) { Logger.Info("Validating oleaut registries"); if (FixUpOle.FixOle((string)null)) { Logger.Info("Oleaut Validation successful"); } else { Logger.Info("Oleaut Validation failed, continuing anyway"); } } if (BlueStacks.ComRegistrar.ComRegistrar.sOpt.reg) { ulong num = RegisterProxyStub.DllRegisterServer(); if (num != 0UL) { MultiInstanceUtils.SetDeviceCapsRegistry(string.Format("Registration error: {0}", (object)num), EngineState.legacy.ToString()); Logger.Fatal("Unable to register BstkProxyStub.dll, Error: {0}", (object)num); Environment.Exit(10); } } else if (BlueStacks.ComRegistrar.ComRegistrar.sOpt.unreg) { Logger.Info("Unregistering components"); long num = (long)RegisterProxyStub.DllUnregisterServer(); } Environment.Exit(0); }
public static bool IsOs64Bit() { switch (IntPtr.Size) { case 4: if (!FixUpOle.InternalCheckIsWow64()) { break; } goto case 8; case 8: return(true); } return(false); }
public static bool FixOle(string arg) { bool blAdd = true; if (arg != null && arg.Contains("s")) { blAdd = false; } StringBuilder lpBuffer = new StringBuilder(); int systemDirectory = (int)FixUpOle.GetSystemDirectory(lpBuffer, FixUpOle.MAX_BUFF); FixUpOle.olePath = Path.Combine(lpBuffer.ToString(), "oleaut32.dll"); foreach (string str1 in FixUpOle.oleKeyPathsClassesRoot) { RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(str1); if (registryKey != null) { string str2 = (string)registryKey.GetValue((string)null); if (str2 != null && !str2.Equals(FixUpOle.olePath)) { Logger.Info("Trying to fix: classes root - {0}", (object)str1); if (!FixUpOle.WriteTrustedRegistry(0, str1, blAdd)) { return(false); } } } } foreach (string str1 in FixUpOle.oleKeyPathsCurrentUser) { RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(str1); if (registryKey != null) { string str2 = (string)registryKey.GetValue((string)null); if (str2 != null && !str2.Equals(FixUpOle.olePath)) { Logger.Info("Trying to fix: current user - {0}", (object)str1); if (!FixUpOle.WriteTrustedRegistry(1, str1, blAdd)) { return(false); } } } } foreach (string str1 in FixUpOle.oleKeyPathsLocalMachine) { RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(str1); if (registryKey != null) { string str2 = (string)registryKey.GetValue((string)null); if (str2 != null && !str2.Equals(FixUpOle.olePath)) { Logger.Info("Trying to fix: local machine - {0}", (object)str1); if (!FixUpOle.WriteTrustedRegistry(2, str1, blAdd)) { return(false); } } } } return(true); }