write some CKStateChunk code
This commit is contained in:
parent
bf7c669ce6
commit
e450fa532d
|
@ -6,6 +6,8 @@ lost 24 byte, 6 fields or 2 lists
|
|||
Important CK Class size
|
||||
CKObject no change. 0x14(20)
|
||||
CKSceneObject no change 0x1C(28), share Load/Save with CKObject
|
||||
|
||||
CKBehavior no change 0x6C(108)
|
||||
CKBeObject 0x50(80) count 20
|
||||
|
||||
CKGroup 0x68(104) count 26
|
||||
|
@ -39,6 +41,14 @@ CKFileManagerData no change (12)
|
|||
CKStateChunk is 0x28u black box
|
||||
CKBufferParser also is 0x10u black box
|
||||
|
||||
typedef char* CKSTRING;
|
||||
typedef char CKCHAR;
|
||||
typedef int CKBOOL;
|
||||
typedef unsigned char CKBYTE;
|
||||
typedef unsigned int CKDWORD;
|
||||
typedef unsigned short CKWORD;
|
||||
typedef int CKERROR;
|
||||
|
||||
struct CKGUID {
|
||||
DWORD d1,d2;
|
||||
};
|
||||
|
@ -98,6 +108,38 @@ struct XFileObjectsTable {
|
|||
};
|
||||
|
||||
|
||||
struct CKObject {
|
||||
DWORD* vtable;
|
||||
CK_ID m_ID;
|
||||
CKSTRING m_Name;
|
||||
CKDWORD m_ObjectFlags;
|
||||
CKContext *m_Context;
|
||||
};
|
||||
|
||||
struct CKSceneObject : CKObject {
|
||||
XBitArray m_Scenes;
|
||||
};
|
||||
|
||||
struct BehaviorBlockData{};
|
||||
struct BehaviorGraphData{};
|
||||
struct CKBehavior : CKSceneObject {
|
||||
CK_ID m_Owner;
|
||||
CK_ID m_BehParent;
|
||||
XSObjectPointerArray m_InputArray;
|
||||
XSObjectPointerArray m_OutputArray;
|
||||
XSObjectPointerArray m_InParameter;
|
||||
XSObjectPointerArray m_OutParameter;
|
||||
XSObjectPointerArray m_LocalParameter;
|
||||
CK_CLASSID m_CompatibleClassID;
|
||||
int m_Priority;
|
||||
CKDWORD m_Flags;
|
||||
CKStateChunk * m_InterfaceChunk;
|
||||
BehaviorGraphData* m_GraphData;
|
||||
BehaviorBlockData* m_BlockData;
|
||||
float m_LastExecutionTime;
|
||||
CK_ID m_InputTargetParam;
|
||||
};
|
||||
|
||||
struct CKFileInfo
|
||||
{
|
||||
DWORD ProductVersion; // Virtools Version (Dev/Creation). (CK_VIRTOOLS_VERSION)
|
||||
|
@ -180,6 +222,28 @@ struct CKStateChunk {
|
|||
CKFile* m_BindFile;
|
||||
DWORD m_unknow;
|
||||
};
|
||||
struct CKStateChunkRemap { // 0x40 count 16
|
||||
DWORD m_ChunkVersion;
|
||||
DWORD* m_pData;
|
||||
DWORD m_DataDwordSize;
|
||||
DWORD unknow_3;
|
||||
DWORD* m_ObjList_pData;
|
||||
DWORD m_ObjList_Count;
|
||||
DWORD* m_ChkList_pData;
|
||||
DWORD m_ChkList_Count;
|
||||
|
||||
DWORD unknow_8;
|
||||
DWORD unknow_9;
|
||||
DWORD unknow_10;
|
||||
DWORD unknow_11;
|
||||
DWORD unknow_12;
|
||||
DWORD unknow_13;
|
||||
|
||||
CKDependenciesContext* m_DepCtx;
|
||||
CKContext* m_Ctx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct CKBufferParser {
|
||||
char* m_MemBegin;
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace LibCmo {
|
|||
using XClassArray = std::vector<T>;
|
||||
//using CKObjectArray = std::vector<CKObject*>;
|
||||
|
||||
|
||||
struct CKGUID {
|
||||
union {
|
||||
struct {
|
||||
|
|
|
@ -347,6 +347,11 @@ namespace LibCmo {
|
|||
return CKERROR::CKERR_OK;
|
||||
}
|
||||
|
||||
CKERROR CKFile::DeepLoad(CKSTRING u8_filename, CKFileData::DeepDocument** out_doc) {
|
||||
return CKERROR::CKERR_OK;
|
||||
}
|
||||
|
||||
|
||||
//CKERROR CKFile::Load(CKSTRING u8_filename, /*CKObjectArray list, */ CK_LOAD_FLAGS flags) {
|
||||
// CKERROR result = this->OpenFile(u8_filename, flags);
|
||||
// if (result == CKERROR::CKERR_OK || result == CKERROR::CKERR_PLUGINSMISSING) {
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
#include "CKDefines.hpp"
|
||||
#include "CKEnums.hpp"
|
||||
#include "VTEncoding.hpp"
|
||||
#include "VTObjects.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
namespace LibCmo {
|
||||
|
||||
// forward decl to rm recursive reference
|
||||
namespace ObjsImpl { class CKObject; }
|
||||
|
||||
class CKMinContext {
|
||||
public:
|
||||
CKMinContext();
|
||||
|
@ -19,7 +17,7 @@ namespace LibCmo {
|
|||
|
||||
void Printf(CKSTRING fmt, ...);
|
||||
|
||||
ObjsImpl::CKObject* CreateObject(CK_ID id, CKSTRING name);
|
||||
ObjsImpl::CKObject* CreateObject(CK_ID id, CK_CLASSID cls, CKSTRING name);
|
||||
void DestroyObject(ObjsImpl::CKObject* obj);
|
||||
|
||||
void GetUtf8ObjectName(std::string& native_name, std::string& u8_name);
|
||||
|
|
|
@ -9,27 +9,96 @@
|
|||
|
||||
namespace LibCmo {
|
||||
|
||||
#pragma region Ctor Dtor
|
||||
|
||||
CKStateChunk::CKStateChunk() :
|
||||
m_ClassId(CK_CLASSID::CKCID_OBJECT), m_DataDwSize(0u), m_pData(nullptr),
|
||||
m_DataVersion(CK_STATECHUNK_DATAVERSION::CHUNKDATA_CURRENTVERSION), m_ChunkVersion(CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4),
|
||||
m_Parser{ 0u, 0u, 0u },
|
||||
m_Parser{ CKStateChunkStatus::IDLE, 0u, 0u, 0u },
|
||||
m_ObjectList(), m_ChunkList(), m_ManagerList()
|
||||
{
|
||||
;
|
||||
}
|
||||
LibCmo::CKStateChunk::CKStateChunk(CK_CLASSID clsid) :
|
||||
m_ClassId(clsid), m_DataDwSize(0u), m_pData(nullptr),
|
||||
m_DataVersion(CK_STATECHUNK_DATAVERSION::CHUNKDATA_CURRENTVERSION), m_ChunkVersion(CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4),
|
||||
m_Parser{ 0u, 0u, 0u },
|
||||
m_ObjectList(), m_ChunkList(), m_ManagerList()
|
||||
CKStateChunk::CKStateChunk(const CKStateChunk& rhs) :
|
||||
m_ClassId(rhs.m_ClassId), m_DataVersion(rhs.m_DataVersion), m_ChunkVersion(rhs.m_ChunkVersion),
|
||||
m_Parser(rhs.m_Parser),
|
||||
m_ObjectList(rhs.m_ObjectList), m_ManagerList(rhs.m_ManagerList), m_ChunkList(rhs.m_ChunkList),
|
||||
m_pData(nullptr), m_DataDwSize(rhs.m_DataDwSize)
|
||||
{
|
||||
;
|
||||
// copy buffer
|
||||
if (rhs.m_pData != nullptr) {
|
||||
this->m_pData = new(std::nothrow) CKDWORD[rhs.m_DataDwSize];
|
||||
if (this->m_pData != nullptr) {
|
||||
memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
CKStateChunk& CKStateChunk::operator=(const CKStateChunk& rhs) {
|
||||
this->Clear();
|
||||
|
||||
this->m_DataVersion = rhs.m_DataVersion;
|
||||
this->m_ChunkVersion = rhs.m_ChunkVersion;
|
||||
this->m_ClassId = rhs.m_ClassId;
|
||||
|
||||
this->m_Parser = rhs.m_Parser;
|
||||
|
||||
this->m_ObjectList = rhs.m_ObjectList;
|
||||
this->m_ManagerList = rhs.m_ManagerList;
|
||||
this->m_ChunkList = rhs.m_ChunkList;
|
||||
|
||||
// copy buffer
|
||||
if (rhs.m_pData != nullptr) {
|
||||
this->m_pData = new(std::nothrow) CKDWORD[rhs.m_DataDwSize];
|
||||
if (this->m_pData != nullptr) {
|
||||
memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize);
|
||||
}
|
||||
}
|
||||
this->m_DataDwSize = rhs.m_DataDwSize;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CKStateChunk::~CKStateChunk() {
|
||||
if (this->m_pData != nullptr)
|
||||
delete[] this->m_pData;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Misc Funcs
|
||||
|
||||
void CKStateChunk::Clear(void) {
|
||||
this->m_ClassId = CK_CLASSID::CKCID_OBJECT;
|
||||
//this->m_DataVersion = CK_STATECHUNK_DATAVERSION::CHUNK_DEV_2_1;
|
||||
//this->m_ChunkVersion = CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4;
|
||||
|
||||
this->m_Parser.m_CurrentPos = 0;
|
||||
this->m_Parser.m_DataSize = 0;
|
||||
this->m_Parser.m_PrevIdentifierPos = 0;
|
||||
|
||||
this->m_DataDwSize = 0;
|
||||
if (this->m_pData != nullptr) {
|
||||
delete[] this->m_pData;
|
||||
this->m_pData = nullptr;
|
||||
}
|
||||
|
||||
this->m_ObjectList.clear();
|
||||
this->m_ManagerList.clear();
|
||||
this->m_ChunkList.clear();
|
||||
}
|
||||
|
||||
CKDWORD CKStateChunk::GetDataSize(void) {
|
||||
return sizeof(CKDWORD) * this->m_DataDwSize;
|
||||
}
|
||||
|
||||
void LibCmo::CKStateChunk::_EnsureWriteSpace(CKDWORD size) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Buffer Related
|
||||
|
||||
bool CKStateChunk::ConvertFromBuffer(const void* buf) {
|
||||
if (buf == nullptr) return false;
|
||||
|
||||
|
@ -163,6 +232,9 @@ namespace LibCmo {
|
|||
return 0u;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
//bool CKStateChunk::UnPack(CKDWORD DestSize) {
|
||||
// // NOTE: in UnPack. pData store the compressed buffer, and
|
||||
// // dwSize store the length of compressed buffer as CHAR size, not DWORD size!
|
||||
|
@ -192,20 +264,21 @@ namespace LibCmo {
|
|||
// return true;
|
||||
//}
|
||||
|
||||
CKDWORD CKStateChunk::GetDataSize(void) {
|
||||
return sizeof(CKDWORD) * this->m_DataDwSize;
|
||||
}
|
||||
|
||||
bool CKStateChunk::SeekIdentifier(CKDWORD identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CKStateChunk::StartRead(void) {
|
||||
if (this->m_Parser.m_Status != CKStateChunkStatus::IDLE) return;
|
||||
|
||||
this->m_Parser.m_CurrentPos = 0u;
|
||||
this->m_Parser.m_DataSize = this->m_DataDwSize;
|
||||
this->m_Parser.m_PrevIdentifierPos = 0u;
|
||||
this->m_Parser.m_Status = CKStateChunkStatus::READ;
|
||||
}
|
||||
|
||||
void CKStateChunk::ReadString(std::string& strl) {
|
||||
;
|
||||
}
|
||||
|
||||
void LibCmo::CKStateChunk::_EnsureEnoughSpace(CKDWORD size) {
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,23 +8,30 @@ namespace LibCmo {
|
|||
class CKStateChunk {
|
||||
public:
|
||||
CKStateChunk();
|
||||
CKStateChunk(CK_CLASSID clsid);
|
||||
CKStateChunk(const CKStateChunk&) = delete;
|
||||
CKStateChunk& operator=(const CKStateChunk&) = delete;
|
||||
CKStateChunk(const CKStateChunk&);
|
||||
CKStateChunk& operator=(const CKStateChunk&);
|
||||
~CKStateChunk();
|
||||
|
||||
bool ConvertFromOldBuffer(const void* buf, CKDWORD buf_size, CKDWORD blk_size, CK_FILE_WRITEMODE mode);
|
||||
void Clear(void);
|
||||
|
||||
bool ConvertFromBuffer(const void* buf);
|
||||
CKDWORD ConvertToBuffer(void* buf);
|
||||
|
||||
bool UnPack(CKDWORD DestSize);
|
||||
//bool UnPack(CKDWORD DestSize);
|
||||
CKDWORD GetDataSize(void);
|
||||
|
||||
bool SeekIdentifier(CKDWORD identifier);
|
||||
|
||||
void StartRead(void);
|
||||
void ReadString(std::string& strl);
|
||||
|
||||
private:
|
||||
enum class CKStateChunkStatus : int32_t {
|
||||
IDLE,
|
||||
READ,
|
||||
WRITE
|
||||
};
|
||||
|
||||
CK_CLASSID m_ClassId;
|
||||
CKDWORD m_DataDwSize;
|
||||
CKDWORD* m_pData;
|
||||
|
@ -33,6 +40,7 @@ namespace LibCmo {
|
|||
CK_STATECHUNK_CHUNKVERSION m_ChunkVersion;
|
||||
|
||||
struct {
|
||||
CKStateChunkStatus m_Status;
|
||||
CKDWORD m_CurrentPos;
|
||||
CKDWORD m_DataSize;
|
||||
CKDWORD m_PrevIdentifierPos;
|
||||
|
@ -43,8 +51,10 @@ namespace LibCmo {
|
|||
std::vector<CKDWORD> m_ManagerList;
|
||||
|
||||
private:
|
||||
void _EnsureEnoughSpace(CKDWORD size);
|
||||
|
||||
void _EnsureWriteSpace(CKDWORD size);
|
||||
inline bool _EnsureReadSpace(CKDWORD required) {
|
||||
return (this->m_Parser.m_CurrentPos <= this->m_Parser.m_DataSize) && (required <= (this->m_Parser.m_DataSize - this->m_Parser.m_CurrentPos));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -190,6 +190,7 @@
|
|||
<ClInclude Include="CKMinContext.hpp" />
|
||||
<ClInclude Include="CKStateChunk.hpp" />
|
||||
<ClInclude Include="VTEncoding.hpp" />
|
||||
<ClInclude Include="VTManagers.hpp" />
|
||||
<ClInclude Include="VTObjects.hpp" />
|
||||
<ClInclude Include="VTUtils.hpp" />
|
||||
<ClInclude Include="VxMemoryMappedFile.hpp" />
|
||||
|
|
|
@ -80,5 +80,8 @@
|
|||
<ClInclude Include="CKMinContext.hpp">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VTManagers.hpp">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
26
LibCmo/VTManagers.hpp
Normal file
26
LibCmo/VTManagers.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include "CKDefines.hpp"
|
||||
#include "CKEnums.hpp"
|
||||
|
||||
namespace LibCmo {
|
||||
|
||||
// forward decl to rm recursive reference
|
||||
class CKMinContext;
|
||||
class CKStateChunk;
|
||||
|
||||
namespace MgrsImpl {
|
||||
|
||||
class CKBaseManager {
|
||||
public:
|
||||
CKBaseManager();
|
||||
CKBaseManager(const CKBaseManager&) = delete;
|
||||
CKBaseManager& operator=(const CKBaseManager&) = delete;
|
||||
virtual ~CKBaseManager();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
#include "CKDefines.hpp"
|
||||
#include "CKEnums.hpp"
|
||||
#include "CKStateChunk.hpp"
|
||||
|
||||
namespace LibCmo {
|
||||
|
||||
// forward decl to rm recursive reference
|
||||
class CKMinContext;
|
||||
class CKStateChunk;
|
||||
|
||||
namespace ObjsImpl {
|
||||
|
||||
class CKObject {
|
||||
|
|
|
@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
LibCmo::CKFile vtfile(&vtctx);
|
||||
LibCmo::CKFileData::ShallowDocument* doc;
|
||||
LibCmo::CKERROR err = vtfile.ShallowLoad("combining behaviors.cmo", &doc);
|
||||
LibCmo::CKERROR err = vtfile.ShallowLoad("Language.old.nmo", &doc);
|
||||
|
||||
if (doc)
|
||||
Unvirt::StructFormatter::PrintCKFileInfo(doc->m_FileInfo);
|
||||
|
|
|
@ -59,6 +59,31 @@ std::map<intptr_t, MyModuleInfo> ConstructModuleList() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void PrintVTable(std::map<intptr_t, MyModuleInfo>& modules, CKDWORD* pCls, size_t vtable_len, char indent) {
|
||||
if (pCls == nullptr) {
|
||||
fputc('\n', stdout);
|
||||
return;
|
||||
}
|
||||
CKDWORD* vtable = *(reinterpret_cast<CKDWORD**>(pCls));
|
||||
|
||||
for (size_t i = 0; i < vtable_len; ++i) {
|
||||
intptr_t addr = vtable[i];
|
||||
const auto& it = modules.lower_bound(addr);
|
||||
if (it != modules.end() && it != modules.begin()) {
|
||||
const auto& itt = std::prev(it);
|
||||
fprintf(stdout, "%s::", itt->second.ModuleName.c_str());
|
||||
addr = addr - itt->second.BaseOfDll;
|
||||
|
||||
if (itt->second.ModuleName == "CK2_3D.dll")
|
||||
addr += 0x10000000u;
|
||||
else if (itt->second.ModuleName == "CK2.dll")
|
||||
addr += 0x24000000u;
|
||||
}
|
||||
fprintf(stdout, "%08X%c", addr, indent);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
Assert(LoadLibrary("CK2.dll"), "Error loading CK2.dll");
|
||||
|
||||
|
@ -88,141 +113,137 @@ int main() {
|
|||
std::cout << "Press any key to run..." << std::endl;
|
||||
system("pause");
|
||||
|
||||
static std::vector<CK_CLASSID> cls{
|
||||
CKCID_OBJECT,
|
||||
CKCID_PARAMETERIN,
|
||||
CKCID_PARAMETEROPERATION,
|
||||
CKCID_STATE,
|
||||
CKCID_BEHAVIORLINK,
|
||||
CKCID_BEHAVIOR,
|
||||
CKCID_BEHAVIORIO,
|
||||
CKCID_RENDERCONTEXT,
|
||||
CKCID_KINEMATICCHAIN,
|
||||
CKCID_SCENEOBJECT,
|
||||
CKCID_OBJECTANIMATION,
|
||||
CKCID_ANIMATION,
|
||||
CKCID_KEYEDANIMATION,
|
||||
CKCID_BEOBJECT,
|
||||
CKCID_DATAARRAY,
|
||||
CKCID_SCENE,
|
||||
CKCID_LEVEL,
|
||||
CKCID_PLACE,
|
||||
CKCID_GROUP,
|
||||
CKCID_SOUND,
|
||||
CKCID_WAVESOUND,
|
||||
CKCID_MIDISOUND,
|
||||
CKCID_MATERIAL,
|
||||
CKCID_TEXTURE,
|
||||
CKCID_MESH,
|
||||
CKCID_PATCHMESH,
|
||||
CKCID_RENDEROBJECT,
|
||||
CKCID_2DENTITY,
|
||||
CKCID_SPRITE,
|
||||
CKCID_SPRITETEXT,
|
||||
CKCID_3DENTITY,
|
||||
CKCID_GRID,
|
||||
CKCID_CURVEPOINT,
|
||||
CKCID_SPRITE3D,
|
||||
CKCID_CURVE,
|
||||
CKCID_CAMERA,
|
||||
CKCID_TARGETCAMERA,
|
||||
CKCID_LIGHT,
|
||||
CKCID_TARGETLIGHT,
|
||||
CKCID_CHARACTER,
|
||||
CKCID_3DOBJECT,
|
||||
CKCID_BODYPART,
|
||||
CKCID_PARAMETER,
|
||||
CKCID_PARAMETERLOCAL,
|
||||
CKCID_PARAMETERVARIABLE,
|
||||
CKCID_PARAMETEROUT,
|
||||
CKCID_INTERFACEOBJECTMANAGER,
|
||||
CKCID_CRITICALSECTION,
|
||||
CKCID_LAYER,
|
||||
CKCID_PROGRESSIVEMESH,
|
||||
CKCID_SYNCHRO
|
||||
};
|
||||
static std::vector<const char*> clsname{
|
||||
"CKCID_OBJECT",
|
||||
"CKCID_PARAMETERIN",
|
||||
"CKCID_PARAMETEROPERATION",
|
||||
"CKCID_STATE",
|
||||
"CKCID_BEHAVIORLINK",
|
||||
"CKCID_BEHAVIOR",
|
||||
"CKCID_BEHAVIORIO",
|
||||
"CKCID_RENDERCONTEXT",
|
||||
"CKCID_KINEMATICCHAIN",
|
||||
"CKCID_SCENEOBJECT",
|
||||
"CKCID_OBJECTANIMATION",
|
||||
"CKCID_ANIMATION",
|
||||
"CKCID_KEYEDANIMATION",
|
||||
"CKCID_BEOBJECT",
|
||||
"CKCID_DATAARRAY",
|
||||
"CKCID_SCENE",
|
||||
"CKCID_LEVEL",
|
||||
"CKCID_PLACE",
|
||||
"CKCID_GROUP",
|
||||
"CKCID_SOUND",
|
||||
"CKCID_WAVESOUND",
|
||||
"CKCID_MIDISOUND",
|
||||
"CKCID_MATERIAL",
|
||||
"CKCID_TEXTURE",
|
||||
"CKCID_MESH",
|
||||
"CKCID_PATCHMESH",
|
||||
"CKCID_RENDEROBJECT",
|
||||
"CKCID_2DENTITY",
|
||||
"CKCID_SPRITE",
|
||||
"CKCID_SPRITETEXT",
|
||||
"CKCID_3DENTITY",
|
||||
"CKCID_GRID",
|
||||
"CKCID_CURVEPOINT",
|
||||
"CKCID_SPRITE3D",
|
||||
"CKCID_CURVE",
|
||||
"CKCID_CAMERA",
|
||||
"CKCID_TARGETCAMERA",
|
||||
"CKCID_LIGHT",
|
||||
"CKCID_TARGETLIGHT",
|
||||
"CKCID_CHARACTER",
|
||||
"CKCID_3DOBJECT",
|
||||
"CKCID_BODYPART",
|
||||
"CKCID_PARAMETER",
|
||||
"CKCID_PARAMETERLOCAL",
|
||||
"CKCID_PARAMETERVARIABLE",
|
||||
"CKCID_PARAMETEROUT",
|
||||
"CKCID_INTERFACEOBJECTMANAGER",
|
||||
"CKCID_CRITICALSECTION",
|
||||
"CKCID_LAYER",
|
||||
"CKCID_PROGRESSIVEMESH",
|
||||
"CKCID_SYNCHRO"
|
||||
};
|
||||
// print CKObject vtable
|
||||
//static std::vector<CK_CLASSID> cls{
|
||||
// CKCID_OBJECT,
|
||||
// CKCID_PARAMETERIN,
|
||||
// CKCID_PARAMETEROPERATION,
|
||||
// CKCID_STATE,
|
||||
// CKCID_BEHAVIORLINK,
|
||||
// CKCID_BEHAVIOR,
|
||||
// CKCID_BEHAVIORIO,
|
||||
// CKCID_RENDERCONTEXT,
|
||||
// CKCID_KINEMATICCHAIN,
|
||||
// CKCID_SCENEOBJECT,
|
||||
// CKCID_OBJECTANIMATION,
|
||||
// CKCID_ANIMATION,
|
||||
// CKCID_KEYEDANIMATION,
|
||||
// CKCID_BEOBJECT,
|
||||
// CKCID_DATAARRAY,
|
||||
// CKCID_SCENE,
|
||||
// CKCID_LEVEL,
|
||||
// CKCID_PLACE,
|
||||
// CKCID_GROUP,
|
||||
// CKCID_SOUND,
|
||||
// CKCID_WAVESOUND,
|
||||
// CKCID_MIDISOUND,
|
||||
// CKCID_MATERIAL,
|
||||
// CKCID_TEXTURE,
|
||||
// CKCID_MESH,
|
||||
// CKCID_PATCHMESH,
|
||||
// CKCID_RENDEROBJECT,
|
||||
// CKCID_2DENTITY,
|
||||
// CKCID_SPRITE,
|
||||
// CKCID_SPRITETEXT,
|
||||
// CKCID_3DENTITY,
|
||||
// CKCID_GRID,
|
||||
// CKCID_CURVEPOINT,
|
||||
// CKCID_SPRITE3D,
|
||||
// CKCID_CURVE,
|
||||
// CKCID_CAMERA,
|
||||
// CKCID_TARGETCAMERA,
|
||||
// CKCID_LIGHT,
|
||||
// CKCID_TARGETLIGHT,
|
||||
// CKCID_CHARACTER,
|
||||
// CKCID_3DOBJECT,
|
||||
// CKCID_BODYPART,
|
||||
// CKCID_PARAMETER,
|
||||
// CKCID_PARAMETERLOCAL,
|
||||
// CKCID_PARAMETERVARIABLE,
|
||||
// CKCID_PARAMETEROUT,
|
||||
// CKCID_INTERFACEOBJECTMANAGER,
|
||||
// CKCID_CRITICALSECTION,
|
||||
// CKCID_LAYER,
|
||||
// CKCID_PROGRESSIVEMESH,
|
||||
// CKCID_SYNCHRO
|
||||
//};
|
||||
//static std::vector<const char*> clsname{
|
||||
// "CKCID_OBJECT",
|
||||
// "CKCID_PARAMETERIN",
|
||||
// "CKCID_PARAMETEROPERATION",
|
||||
// "CKCID_STATE",
|
||||
// "CKCID_BEHAVIORLINK",
|
||||
// "CKCID_BEHAVIOR",
|
||||
// "CKCID_BEHAVIORIO",
|
||||
// "CKCID_RENDERCONTEXT",
|
||||
// "CKCID_KINEMATICCHAIN",
|
||||
// "CKCID_SCENEOBJECT",
|
||||
// "CKCID_OBJECTANIMATION",
|
||||
// "CKCID_ANIMATION",
|
||||
// "CKCID_KEYEDANIMATION",
|
||||
// "CKCID_BEOBJECT",
|
||||
// "CKCID_DATAARRAY",
|
||||
// "CKCID_SCENE",
|
||||
// "CKCID_LEVEL",
|
||||
// "CKCID_PLACE",
|
||||
// "CKCID_GROUP",
|
||||
// "CKCID_SOUND",
|
||||
// "CKCID_WAVESOUND",
|
||||
// "CKCID_MIDISOUND",
|
||||
// "CKCID_MATERIAL",
|
||||
// "CKCID_TEXTURE",
|
||||
// "CKCID_MESH",
|
||||
// "CKCID_PATCHMESH",
|
||||
// "CKCID_RENDEROBJECT",
|
||||
// "CKCID_2DENTITY",
|
||||
// "CKCID_SPRITE",
|
||||
// "CKCID_SPRITETEXT",
|
||||
// "CKCID_3DENTITY",
|
||||
// "CKCID_GRID",
|
||||
// "CKCID_CURVEPOINT",
|
||||
// "CKCID_SPRITE3D",
|
||||
// "CKCID_CURVE",
|
||||
// "CKCID_CAMERA",
|
||||
// "CKCID_TARGETCAMERA",
|
||||
// "CKCID_LIGHT",
|
||||
// "CKCID_TARGETLIGHT",
|
||||
// "CKCID_CHARACTER",
|
||||
// "CKCID_3DOBJECT",
|
||||
// "CKCID_BODYPART",
|
||||
// "CKCID_PARAMETER",
|
||||
// "CKCID_PARAMETERLOCAL",
|
||||
// "CKCID_PARAMETERVARIABLE",
|
||||
// "CKCID_PARAMETEROUT",
|
||||
// "CKCID_INTERFACEOBJECTMANAGER",
|
||||
// "CKCID_CRITICALSECTION",
|
||||
// "CKCID_LAYER",
|
||||
// "CKCID_PROGRESSIVEMESH",
|
||||
// "CKCID_SYNCHRO"
|
||||
//};
|
||||
//
|
||||
//auto moduleInfos = ConstructModuleList();
|
||||
|
||||
//fputs("Class Name,Class Id,Show(),IsHiddenByParent(),CanBeHide(),IsVisible(),~dtor(),GetClassID(),PreSave(),Save(),Load(),PostLoad(),PreDelete(),CheckPreDeletion(),CheckPostDeletion(),GetMemoryOccupation(),IsObjectUsed(),PrepareDependencies(),RemapDependencies(),Copy(),\n", stdout);
|
||||
//for (size_t j = 0; j < cls.size(); ++j) {
|
||||
// CK_CLASSID item = cls[j];
|
||||
// const char* itemname = clsname[j];
|
||||
|
||||
// CKObject* obj = ctx->CreateObject(item, NULL, CK_OBJECTCREATION_NONAMECHECK, NULL);
|
||||
|
||||
// fprintf(stdout, "%s,%d,", itemname, item);
|
||||
// PrintVTable(moduleInfos, reinterpret_cast<CKDWORD*>(obj), 18);
|
||||
//}
|
||||
|
||||
// print manager vtables
|
||||
auto moduleInfos = ConstructModuleList();
|
||||
int count = ctx->GetManagerCount();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CKBaseManager* mgr = ctx->GetManager(i);
|
||||
|
||||
fputs("Class Name,Class Id,Show(),IsHiddenByParent(),CanBeHide(),IsVisible(),~dtor(),GetClassID(),PreSave(),Save(),Load(),PostLoad(),PreDelete(),CheckPreDeletion(),CheckPostDeletion(),GetMemoryOccupation(),IsObjectUsed(),PrepareDependencies(),RemapDependencies(),Copy(),\n", stdout);
|
||||
for (size_t j = 0; j < cls.size(); ++j) {
|
||||
CK_CLASSID item = cls[j];
|
||||
const char* itemname = clsname[j];
|
||||
|
||||
CKObject* obj = ctx->CreateObject(item, NULL, CK_OBJECTCREATION_NONAMECHECK, NULL);
|
||||
if (obj == nullptr) continue;
|
||||
CKDWORD* vtable = *(reinterpret_cast<CKDWORD**>(obj));
|
||||
|
||||
fprintf(stdout, "%s,%d,", itemname, item);
|
||||
for (size_t i = 0; i < 18; ++i) {
|
||||
intptr_t addr = vtable[i];
|
||||
const auto& it = moduleInfos.lower_bound(addr);
|
||||
if (it != moduleInfos.end() && it != moduleInfos.begin()) {
|
||||
const auto& itt = std::prev(it);
|
||||
fprintf(stdout, "%s::", itt->second.ModuleName.c_str());
|
||||
addr = addr - itt->second.BaseOfDll;
|
||||
|
||||
if (itt->second.ModuleName == "CK2_3D.dll")
|
||||
addr += 0x10000000u;
|
||||
else if (itt->second.ModuleName == "CK2.dll")
|
||||
addr += 0x24000000u;
|
||||
}
|
||||
fprintf(stdout, "%08X,", addr);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
CKSTRING name = mgr->GetName();
|
||||
CKGUID guid = mgr->GetGuid();
|
||||
fprintf(stdout, "%s\t0x%08x, 0x%08x\t", name, guid.d1, guid.d2);
|
||||
PrintVTable(moduleInfos, reinterpret_cast<CKDWORD*>(mgr), 30, '\t');
|
||||
}
|
||||
|
||||
// call reader
|
||||
|
|
Loading…
Reference in New Issue
Block a user