Exemplo n.º 1
0
        static Program()
        {
            //this needs to be done before the warnings/errors show up
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
#if WINDOWS
            //try loading libraries we know we'll need
            //something in the winforms, etc. code below will cause .net to popup a missing msvcr100.dll in case that one's missing
            //but oddly it lets us proceed and we'll then catch it here
            var  d3dx9 = Win32.LoadLibrary("d3dx9_43.dll");
            var  vc2015 = Win32.LoadLibrary("vcruntime140.dll");
            var  vc2010 = Win32.LoadLibrary("msvcr100.dll");            //TODO - check version?
            var  vc2010p = Win32.LoadLibrary("msvcp100.dll");
            bool fail = false, warn = false;
            warn |= d3dx9 == IntPtr.Zero;
            fail |= vc2015 == IntPtr.Zero;
            fail |= vc2010 == IntPtr.Zero;
            fail |= vc2010p == IntPtr.Zero;
            if (fail || warn)
            {
                var sw = new System.IO.StringWriter();
                sw.WriteLine("[ OK ] .Net 4.0 (You couldn't even get here without it)");
                sw.WriteLine("[{0}] Direct3d 9", d3dx9 == IntPtr.Zero ? "FAIL" : " OK ");
                sw.WriteLine("[{0}] Visual C++ 2010 SP1 Runtime", (vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero) ? "FAIL" : " OK ");
                sw.WriteLine("[{0}] Visual C++ 2015 Runtime", (vc2015 == IntPtr.Zero) ? "FAIL" : " OK ");
                var str = sw.ToString();
                var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail);
                box.textBox1.Text = str;
                box.ShowDialog();
                if (!fail)
                {
                }
                else
                {
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
            }

            Win32.FreeLibrary(d3dx9);
            Win32.FreeLibrary(vc2015);
            Win32.FreeLibrary(vc2010);
            Win32.FreeLibrary(vc2010p);

            // this will look in subdirectory "dll" to load pinvoked stuff
            string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
            SetDllDirectory(dllDir);

            //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            //but before we even try doing that, whack the MOTW from everything in that directory (thats a dll)
            //otherwise, some people will have crashes at boot-up due to .net security disliking MOTW.
            //some people are getting MOTW through a combination of browser used to download bizhawk, and program used to dearchive it
            WhackAllMOTW(dllDir);

            //We need to do it here too... otherwise people get exceptions when externaltools we distribute try to startup
#endif
        }
Exemplo n.º 2
0
        static Program()
        {
            //this needs to be done before the warnings/errors show up
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
            #if WINDOWS
            //try loading libraries we know we'll need
            //something in the winforms, etc. code below will cause .net to popup a missing msvcr100.dll in case that one's missing
            //but oddly it lets us proceed and we'll then catch it here
            var d3dx9 = Win32.LoadLibrary("d3dx9_43.dll");
            var vc2015 = Win32.LoadLibrary("vcruntime140.dll");
            var vc2010 = Win32.LoadLibrary("msvcr100.dll"); //TODO - check version?
            var vc2010p = Win32.LoadLibrary("msvcp100.dll");
            bool fail = false, warn = false;
            warn |= d3dx9 == IntPtr.Zero;
            fail |= vc2015 == IntPtr.Zero;
            fail |= vc2010 == IntPtr.Zero;
            fail |= vc2010p == IntPtr.Zero;
            if (fail || warn)
            {
                var sw = new System.IO.StringWriter();
                sw.WriteLine("[ OK ] .Net 4.0 (You couldn't even get here without it)");
                sw.WriteLine("[{0}] Direct3d 9", d3dx9 == IntPtr.Zero ? "FAIL" : " OK ");
                sw.WriteLine("[{0}] Visual C++ 2010 SP1 Runtime", (vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero) ? "FAIL" : " OK ");
                sw.WriteLine("[{0}] Visual C++ 2015 Runtime", (vc2015 == IntPtr.Zero) ? "FAIL" : " OK ");
                var str = sw.ToString();
                var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail);
                box.textBox1.Text = str;
                box.ShowDialog();
                if (!fail) { }
                else
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
            }

            Win32.FreeLibrary(d3dx9);
            Win32.FreeLibrary(vc2015);
            Win32.FreeLibrary(vc2010);
            Win32.FreeLibrary(vc2010p);

            // this will look in subdirectory "dll" to load pinvoked stuff
            string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
            SetDllDirectory(dllDir);

            //but before we even try doing that, whack the MOTW from everything in that directory (thats a dll)
            //otherwise, some people will have crashes at boot-up due to .net security disliking MOTW.
            //some people are getting MOTW through a combination of browser used to download bizhawk, and program used to dearchive it
            WhackAllMOTW(dllDir);

            //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            #endif
        }
Exemplo n.º 3
0
        static Program()
        {
            //this needs to be done before the warnings/errors show up
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
            {
                var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;

                //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips

                //try loading libraries we know we'll need
                //something in the winforms, etc. code below will cause .net to popup a missing msvcr100.dll in case that one's missing
                //but oddly it lets us proceed and we'll then catch it here
                var d3dx9   = libLoader.LoadPlatformSpecific("d3dx9_43.dll");
                var vc2015  = libLoader.LoadPlatformSpecific("vcruntime140.dll");
                var vc2012  = libLoader.LoadPlatformSpecific("msvcr120.dll");                //TODO - check version?
                var vc2010  = libLoader.LoadPlatformSpecific("msvcr100.dll");                //TODO - check version?
                var vc2010p = libLoader.LoadPlatformSpecific("msvcp100.dll");
                var fail    = vc2015 == IntPtr.Zero || vc2010 == IntPtr.Zero || vc2012 == IntPtr.Zero || vc2010p == IntPtr.Zero;
                var warn    = d3dx9 == IntPtr.Zero;
                if (fail || warn)
                {
                    var alertLines = new[]
                    {
                        "[ OK ] .NET CLR (You wouldn't even get here without it)",
                        $"[{(d3dx9 == IntPtr.Zero ? "WARN" : " OK ")}] Direct3d 9",
                        $"[{(vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero ? "FAIL" : " OK ")}] Visual C++ 2010 SP1 Runtime",
                        $"[{(vc2012 == IntPtr.Zero ? "FAIL" : " OK ")}] Visual C++ 2012 Runtime",
                        $"[{(vc2015 == IntPtr.Zero ? "FAIL" : " OK ")}] Visual C++ 2015 Runtime"
                    };
                    var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail)
                    {
                        textBox1 = { Text = string.Concat("\n", alertLines) }
                    };
                    box.ShowDialog();
                    if (fail)
                    {
                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                    }
                }

                libLoader.FreePlatformSpecific(d3dx9);
                libLoader.FreePlatformSpecific(vc2015);
                libLoader.FreePlatformSpecific(vc2012);
                libLoader.FreePlatformSpecific(vc2010);
                libLoader.FreePlatformSpecific(vc2010p);

                // this will look in subdirectory "dll" to load pinvoked stuff
                var dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
                SetDllDirectory(dllDir);

                //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

                //but before we even try doing that, whack the MOTW from everything in that directory (thats a dll)
                //otherwise, some people will have crashes at boot-up due to .net security disliking MOTW.
                //some people are getting MOTW through a combination of browser used to download bizhawk, and program used to dearchive it
                WhackAllMOTW(dllDir);

                //We need to do it here too... otherwise people get exceptions when externaltools we distribute try to startup
            }
        }