public static string GetStoredCoreDllPath(GameExecutableType exeType, bool isLib)
        {
            string fileName;

            if (isLib)
            {
                fileName = LibFileName;
            }
            else
            {
                fileName = GetNewDLLName(exeType);
            }

            if (Settings.DeveloperMode || Settings.DebugMode)
            {
                string devOutPath = GetOverrideDllPath(exeType, isLib);
                if (File.Exists(devOutPath))
                {
                    return(devOutPath);
                }
            }

            string outPath = Path.Combine(Settings.CoreLibsPath, fileName);

            if (File.Exists(outPath))
            {
                return(outPath);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 /*public static int[] ExecutableSizes = {
  *                             /* DISK*    24909584,
  *                             /* ORIGIN * 31347984,
  *                             /* ORIGIN_P * 24898224,
  *                             /* STEAM *  24888320,
  *                             /* STEAM_P *24885248,
  *                             /*NONE* 0};
  *
  * public static string[] VersionNames = {
  *                                        "disk",
  *                                        "steam_patched",  // origin uses the steam_patched one
  *                                        "steam_patched",  // origin uses the steam_patched one
  *                                        "steam",
  *                                        "steam_patched",
  *                                        null };*/
 public static string GetExecutableDllSuffix(GameExecutableType version)
 {
     if (version == GameExecutableType.Disk__1_5_1)
     {
         return("disk");
     }
     else if (version == GameExecutableType.GogOrSteam__1_5_1)
     {
         return("steam");
     }
     else
     {
         return("steam_patched");
     }
 }
        public static string GetInjectableCoreDllPath(GameExecutableType exeType, bool isLib)
        {
            string fileName;

            if (isLib)
            {
                fileName = LibFileName;
            }
            else
            {
                fileName = "SporeModAPI.dll";
            }

            return(Path.Combine(Settings.ModLibsPath, fileName));
        }
        public static string GetOverrideDllPath(GameExecutableType exeType, bool isLib)
        {
            string fileName;

            if (isLib)
            {
                fileName = LibFileName;
            }
            else
            {
                fileName = GetNewDLLName(exeType);
            }

            return(Path.Combine(Settings.OverrideLibsPath, fileName));
        }
 public static void InstallOverrideDll(string path, GameExecutableType type)
 {
     if (type == GameExecutableType.None)
     {
         string destPath = GetOverrideDllPath(GameExecutableType.GogOrSteam__March2017, true);
         File.Copy(path, destPath, true);
         Permissions.GrantAccessFile(destPath);
     }
     else
     {
         string destPath = GetOverrideDllPath(type);
         File.Copy(path, destPath, true);
         Permissions.GrantAccessFile(destPath);
     }
 }
 public static string GetNewDLLName(GameExecutableType type)
 {
     if (type == GameExecutableType.Disk__1_5_1)
     {
         return("SporeModAPI.disk.dll");
     }
     else if ((type == GameExecutableType.Origin__1_5_1) || (type == GameExecutableType.Origin__March2017) || (type == GameExecutableType.GogOrSteam__March2017))
     {
         return("SporeModAPI.march2017.dll");
     }
     else
     {
         //System.Windows.Forms.MessageBox.Show("This version of Spore (" + type.ToString() + ") is not supported. Please inform rob55rod or emd4600 immediately.", "Unsupported Game Version");
         //System.Windows.Forms.MessageBox.Show("If you're using the Steam version of Spore or the GOG version of Spore, please update to version 3.1.0.22 to proceed. If you're using Origin Spore and you see this message, or if you're already using a higher version of Spore, please inform rob55rod or emd4600 immediately.", "Unsupported Game Version");
         Process.Start(@"http://davoonline.com/phpBB3/viewtopic.php?f=108&t=6300"); //(@"https://github.com/emd4600/Spore-ModAPI/issues/new");
         Process.GetCurrentProcess().Kill();
         return(string.Empty);
     }
 }
 public static string GetInjectableCoreDllPath(GameExecutableType exeType) => GetInjectableCoreDllPath(exeType, false);
 public static string GetOverrideDllPath(GameExecutableType exeType) => GetOverrideDllPath(exeType, false);
Esempio n. 9
0
        public static void LaunchGame()
        {
            try
            {
                _executablePath = Path.Combine(SporebinEP1, "SporeApp.exe");
                if (File.Exists(_executablePath))
                {
                    //IEnumerable<int> rawExeSizes = Enum.GetValues(typeof(GameInfo.)).Cast<long>();

                    /*long[] exeSizes = new long[rawExeSizes.Length];
                     * //exeSizes.CopyTo(rawExeSizes, 0);
                     * for (int i = 0; i < rawExeSizes.Length; i++)
                     *  exeSizes[i] = (long)rawExeSizes.GetValue(i);*/

                    bool exeSizeRecognized = ExecutableFileGameTypes.Keys.Contains(new FileInfo(_executablePath).Length);
                    if (IsValidExe())
                    {
                        try
                        {
                            _executableType = GetExecutableType();
                        }
                        catch (Exception ex)
                        {
                            MessageDisplay.RaiseError(new ErrorEventArgs(ex)); //ex.Message + "\n\n" + ex.StackTrace
                            return;
                        }

                        // Steam users need to do something different...something which doesn't even work most of the time.
                        if (!SporeIsInstalledOnSteam())
                        {
                            MessageDisplay.DebugShowMessageBox("2. Executable type: " + _executableType);

                            if (_executableType == GameExecutableType.None)
                            {
                                // don't execute the game if the user closed the dialog
                                return;
                            }

                            // get the correct executable path
                            _executablePath = Path.Combine(SporebinEP1, ExecutableFileNames[_executableType]);

                            if ((_executableType == GameExecutableType.Origin__1_5_1 ||
                                 _executableType == GameExecutableType.Origin__March2017) &&
                                !File.Exists(_executablePath))
                            {
                                var startInfo = new ProcessStartInfo(
                                    Path.Combine(Settings.ManagerInstallLocationPath, "Spore Mod Launcher.exe"),
                                    "--modapifix " + Directory.GetParent(_executablePath).FullName)
                                {
                                    Verb = "runas"
                                };
                                var p = Process.Start(startInfo);
                                p.WaitForExit();
                            }

                            string dllEnding = GetExecutableDllSuffix(_executableType);

                            MessageDisplay.DebugShowMessageBox("4. DLL suffix: " + dllEnding);

                            if (dllEnding == null)
                            {
                                MessageDisplay.DebugShowMessageBox(Settings.GetLanguageString(3, "NullDllSuffix")); //MessageBox.Show(Strings.VersionNotDetected, CommonStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }

                            InjectNormalSporeProcess(dllEnding);
                        }
                        else
                        {
                            InjectSteamSporeProcess();
                        }
                    }
                }

                int lastError = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

                if ((CurrentError != 0) && (CurrentError != 18) && (CurrentError != 87) && (CurrentError != lastError))
                {
                    try
                    {
                        ThrowWin32Exception("Something went wrong", CurrentError);
                    }
                    catch (Exception ex)
                    {
                        MessageDisplay.RaiseError(new ErrorEventArgs(ex));
                    }
                }

                if ((lastError != 0) && (lastError != 18))
                {
                    ThrowWin32Exception("Something went wrong", lastError);
                }
            }
            catch (Exception ex)
            {
                MessageDisplay.RaiseError(new ErrorEventArgs(ex));
                return;
            }
        }