mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
backup scripts
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
namespace Anim {
|
||||
class IPoseElement;
|
||||
}
|
||||
@ -78,105 +77,105 @@ class mtx34;
|
||||
class CGSObject;
|
||||
class IControlObject;
|
||||
|
||||
class __declspec(dllimport) IModelObject {
|
||||
class IModelObject {
|
||||
public:
|
||||
__cdecl IModelObject(class IModelObject const&);
|
||||
void AdjustExtentsToAllElements(bool, bool);
|
||||
class Anim::IPoseElement* AnimGetMeshPoseElement(void);
|
||||
class Anim::IPoseElement const* AnimGetMeshPoseElement(void) const;
|
||||
class Anim::IPoseElement* AnimGetModelObjectMorphPoseElement(void);
|
||||
class Anim::IPoseElement const* AnimGetModelObjectMorphPoseElement(void) const;
|
||||
class Anim::IPoseElement* AnimGetModelObjectPoseElement(void);
|
||||
class Anim::IPoseElement const* AnimGetModelObjectPoseElement(void) const;
|
||||
bool AnimReInit(class ttl::string_base<char> const&);
|
||||
static void CollectMeshSkins(class ttl::string_base<char> const&, bool, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&);
|
||||
void CollectUsedTextures(class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&);
|
||||
void CopyElementsPosition(class IModelObject*);
|
||||
void DissolveObject(bool);
|
||||
void DumpAnims(void);
|
||||
bool EnableElementPhysics(int, bool, bool);
|
||||
void EnableHierarchySerialization(bool);
|
||||
void EnableRenderingRayTracing(bool);
|
||||
void EnableRenderingScene(bool);
|
||||
void EnableRenderingShadows(bool);
|
||||
void EnableUpdateExtents(bool);
|
||||
class aabb const& GetAABBExtents(void) const;
|
||||
void GetAnimationNames(class ttl::map<class ttl::string_base<char>, struct TAnimId, struct ttl::less<class ttl::string_base<char>>, class ttl::allocator>&);
|
||||
int GetCurrentLOD(void) const;
|
||||
union LodDissolves::SState GetCurrentLodState(void) const;
|
||||
static enum COFlags::TYPE GetDefaultCOFlags(void);
|
||||
char GetForcedAnimLod(void) const;
|
||||
float GetLodDissolveStep(void) const;
|
||||
void GetMeshElementsMatrices(class ttl::vector<class mtx34, class ttl::vector_allocators::heap_allocator<class mtx34>, 0>&) const;
|
||||
unsigned int GetMeshElementsMatricesCount(void) const;
|
||||
int GetMeshElementsState(class ttl::vector<unsigned char, class ttl::vector_allocators::heap_allocator<unsigned char>, 8>&, class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
int GetMeshElementsStateSize(class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
float GetMeshLodDistance(int) const;
|
||||
struct SMeshVisibilityParams const* GetMeshVisibilityParams(void) const;
|
||||
float GetMeshVisibilityRange(void);
|
||||
static class IModelObject* GetModelObject(class IGSObject*);
|
||||
static class IModelObject* GetModelObject(class cbs::CEntity const*);
|
||||
static class IModelObject const* GetModelObject(class IGSObject const*);
|
||||
static class CRTTI const* GetNativeClass(void);
|
||||
unsigned int GetNumCollisionHullFaces(void) const;
|
||||
unsigned int GetNumCollisionHullPrimitives(void) const;
|
||||
unsigned int GetNumCollisionHullVertices(void) const;
|
||||
unsigned int GetNumSurfaceParams(void) const;
|
||||
unsigned int GetNumTraceHullFaces(void) const;
|
||||
unsigned int GetNumTraceHullPrimitives(void) const;
|
||||
unsigned int GetNumTraceHullVertices(void) const;
|
||||
class ttl::string_const<char> GetSkin(void) const;
|
||||
static __int64 GetSkinTagsFromStr(char const*);
|
||||
struct SSurfParams* GetSurfaceParams(void) const;
|
||||
int GetTraceCollType(void) const;
|
||||
bool GetValidSkinsEditor(class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&) const;
|
||||
bool IsDefaultMeshLoaded(void);
|
||||
bool IsElementIDValid(int) const;
|
||||
bool IsElementPhysicsEnabled(int);
|
||||
bool IsObjectDissolved(void) const;
|
||||
void LoadMesh(bool);
|
||||
void LoadMeshElements(class ISGChunk*);
|
||||
int MT_GetCount(void);
|
||||
char const* MT_GetName(unsigned int);
|
||||
float MT_WeightGet(unsigned int);
|
||||
static bool MeshAndSkinExists(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
static bool MeshExist(class ttl::string_base<char> const&);
|
||||
void MeshUseDefaultVisibilityParameters(void);
|
||||
void MoveElementBoxSide(int, int, float);
|
||||
void MoveElementBoxSides(int, class vec3 const&, class vec3 const&);
|
||||
void MoveElementBoxSides(int, float, float, float, float, float, float);
|
||||
bool RaytestMe(class vec3 const&, class vec3&, unsigned short, bool, unsigned short);
|
||||
bool RaytraceMe(struct SCollision*, class vec3 const&, class vec3&, unsigned short, bool, unsigned short);
|
||||
bool ReplaceMaterial(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
void ResetBoneAndDescendantsToReferenceFrame(int);
|
||||
void ResetBonesExtentsToReferenceFrame(void);
|
||||
void ResetBonesToReferenceFrame(bool);
|
||||
void ResetElementsDescendantsToReferenceFrame(int);
|
||||
void SaveMeshElements(class ISGChunk*);
|
||||
void SetBestGeomLods(void);
|
||||
void SetDontApplyAnim(bool);
|
||||
void SetEngineObject(class CGSObject*);
|
||||
void SetExtentsLocal(class extents const&);
|
||||
void SetForcedAnimLod(char);
|
||||
void SetLodDissolveStep(float);
|
||||
void SetLodStateForSpawnedObjects(union LodDissolves::SState);
|
||||
void SetMeshCullSizeEnable(bool);
|
||||
bool SetMeshElementsMatrices(class ttl::vector<class mtx34, class ttl::vector_allocators::heap_allocator<class mtx34>, 0> const&);
|
||||
int SetMeshElementsState(class ttl::vector<unsigned char, class ttl::vector_allocators::heap_allocator<unsigned char>, 8> const&, class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&, bool, bool);
|
||||
void SetMeshLodDistance(int, float);
|
||||
void SetMeshVisibilityRange(float);
|
||||
bool SetSkin(void);
|
||||
bool SetSkinNoCharacterPreset(void);
|
||||
void SetTraceCollType(int);
|
||||
bool ShouldApplyAnim(void) const;
|
||||
void ShowCollisionHull(bool);
|
||||
void ShowElementBox(class ttl::string_base<char> const&);
|
||||
void ShowElementBoxes(bool);
|
||||
void ShowElementBoxesFrom(class ttl::string_base<char> const&);
|
||||
void ShowElementBoxesFromTo(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
void ShowElementBoxesTo(class ttl::string_base<char> const&);
|
||||
void ShowExtents(bool);
|
||||
bool SkinExists(class ttl::string_base<char> const&);
|
||||
class CModelObject* ToCModelObject(void);
|
||||
class CModelObject const* ToCModelObject(void) const;
|
||||
__declspec(dllimport) __cdecl IModelObject(class IModelObject const&);
|
||||
__declspec(dllimport) void AdjustExtentsToAllElements(bool, bool);
|
||||
__declspec(dllimport) class Anim::IPoseElement* AnimGetMeshPoseElement(void);
|
||||
__declspec(dllimport) class Anim::IPoseElement const* AnimGetMeshPoseElement(void) const;
|
||||
__declspec(dllimport) class Anim::IPoseElement* AnimGetModelObjectMorphPoseElement(void);
|
||||
__declspec(dllimport) class Anim::IPoseElement const* AnimGetModelObjectMorphPoseElement(void) const;
|
||||
__declspec(dllimport) class Anim::IPoseElement* AnimGetModelObjectPoseElement(void);
|
||||
__declspec(dllimport) class Anim::IPoseElement const* AnimGetModelObjectPoseElement(void) const;
|
||||
__declspec(dllimport) bool AnimReInit(class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) static void CollectMeshSkins(class ttl::string_base<char> const&, bool, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&);
|
||||
__declspec(dllimport) void CollectUsedTextures(class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&);
|
||||
__declspec(dllimport) void CopyElementsPosition(class IModelObject*);
|
||||
__declspec(dllimport) void DissolveObject(bool);
|
||||
__declspec(dllimport) void DumpAnims(void);
|
||||
__declspec(dllimport) bool EnableElementPhysics(int, bool, bool);
|
||||
__declspec(dllimport) void EnableHierarchySerialization(bool);
|
||||
__declspec(dllimport) void EnableRenderingRayTracing(bool);
|
||||
__declspec(dllimport) void EnableRenderingScene(bool);
|
||||
__declspec(dllimport) void EnableRenderingShadows(bool);
|
||||
__declspec(dllimport) void EnableUpdateExtents(bool);
|
||||
__declspec(dllimport) class aabb const& GetAABBExtents(void) const;
|
||||
__declspec(dllimport) void GetAnimationNames(class ttl::map<class ttl::string_base<char>, struct TAnimId, struct ttl::less<class ttl::string_base<char>>, class ttl::allocator>&);
|
||||
__declspec(dllimport) int GetCurrentLOD(void) const;
|
||||
__declspec(dllimport) union LodDissolves::SState GetCurrentLodState(void) const;
|
||||
__declspec(dllimport) static enum COFlags::TYPE GetDefaultCOFlags(void);
|
||||
__declspec(dllimport) char GetForcedAnimLod(void) const;
|
||||
__declspec(dllimport) float GetLodDissolveStep(void) const;
|
||||
__declspec(dllimport) void GetMeshElementsMatrices(class ttl::vector<class mtx34, class ttl::vector_allocators::heap_allocator<class mtx34>, 0>&) const;
|
||||
__declspec(dllimport) unsigned int GetMeshElementsMatricesCount(void) const;
|
||||
__declspec(dllimport) int GetMeshElementsState(class ttl::vector<unsigned char, class ttl::vector_allocators::heap_allocator<unsigned char>, 8>&, class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
__declspec(dllimport) int GetMeshElementsStateSize(class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
__declspec(dllimport) float GetMeshLodDistance(int) const;
|
||||
__declspec(dllimport) struct SMeshVisibilityParams const* GetMeshVisibilityParams(void) const;
|
||||
__declspec(dllimport) float GetMeshVisibilityRange(void);
|
||||
__declspec(dllimport) static class IModelObject* GetModelObject(class IGSObject*);
|
||||
__declspec(dllimport) static class IModelObject* GetModelObject(class cbs::CEntity const*);
|
||||
__declspec(dllimport) static class IModelObject const* GetModelObject(class IGSObject const*);
|
||||
__declspec(dllimport) static class CRTTI const* GetNativeClass(void);
|
||||
__declspec(dllimport) unsigned int GetNumCollisionHullFaces(void) const;
|
||||
__declspec(dllimport) unsigned int GetNumCollisionHullPrimitives(void) const;
|
||||
__declspec(dllimport) unsigned int GetNumCollisionHullVertices(void) const;
|
||||
__declspec(dllimport) unsigned int GetNumSurfaceParams(void) const;
|
||||
__declspec(dllimport) unsigned int GetNumTraceHullFaces(void) const;
|
||||
__declspec(dllimport) unsigned int GetNumTraceHullPrimitives(void) const;
|
||||
__declspec(dllimport) unsigned int GetNumTraceHullVertices(void) const;
|
||||
__declspec(dllimport) class ttl::string_const<char> GetSkin(void) const;
|
||||
__declspec(dllimport) static __int64 GetSkinTagsFromStr(char const*);
|
||||
__declspec(dllimport) struct SSurfParams* GetSurfaceParams(void) const;
|
||||
__declspec(dllimport) int GetTraceCollType(void) const;
|
||||
__declspec(dllimport) bool GetValidSkinsEditor(class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&) const;
|
||||
__declspec(dllimport) bool IsDefaultMeshLoaded(void);
|
||||
__declspec(dllimport) bool IsElementIDValid(int) const;
|
||||
__declspec(dllimport) bool IsElementPhysicsEnabled(int);
|
||||
__declspec(dllimport) bool IsObjectDissolved(void) const;
|
||||
__declspec(dllimport) void LoadMesh(bool);
|
||||
__declspec(dllimport) void LoadMeshElements(class ISGChunk*);
|
||||
__declspec(dllimport) int MT_GetCount(void);
|
||||
__declspec(dllimport) char const* MT_GetName(unsigned int);
|
||||
__declspec(dllimport) float MT_WeightGet(unsigned int);
|
||||
__declspec(dllimport) static bool MeshAndSkinExists(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) static bool MeshExist(class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) void MeshUseDefaultVisibilityParameters(void);
|
||||
__declspec(dllimport) void MoveElementBoxSide(int, int, float);
|
||||
__declspec(dllimport) void MoveElementBoxSides(int, class vec3 const&, class vec3 const&);
|
||||
__declspec(dllimport) void MoveElementBoxSides(int, float, float, float, float, float, float);
|
||||
__declspec(dllimport) bool RaytestMe(class vec3 const&, class vec3&, unsigned short, bool, unsigned short);
|
||||
__declspec(dllimport) bool RaytraceMe(struct SCollision*, class vec3 const&, class vec3&, unsigned short, bool, unsigned short);
|
||||
__declspec(dllimport) bool ReplaceMaterial(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) void ResetBoneAndDescendantsToReferenceFrame(int);
|
||||
__declspec(dllimport) void ResetBonesExtentsToReferenceFrame(void);
|
||||
__declspec(dllimport) void ResetBonesToReferenceFrame(bool);
|
||||
__declspec(dllimport) void ResetElementsDescendantsToReferenceFrame(int);
|
||||
__declspec(dllimport) void SaveMeshElements(class ISGChunk*);
|
||||
__declspec(dllimport) void SetBestGeomLods(void);
|
||||
__declspec(dllimport) void SetDontApplyAnim(bool);
|
||||
__declspec(dllimport) void SetEngineObject(class CGSObject*);
|
||||
__declspec(dllimport) void SetExtentsLocal(class extents const&);
|
||||
__declspec(dllimport) void SetForcedAnimLod(char);
|
||||
__declspec(dllimport) void SetLodDissolveStep(float);
|
||||
__declspec(dllimport) void SetLodStateForSpawnedObjects(union LodDissolves::SState);
|
||||
__declspec(dllimport) void SetMeshCullSizeEnable(bool);
|
||||
__declspec(dllimport) bool SetMeshElementsMatrices(class ttl::vector<class mtx34, class ttl::vector_allocators::heap_allocator<class mtx34>, 0> const&);
|
||||
__declspec(dllimport) int SetMeshElementsState(class ttl::vector<unsigned char, class ttl::vector_allocators::heap_allocator<unsigned char>, 8> const&, class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&, bool, bool);
|
||||
__declspec(dllimport) void SetMeshLodDistance(int, float);
|
||||
__declspec(dllimport) void SetMeshVisibilityRange(float);
|
||||
__declspec(dllimport) bool SetSkin(void);
|
||||
__declspec(dllimport) bool SetSkinNoCharacterPreset(void);
|
||||
__declspec(dllimport) void SetTraceCollType(int);
|
||||
__declspec(dllimport) bool ShouldApplyAnim(void) const;
|
||||
__declspec(dllimport) void ShowCollisionHull(bool);
|
||||
__declspec(dllimport) void ShowElementBox(class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) void ShowElementBoxes(bool);
|
||||
__declspec(dllimport) void ShowElementBoxesFrom(class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) void ShowElementBoxesFromTo(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) void ShowElementBoxesTo(class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) void ShowExtents(bool);
|
||||
__declspec(dllimport) bool SkinExists(class ttl::string_base<char> const&);
|
||||
__declspec(dllimport) class CModelObject* ToCModelObject(void);
|
||||
__declspec(dllimport) class CModelObject const* ToCModelObject(void) const;
|
||||
};
|
@ -102,6 +102,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
@ -112,12 +113,14 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)$(Platform)\Debug\</OutDir>
|
||||
<IntDir>$(Platform)\Debug\</IntDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@ -150,10 +153,12 @@
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
</Link>
|
||||
@ -220,6 +225,7 @@
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -246,6 +252,7 @@
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
Binary file not shown.
Binary file not shown.
707
EGameSDK/proxies/engine_x64_rwdi/scripts/ExportClassToCPPH.py
Normal file
707
EGameSDK/proxies/engine_x64_rwdi/scripts/ExportClassToCPPH.py
Normal file
@ -0,0 +1,707 @@
|
||||
import re
|
||||
import os
|
||||
import idc
|
||||
import idaapi
|
||||
import idautils
|
||||
import ida_kernwin
|
||||
import ida_nalt
|
||||
import ida_bytes
|
||||
import ida_ida
|
||||
import struct
|
||||
from collections import defaultdict
|
||||
|
||||
# Configuration
|
||||
PROJECT_FOLDER = "D:\PROJECTS\Visual Studio\EGameSDK\EGameSDK\include"
|
||||
IDA_NALT_ENCODING = ida_nalt.get_default_encoding_idx(ida_nalt.BPU_1B)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# String and type formatting utilities
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def fix_spacing(s):
|
||||
"""Fix spacing for pointers/references, commas, and angle brackets."""
|
||||
s = re.sub(r'\s+([*&])', r'\1', s) # Remove space before '*' or '&'
|
||||
s = re.sub(r'\s*,\s*', ', ', s) # Ensure comma followed by one space
|
||||
s = re.sub(r'<\s+', '<', s) # Remove space after '<'
|
||||
s = re.sub(r'\s+>', '>', s) # Remove space before '>'
|
||||
s = re.sub(r'\s+', ' ', s) # Collapse multiple spaces
|
||||
return s.strip()
|
||||
|
||||
def clean_type(s):
|
||||
"""Remove unwanted tokens from a type string, then fix spacing."""
|
||||
s = re.sub(r'\b(__cdecl|__ptr64|class|struct|enum|union)\b', '', s)
|
||||
return fix_spacing(s)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Function signature parsing
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def parse_function_signature(signature):
|
||||
"""Parse a demangled function signature for class methods."""
|
||||
signature = signature.strip()
|
||||
|
||||
# Pattern 1: With return type
|
||||
pattern1 = r"^(?:(public:|protected:|private:)\s+)?([\w\s:*&<>,]+)\s+(?:__cdecl\s+)?([A-Za-z_][\w:~<>]*)::([\w~<>]+)\((.*?)\)\s*(const)?$"
|
||||
m = re.match(pattern1, signature)
|
||||
if m:
|
||||
access, return_type, class_name, function_name, parameters, const = m.groups()
|
||||
return {
|
||||
"type": "method",
|
||||
"access": access.strip() if access else "public",
|
||||
"return_type": return_type.strip(),
|
||||
"class_name": class_name.strip(),
|
||||
"function_name": function_name.strip(),
|
||||
"parameters": parameters.strip(),
|
||||
"const": "const" if const else "",
|
||||
}
|
||||
|
||||
# Pattern 2: Without return type (assume empty return type)
|
||||
pattern2 = r"^(?:(public:|protected:|private:)\s+)?([A-Za-z_][\w:~<>]*)::([\w~<>]+)\((.*?)\)\s*(const)?$"
|
||||
m = re.match(pattern2, signature)
|
||||
if m:
|
||||
access, class_name, function_name, parameters, const = m.groups()
|
||||
return {
|
||||
"type": "method",
|
||||
"access": access.strip() if access else "public",
|
||||
"return_type": "",
|
||||
"class_name": class_name.strip(),
|
||||
"function_name": function_name.strip(),
|
||||
"parameters": parameters.strip(),
|
||||
"const": "const" if const else "",
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# IDA pattern search utilities
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def bytes_to_ida_pattern(data):
|
||||
"""Convert bytes to IDA-friendly hex pattern string."""
|
||||
return " ".join("{:02X}".format(b) for b in data)
|
||||
|
||||
def get_section_info(section_name):
|
||||
"""Get start address and size of a specified section."""
|
||||
for seg_ea in idautils.Segments():
|
||||
if idc.get_segm_name(seg_ea) == section_name:
|
||||
start = seg_ea
|
||||
end = idc.get_segm_end(seg_ea)
|
||||
return start, end - start
|
||||
return None, None
|
||||
|
||||
def find_all_patterns_in_range(pattern, start, size):
|
||||
"""Find all occurrences of a pattern within a memory range."""
|
||||
addresses = []
|
||||
ea = start
|
||||
end = start + size
|
||||
|
||||
while ea < end:
|
||||
compiled_pattern = ida_bytes.compiled_binpat_vec_t()
|
||||
err = ida_bytes.parse_binpat_str(compiled_pattern, 0, pattern, 16, IDA_NALT_ENCODING)
|
||||
if err:
|
||||
return []
|
||||
|
||||
found = ida_bytes.bin_search(ea, end, compiled_pattern, ida_bytes.BIN_SEARCH_FORWARD)
|
||||
if found == idc.BADADDR:
|
||||
break
|
||||
|
||||
addresses.append(found)
|
||||
ea = found + 8 # advance past found pattern
|
||||
|
||||
return addresses
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# RTTI and vtable analysis
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def get_vtable_ptr(class_name):
|
||||
"""
|
||||
Find vtable pointer for a class using RTTI information.
|
||||
Returns the vtable pointer (an integer) or 0 if not found.
|
||||
"""
|
||||
if not class_name:
|
||||
return 0
|
||||
|
||||
base_address = idaapi.get_imagebase()
|
||||
|
||||
# Find type descriptor
|
||||
type_descriptor_name = f".?AV{class_name}@@"
|
||||
type_descriptor_bytes = type_descriptor_name.encode('ascii')
|
||||
ida_pattern = bytes_to_ida_pattern(type_descriptor_bytes)
|
||||
|
||||
# Search in .rdata
|
||||
rdata_start, rdata_size = get_section_info(".rdata")
|
||||
if rdata_start is None:
|
||||
return 0
|
||||
|
||||
# Look for the type descriptor
|
||||
compiled_pattern = ida_bytes.compiled_binpat_vec_t()
|
||||
err = ida_bytes.parse_binpat_str(compiled_pattern, 0, ida_pattern, 16, IDA_NALT_ENCODING)
|
||||
if err:
|
||||
return 0
|
||||
|
||||
found_addr = ida_bytes.bin_search(rdata_start, ida_ida.cvar.inf.max_ea, compiled_pattern, ida_bytes.BIN_SEARCH_FORWARD)
|
||||
if found_addr == idc.BADADDR:
|
||||
idaapi.msg(f"Type descriptor pattern not found for {class_name}.\n")
|
||||
return 0
|
||||
|
||||
# Adjust to get RTTI type descriptor
|
||||
rtti_type_descriptor = found_addr - 0x10
|
||||
|
||||
# Compute offset relative to base address
|
||||
final_offset = rtti_type_descriptor - base_address
|
||||
final_offset_bytes = struct.pack("<I", final_offset)
|
||||
offset_pattern = bytes_to_ida_pattern(final_offset_bytes)
|
||||
|
||||
# Search for references to this offset
|
||||
xrefs = find_all_patterns_in_range(offset_pattern, rdata_start, rdata_size)
|
||||
|
||||
# Analyze each reference to find the vtable
|
||||
for xref in xrefs:
|
||||
# Check offset from class
|
||||
offset_from_class = idc.get_wide_dword(xref - 8)
|
||||
if offset_from_class != 0:
|
||||
continue
|
||||
|
||||
# Get object locator
|
||||
object_locator = xref - 0xC
|
||||
|
||||
# Look for references to the object locator
|
||||
object_locator_bytes = struct.pack("<Q", object_locator)
|
||||
locator_pattern = bytes_to_ida_pattern(object_locator_bytes)
|
||||
|
||||
compiled_pattern = ida_bytes.compiled_binpat_vec_t()
|
||||
err = ida_bytes.parse_binpat_str(compiled_pattern, 0, locator_pattern, 16, IDA_NALT_ENCODING)
|
||||
if err:
|
||||
continue
|
||||
|
||||
locator_found = ida_bytes.bin_search(rdata_start, ida_ida.cvar.inf.max_ea, compiled_pattern, ida_bytes.BIN_SEARCH_FORWARD)
|
||||
if locator_found == idc.BADADDR:
|
||||
continue
|
||||
|
||||
# Vtable pointer is at (locator_found + 0x8)
|
||||
vtable_addr = locator_found + 8
|
||||
if vtable_addr <= 8:
|
||||
continue
|
||||
|
||||
return vtable_addr
|
||||
|
||||
idaapi.msg(f"Failed to locate vtable pointer for {class_name}.\n")
|
||||
return 0
|
||||
|
||||
def get_vtable_order(target_class):
|
||||
"""
|
||||
Get the ordered list of function names from a class's vtable.
|
||||
"""
|
||||
vtable_ptr = get_vtable_ptr(target_class)
|
||||
if vtable_ptr == 0:
|
||||
idaapi.msg(f"Vtable pointer not found for {target_class}.\n")
|
||||
return []
|
||||
|
||||
order = []
|
||||
seg_end = idc.get_segm_end(vtable_ptr)
|
||||
ea = vtable_ptr
|
||||
|
||||
while ea < seg_end:
|
||||
ptr = idc.get_qword(ea)
|
||||
if ptr == 0:
|
||||
break
|
||||
|
||||
seg = idaapi.getseg(ptr)
|
||||
if seg is None or seg.type != idaapi.SEG_CODE:
|
||||
break
|
||||
|
||||
func_name = idc.get_func_name(ptr) or idc.get_name(ptr)
|
||||
order.append(func_name)
|
||||
ea += 8
|
||||
|
||||
return order
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Vtable function processing
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
placeholder_counter = 0
|
||||
|
||||
def create_placeholder_method(target_class, index):
|
||||
"""Create a placeholder method dictionary for stripped virtual functions."""
|
||||
return {
|
||||
"type": "method",
|
||||
"access": "public",
|
||||
"return_type": "virtual void",
|
||||
"class_name": target_class,
|
||||
"function_name": f"StrippedVFunc{index}",
|
||||
"parameters": "",
|
||||
"const": "",
|
||||
}
|
||||
|
||||
def parse_vtable_functions(vtable_order, target_class):
|
||||
"""
|
||||
Parse vtable entries into function dictionaries.
|
||||
Creates placeholders for functions without proper names.
|
||||
"""
|
||||
global placeholder_counter
|
||||
vtable_methods = []
|
||||
|
||||
for entry in vtable_order:
|
||||
# Attempt to demangle the name
|
||||
demangled = idaapi.demangle_name(entry, idaapi.MNG_LONG_FORM)
|
||||
|
||||
if demangled:
|
||||
# Parse the signature
|
||||
parsed = parse_function_signature(demangled)
|
||||
if parsed and parsed["class_name"] == target_class:
|
||||
vtable_methods.append(parsed)
|
||||
continue
|
||||
|
||||
# Create placeholder for entries we can't parse
|
||||
vtable_methods.append(create_placeholder_method(target_class, placeholder_counter))
|
||||
placeholder_counter += 1
|
||||
|
||||
return vtable_methods
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Type extraction and processing
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def extract_types_from_string(s):
|
||||
"""Extract potential type names from a string."""
|
||||
# Remove pointer/reference symbols and qualifiers
|
||||
cleaned = s.replace("*", " ").replace("&", " ")
|
||||
tokens = re.findall(r"[A-Za-z_][\w:]*", cleaned)
|
||||
return tokens
|
||||
|
||||
def extract_custom_types_from_template(content, target_class, custom_types):
|
||||
"""Extract custom types from template parameters."""
|
||||
if '<' in content and '>' in content:
|
||||
inner_contents = re.findall(r'<\s*([^>]+?)\s*>', content)
|
||||
for inner_content in inner_contents:
|
||||
for part in inner_content.split(','):
|
||||
part = part.strip()
|
||||
tokens = extract_types_from_string(part)
|
||||
|
||||
# Add type if it matches our patterns and isn't the target class
|
||||
if tokens:
|
||||
if (tokens[0] in ("class", "struct", "enum", "union") and
|
||||
len(tokens) > 1 and tokens[1] != target_class):
|
||||
custom_types.add((tokens[0], tokens[1]))
|
||||
elif (len(tokens) > 2 and
|
||||
tokens[0] in ("virtual", "static") and
|
||||
tokens[1] in ("class", "struct", "enum", "union") and
|
||||
tokens[2] != target_class):
|
||||
custom_types.add((tokens[1], tokens[2]))
|
||||
|
||||
def extract_custom_types_from_functions(functions, target_class):
|
||||
"""Extract all custom types from a list of function dictionaries."""
|
||||
custom_types = set()
|
||||
|
||||
for func in functions:
|
||||
# Process return type
|
||||
raw_rt = func.get("return_type", "")
|
||||
tokens_rt = extract_types_from_string(raw_rt)
|
||||
|
||||
if len(tokens_rt) > 1:
|
||||
if (tokens_rt[0] in ("class", "struct", "enum", "union") and
|
||||
tokens_rt[1] != target_class):
|
||||
custom_types.add((tokens_rt[0], tokens_rt[1]))
|
||||
elif (len(tokens_rt) > 2 and
|
||||
tokens_rt[0] in ("virtual", "static") and
|
||||
tokens_rt[1] in ("class", "struct", "enum", "union") and
|
||||
tokens_rt[2] != target_class):
|
||||
custom_types.add((tokens_rt[1], tokens_rt[2]))
|
||||
|
||||
# Process template parameters in return type
|
||||
extract_custom_types_from_template(raw_rt, target_class, custom_types)
|
||||
|
||||
# Process parameters
|
||||
raw_params = func.get("parameters", "")
|
||||
param_chunks = [chunk.strip() for chunk in raw_params.split(',') if chunk.strip()]
|
||||
|
||||
for chunk in param_chunks:
|
||||
tokens_params = extract_types_from_string(chunk)
|
||||
|
||||
if len(tokens_params) > 1:
|
||||
if (tokens_params[0] in ("class", "struct", "enum", "union") and
|
||||
tokens_params[1] != target_class):
|
||||
custom_types.add((tokens_params[0], tokens_params[1]))
|
||||
elif (len(tokens_params) > 2 and
|
||||
tokens_params[0] in ("virtual", "static") and
|
||||
tokens_params[1] in ("class", "struct", "enum", "union") and
|
||||
tokens_params[2] != target_class):
|
||||
custom_types.add((tokens_params[1], tokens_params[2]))
|
||||
|
||||
# Process template parameters in chunk
|
||||
extract_custom_types_from_template(chunk, target_class, custom_types)
|
||||
|
||||
return custom_types
|
||||
|
||||
def search_for_class_definition(project_folder, full_class_name):
|
||||
"""Search project for existing class definitions."""
|
||||
# Stubbed out - always returns False in this version
|
||||
return False
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Forward declaration generation
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def build_namespace_tree(custom_types):
|
||||
"""
|
||||
Build a namespace tree from custom types.
|
||||
Returns a tree structure representing nested namespaces.
|
||||
"""
|
||||
tree = {"decls": [], "children": {}}
|
||||
|
||||
for decl, full_name in custom_types:
|
||||
parts = full_name.split("::")
|
||||
|
||||
if len(parts) == 1:
|
||||
# No namespace: add to root declarations
|
||||
tree["decls"].append((decl, full_name))
|
||||
else:
|
||||
namespaces = parts[:-1] # All but the last part
|
||||
type_name = parts[-1] # The last part is the type name
|
||||
|
||||
# Navigate to the correct namespace node
|
||||
node = tree
|
||||
for ns in namespaces:
|
||||
node = node["children"].setdefault(ns, {"decls": [], "children": {}})
|
||||
|
||||
# Add the declaration to this namespace
|
||||
node["decls"].append((decl, type_name))
|
||||
|
||||
return tree
|
||||
|
||||
def generate_namespace_tree_code(tree, indent=""):
|
||||
"""
|
||||
Generate code for a namespace tree with proper indentation.
|
||||
"""
|
||||
lines = []
|
||||
|
||||
# Generate child namespace blocks first
|
||||
children = sorted(tree.get("children", {}).items(), key=lambda x: x[0])
|
||||
for idx, (ns, subtree) in enumerate(children):
|
||||
lines.append(f"{indent}namespace {ns} {{")
|
||||
child_code = generate_namespace_tree_code(subtree, indent + " ")
|
||||
lines.append(child_code)
|
||||
lines.append(f"{indent}}}")
|
||||
|
||||
# Add blank line between top-level namespaces
|
||||
if indent == "" and idx < len(children) - 1:
|
||||
lines.append("")
|
||||
|
||||
# Add blank line between namespaces and declarations
|
||||
if children and tree.get("decls", []):
|
||||
lines.append("")
|
||||
|
||||
# Output direct declarations in the current namespace
|
||||
for decl, name in sorted(tree.get("decls", []), key=lambda x: x[1]):
|
||||
lines.append(f"{indent}{decl} {name};")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
def build_forward_declarations(custom_types):
|
||||
"""Generate forward declaration code from custom types."""
|
||||
tree = build_namespace_tree(custom_types)
|
||||
return generate_namespace_tree_code(tree)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Recursive class generation for missing types
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Track classes we've already processed to avoid circular dependencies
|
||||
processed_classes = set()
|
||||
|
||||
def should_generate_class_definition(class_name):
|
||||
"""
|
||||
Determine if a class should have a full definition generated.
|
||||
Returns True if the class has virtual or exported functions.
|
||||
Uses the cached function signatures for efficiency.
|
||||
"""
|
||||
# Check if class has a vtable
|
||||
vtable_entries = get_vtable_order(class_name)
|
||||
if vtable_entries:
|
||||
return True
|
||||
|
||||
# Check if class has any functions in our parsed functions cache
|
||||
if class_name in parsed_functions_by_class and parsed_functions_by_class[class_name]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def process_missing_classes(missing_types):
|
||||
"""
|
||||
Process missing types to generate class definitions when appropriate.
|
||||
Returns a tuple: (class_definitions, remaining_forward_decls)
|
||||
"""
|
||||
class_definitions = []
|
||||
remaining_forward_decls = set()
|
||||
|
||||
for decl, full_name in missing_types:
|
||||
# Only process classes, not enums, structs, etc.
|
||||
if decl != "class":
|
||||
remaining_forward_decls.add((decl, full_name))
|
||||
continue
|
||||
|
||||
# Skip if already processed to prevent infinite recursion
|
||||
if full_name in processed_classes:
|
||||
remaining_forward_decls.add((decl, full_name))
|
||||
continue
|
||||
|
||||
# Extract the simple class name (without namespace)
|
||||
class_name = full_name.split("::")[-1]
|
||||
|
||||
# Check if we should generate a full definition
|
||||
if should_generate_class_definition(class_name):
|
||||
processed_classes.add(full_name)
|
||||
|
||||
# Collect functions for this class
|
||||
parsed_functions = collect_function_signatures(class_name)
|
||||
|
||||
if parsed_functions:
|
||||
# Generate the class definition
|
||||
class_def = generate_header_for_class(class_name, parsed_functions)
|
||||
class_definitions.append(class_def)
|
||||
|
||||
# Note: this might recursively handle dependencies of this class
|
||||
else:
|
||||
# No functions found, just forward declare
|
||||
remaining_forward_decls.add((decl, full_name))
|
||||
else:
|
||||
# No virtual or exported functions, just forward declare
|
||||
remaining_forward_decls.add((decl, full_name))
|
||||
|
||||
return class_definitions, remaining_forward_decls
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Header generation
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
first_non_virtual = False
|
||||
|
||||
def generate_class_method_code(func):
|
||||
"""Generate code for a single class method."""
|
||||
const_str = " const" if func["const"] else ""
|
||||
rt = clean_type(func['return_type'])
|
||||
if rt:
|
||||
rt += " "
|
||||
|
||||
params = clean_type(func['parameters'])
|
||||
if params.strip() == "void":
|
||||
params = ""
|
||||
|
||||
return f" {rt}{func['function_name']}({params}){const_str};"
|
||||
|
||||
def generate_class_definition(target_class, combined_methods):
|
||||
"""Generate a class definition from a list of methods."""
|
||||
global first_non_virtual
|
||||
first_non_virtual = False
|
||||
|
||||
# Build the class definition
|
||||
class_lines = [f"class __declspec(dllimport) {target_class} {{", "public:"]
|
||||
|
||||
for func in combined_methods:
|
||||
# Add spacing before first non-virtual method
|
||||
if 'virtual' not in func['return_type'] and not first_non_virtual:
|
||||
first_non_virtual = True
|
||||
class_lines.append("")
|
||||
|
||||
class_lines.append(generate_class_method_code(func))
|
||||
|
||||
class_lines.append("};")
|
||||
return "\n".join(class_lines)
|
||||
|
||||
def generate_header_for_class(target_class, parsed_functions):
|
||||
"""
|
||||
Generate a C++ header file for the target class.
|
||||
Organizes methods with vtable order first, then remaining methods.
|
||||
Also handles dependencies by generating classes for missing types.
|
||||
"""
|
||||
# Get vtable methods
|
||||
vtable_entries = get_vtable_order(target_class)
|
||||
vtable_methods = []
|
||||
if vtable_entries:
|
||||
vtable_methods = parse_vtable_functions(vtable_entries, target_class)
|
||||
else:
|
||||
idaapi.msg(f"No vtable entries found for {target_class}. Generating normal header.\n")
|
||||
|
||||
# Get non-vtable methods
|
||||
vtable_names = {m["function_name"] for m in vtable_methods}
|
||||
normal_methods = [
|
||||
f for f in parsed_functions
|
||||
if f["type"] == "method"
|
||||
and f["class_name"] == target_class
|
||||
and f["function_name"] not in vtable_names
|
||||
and "virtual" not in f["return_type"]
|
||||
]
|
||||
|
||||
# Combine methods: vtable first, then the rest
|
||||
combined_methods = vtable_methods + normal_methods
|
||||
|
||||
# Generate the class definition
|
||||
class_def = generate_class_definition(target_class, combined_methods)
|
||||
|
||||
# Extract custom types used by this class
|
||||
custom_types = extract_custom_types_from_functions(combined_methods, target_class)
|
||||
missing_types = {
|
||||
(decl, full_name)
|
||||
for (decl, full_name) in custom_types
|
||||
if not search_for_class_definition(PROJECT_FOLDER, full_name)
|
||||
}
|
||||
|
||||
# Process missing classes - generate definitions for those with virtual/exported functions
|
||||
dependent_class_defs, types_to_forward_declare = process_missing_classes(missing_types)
|
||||
|
||||
# Generate forward declarations for remaining types
|
||||
forward_decls = build_forward_declarations(types_to_forward_declare)
|
||||
|
||||
# Combine all parts of the header
|
||||
header_parts = ["#pragma once"]
|
||||
|
||||
# Add dependent class definitions
|
||||
if dependent_class_defs:
|
||||
for class_def in dependent_class_defs:
|
||||
# Remove the #pragma once from dependent class definitions
|
||||
clean_def = class_def.replace("#pragma once", "").strip()
|
||||
if clean_def:
|
||||
header_parts.append("\n" + clean_def)
|
||||
|
||||
# Add forward declarations
|
||||
if forward_decls:
|
||||
header_parts.append("\n" + forward_decls)
|
||||
|
||||
# Add the main class definition
|
||||
header_parts.append("\n" + class_def)
|
||||
|
||||
return "".join(header_parts)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Main functionality
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Global cache of parsed functions by class name
|
||||
parsed_functions_by_class = {}
|
||||
all_functions_parsed = False
|
||||
|
||||
def collect_function_signatures(target_class=None):
|
||||
"""
|
||||
Collect and parse all function signatures from the IDA database.
|
||||
If target_class is provided, only return functions for that class.
|
||||
Caches results for better performance on subsequent calls.
|
||||
"""
|
||||
global parsed_functions_by_class, all_functions_parsed
|
||||
|
||||
# If we haven't parsed all functions yet, do it now
|
||||
if not all_functions_parsed:
|
||||
# Iterate over all functions in the database
|
||||
for ea in idautils.Functions():
|
||||
# Get function name and try to demangle it
|
||||
name = idc.get_name(ea)
|
||||
demangled = idaapi.demangle_name(name, idaapi.MNG_LONG_FORM)
|
||||
|
||||
if demangled is None:
|
||||
continue
|
||||
|
||||
signature = demangled.strip()
|
||||
parsed_func = parse_function_signature(signature)
|
||||
|
||||
if parsed_func and "class_name" in parsed_func:
|
||||
class_name = parsed_func["class_name"]
|
||||
if class_name not in parsed_functions_by_class:
|
||||
parsed_functions_by_class[class_name] = []
|
||||
parsed_functions_by_class[class_name].append(parsed_func)
|
||||
|
||||
all_functions_parsed = True
|
||||
|
||||
# Return the requested functions
|
||||
if target_class is None:
|
||||
# Return all parsed functions
|
||||
all_functions = []
|
||||
for funcs in parsed_functions_by_class.values():
|
||||
all_functions.extend(funcs)
|
||||
return all_functions
|
||||
else:
|
||||
# Return only functions for the specified class
|
||||
return parsed_functions_by_class.get(target_class, [])
|
||||
|
||||
def export_class_header(target_class):
|
||||
"""Generate and save a C++ header file for the target class."""
|
||||
global processed_classes
|
||||
|
||||
# Reset the processed classes set
|
||||
processed_classes = set()
|
||||
|
||||
# Add the target class to processed classes to prevent recursion
|
||||
processed_classes.add(target_class)
|
||||
|
||||
# Get parsed function signatures
|
||||
parsed_functions = collect_function_signatures(target_class)
|
||||
|
||||
if not parsed_functions:
|
||||
ida_kernwin.msg("No matching function signatures were found in the database.\n")
|
||||
return False
|
||||
|
||||
# Generate header code
|
||||
header_code = generate_header_for_class(target_class, parsed_functions)
|
||||
|
||||
# Write header to file
|
||||
output_filename = f"{target_class}.h"
|
||||
try:
|
||||
with open(output_filename, 'w') as header_file:
|
||||
header_file.write(header_code)
|
||||
ida_kernwin.msg(f"Header file '{output_filename}' created successfully.\n")
|
||||
|
||||
# Report how many additional classes were included
|
||||
additional_classes = len(processed_classes) - 1
|
||||
if additional_classes > 0:
|
||||
ida_kernwin.msg(f"Included definitions for {additional_classes} additional dependent classes.\n")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
ida_kernwin.msg(f"Error writing header file '{output_filename}': {e}\n")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Main entry point for the script."""
|
||||
# Default target class for testing
|
||||
target_class = "IModelObject"
|
||||
|
||||
# Uncomment to ask user for target class
|
||||
#target_class = ida_kernwin.ask_str("", 0, "Enter target class name:")
|
||||
|
||||
if not target_class:
|
||||
ida_kernwin.msg("No target class specified. Aborting.\n")
|
||||
return
|
||||
|
||||
breakpoint()
|
||||
export_class_header(target_class)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# IDA plugin integration
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
class ExportClassToCPPH(idaapi.plugin_t):
|
||||
"""IDA Pro plugin for exporting C++ class definitions to header files."""
|
||||
flags = idaapi.PLUGIN_UNL
|
||||
comment = "Extract exported and virtual functions and generate a C++ header"
|
||||
help = "Extracts exported and virtual functions and generates a C++ header"
|
||||
wanted_name = "Export Class to C++ Header"
|
||||
wanted_hotkey = "Shift-F"
|
||||
|
||||
def init(self):
|
||||
idaapi.msg(f"[DEBUG] Initializing \"{self.wanted_name}\" Plugin\n")
|
||||
return idaapi.PLUGIN_OK
|
||||
|
||||
def run(self, arg):
|
||||
idaapi.msg(f"[DEBUG] Running \"{self.wanted_name}\" Plugin\n")
|
||||
main()
|
||||
|
||||
def term(self):
|
||||
idaapi.msg(f"[DEBUG] Terminating \"{self.wanted_name}\" Plugin\n")
|
||||
pass
|
||||
|
||||
def PLUGIN_ENTRY():
|
||||
idaapi.msg(f"[DEBUG] Creating \"Export Class to C++ Header\" Plugin entry\n")
|
||||
return ExportClassToCPPH()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
File diff suppressed because it is too large
Load Diff
@ -1,273 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace Anim {
|
||||
class IPoseElement;
|
||||
}
|
||||
|
||||
namespace Audio {
|
||||
struct SAudioEventExtraData;
|
||||
struct SAudioEventExtraDataID;
|
||||
}
|
||||
|
||||
namespace COFlags {
|
||||
enum TYPE;
|
||||
}
|
||||
|
||||
namespace EBones {
|
||||
enum TYPE;
|
||||
}
|
||||
|
||||
namespace EObjectToSimpleObjectsQueryResult {
|
||||
enum TYPE;
|
||||
}
|
||||
|
||||
namespace LodDissolves {
|
||||
union SState;
|
||||
}
|
||||
|
||||
namespace cbs {
|
||||
class CEntity;
|
||||
class CPointer;
|
||||
}
|
||||
|
||||
struct AnimEventInfo;
|
||||
class CHierarchyElement;
|
||||
class CModelObject;
|
||||
class CRTTI;
|
||||
class IAnimBind;
|
||||
class ICoSkeleton;
|
||||
class IGSObject;
|
||||
class IMpc;
|
||||
class ISGChunk;
|
||||
struct SCollision;
|
||||
struct SMeshVisibilityParams;
|
||||
struct SSurfParams;
|
||||
struct TAnimId;
|
||||
class aabb;
|
||||
class extents;
|
||||
struct uint4;
|
||||
|
||||
class __declspec(dllimport) IModelObject {
|
||||
public:
|
||||
__cdecl IModelObject(void);
|
||||
__cdecl IModelObject(class IModelObject const&);
|
||||
virtual ~IModelObject(void);
|
||||
void AdjustExtentsToAllElements(bool, bool);
|
||||
virtual void AllowSkinsToModifyElementFlags(int, bool);
|
||||
class Anim::IPoseElement* AnimGetMeshPoseElement(void);
|
||||
class Anim::IPoseElement const* AnimGetMeshPoseElement(void) const;
|
||||
class Anim::IPoseElement* AnimGetModelObjectMorphPoseElement(void);
|
||||
class Anim::IPoseElement const* AnimGetModelObjectMorphPoseElement(void) const;
|
||||
class Anim::IPoseElement* AnimGetModelObjectPoseElement(void);
|
||||
class Anim::IPoseElement const* AnimGetModelObjectPoseElement(void) const;
|
||||
bool AnimReInit(class ttl::string_base<char> const&);
|
||||
virtual bool AreSkinsAllowedToModifyElementFlags(int) const;
|
||||
virtual unsigned int AttachAudioEvent(int, class ttl::string_base<char> const&, struct Audio::SAudioEventExtraData const*, class vec3 const&);
|
||||
virtual void AttachChildToMeshElement(class IControlObject*, int, bool);
|
||||
virtual enum EObjectToSimpleObjectsQueryResult::TYPE CanGoToSimpleObjectsEditor(void) const;
|
||||
virtual bool CharacterPresetExists(class ttl::string_base<char> const&) const;
|
||||
static void CollectMeshSkins(class ttl::string_base<char> const&, bool, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&);
|
||||
void CollectUsedTextures(class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&);
|
||||
void CopyElementsPosition(class IModelObject*);
|
||||
virtual void DebugRenderElementBoxes(void);
|
||||
void DissolveObject(bool);
|
||||
virtual void DissolveObjectProgress(float, bool);
|
||||
void DumpAnims(void);
|
||||
virtual void ElementSetWorldMatrixFromQuatPos(int, class vec3 const&, float, class vec3 const&);
|
||||
virtual bool EnableCollisionsElement(int, bool);
|
||||
bool EnableElementPhysics(int, bool, bool);
|
||||
virtual bool EnableElementTraceColl(int, bool);
|
||||
void EnableHierarchySerialization(bool);
|
||||
virtual void EnableMotionBlur(bool);
|
||||
virtual void EnableRendering(bool);
|
||||
void EnableRenderingRayTracing(bool);
|
||||
void EnableRenderingScene(bool);
|
||||
void EnableRenderingShadows(bool);
|
||||
void EnableUpdateExtents(bool);
|
||||
virtual void ExecuteAnimActions(int, int, struct TAnimId, void const*, unsigned int);
|
||||
virtual void ForceUpdateAnimations(void);
|
||||
virtual void FromUpForwardPosElementLocal(int, class vec3 const&, class vec3 const&, class vec3 const&);
|
||||
virtual void FromUpForwardPosElementWorld(int, class vec3 const&, class vec3 const&, class vec3 const&);
|
||||
virtual void GatherMeshAndSkinName(class ttl::string_base<char>&, class ttl::string_base<char>&) const;
|
||||
class aabb const& GetAABBExtents(void) const;
|
||||
virtual class IAnimBind* GetAnimBind(void);
|
||||
virtual class IAnimBind const* GetAnimBind(void) const;
|
||||
virtual float GetAnimCurrentTime(struct TAnimId);
|
||||
virtual float GetAnimLength(class ttl::string_base<char> const&) const;
|
||||
virtual float GetAnimLength(struct TAnimId) const;
|
||||
virtual float GetAnimTimeDelta(void) const;
|
||||
virtual class ttl::string_base<char> GetAnimationFile(class ttl::string_base<char> const&) const;
|
||||
virtual struct TAnimId GetAnimationId(class ttl::string_const<char>, bool) const;
|
||||
void GetAnimationNames(class ttl::map<class ttl::string_base<char>, struct TAnimId, struct ttl::less<class ttl::string_base<char>>, class ttl::allocator>&);
|
||||
virtual class vec3 GetBoneDirVector(enum EBones::TYPE) const;
|
||||
virtual enum EBones::TYPE GetBoneIDFromMeshElem(int) const;
|
||||
virtual class vec3 GetBoneJointPos(enum EBones::TYPE) const;
|
||||
virtual class vec3 GetBonePerpVector(enum EBones::TYPE) const;
|
||||
virtual class ttl::string_base<char> GetCharacterName(unsigned int) const;
|
||||
virtual void GetCharacterNames(class ttl::string_base<char>&, class ttl::string_base<char>&);
|
||||
virtual int GetChildrenElementsNumber(int) const;
|
||||
int GetCurrentLOD(void) const;
|
||||
union LodDissolves::SState GetCurrentLodState(void) const;
|
||||
static enum COFlags::TYPE GetDefaultCOFlags(void);
|
||||
virtual int GetElementChild(int) const;
|
||||
virtual class extents GetElementExtentsInWorld(int) const;
|
||||
virtual class extents GetElementExtentsLocal(int) const;
|
||||
virtual unsigned int GetElementFlags(int) const;
|
||||
virtual int GetElementID(unsigned int) const;
|
||||
virtual int GetElementID(char const*) const;
|
||||
virtual int GetElementIDByLowercaseName(char const*) const;
|
||||
virtual int GetElementIndex(char const*) const;
|
||||
virtual void GetElementInvWorldMatrix(int, class mtx34&) const;
|
||||
virtual void GetElementLocalMatrices(int const*, unsigned int, class mtx34*);
|
||||
virtual class mtx34 const& GetElementLocalMatrix(int) const;
|
||||
virtual class vec3 GetElementLocalPos(int) const;
|
||||
virtual class ttl::string_base<char> GetElementName(int) const;
|
||||
virtual char const* GetElementNameCStr(int) const;
|
||||
virtual int GetElementNext(int) const;
|
||||
virtual int GetElementParent(int) const;
|
||||
virtual class extents GetElementReferenceExtents(int) const;
|
||||
virtual class mtx34 const& GetElementWorldMatrix(int) const;
|
||||
virtual class mtx34 GetElementWorldMtx(int) const;
|
||||
virtual class vec3 GetElementWorldPos(int) const;
|
||||
virtual int GetElementsNumber(void) const;
|
||||
char GetForcedAnimLod(void) const;
|
||||
virtual class CHierarchyElement* GetHElement(int) const;
|
||||
virtual float GetLastAnimApplyTime(void) const;
|
||||
virtual float GetLastAnimUpdateTime(void) const;
|
||||
float GetLodDissolveStep(void) const;
|
||||
virtual class vec4 const& GetMeshAttribute(unsigned int) const;
|
||||
virtual class mtx34 const& GetMeshAttributeMtx(unsigned int) const;
|
||||
virtual unsigned int GetMeshAttributesCount(void) const;
|
||||
virtual struct uint4 const& GetMeshColor(void) const;
|
||||
virtual class vec4 const& GetMeshColor(unsigned int) const;
|
||||
virtual bool GetMeshDataForSimpleObjectsEditor(class ttl::string_base<char>*, class ttl::string_base<char>*, __int64*, __int64*, int*);
|
||||
virtual int GetMeshElemFromBoneID(enum EBones::TYPE) const;
|
||||
void GetMeshElementsMatrices(class ttl::vector<class mtx34, class ttl::vector_allocators::heap_allocator<class mtx34>, 0>&) const;
|
||||
unsigned int GetMeshElementsMatricesCount(void) const;
|
||||
int GetMeshElementsState(class ttl::vector<unsigned char, class ttl::vector_allocators::heap_allocator<unsigned char>, 8>&, class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
int GetMeshElementsStateSize(class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
float GetMeshLodDistance(int) const;
|
||||
virtual class ttl::string_const<char> GetMeshName(void) const;
|
||||
struct SMeshVisibilityParams const* GetMeshVisibilityParams(void) const;
|
||||
float GetMeshVisibilityRange(void);
|
||||
static class IModelObject* GetModelObject(class IGSObject*);
|
||||
static class IModelObject* GetModelObject(class cbs::CEntity const*);
|
||||
static class IModelObject const* GetModelObject(class IGSObject const*);
|
||||
static class CRTTI const* GetNativeClass(void);
|
||||
unsigned int GetNumCollisionHullFaces(void) const;
|
||||
unsigned int GetNumCollisionHullPrimitives(void) const;
|
||||
unsigned int GetNumCollisionHullVertices(void) const;
|
||||
unsigned int GetNumSurfaceParams(void) const;
|
||||
unsigned int GetNumTraceHullFaces(void) const;
|
||||
unsigned int GetNumTraceHullPrimitives(void) const;
|
||||
unsigned int GetNumTraceHullVertices(void) const;
|
||||
virtual class cbs::CPointer<class ICoSkeleton> GetSkeleton(void) const;
|
||||
class ttl::string_const<char> GetSkin(void) const;
|
||||
virtual unsigned int GetSkinCount(void) const;
|
||||
virtual __int64 GetSkinMustHaveTags(void) const;
|
||||
virtual __int64 GetSkinMustNotHaveTags(void) const;
|
||||
virtual class ttl::string_const<char> GetSkinName(void) const;
|
||||
virtual void GetSkinName(unsigned int, class ttl::string_base<char>&) const;
|
||||
virtual int GetSkinSeed(void) const;
|
||||
static __int64 GetSkinTagsFromStr(char const*);
|
||||
struct SSurfParams* GetSurfaceParams(void) const;
|
||||
int GetTraceCollType(void) const;
|
||||
bool GetValidSkinsEditor(class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>&) const;
|
||||
virtual float GetWaterCurrentSpeed(void);
|
||||
virtual class mtx34 const& GetWorldXform(void) const;
|
||||
virtual bool HideElement(int);
|
||||
virtual void HideElementsByMask(bool, class ttl::string_base<char> const&);
|
||||
virtual bool InitAnimSeqFile(class ttl::string_base<char> const&);
|
||||
virtual bool IsBiped(void) const;
|
||||
bool IsDefaultMeshLoaded(void);
|
||||
virtual bool IsElementABone(int);
|
||||
virtual bool IsElementCollsionsEnabled(int);
|
||||
virtual bool IsElementHidden(int) const;
|
||||
bool IsElementIDValid(int) const;
|
||||
bool IsElementPhysicsEnabled(int);
|
||||
virtual bool IsElementTraceCollEnabled(int);
|
||||
bool IsObjectDissolved(void) const;
|
||||
virtual bool IsRenderable(void) const;
|
||||
void LoadMesh(bool);
|
||||
void LoadMeshElements(class ISGChunk*);
|
||||
int MT_GetCount(void);
|
||||
char const* MT_GetName(unsigned int);
|
||||
float MT_WeightGet(unsigned int);
|
||||
static bool MeshAndSkinExists(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
static bool MeshExist(class ttl::string_base<char> const&);
|
||||
void MeshUseDefaultVisibilityParameters(void);
|
||||
void MoveElementBoxSide(int, int, float);
|
||||
void MoveElementBoxSides(int, class vec3 const&, class vec3 const&);
|
||||
void MoveElementBoxSides(int, float, float, float, float, float, float);
|
||||
virtual void OnAnimBindDestroyed(void);
|
||||
virtual void OnAnimEvent(struct AnimEventInfo const&);
|
||||
virtual void OnMpcCreated(class IMpc*);
|
||||
virtual unsigned int PlayAudioEvent(class ttl::string_base<char> const&, struct Audio::SAudioEventExtraData const*, class vec3 const&, class vec3 const&);
|
||||
virtual unsigned int PlayAudioEvent(unsigned int, struct Audio::SAudioEventExtraDataID const*, class vec3 const&, class vec3 const&);
|
||||
virtual class vec3 PointLocalToWorld(int, class vec3 const&);
|
||||
virtual class vec3 PointWorldToLocal(int, class vec3 const&);
|
||||
bool RaytestMe(class vec3 const&, class vec3&, unsigned short, bool, unsigned short);
|
||||
bool RaytraceMe(struct SCollision*, class vec3 const&, class vec3&, unsigned short, bool, unsigned short);
|
||||
bool ReplaceMaterial(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
void ResetBoneAndDescendantsToReferenceFrame(int);
|
||||
void ResetBonesExtentsToReferenceFrame(void);
|
||||
void ResetBonesToReferenceFrame(bool);
|
||||
void ResetElementsDescendantsToReferenceFrame(int);
|
||||
virtual void RestoreAnimationUpdateAbility(bool const&, class ttl::vector<bool, class ttl::vector_allocators::heap_allocator<bool>, 8> const&);
|
||||
virtual void RotateElement(int, class vec3 const&, float);
|
||||
void SaveMeshElements(class ISGChunk*);
|
||||
virtual void SetAudioEventSwitch(unsigned int, class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
void SetBestGeomLods(void);
|
||||
virtual void SetBoneOrientation(unsigned char, class vec3 const&, class vec3 const&);
|
||||
virtual void SetCharacterNames(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
void SetDontApplyAnim(bool);
|
||||
virtual void SetElementExtentsLocal(class extents const&, int);
|
||||
virtual void SetElementLocalMatrices(int const*, unsigned int, class mtx34 const*);
|
||||
virtual void SetElementLocalMatrix(int, class mtx34 const&);
|
||||
virtual void SetElementLocalMatrixNoPropagate(int, class mtx34 const&);
|
||||
virtual void SetElementLocalPos(int, class vec3 const&);
|
||||
virtual void SetElementWorldMatrix(int, class mtx34 const&);
|
||||
virtual void SetElementWorldMatrixNoPropagate(int, class mtx34 const&);
|
||||
virtual void SetElementWorldPos(int, class vec3 const&);
|
||||
virtual void SetEngineObject(class CGSObject*);
|
||||
void SetExtentsLocal(class extents const&);
|
||||
void SetForcedAnimLod(char);
|
||||
virtual void SetInitializeMesh(bool);
|
||||
void SetLodDissolveStep(float);
|
||||
void SetLodStateForSpawnedObjects(union LodDissolves::SState);
|
||||
virtual void SetMeshAttribute(unsigned int, class vec4 const&);
|
||||
virtual void SetMeshAttributeMtx(unsigned int, class mtx34 const&);
|
||||
virtual void SetMeshColor(struct uint4 const&);
|
||||
virtual void SetMeshColor(unsigned int, class vec4 const&);
|
||||
void SetMeshCullSizeEnable(bool);
|
||||
bool SetMeshElementsMatrices(class ttl::vector<class mtx34, class ttl::vector_allocators::heap_allocator<class mtx34>, 0> const&);
|
||||
int SetMeshElementsState(class ttl::vector<unsigned char, class ttl::vector_allocators::heap_allocator<unsigned char>, 8> const&, class ttl::vector<int, class ttl::vector_allocators::heap_allocator<int>, 2> const&, bool, bool);
|
||||
void SetMeshLodDistance(int, float);
|
||||
virtual void SetMeshName(class ttl::string_const<char>);
|
||||
void SetMeshVisibilityRange(float);
|
||||
virtual void SetPivotPointFromElement(int);
|
||||
bool SetSkin(void);
|
||||
virtual void SetSkinMustHaveTags(__int64);
|
||||
virtual void SetSkinMustNotHaveTags(__int64);
|
||||
virtual void SetSkinName(class ttl::string_const<char>);
|
||||
bool SetSkinNoCharacterPreset(void);
|
||||
virtual void SetSkinSeed(int);
|
||||
void SetTraceCollType(int);
|
||||
virtual void SetupMeshPartClothSet(bool, bool, class ttl::vector<class ttl::string_base<char>, class ttl::vector_allocators::heap_allocator<class ttl::string_base<char>>, 1>*);
|
||||
bool ShouldApplyAnim(void) const;
|
||||
void ShowCollisionHull(bool);
|
||||
void ShowElementBox(class ttl::string_base<char> const&);
|
||||
void ShowElementBoxes(bool);
|
||||
void ShowElementBoxesFrom(class ttl::string_base<char> const&);
|
||||
void ShowElementBoxesFromTo(class ttl::string_base<char> const&, class ttl::string_base<char> const&);
|
||||
void ShowElementBoxesTo(class ttl::string_base<char> const&);
|
||||
void ShowExtents(bool);
|
||||
bool SkinExists(class ttl::string_base<char> const&);
|
||||
virtual void StopAnimActions(int, struct TAnimId, void const*, float);
|
||||
class CModelObject* ToCModelObject(void);
|
||||
class CModelObject const* ToCModelObject(void) const;
|
||||
virtual bool UnhideElement(int);
|
||||
virtual void UnlockAnimationUpdateAbility(bool&, class ttl::vector<bool, class ttl::vector_allocators::heap_allocator<bool>, 8>&);
|
||||
virtual class vec3 VectorLocalToWorld(int, class vec3 const&) const;
|
||||
virtual class vec3 VectorWorldToLocal(int, class vec3 const&);
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,296 @@
|
||||
#pragma once
|
||||
|
||||
namespace Anim {
|
||||
class IPoseElement;
|
||||
}
|
||||
|
||||
namespace Audio {
|
||||
struct SAudioEventExtraData;
|
||||
struct SAudioEventExtraDataID;
|
||||
}
|
||||
|
||||
namespace EBones {
|
||||
enum TYPE;
|
||||
}
|
||||
|
||||
namespace LodDissolves {
|
||||
union SState;
|
||||
}
|
||||
|
||||
namespace cbs {
|
||||
class CEntity;
|
||||
}
|
||||
|
||||
namespace ttl {
|
||||
namespace vector_allocators {
|
||||
class heap_allocator;
|
||||
}
|
||||
|
||||
class allocator;
|
||||
struct less;
|
||||
class map;
|
||||
class string_base;
|
||||
class string_const;
|
||||
class vector;
|
||||
}
|
||||
|
||||
class CGSObject;
|
||||
class IControlObject;
|
||||
class IGSObject;
|
||||
class ISGChunk;
|
||||
struct SCollision;
|
||||
struct SMeshVisibilityParams;
|
||||
struct SSurfParams;
|
||||
struct TAnimId;
|
||||
class aabb;
|
||||
class extents;
|
||||
class mtx34;
|
||||
struct uint4;
|
||||
class vec3;
|
||||
class vec4;
|
||||
|
||||
class __declspec(dllimport) IModelObject {
|
||||
public:
|
||||
virtual void StrippedVFunc0();
|
||||
virtual IAnimBind const* GetAnimBind() const;
|
||||
virtual IAnimBind const* GetAnimBind() const;
|
||||
virtual vec3 VectorLocalToWorld(int, vec3 const&) const;
|
||||
virtual ttl::string_base<char> GetAnimationFile(ttl::string_base<char> const&) const;
|
||||
virtual TAnimId GetAnimationId(ttl::string_const<char>, bool) const;
|
||||
virtual float GetAnimLength(TAnimId) const;
|
||||
virtual float GetAnimLength(ttl::string_base<char> const&) const;
|
||||
virtual void StrippedVFunc1();
|
||||
virtual mtx34 const& GetWorldXform() const;
|
||||
virtual int GetElementIndex(char const*) const;
|
||||
virtual ttl::string_base<char> GetElementName(int) const;
|
||||
virtual int GetElementsNumber() const;
|
||||
virtual unsigned int GetElementFlags(int) const;
|
||||
virtual mtx34 GetElementWorldMtx(int) const;
|
||||
virtual vec3 GetElementWorldPos(int) const;
|
||||
virtual int GetMeshElemFromBoneID(EBones::TYPE) const;
|
||||
virtual extents GetElementExtentsInWorld(int) const;
|
||||
virtual void StrippedVFunc2();
|
||||
virtual void ExecuteAnimActions(int, int, TAnimId, void const*, unsigned int);
|
||||
virtual void StopAnimActions(int, TAnimId, void const*, float);
|
||||
virtual void StrippedVFunc3();
|
||||
virtual void SetEngineObject(CGSObject*);
|
||||
virtual void StrippedVFunc4();
|
||||
virtual void StrippedVFunc5();
|
||||
virtual void StrippedVFunc6();
|
||||
virtual void StrippedVFunc7();
|
||||
virtual void StrippedVFunc8();
|
||||
virtual void StrippedVFunc9();
|
||||
virtual void StrippedVFunc10();
|
||||
virtual void StrippedVFunc11();
|
||||
virtual void StrippedVFunc12();
|
||||
virtual void StrippedVFunc13();
|
||||
virtual int GetChildrenElementsNumber(int) const;
|
||||
virtual int GetElementParent(int) const;
|
||||
virtual int GetElementChild(int) const;
|
||||
virtual int GetElementNext(int) const;
|
||||
virtual void SetMeshName(ttl::string_const<char>);
|
||||
virtual void SetInitializeMesh(bool);
|
||||
virtual ttl::string_const<char> GetMeshName() const;
|
||||
virtual void StrippedVFunc14();
|
||||
virtual void SetSkinName(ttl::string_const<char>);
|
||||
virtual void StrippedVFunc15();
|
||||
virtual void GetSkinName(unsigned int, ttl::string_base<char>&) const;
|
||||
virtual ttl::string_const<char> GetSkinName() const;
|
||||
virtual void SetSkinSeed(int);
|
||||
virtual int GetSkinSeed() const;
|
||||
virtual __int64 GetSkinMustHaveTags() const;
|
||||
virtual void SetSkinMustHaveTags(__int64);
|
||||
virtual __int64 GetSkinMustNotHaveTags() const;
|
||||
virtual void SetSkinMustNotHaveTags(__int64);
|
||||
virtual unsigned int GetSkinCount() const;
|
||||
virtual void SetCharacterNames(ttl::string_base<char> const&, ttl::string_base<char> const&);
|
||||
virtual bool CharacterPresetExists(ttl::string_base<char> const&) const;
|
||||
virtual void GetCharacterNames(ttl::string_base<char>&, ttl::string_base<char>&);
|
||||
virtual ttl::string_base<char> GetCharacterName(unsigned int) const;
|
||||
virtual void SetMeshColor(uint4 const&);
|
||||
virtual void SetMeshColor(unsigned int, vec4 const&);
|
||||
virtual uint4 const& GetMeshColor() const;
|
||||
virtual vec4 const& GetMeshColor(unsigned int) const;
|
||||
virtual void SetMeshAttribute(unsigned int, vec4 const&);
|
||||
virtual void SetMeshAttributeMtx(unsigned int, mtx34 const&);
|
||||
virtual vec4 const& GetMeshAttribute(unsigned int) const;
|
||||
virtual mtx34 const& GetMeshAttributeMtx(unsigned int) const;
|
||||
virtual unsigned int GetMeshAttributesCount() const;
|
||||
virtual extents GetElementReferenceExtents(int) const;
|
||||
virtual extents GetElementExtentsLocal(int) const;
|
||||
virtual void SetElementExtentsLocal(extents const&, int);
|
||||
virtual int GetElementID(unsigned int) const;
|
||||
virtual int GetElementIDByLowercaseName(char const*) const;
|
||||
virtual int GetElementIndex(char const*) const;
|
||||
virtual char const* GetElementNameCStr(int) const;
|
||||
virtual bool IsBiped() const;
|
||||
virtual bool IsRenderable() const;
|
||||
virtual void SetElementWorldPos(int, vec3 const&);
|
||||
virtual vec3 GetElementLocalPos(int) const;
|
||||
virtual void SetElementLocalPos(int, vec3 const&);
|
||||
virtual void StrippedVFunc16();
|
||||
virtual void StrippedVFunc17();
|
||||
virtual mtx34 const& GetElementLocalMatrix(int) const;
|
||||
virtual void SetElementLocalMatrix(int, mtx34 const&);
|
||||
virtual void SetElementLocalMatrixNoPropagate(int, mtx34 const&);
|
||||
virtual void GetElementLocalMatrices(int const*, unsigned int, mtx34*);
|
||||
virtual void SetElementLocalMatrices(int const*, unsigned int, mtx34 const*);
|
||||
virtual mtx34 const& GetElementWorldMatrix(int) const;
|
||||
virtual void SetElementWorldMatrix(int, mtx34 const&);
|
||||
virtual void SetElementWorldMatrixNoPropagate(int, mtx34 const&);
|
||||
virtual void GetElementInvWorldMatrix(int, mtx34&) const;
|
||||
virtual void StrippedVFunc18();
|
||||
virtual void RotateElement(int, vec3 const&, float);
|
||||
virtual void ElementSetWorldMatrixFromQuatPos(int, vec3 const&, float, vec3 const&);
|
||||
virtual void FromUpForwardPosElementLocal(int, vec3 const&, vec3 const&, vec3 const&);
|
||||
virtual void FromUpForwardPosElementWorld(int, vec3 const&, vec3 const&, vec3 const&);
|
||||
virtual void SetPivotPointFromElement(int);
|
||||
virtual float GetAnimTimeDelta() const;
|
||||
virtual float GetLastAnimUpdateTime() const;
|
||||
virtual float GetLastAnimApplyTime() const;
|
||||
virtual bool InitAnimSeqFile(ttl::string_base<char> const&);
|
||||
virtual void StrippedVFunc19();
|
||||
virtual vec3 GetBoneDirVector(EBones::TYPE) const;
|
||||
virtual vec3 GetBonePerpVector(EBones::TYPE) const;
|
||||
virtual vec3 GetBoneJointPos(EBones::TYPE) const;
|
||||
virtual EBones::TYPE GetBoneIDFromMeshElem(int) const;
|
||||
virtual void AttachChildToMeshElement(IControlObject*, int, bool);
|
||||
virtual CHierarchyElement* GetHElement(int) const;
|
||||
virtual void EnableRendering(bool);
|
||||
virtual void DebugRenderElementBoxes();
|
||||
virtual void ForceUpdateAnimations();
|
||||
virtual unsigned int AttachAudioEvent(int, ttl::string_base<char> const&, Audio::SAudioEventExtraData const*, vec3 const&);
|
||||
virtual unsigned int PlayAudioEvent(unsigned int, Audio::SAudioEventExtraDataID const*, vec3 const&, vec3 const&);
|
||||
virtual unsigned int PlayAudioEvent(ttl::string_base<char> const&, Audio::SAudioEventExtraData const*, vec3 const&, vec3 const&);
|
||||
virtual void SetAudioEventSwitch(unsigned int, ttl::string_base<char> const&, ttl::string_base<char> const&);
|
||||
virtual vec3 PointLocalToWorld(int, vec3 const&);
|
||||
virtual vec3 PointWorldToLocal(int, vec3 const&);
|
||||
virtual vec3 VectorWorldToLocal(int, vec3 const&);
|
||||
virtual void HideElementsByMask(bool, ttl::string_base<char> const&);
|
||||
virtual bool HideElement(int);
|
||||
virtual bool UnhideElement(int);
|
||||
virtual bool IsElementHidden(int) const;
|
||||
virtual void StrippedVFunc20();
|
||||
virtual void StrippedVFunc21();
|
||||
virtual void StrippedVFunc22();
|
||||
virtual void StrippedVFunc23();
|
||||
virtual void StrippedVFunc24();
|
||||
virtual void StrippedVFunc25();
|
||||
virtual void StrippedVFunc26();
|
||||
virtual void StrippedVFunc27();
|
||||
virtual void StrippedVFunc28();
|
||||
virtual void StrippedVFunc29();
|
||||
virtual void StrippedVFunc30();
|
||||
virtual void UnlockAnimationUpdateAbility(bool&, ttl::vector<bool, ttl::vector_allocators::heap_allocator<bool>, 8>&);
|
||||
virtual void RestoreAnimationUpdateAbility(bool const&, ttl::vector<bool, ttl::vector_allocators::heap_allocator<bool>, 8> const&);
|
||||
virtual bool EnableCollisionsElement(int, bool);
|
||||
virtual bool IsElementCollsionsEnabled(int);
|
||||
virtual bool AreSkinsAllowedToModifyElementFlags(int) const;
|
||||
virtual void AllowSkinsToModifyElementFlags(int, bool);
|
||||
virtual bool EnableElementTraceColl(int, bool);
|
||||
virtual bool IsElementTraceCollEnabled(int);
|
||||
virtual bool IsElementABone(int);
|
||||
virtual void SetupMeshPartClothSet(bool, bool, ttl::vector<ttl::string_base<char>, ttl::vector_allocators::heap_allocator<ttl::string_base<char>>, 1>*);
|
||||
virtual void StrippedVFunc31();
|
||||
virtual void StrippedVFunc32();
|
||||
virtual void StrippedVFunc33();
|
||||
virtual void DissolveObjectProgress(float, bool);
|
||||
virtual void GatherMeshAndSkinName(ttl::string_base<char>&, ttl::string_base<char>&) const;
|
||||
virtual void EnableMotionBlur(bool);
|
||||
virtual void StrippedVFunc34();
|
||||
virtual bool GetMeshDataForSimpleObjectsEditor(ttl::string_base<char>*, ttl::string_base<char>*, __int64*, __int64*, int*);
|
||||
virtual void StrippedVFunc35();
|
||||
virtual void StrippedVFunc36();
|
||||
protected: IModelObject();
|
||||
public: IModelObject(IModelObject const&);
|
||||
void MoveElementBoxSides(int, vec3 const&, vec3 const&);
|
||||
void AdjustExtentsToAllElements(bool, bool);
|
||||
Anim::IPoseElement const* AnimGetMeshPoseElement() const;
|
||||
Anim::IPoseElement const* AnimGetModelObjectMorphPoseElement() const;
|
||||
Anim::IPoseElement const* AnimGetModelObjectPoseElement() const;
|
||||
bool AnimReInit(ttl::string_base<char> const&);
|
||||
static void CollectMeshSkins(ttl::string_base<char> const&, bool, ttl::vector<ttl::string_base<char>, ttl::vector_allocators::heap_allocator<ttl::string_base<char>>, 1>&);
|
||||
void CollectUsedTextures(ttl::vector<ttl::string_base<char>, ttl::vector_allocators::heap_allocator<ttl::string_base<char>>, 1>&);
|
||||
void CopyElementsPosition(IModelObject*);
|
||||
void DumpAnims();
|
||||
bool EnableElementPhysics(int, bool, bool);
|
||||
void EnableHierarchySerialization(bool);
|
||||
void EnableRenderingRayTracing(bool);
|
||||
void EnableRenderingScene(bool);
|
||||
void EnableRenderingShadows(bool);
|
||||
void EnableUpdateExtents(bool);
|
||||
aabb const& GetAABBExtents() const;
|
||||
void GetAnimationNames(ttl::map<ttl::string_base<char>, TAnimId, ttl::less<ttl::string_base<char>>, ttl::allocator>&);
|
||||
static COFlags::TYPE GetDefaultCOFlags();
|
||||
int GetCurrentLOD() const;
|
||||
LodDissolves::SState GetCurrentLodState() const;
|
||||
char GetForcedAnimLod() const;
|
||||
float GetLodDissolveStep() const;
|
||||
void GetMeshElementsMatrices(ttl::vector<mtx34, ttl::vector_allocators::heap_allocator<mtx34>, 0>&) const;
|
||||
unsigned int GetMeshElementsMatricesCount() const;
|
||||
int GetMeshElementsState(ttl::vector<unsigned char, ttl::vector_allocators::heap_allocator<unsigned char>, 8>&, ttl::vector<int, ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
int GetMeshElementsStateSize(ttl::vector<int, ttl::vector_allocators::heap_allocator<int>, 2> const&) const;
|
||||
float GetMeshLodDistance(int) const;
|
||||
SMeshVisibilityParams const* GetMeshVisibilityParams() const;
|
||||
float GetMeshVisibilityRange();
|
||||
static IModelObject* GetModelObject(IGSObject*);
|
||||
static IModelObject* GetModelObject(cbs::CEntity const*);
|
||||
static IModelObject const* GetModelObject(IGSObject const*);
|
||||
unsigned int GetNumCollisionHullFaces() const;
|
||||
unsigned int GetNumCollisionHullPrimitives() const;
|
||||
unsigned int GetNumCollisionHullVertices() const;
|
||||
unsigned int GetNumSurfaceParams() const;
|
||||
unsigned int GetNumTraceHullFaces() const;
|
||||
unsigned int GetNumTraceHullPrimitives() const;
|
||||
unsigned int GetNumTraceHullVertices() const;
|
||||
ttl::string_const<char> GetSkin() const;
|
||||
static __int64 GetSkinTagsFromStr(char const*);
|
||||
SSurfParams* GetSurfaceParams() const;
|
||||
int GetTraceCollType() const;
|
||||
bool GetValidSkinsEditor(ttl::vector<ttl::string_base<char>, ttl::vector_allocators::heap_allocator<ttl::string_base<char>>, 1>&, ttl::vector<ttl::string_base<char>, ttl::vector_allocators::heap_allocator<ttl::string_base<char>>, 1>&) const;
|
||||
bool IsDefaultMeshLoaded();
|
||||
bool IsElementIDValid(int) const;
|
||||
bool IsElementPhysicsEnabled(int);
|
||||
bool IsObjectDissolved() const;
|
||||
void LoadMesh(bool);
|
||||
void LoadMeshElements(ISGChunk*);
|
||||
int MT_GetCount();
|
||||
char const* MT_GetName(unsigned int);
|
||||
float MT_WeightGet(unsigned int);
|
||||
static bool MeshAndSkinExists(ttl::string_base<char> const&, ttl::string_base<char> const&);
|
||||
static bool MeshExist(ttl::string_base<char> const&);
|
||||
void MeshUseDefaultVisibilityParameters();
|
||||
void MoveElementBoxSide(int, int, float);
|
||||
void MoveElementBoxSides(int, float, float, float, float, float, float);
|
||||
bool RaytestMe(vec3 const&, vec3&, unsigned short, bool, unsigned short);
|
||||
bool RaytraceMe(SCollision*, vec3 const&, vec3&, unsigned short, bool, unsigned short);
|
||||
bool ReplaceMaterial(ttl::string_base<char> const&, ttl::string_base<char> const&);
|
||||
void ResetBoneAndDescendantsToReferenceFrame(int);
|
||||
void ResetBonesExtentsToReferenceFrame();
|
||||
void ResetBonesToReferenceFrame(bool);
|
||||
void ResetElementsDescendantsToReferenceFrame(int);
|
||||
void SaveMeshElements(ISGChunk*);
|
||||
void SetBestGeomLods();
|
||||
void SetDontApplyAnim(bool);
|
||||
void SetExtentsLocal(extents const&);
|
||||
void SetForcedAnimLod(char);
|
||||
void SetLodDissolveStep(float);
|
||||
void SetLodStateForSpawnedObjects(LodDissolves::SState);
|
||||
void SetMeshCullSizeEnable(bool);
|
||||
bool SetMeshElementsMatrices(ttl::vector<mtx34, ttl::vector_allocators::heap_allocator<mtx34>, 0> const&);
|
||||
int SetMeshElementsState(ttl::vector<unsigned char, ttl::vector_allocators::heap_allocator<unsigned char>, 8> const&, ttl::vector<int, ttl::vector_allocators::heap_allocator<int>, 2> const&, bool, bool);
|
||||
void SetMeshLodDistance(int, float);
|
||||
void SetMeshVisibilityRange(float);
|
||||
bool SetSkin();
|
||||
bool SetSkinNoCharacterPreset();
|
||||
void SetTraceCollType(int);
|
||||
bool ShouldApplyAnim() const;
|
||||
void ShowCollisionHull(bool);
|
||||
void ShowElementBox(ttl::string_base<char> const&);
|
||||
void ShowElementBoxes(bool);
|
||||
void ShowElementBoxesFrom(ttl::string_base<char> const&);
|
||||
void ShowElementBoxesFromTo(ttl::string_base<char> const&, ttl::string_base<char> const&);
|
||||
void ShowElementBoxesTo(ttl::string_base<char> const&);
|
||||
void ShowExtents(bool);
|
||||
bool SkinExists(ttl::string_base<char> const&);
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,282 +0,0 @@
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
# Global variable for the project folder—set this to your project's path as needed.
|
||||
PROJECT_FOLDER = "D:\PROJECTS\Visual Studio\EGameSDK\EGameSDK\include"
|
||||
|
||||
def fix_spacing(s):
|
||||
"""Fix spacing for pointers/references, commas, and angle brackets."""
|
||||
# Remove extra space before '*' or '&'
|
||||
s = re.sub(r'\s+([*&])', r'\1', s)
|
||||
# Ensure each comma is followed by exactly one space.
|
||||
s = re.sub(r'\s*,\s*', ', ', s)
|
||||
# Remove extra space after '<' and before '>'
|
||||
s = re.sub(r'<\s+', '<', s)
|
||||
s = re.sub(r'\s+>', '>', s)
|
||||
s = s.strip()
|
||||
# Collapse multiple spaces into a single space
|
||||
s = re.sub(r'\s+', ' ', s)
|
||||
return s
|
||||
|
||||
def clean_type(s):
|
||||
"""Removes unwanted tokens (__cdecl, __ptr64, class, struct, enum) from a type string,
|
||||
then fixes spacing."""
|
||||
# Remove the unwanted tokens as whole words.
|
||||
s = re.sub(r'\b(__ptr64)\b', '', s)
|
||||
return fix_spacing(s)
|
||||
|
||||
def parse_function_signature(signature):
|
||||
# Match class methods (including templates)
|
||||
match_function = re.match(
|
||||
r"(public:|protected:|private:)?\s*(.*?)\s+(?:__cdecl\s+)?([a-zA-Z_][\w:~<>]*)::([\w~<>]+)\((.*?)\)\s*(const)?", signature
|
||||
)
|
||||
|
||||
# Match global variables (including pointer types)
|
||||
match_global_var = re.match(
|
||||
r"(.*?)\s+(__cdecl\s+)?([\w:~<>]+)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(.*)$", signature
|
||||
)
|
||||
|
||||
# Handle class methods
|
||||
if match_function:
|
||||
access, return_type, class_name, function_name, parameters, const = match_function.groups()
|
||||
return {
|
||||
"type": "method",
|
||||
"access": access.strip() if access else "public",
|
||||
"return_type": return_type.strip(),
|
||||
"class_name": class_name.strip(),
|
||||
"function_name": function_name.strip(),
|
||||
"parameters": parameters.strip(),
|
||||
"const": "const" if const else "", # Capture const if it exists
|
||||
}
|
||||
|
||||
# Handle global variables
|
||||
elif match_global_var:
|
||||
return_type, _, _, var_name, modifiers = match_global_var.groups()
|
||||
return {
|
||||
"type": "global_var",
|
||||
"return_type": return_type.strip(),
|
||||
"var_name": var_name.strip(),
|
||||
"modifiers": modifiers.strip(),
|
||||
}
|
||||
|
||||
# Handle free functions (not in a class)
|
||||
match_free_func = re.match(
|
||||
r"(.*?)\s+(__cdecl\s+)?([\w:~<>]+(?:<[^>]*>)?)\s+([a-zA-Z_][a-zA-Z0-9_]*)\((.*?)\)\s*(const)?", signature
|
||||
)
|
||||
if match_free_func:
|
||||
return_type, _, function_name, parameters, const = match_free_func.groups()
|
||||
return {
|
||||
"type": "free_function",
|
||||
"return_type": return_type.strip(),
|
||||
"function_name": function_name.strip(),
|
||||
"parameters": parameters.strip(),
|
||||
"const": "const" if const else "", # Capture const if it exists
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
def generate_header_for_class(target_class, parsed_functions):
|
||||
header_code = ""
|
||||
# Filter only the methods belonging to the target class.
|
||||
methods = [func for func in parsed_functions if func["type"] == "method" and func["class_name"] == target_class]
|
||||
if methods:
|
||||
header_code += f"class __declspec(dllimport) {target_class} {{\n"
|
||||
header_code += "public:\n"
|
||||
for func in methods:
|
||||
const = " const" if func["const"] else ""
|
||||
rt = (f"{func['return_type']} " if func["return_type"] else "")
|
||||
# Remove unwanted tokens.
|
||||
rt = clean_type(func['return_type'])
|
||||
if rt:
|
||||
rt += " "
|
||||
params = clean_type(func['parameters'])
|
||||
#if params.strip() == "void":
|
||||
#params = ""
|
||||
header_code += f" {rt}{func['function_name']}({params}){const};\n"
|
||||
header_code += "};\n"
|
||||
else:
|
||||
# If no methods were found for the class, generate a minimal empty definition.
|
||||
header_code += f"class __declspec(dllimport) {target_class};\n"
|
||||
return header_code
|
||||
|
||||
def extract_types_from_string(s):
|
||||
# Remove pointer/reference symbols and qualifiers.
|
||||
cleaned = s.replace("*", " ").replace("&", " ")
|
||||
tokens = re.findall(r"[A-Za-z_][\w:]*", cleaned)
|
||||
return tokens
|
||||
|
||||
def extract_custom_types_from_functions(filtered_functions, target_class):
|
||||
custom_types = set()
|
||||
for func in filtered_functions:
|
||||
raw_rt = func.get("return_type", "")
|
||||
tokens_rt = extract_types_from_string(raw_rt)
|
||||
if len(tokens_rt) > 1:
|
||||
if (tokens_rt[0] in ("class", "struct", "enum", "union") and tokens_rt[1] != target_class):
|
||||
custom_types.add((tokens_rt[0], tokens_rt[1]))
|
||||
elif (len(tokens_rt) > 2 and tokens_rt[0] in ("virtual", "static") and tokens_rt[1] in ("class", "struct", "enum", "union") and tokens_rt[2] != target_class):
|
||||
custom_types.add((tokens_rt[1], tokens_rt[2]))
|
||||
if '<' in raw_rt and '>' in raw_rt:
|
||||
inner_contents = re.findall(r'<\s*([^>]+?)\s*>', raw_rt)
|
||||
for content in inner_contents:
|
||||
for part in content.split(','):
|
||||
part = part.strip()
|
||||
tokens_inner = extract_types_from_string(part)
|
||||
if (tokens_inner[0] in ("class", "struct", "enum", "union") and tokens_inner[1] != target_class):
|
||||
custom_types.add((tokens_inner[0], tokens_inner[1]))
|
||||
elif (len(tokens_inner) > 2 and tokens_inner[0] in ("virtual", "static") and tokens_inner[1] in ("class", "struct", "enum", "union") and tokens_inner[2] != target_class):
|
||||
custom_types.add((tokens_inner[1], tokens_inner[2]))
|
||||
|
||||
raw_params = func.get("parameters", "")
|
||||
param_chunks = [chunk.strip() for chunk in raw_params.split(',')]
|
||||
|
||||
for chunk in param_chunks:
|
||||
tokens_params = extract_types_from_string(chunk)
|
||||
if len(tokens_params) > 1:
|
||||
if (tokens_params[0] in ("class", "struct", "enum", "union") and tokens_params[1] != target_class):
|
||||
custom_types.add((tokens_params[0], tokens_params[1]))
|
||||
elif (len(tokens_params) > 2 and tokens_params[0] in ("virtual", "static") and tokens_params[1] in ("class", "struct", "enum", "union") and tokens_params[2] != target_class):
|
||||
custom_types.add((tokens_params[1], tokens_params[2]))
|
||||
if '<' in chunk and '>' in chunk:
|
||||
inner_contents = re.findall(r'<\s*([^>]+?)\s*>', chunk)
|
||||
for content in inner_contents:
|
||||
for part in content.split(','):
|
||||
part = part.strip()
|
||||
tokens_inner = extract_types_from_string(part)
|
||||
if (tokens_inner[0] in ("class", "struct", "enum", "union") and tokens_inner[1] != target_class):
|
||||
custom_types.add((tokens_inner[0], tokens_inner[1]))
|
||||
elif (len(tokens_inner) > 2 and tokens_inner[0] in ("virtual", "static") and tokens_inner[1] in ("class", "struct", "enum", "union") and tokens_inner[2] != target_class):
|
||||
custom_types.add((tokens_inner[1], tokens_inner[2]))
|
||||
|
||||
return custom_types
|
||||
|
||||
def search_for_class_definition(project_folder, full_class_name):
|
||||
"""
|
||||
Searches the given project folder recursively for a file that contains a definition
|
||||
for the specified class/struct/enum/union. This function uses a regex that matches
|
||||
'struct', 'class', 'enum', or 'union' followed by any non-space tokens and then the
|
||||
target name, which is then followed by either a semicolon or an opening brace.
|
||||
For namespaced classes, only the last part is used.
|
||||
"""
|
||||
search_name = full_class_name.split("::")[-1]
|
||||
pattern = re.compile(r'\b(?:struct|class|enum|union)\s+(?:\S+\s+)*' + re.escape(search_name) + r'\b(?=\s*[;{])', re.MULTILINE)
|
||||
for root, dirs, files in os.walk(project_folder):
|
||||
for file in files:
|
||||
if file.endswith(('.h')):
|
||||
file_path = os.path.join(root, file)
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
|
||||
content = f.read()
|
||||
if pattern.search(content):
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error reading {file_path}: {e}")
|
||||
return False
|
||||
|
||||
def is_namespace_type(full_class_name):
|
||||
"""
|
||||
Returns True if full_class_name is namespaced (e.g., 'EBones::TYPE'),
|
||||
otherwise False (e.g., 'IAnimBind').
|
||||
"""
|
||||
return len(full_class_name.split("::")) > 1
|
||||
|
||||
def group_placeholder_definitions(custom_types):
|
||||
ns_groups = defaultdict(list)
|
||||
non_ns = []
|
||||
for decl, full_name in sorted(custom_types, key=lambda x: x[1]):
|
||||
if "::" in full_name:
|
||||
parts = full_name.split("::")
|
||||
ns_key = tuple(parts[:-1])
|
||||
type_name = parts[-1]
|
||||
ns_groups[ns_key].append((decl, type_name))
|
||||
else:
|
||||
non_ns.append((decl, full_name))
|
||||
return ns_groups, non_ns
|
||||
|
||||
def generate_namespace_placeholder(ns_key, type_list):
|
||||
"""
|
||||
Given a namespace key (tuple of namespace parts) and a set of class names,
|
||||
generate a single forward declaration block with nested namespace blocks.
|
||||
"""
|
||||
ns_open = "\n".join(f"namespace {ns} {{" for ns in ns_key)
|
||||
class_defs = "\n".join(f" {decl} {name};" for decl, name in sorted(type_list, key=lambda x: x[1]))
|
||||
ns_close = "\n".join("}" for _ in ns_key)
|
||||
return f"{ns_open}\n{class_defs}\n{ns_close}"
|
||||
|
||||
def build_final_placeholders_string(custom_types):
|
||||
ns_groups, non_ns = group_placeholder_definitions(custom_types)
|
||||
namespace_placeholders = [generate_namespace_placeholder(ns_key, type_list) for ns_key, type_list in ns_groups.items()]
|
||||
class_placeholders = [f"{decl} {name};" for decl, name in sorted(non_ns, key=lambda x: x[1])]
|
||||
|
||||
ns_part = "\n\n".join(namespace_placeholders) if namespace_placeholders else ""
|
||||
cls_part = "\n".join(class_placeholders) if class_placeholders else ""
|
||||
|
||||
if ns_part and cls_part:
|
||||
return ns_part + "\n\n" + cls_part
|
||||
else:
|
||||
return ns_part or cls_part
|
||||
|
||||
def generate_full_header_for_class(target_class, parsed_functions):
|
||||
filtered_functions = [func for func in parsed_functions if func["type"] == "method" and func["class_name"] == target_class]
|
||||
header_content = generate_header_for_class(target_class, filtered_functions)
|
||||
|
||||
# Extract custom types from the filtered functions.
|
||||
custom_types = extract_custom_types_from_functions(filtered_functions, target_class)
|
||||
|
||||
# For each custom type, if not found in the project folder, keep it.
|
||||
missing_custom_types = {(decl, full_name) for decl, full_name in custom_types if not search_for_class_definition(PROJECT_FOLDER, full_name)}
|
||||
|
||||
placeholders_str = build_final_placeholders_string(missing_custom_types)
|
||||
|
||||
if placeholders_str:
|
||||
final_header = placeholders_str + "\n\n" + header_content
|
||||
else:
|
||||
final_header = header_content
|
||||
return f"#pragma once\n\n{final_header}"
|
||||
|
||||
def read_function_signatures_from_file(file_path):
|
||||
"""Reads the function signatures from a file and returns them as a list."""
|
||||
try:
|
||||
with open(file_path, 'r') as file:
|
||||
return file.readlines()
|
||||
except FileNotFoundError:
|
||||
print(f"Error: The file '{file_path}' was not found.")
|
||||
return []
|
||||
except IOError:
|
||||
print(f"Error: Unable to read the file '{file_path}'.")
|
||||
return []
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python script.py <TargetClassName>")
|
||||
return
|
||||
|
||||
target_class = sys.argv[1]
|
||||
file_path = "demangled.txt" # Replace with your file path containing function signatures.
|
||||
function_signatures = read_function_signatures_from_file(file_path)
|
||||
|
||||
if not function_signatures:
|
||||
return
|
||||
|
||||
parsed_functions = []
|
||||
for signature in function_signatures:
|
||||
signature = signature.strip()
|
||||
if signature:
|
||||
parsed_func = parse_function_signature(signature)
|
||||
if parsed_func:
|
||||
parsed_functions.append(parsed_func)
|
||||
|
||||
full_header = generate_full_header_for_class(target_class, parsed_functions)
|
||||
|
||||
# Create the header file named after the target class (e.g., IGame.h)
|
||||
output_filename = f"{target_class}.h"
|
||||
try:
|
||||
with open(output_filename, 'w') as header_file:
|
||||
header_file.write(full_header)
|
||||
print(f"Header file '{output_filename}' created successfully.")
|
||||
except Exception as e:
|
||||
print(f"Error writing header file '{output_filename}': {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
File diff suppressed because it is too large
Load Diff
@ -456,7 +456,21 @@ namespace EGT::Menu {
|
||||
if (ImGui::Checkbox("Enable Player Shadows", &enablePlayerShadows)) {
|
||||
auto player = EGSDK::GamePH::PlayerDI_PH::Get();
|
||||
if (player) {
|
||||
int LOD = player->GetCurrentLOD();
|
||||
float meshVisibilityRange = player->GetMeshVisibilityRange();
|
||||
unsigned int numCollisionHullFaces = player->GetNumCollisionHullFaces();
|
||||
unsigned int numCollisionHullPrimitives = player->GetNumCollisionHullPrimitives();
|
||||
unsigned int numCollisionHullVertices = player->GetNumCollisionHullVertices();
|
||||
unsigned int numSurfaceParams = player->GetNumSurfaceParams();
|
||||
unsigned int numTraceHullFaces = player->GetNumTraceHullFaces();
|
||||
unsigned int numTraceHullPrimitives = player->GetNumTraceHullPrimitives();
|
||||
unsigned int numTraceHullVertices = player->GetNumTraceHullVertices();
|
||||
|
||||
player->EnableRenderingShadows(enablePlayerShadows);
|
||||
player->EnableElementPhysics(0, enablePlayerShadows, enablePlayerShadows);
|
||||
player->EnableRenderingScene(enablePlayerShadows);
|
||||
player->ShowElementBoxes(!enablePlayerShadows);
|
||||
player->ShowExtents(!enablePlayerShadows);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user