Skip to content

Commit

Permalink
Added signatures and updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SK83RJOSH committed Nov 18, 2020
1 parent 86b6dfd commit df827e3
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Teardown Types

The goal of this repository is to share my reverse engineering efforts with the community. Contributions are welcome, and if structure layouts are present between versions, please let me know!
The goal of this repository is to share my reverse engineering efforts with the community. Contributions are welcome, and if structure layouts differences are present between versions, please let me know!
4 changes: 4 additions & 0 deletions entities/body.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ namespace Teardown { namespace Entities {
uint32_t dwordF0;
uint8_t m_IsDynamic; uint8_t padF5[3];
uint64_t qwordF8;

inline static function_signature<void(__fastcall*)(Body* ptr, Transform* transform)> IsDebris = { "\x80\xB9\xF4\x00\x00\x00\x00\x75\x2A\x32\xC0" };
inline static function_signature<void(__fastcall*)(Body* ptr, Transform* transform)> SetTransform = { "\x48\x89\x5C\x24\x10\x57\x48\x83\xEC\x20\x80\xB9\xFC\x00\x00\x00\x00" };
inline static function_signature<void(__fastcall*)(Body* ptr, small_vector<struct Shape*>& list)> GetShapes = { "\x45\x33\xC9\x45\x8D\x41\x02\xE9\x2A\x2A\x2A\x2A" };
};

static_assert(sizeof(Body) == 0x100u, "Body size is incorrect!");
Expand Down
8 changes: 8 additions & 0 deletions entities/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ namespace Teardown { namespace Entities {
Entity* m_Parent;
Entity* m_Sibling;
Entity* m_Child;

inline static function_signature<void(__fastcall*)(Entity* ptr, small_string* tag)> HasTag = { "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x41\x56\x48\x83\xEC\x20\xF6\x41\x09\x01" };
inline static function_signature<void(__fastcall*)(Entity* ptr, small_string* tag)> RemoveTag = { "\x40\x57\x41\x57" };
inline static function_signature<void(__fastcall*)(Entity* ptr, small_string* tag, small_string* tag_value)> SetTag = { "\x4C\x89\x44\x24\x18\x57\x41\x56" };
inline static function_signature<void(__fastcall*)(Entity* ptr, small_string& result, small_string* tag)> GetTagValue = { "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x41\x56\x41\x57\x48\x83\xEC\x30\x33\xDB" };
inline static function_signature<void(__fastcall*)(Entity* ptr, Entity* parent)> SetParent = { "\x4C\x8B\xC1\x48\x8B\x49\x10\x48\x8B\x41\x20" };
inline static function_signature<void(__fastcall*)(Entity* ptr, small_vector<Entity*>& list, Type type, bool recursive)> FindParentOfType = { "\x48\x8B\x41\x10\x48\x85\xC0\x74\x2A\x0F\x1F\x80\x00\x00\x00\x00" };
inline static function_signature<void(__fastcall*)(Entity* ptr, small_vector<Entity*>& list, Type type, bool recursive)> FindChildrenOfType = { "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x20\x48\x8B\x59\x20" };
};

static_assert(sizeof(Entity::vftable) == 0x20u, "Entity::vftable size is incorrect!");
Expand Down
2 changes: 2 additions & 0 deletions entities/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace Teardown { namespace Entities {
uint64_t qwordA0;
float m_Emissive;
bool m_Broken; uint8_t pad[3];

inline static function_signature<void(__fastcall*)(Shape* ptr, Transform& transform)> GetWorldTransform = { "\x40\x53\x48\x83\xEC\x20\x4C\x8D\x41\x28" };
};

static_assert(sizeof(Shape) == 0xB0u, "Shape size is incorrect!");
Expand Down
6 changes: 6 additions & 0 deletions game.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ namespace Teardown
int field_3B4;
uint8_t gap_3B8[56];
char field_3F0;

inline static function_signature<void(__fastcall*)(Game* ptr)> LoadQuickSave = { "\x40\x57\x48\x81\xEC\xB0\x00\x00\x00\x48\xC7\x44\x24\x30\xFE\xFF\xFF\xFF" };
inline static function_signature<void(__fastcall*)(Game* ptr, __int64 unk1)> Update = { "\x48\x8B\xC4\x55\x41\x56\x41\x57\x48\x8D\xA8\x18\xF7\xFF\xFF" };
inline static function_signature<void(__fastcall*)(Game* ptr, State state)> SetState = { "\x39\x51\x0C\x74\x2A\x8D\x42\xFF" };
};

inline static function_signature<void(__fastcall*)(small_string* string)> DebugLog = { "\x80\x79\x0F\x00\x74\x2A\x48\x8B\x09\x48\x8B\xD1" };

static_assert(sizeof(Game) == 0x3EDu, "Game size is incorrect!");
static_assert(sizeof(Game::Timer) == 0x10u, "Game::Timer size is incorrect!");
static_assert(sizeof(Game::State) == 0x4u, "Game::State size is incorrect!");
Expand Down
4 changes: 4 additions & 0 deletions player.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ namespace Teardown {
int field_3568;
int64_t field_356C;
int field_3574;

inline static function_signature<void(__fastcall*)(Player* ptr, float unk1, float unk2)> UpdateInput = { "\x48\x8B\xC4\x55\x41\x56\x41\x57\x48\x8D\x68\xC8" };
inline static function_signature<void(__fastcall*)(Player* ptr, Transform* transform)> SetTransform = { "\x40\x53\x48\x83\xEC\x30\x33\xDB" };
inline static function_signature<void(__fastcall*)(Player* ptr, float amount)> Damage = { "\xF3\x0F\x10\x91\x5C\x01\x00\x00" };
};

static_assert(sizeof(Player) == 0x3578u, "Player size is incorrect!");
Expand Down
4 changes: 4 additions & 0 deletions scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ namespace Teardown {
uint32_t dword_784;
uint64_t qword_788;
uint8_t gap_790[128];

inline static function_signature<bool(__fastcall*)(Scene* ptr, Vector3_f32* pos, Vector3_f32* dir, float dist, RaycastFilter* f, float* out_dist, Vector3_f32* out_pos, void* out_obj, __int64 out_unk)> Raycast = { "\x48\x8B\xC4\x4C\x89\x40\x18\x48\x89\x50\x10\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xA8\x38\xFC\xFF\xFF" };
inline static function_signature<bool(__fastcall*)(Scene* ptr, Vector3_f32* pos, float radius)> CreateExplosion = { "\x48\x8B\xC4\xF3\x0F\x11\x50\x18\x55" };
inline static function_signature<bool(__fastcall*)(Scene* ptr, Vector3_f32* pos, Vector3_f32* dir, __int32 type)> CreateProjectile = { "\x48\x89\x5C\x24\x08\x57\x48\x81\xEC\x80\x00\x00\x00" };
};

static_assert(sizeof(Scene::RaycastFilter) == 0x50u, "Scene::RaycastFilter size is incorrect!");
Expand Down
17 changes: 17 additions & 0 deletions types.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,21 @@ namespace Teardown {

static_assert(sizeof(small_string) == 16, "small_string size is incorrect!");
static_assert(sizeof(small_vector<void>) == 16, "small_vector size is incorrect!");

/*
* Represents a known good function signature.
*
* Example usage:
* decltype(Teardown::Game::Update)::Type Game_Update = FindSignature(Teardown::Game.Signature);
*
* FindSignature is a user defined function accepting a const* char which scans the main Teardown.exe module.
*/
template<typename T>
struct function_signature
{
/// You can retrieve the function type using decltype(Teardown::Game::Update)::Type.
using Type = T;
/// You can retrieve the function sigature using Teardown::Game::Update.Signature. Signatures use "\x2A" to represent wild cards.
const char* Signature = "";
};
};
6 changes: 6 additions & 0 deletions voxels.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ namespace Teardown {
uint8_t pad55[3];
uint32_t m_VoxelCount; // Amount of "solid" voxels in the physics object; used for mass calculations
uint8_t pad5C[4];

inline static function_signature<Voxels*(__fastcall*)(Voxels* ptr, uint32_t width, uint32_t height, uint32_t depth)> CreateBuffer = { "\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x20\x48\x8B\xF9\x89\x11" };
inline static function_signature<Voxels*(__fastcall*)(Voxels* ptr)> CreatePhysics = { "\x40\x53\x56\x57\x41\x55" };
inline static function_signature<Voxels*(__fastcall*)(Voxels* ptr)> CreateTexture = { "\x48\x89\x4C\x24\x08\x57\x41\x54\x41\x55\x41\x57" };
inline static function_signature<Voxels*(__fastcall*)(Voxels* ptr, Vector3_f32* pos, float radius, int type, float probability)> Paint = { "\x48\x8B\xC4\x48\x89\x50\x10\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x40\x01\x00\x00" };
inline static function_signature<Voxels*(__fastcall*)(Vector3_u32* size)> New = { "\x48\x89\x5C\x24\x08\x48\x89\x74\x24\x10\x57\x48\x83\xEC\x20\x48\x8B\xF1\xB9\x60\x00\x00\x00" };
};

static_assert(sizeof(VoxelMaterial) == 0x10u, "VoxelMaterial size is incorrect!");
Expand Down

0 comments on commit df827e3

Please sign in to comment.