Skip to content

Commit

Permalink
Fix SDKtoGhidra script, update Ghidra information
Browse files Browse the repository at this point in the history
  • Loading branch information
emd4600 committed Jan 7, 2024
1 parent 98c3aa4 commit 833c42e
Show file tree
Hide file tree
Showing 27 changed files with 15,994 additions and 4,406 deletions.
10,139 changes: 7,925 additions & 2,214 deletions SDKtoGhidra/SporeGhidra_disk.xml

Large diffs are not rendered by default.

10,103 changes: 7,925 additions & 2,178 deletions SDKtoGhidra/SporeGhidra_march2017.xml

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions SDKtoGhidra/eastl_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ namespace eastl
};
static_assert(sizeof(hash_map<int,int>) == 0x20, "sizeof(hash_map<int,int>) == 0x20");

template <typename T, typename _Allocator=allocator>
struct hash_set
{
static allocator _DEFAULT__Allocator;

int field_0;
void* mpBucketArray;
int mnBucketCount;
int mnElementCount;
float mfMaxLoadFactor;
float mfGrowthFactor;
int mnNextResize;
_Allocator mAllocator;
};
static_assert(sizeof(hash_set<int>) == 0x20, "sizeof(hash_set<int>) == 0x20");

struct rbtree_node_base
{
rbtree_node_base* mpNodeLeft;
Expand Down
Empty file.
27 changes: 26 additions & 1 deletion SDKtoGhidra/fake_includes/wintypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct HMONITOR{int unused;};
struct HDC{int unused;};

union LARGE_INTEGER {
struct {
struct LargeIntegerTwoParts {
DWORD LowPart;
LONG HighPart;
} u;
Expand Down Expand Up @@ -137,4 +137,29 @@ struct POINT
{
LONG x;
LONG y;
};

struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
};

struct HKL
{
int unused;
};

typedef WORD ATOM;

struct HCURSOR
{
int unused;
};

struct HBRUSH
{
int unused;
};
4 changes: 2 additions & 2 deletions SDKtoGhidra/ghidra_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,9 @@ def add_structure(self, namespace_list, obj_name, structure_node, template_args=
elif child.kind == cindex.CursorKind.CXX_BASE_SPECIFIER:
# The displayname has 'class ' at the beginning
basename = child.displayname.split(' ')[-1]
base_structure = self.structures.get(basename, None)
base_structure, _ = try_namespace_list(self.structures, basename, namespace_list)
if base_structure is None:
raise SyntaxError(f'Unrecognized base class {basename}')
raise SyntaxError(f'Unrecognized base class {basename} for structure {fullname}')

struct_alignment = max(struct_alignment, base_structure.alignment)
if base_structure.has_vftable:
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/App/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <Spore\App\cArithmeticaResource.h>
#include <Spore\App\ConfigManager.h>
#include <Spore\App\IStateManager.h>
#include <Spore\App\cAppSystem.h>
#endif
#include <Spore\App\CommandLine.h>

Expand Down Expand Up @@ -86,6 +87,9 @@ namespace App

auto_STATIC_METHOD_(IStateManager, IStateManager*, Get);


auto_STATIC_METHOD_(cAppSystem, cAppSystem*, Create);

#endif


Expand Down
2 changes: 1 addition & 1 deletion Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ namespace Addresses(Simulator)
DefineAddress(sSpacePlayerData, SelectAddress(0x16E1D0C, 0x16DDA8C));
DefineAddress(sScenarioEditHistory, SelectAddress(0x160A850, 0x16065D8));
DefineAddress(TimeAtStartOfFrame, SelectAddress(0xB63580, 0xB63980));
DefineAddress(cCreatureGameData, SelectAddress(0x16A25F0, 0x169E370));
DefineAddress(sCreatureGameData, SelectAddress(0x16A25F0, 0x169E370));
}
#endif

Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/DLL/AddressesSkinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ namespace Skinner
}
namespace Addresses(Skinner)
{
#ifdef SDK_TO_GHIDRA
DefineAddress(sCurrentColors, SelectAddress(0x15E3370, 0x15DF0F0));
#else
DefineAddress(GetCurrentColors, SelectAddress(0x15E3370, 0x15DF0F0));
#endif
}
#endif
2 changes: 2 additions & 0 deletions Spore ModAPI/SourceCode/Pollinator/Pollinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Pollinator

auto_STATIC_METHOD_(cAchievementsManager, cAchievementsManager*, Get);

auto_METHOD_(cAchievementsManager, bool, Init);

auto_METHOD(cAchievementsManager, cAchievementDefinition*, GetAchievementDefinition, Args(uint32_t aID), Args(aID));

auto_METHOD(cAchievementsManager, bool, EvaluateTriggerOp, Args(uint32_t aID), Args(aID));
Expand Down
2 changes: 2 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/CreatureGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace Simulator

auto_STATIC_METHOD(cCreatureGameData, float, GetEvoPointsToNextBrainLevel, Args(int a), Args(a));

auto_STATIC_METHOD_(cCreatureGameData, cCreatureGameData::AbilityMode, GetAbilityMode);

auto_STATIC_METHOD_VOID(cCreatureGameData, SetAbilityMode, Args(AbilityMode a, bool b), Args(a, b));

auto_STATIC_METHOD_VOID_(cCreatureGameData, AfterGlideFinish);
Expand Down
3 changes: 3 additions & 0 deletions Spore ModAPI/SourceCode/Skinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ namespace Skinner
{
auto_STATIC_METHOD_(cPaintSystem, cPaintSystem*, Get);

#ifndef SDK_TO_GHIDRA
Math::ColorRGB* GetCurrentColors()
{
return (Math::ColorRGB*)GetAddress(Skinner, GetCurrentColors);
}
#endif

auto_STATIC_METHOD_VOID(cSkinPainter, CreateTextures, Args(int textureSize), Args(textureSize));

Expand All @@ -18,6 +20,7 @@ namespace Skinner
auto_METHOD_VOID(cSkinnerTexturePainter, PaintRegion, Args(const Vector2& uv0, const Vector2& uv1, int index), Args(uv0, uv1, index));
auto_METHOD_VOID(cSkinnerTexturePainter, SetColorWriteEnable,
Args(bool a1, bool a2, bool a3, bool a4), Args(a1, a2, a3, a4));
auto_METHOD_(cSkinnerTexturePainter, RenderWare::CompiledState*, LoadMaterial);

void cSkinnerTexturePainter::AddCustomParams(int index, const Math::ColorRGBA& param)
{
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/Spore/App/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ namespace App
/// Only available after the start of cAppSystem::PreInit().
/// @returns
CommandLine* GetAppCommandLine();

#ifdef SDK_TO_GHIDRA
CommandLine* sAppCommandLine;
#endif
}

namespace Addresses(App)
Expand Down
6 changes: 5 additions & 1 deletion Spore ModAPI/Spore/App/StandardMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ namespace App
: public DefaultRefCounted
{
public:
inline RefCountedString(const char* str) : value(str) {}
inline RefCountedString(const char* str)
#ifndef SDK_TO_GHIDRA
: value(str)
#endif
{}

eastl::string value;
};
Expand Down
33 changes: 33 additions & 0 deletions Spore ModAPI/Spore/App/cAppSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,39 @@ namespace App
, public App::IMessageListener
, public RefCountTemplate
{
public:
static cAppSystem* Create();

virtual void SetUserDirNames(const char16_t* mySporeCreationsFolderName, const char16_t* appDataSporeFolderName) override;
virtual bool PreInit(CommandLine* commandLine, const char16_t* ddfListPath) override;
virtual bool Init(CommandLine* commandLine) override;
virtual bool InitPlugins(CommandLine* commandLine) override;
virtual bool Configure(CommandLine* commandLine) override;
virtual bool InitGraphics(CommandLine* commandLine) override;
virtual bool PreShutdown() override;
virtual bool Shutdown() override;
virtual int Pause() override;
virtual int Unpause() override;
virtual bool IsPaused() override;
virtual void SetTimeScale(float scale) override;
virtual void SetFixedStepping(int) override;
virtual void BoostBackgroundJobs(bool) override;
virtual bool IsBoostEnabled() override;
virtual int GetPerfWarnings() override;
virtual bool Demo() override;
virtual void OpenURL(const char16_t*) override;
virtual void func60h() override; // DeactivateApp() ?
virtual void func64h() override; // ToggleFullscreen() ?
virtual void func68h() override; // ToggleDisplay() ?
virtual void HookWindows() override;
virtual void UnhookWindows() override;
virtual void SetEffectCollectionIDs(uint32_t* instanceIDs, uint32_t* groupIDs) override;
virtual void Update(int deltaTimeMS) override;
virtual void func7Ch() override;
virtual void PostUpdate() override;
virtual void func84h(int) override;
virtual int func88h() override;

public:
/* 10h */ Canvas* mpCanvas;
// 1Ch is cResourceManager, 24h is cLocaleManager, 28h is cResourceKeyGenerator, 3Ch is IConfigManager, 40h is cJobManager, CCh is PropertyListPtr mpPreferencesPropList
Expand Down
10 changes: 10 additions & 0 deletions Spore ModAPI/Spore/App/cMouseCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ namespace App
public:
void CalculateViewTransform(Transform& transform);

virtual void Update(int deltaTime, cViewer* pViewer) override;
virtual bool OnKeyDown(int virtualKey, KeyModifiers modifiers) override;
virtual bool OnMouseDown(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) override;
virtual bool OnMouseUp(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) override;
virtual bool OnMouseMove(float mouseX, float mouseY, MouseState mouseState) override;
virtual bool OnMouseWheel(int wheelDelta, float mouseX, float mouseY, MouseState mouseState) override;
virtual void Initialize() override;
virtual void func54h(Vector3& dst) override;
virtual bool HandleMessage(uint32_t messageID, void* pMessage) override;

public:
/* 0Ch */ int mnRefCount;
/* 10h */ bool mCameraIsMayaStyle;
Expand Down
2 changes: 1 addition & 1 deletion Spore ModAPI/Spore/Graphics/cTextureManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace Graphics
{
class TextureContainer
: public intrusive_list_node
: public eastl::intrusive_list_node
, public Texture
{
};
Expand Down
2 changes: 2 additions & 0 deletions Spore ModAPI/Spore/Pollinator/AchievementsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace Pollinator

static cAchievementsManager* Get();

bool Init();

cAchievementDefinition* GetAchievementDefinition(uint32_t achievementID);

/// Evaluates whether the current achievement progress exceeds the trigger,
Expand Down
6 changes: 6 additions & 0 deletions Spore ModAPI/Spore/ResourceKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,15 @@ ASSERT_SIZE(ResourceKey, 0xC);
#define group_id(id) ResourceKey(0, 0, id)

inline ResourceKey::ResourceKey()
#ifndef SDK_TO_GHIDRA
: instanceID(0)
, typeID(0)
, groupID(0)
#else
: instanceID(0)
, typeID((TypeIDs::Names)0)
, groupID((GroupIDs::Names)0)
#endif
{
}

Expand Down
4 changes: 2 additions & 2 deletions Spore ModAPI/Spore/Simulator/Cell/cCellGFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ namespace Simulator
/// Returns the bounding box for the currently visible background.
static Math::BoundingBox& GetVisibleBackgroundBBox();
#ifdef SDK_TO_GHIDRA
Math::BoundingBox sVisibleBackgroundBBox;
static Math::BoundingBox sVisibleBackgroundBBox;
#endif

/// Returns the frustum cull for the currently visible main cell level.
static Graphics::cFrustumCull& GetFrustumCull();
#ifdef SDK_TO_GHIDRA
Math::BoundingBox sFrustumCull;
static Math::BoundingBox sFrustumCull;
#endif

public:
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/Spore/Simulator/Cell/cCellResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ namespace Simulator

namespace Cell
{
#ifndef SDK_TO_GHIDRA
/// Loads the data of a cell file reference, or returns the existing cached file.
/// @param reference
/// @param dst
Expand All @@ -805,5 +806,8 @@ namespace Simulator
Args(cCellDataReference_*, eastl::intrusive_ptr<cCellDataReference<T>>&),
Args(reference, dst));
}
#else
void* GetData(cCellDataReference_* reference, eastl::intrusive_ptr<cCellDataReference_>& dst);
#endif
}
}
3 changes: 3 additions & 0 deletions Spore ModAPI/Spore/Simulator/cCreatureGameData.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace Simulator
/// @returns
static float GetEvoPointsToNextBrainLevel(int currentLevel = -1);

/// Get the current ability mode (Attack or Social)
static AbilityMode GetAbilityMode();

/// Changes the current ability mode (Attack or Social), optionally playing a sound.
/// This does not change the user interface.
static void SetAbilityMode(AbilityMode mode, bool playSound);
Expand Down
10 changes: 5 additions & 5 deletions Spore ModAPI/Spore/Simulator/cGameplayMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ namespace Simulator
/* 108h */ uint32_t mType;
/* 10Ch */ uint32_t mId;
/* 110h */ uint32_t mDefinitionId;
union {
char raw[0x88];
struct MigrationPoint
union UNNAMED(GameplayMarkerData) {
char mRawData[0x88];
struct
{
/* 114h */ int field_114;
/* 118h */ int field_118;
/* 11Ch */ int field_11C;
/* 120h */ int field_120;
/* 124h */ int field_124;
};
} mData;
} migrationPointData;
};
///* 114h */ char mData[0x88]; // possibly a union
/* 19Ch */ cGameplayMarkerPtr mpNextMarker;
/* 1A0h */ cGameplayMarkerPtr mpHeadMarker;
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/Spore/Skinner/cPaintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,9 @@ namespace Skinner

namespace Addresses(Skinner)
{
#ifdef SDK_TO_GHIDRA
DeclareAddress(sCurrentColors); // 0x15E3370 0x15DF0F0
#else
DeclareAddress(GetCurrentColors); // 0x15E3370 0x15DF0F0
#endif
}
3 changes: 3 additions & 0 deletions Spore ModAPI/Spore/Skinner/cSkinnerTexturePainter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Spore\Graphics\IRenderTargetManager.h>
#include <Spore\RenderWare\CompiledState.h>
#include <Spore\App\cViewer.h>

namespace Skinner
Expand Down Expand Up @@ -57,6 +58,8 @@ namespace Skinner
/// @returns
RenderWare::Raster* GetRaster();

RenderWare::CompiledState* LoadMaterial();

public:
/* 00h */ App::cViewer* mpViewer;
/* 04h */ uint32_t mMaterialID;
Expand Down
2 changes: 1 addition & 1 deletion Spore ModAPI/Spore/Swarm/cCameraEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Swarm
: public cComponentBase
{
public:
/* 0Ch */ cCameraDescription mpDescription;
/* 0Ch */ cCameraDescription* mpDescription;
/* 10h */ ICameraManager* mpCameraMgr;
/* 14h */ bool mIsRunning;
/* 18h */ float mInvLifeTime;
Expand Down
1 change: 1 addition & 0 deletions Spore ModAPI/Spore/Swarm/cDistributeEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace Swarm
/* 18Ch */ float field_18C; // 1.0
/* 190h */ int field_190;
/* 194h */ int field_194; // 1
/* 198h */ int field_198; // not initialized
/* 19Ch */ eastl::vector<int> field_19C;
};
ASSERT_SIZE(cDistributeEffect, 0x1B0);
Expand Down

0 comments on commit 833c42e

Please sign in to comment.