Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 53 additions & 36 deletions ModAPI.Common/CommonStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 39 additions & 22 deletions ModAPI.Common/CommonStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,43 +118,60 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="DllsUpdateAvailable" xml:space="preserve">
<value>An update to the ModAPI DLLs is available. It includes new features and bugfixes, and is required to run modern mods. Do you want to download it?</value>
<value>An update to the ModAPI DLLs is available. It includes new features and bugfixes, and is required to use newer mods. Would you like to install it now?

Current Launcher Kit version: $CURRENTLK$
Current ModAPI DLLs version: $CURRENTDLLS$
New ModAPI DLLs version: $NEWDLLS$</value>
</data>
<data name="DllsUpdateAvailableTitle" xml:space="preserve">
<value>ModAPI DLLs Update Available</value>
</data>
<data name="Error" xml:space="preserve">
<value>Error</value>
<data name="GameAlreadyRunning" xml:space="preserve">
<value>Please close Spore before using the Launcher Kit again.

If you have just closed Spore, wait a moment for the game to fully exit. If you continue to get this error, please restart your computer.</value>
</data>
<data name="GameAlreadyRunningTitle" xml:space="preserve">
<value>Game already running</value>
</data>
<data name="GalacticAdventuresNotFound" xml:space="preserve">
<value>Galactic Adventures was not found.</value>
<data name="GameNotFound" xml:space="preserve">
<value>Spore or Spore Galactic Adventures was not found.

Both Spore and Spore Galactic Adventures must be installed from disc, EA App, Steam, or GOG.

Please see https://launcherkit.sporecommunity.com/support for further help.</value>
</data>
<data name="GalacticAdventuresNotFoundSpecifyManual" xml:space="preserve">
<value>Galactic Adventures was not found. Please specify the installation folder manually (usually called SPORE_EP1 or SPORE Galactic Adventures).</value>
<data name="GameNotFoundTitle" xml:space="preserve">
<value>Game not found</value>
</data>
<data name="InvalidPath" xml:space="preserve">
<value>The path specified does not exist or is invalid.</value>
</data>
<data name="InvalidPathTitle" xml:space="preserve">
<value>Invalid path</value>
</data>
<data name="SporeNotFound" xml:space="preserve">
<value>Spore was not found.</value>
<data name="LKUpdateAvailable" xml:space="preserve">
<value>An update to the Spore ModAPI Launcher Kit is now available. Would you like to install it now?

Current Launcher Kit version: $CURRENTLK$
New Launcher Kit version: $NEWLKS$</value>
</data>
<data name="SporeNotFoundSpecifyManual" xml:space="preserve">
<value>Spore was not found. Please specify the installation folder manually (usually called SPORE).</value>
<data name="LKUpdateAvailableTitle" xml:space="preserve">
<value>Launcher Kit Update Available</value>
</data>
<data name="SteamNotFound" xml:space="preserve">
<value>Steam was not found.</value>
<data name="SteamDownloadedButNotLaunched" xml:space="preserve">
<value>Please launch Spore Galactic Adventures once from Steam. This will complete the installation of the game, and allow the Launcher Kit to work.

Afterwards, always use the ModAPI Launcher to play the game.

If you continue to get this message, or the game is not installed from Steam, then the game is likely not installed properly. Please see https://launcherkit.sporecommunity.com/support for further help.</value>
</data>
<data name="SteamNotFoundSpecifyManual" xml:space="preserve">
<value>Steam was not found. Please specify the installation folder manually (usually C:\Program Files (x86)\Steam).</value>
<data name="SteamDownloadedButNotLaunchedTitle" xml:space="preserve">
<value>Steam installation not completed</value>
</data>
<data name="UnauthorizedAccess" xml:space="preserve">
<value>Unauthorized access. Try executing the launcher with Administrator Privileges (Right-click &gt; "Run as Administrator").</value>
<data name="UpdateCheckFailed" xml:space="preserve">
<value>The Launcher Kit could not connect to the update service. Try again in a few minutes, or check https://launcherkit.sporecommunity.com/support for help.</value>
</data>
<data name="UnauthorizedAccessTitle" xml:space="preserve">
<value>Error: Unauthorized access</value>
<data name="UpdateCheckFailedTitle" xml:space="preserve">
<value>Launcher Kit Update</value>
</data>
<data name="UpdatingDllsDialog" xml:space="preserve">
<value>ModAPI DLLs are updating to version </value>
Expand Down
40 changes: 39 additions & 1 deletion ModAPI.Common/GameVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum GameVersionType

public static class GameVersion
{
private static readonly int[] ExecutableSizes = {
private static readonly int[] ExecutableSizes = {
24909584, // Disc
24898224, // Origin_March2017
24906040, // EA_October2024
Expand Down Expand Up @@ -113,5 +113,43 @@ public static string GetNewDLLName(GameVersionType type)
return null;
}
}

public static string GetFriendlyVersionName(GameVersionType type)
{
switch (type)
{
case GameVersionType.Disc:
return "Disc + Patch 5.1, July 2009";
case GameVersionType.Origin_March2017:
return "Origin, March 2017";
case GameVersionType.EA_October2024:
return "EA App, October 2024";
case GameVersionType.Steam_March2017:
return "GOG/Steam, March 2017";
case GameVersionType.GOG_October2024:
return "GOG, October 2024";
case GameVersionType.Steam_October2024:
return "Steam, October 2024";
default:
return "Unknown";
}
}

/// <summary>
/// Returns true if this version type is compatible with LAA (Large Address Aware, aka 4GB patch).
/// </summary>
public static bool IsLAACompatible(GameVersionType type)
{
switch (type)
{
// Steam_October2024 has steamstub DRM which prevents modification of the exe, thus preventing the game from running if LAA is set in PE header
case GameVersionType.Steam_October2024:
return false;
// No known issues with any other versions
default:
return true;
}
}

}
}
38 changes: 38 additions & 0 deletions ModAPI.Common/LAAUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.IO;

namespace ModAPI.Common
{
public static class LAAUtils
{
private const long POINTER_TO_PE_HEADER = 0x3C;
private const long CHARACTERISTICS_OFFSET_FROM_PE_HEADER = 0x16;
private const ushort IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x20;

/// <summary>
/// Returns true if the specified path is a LAA (Large Address Aware, aka 4GB patched) executable.
/// The specified path must be a valid Windows executable, otherwise behavior is undefined.
/// </summary>
public static bool IsLAA(string path)
{
// Based on https://stackoverflow.com/a/9056757

using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
using (var reader = new BinaryReader(stream))
{
// Locate PE header
reader.BaseStream.Position = POINTER_TO_PE_HEADER;
var peHeaderPosition = reader.ReadInt32();

// Locate Characteristics field
reader.BaseStream.Position = peHeaderPosition + CHARACTERISTICS_OFFSET_FROM_PE_HEADER;

// Check if the LAA flag is set
var characteristics = reader.ReadUInt16();
return (characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE) != 0;
}
}
}

}
}
Loading
Loading