add vtables data
This commit is contained in:
parent
58aee73fd6
commit
5ae8c8794b
3239
Documents/VTables.fods
Normal file
3239
Documents/VTables.fods
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -145,7 +145,7 @@ namespace LibCmo {
|
||||||
|
|
||||||
// read normal data
|
// read normal data
|
||||||
this->m_DataDwSize = dwbuf[1];
|
this->m_DataDwSize = dwbuf[1];
|
||||||
bufpos = 2;
|
bufpos = 2u;
|
||||||
|
|
||||||
if (this->m_DataDwSize != 0) {
|
if (this->m_DataDwSize != 0) {
|
||||||
this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize];
|
this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize];
|
||||||
|
|
|
@ -11,7 +11,7 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
LibCmo::Utils::VirtoolsEnvironment vtctx;
|
LibCmo::Utils::VirtoolsEnvironment vtctx;
|
||||||
LibCmo::CKFile vtfile(vtctx);
|
LibCmo::CKFile vtfile(vtctx);
|
||||||
LibCmo::CKERROR err = vtfile.Load("VeryOldFile.nmo", LibCmo::CK_LOAD_FLAGS::CK_LOAD_DEFAULT);
|
LibCmo::CKERROR err = vtfile.Load("vt2obj.nms", LibCmo::CK_LOAD_FLAGS::CK_LOAD_DEFAULT);
|
||||||
|
|
||||||
Unvirt::StructFormatter::PrintCKFileInfo(vtfile.m_FileInfo);
|
Unvirt::StructFormatter::PrintCKFileInfo(vtfile.m_FileInfo);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <Psapi.h>
|
||||||
|
|
||||||
#define BUFFER_SIZE 1024
|
#define BUFFER_SIZE 1024
|
||||||
|
|
||||||
|
@ -12,12 +16,52 @@ void Assert(bool cond, const char* desc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MyModuleInfo {
|
||||||
|
intptr_t BaseOfDll;
|
||||||
|
intptr_t EntryPoint;
|
||||||
|
std::string ModuleName;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<intptr_t, MyModuleInfo> ConstructModuleList() {
|
||||||
|
std::map<intptr_t, MyModuleInfo> result;
|
||||||
|
|
||||||
|
HANDLE hProc = GetCurrentProcess();
|
||||||
|
HMODULE* hMods = new HMODULE[1024];
|
||||||
|
TCHAR* szModName = new TCHAR[MAX_PATH];
|
||||||
|
MODULEINFO infoMod;
|
||||||
|
DWORD cbNeeded;
|
||||||
|
DWORD nameLen;
|
||||||
|
|
||||||
|
if (EnumProcessModules(hProc, hMods, sizeof(HMODULE) * 1024, &cbNeeded)) {
|
||||||
|
for (DWORD i = 0; i < (cbNeeded / sizeof(HMODULE)); ++i) {
|
||||||
|
MyModuleInfo data;
|
||||||
|
|
||||||
|
nameLen = GetModuleBaseName(hProc, hMods[i], szModName, MAX_PATH);
|
||||||
|
if (nameLen) {
|
||||||
|
data.ModuleName.resize(nameLen);
|
||||||
|
memcpy(data.ModuleName.data(), szModName, nameLen * sizeof(TCHAR));
|
||||||
|
} else data.ModuleName = "";
|
||||||
|
|
||||||
|
if (GetModuleInformation(hProc, hMods[i], &infoMod, sizeof(infoMod))) {
|
||||||
|
data.BaseOfDll = reinterpret_cast<intptr_t>(infoMod.lpBaseOfDll);
|
||||||
|
data.EntryPoint = reinterpret_cast<intptr_t>(infoMod.EntryPoint);
|
||||||
|
} else {
|
||||||
|
data.BaseOfDll = 0;
|
||||||
|
data.EntryPoint = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.emplace(data.BaseOfDll, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] hMods;
|
||||||
|
delete[] szModName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Assert(LoadLibrary("CK2.dll"), "Error loading CK2.dll");
|
Assert(LoadLibrary("CK2.dll"), "Error loading CK2.dll");
|
||||||
|
|
||||||
std::cout << "Press any key to run..." << std::endl;
|
|
||||||
system("pause");
|
|
||||||
|
|
||||||
Assert(!CKStartUp(), "CKStartUp Error");
|
Assert(!CKStartUp(), "CKStartUp Error");
|
||||||
std::string sharedStorage;
|
std::string sharedStorage;
|
||||||
sharedStorage.resize(BUFFER_SIZE);
|
sharedStorage.resize(BUFFER_SIZE);
|
||||||
|
@ -41,9 +85,149 @@ int main() {
|
||||||
CKContext* ctx = NULL;
|
CKContext* ctx = NULL;
|
||||||
Assert(!CKCreateContext(&ctx, NULL, 0), "Fail to execute CKCreateContext()");
|
Assert(!CKCreateContext(&ctx, NULL, 0), "Fail to execute CKCreateContext()");
|
||||||
|
|
||||||
|
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_3DENTITY,
|
||||||
|
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_3DENTITY",
|
||||||
|
"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);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// call reader
|
// call reader
|
||||||
CKObjectArray* array = CreateCKObjectArray();
|
//CKObjectArray* array = CreateCKObjectArray();
|
||||||
Assert(!ctx->Load("Language.old.nmo", array, CK_LOAD_DEFAULT, NULL), "Fail to load CMO file");
|
//Assert(!ctx->Load("Language.old.nmo", array, CK_LOAD_DEFAULT, NULL), "Fail to load CMO file");
|
||||||
|
|
||||||
// call saver
|
// call saver
|
||||||
//CKObjectArray* array = CreateCKObjectArray();
|
//CKObjectArray* array = CreateCKObjectArray();
|
||||||
|
@ -54,7 +238,12 @@ int main() {
|
||||||
//dep->m_Flags = CK_DEPENDENCIES_FULL;
|
//dep->m_Flags = CK_DEPENDENCIES_FULL;
|
||||||
//Assert(!ctx->Save("result.cmo", array, 0xFFFFFFFF, dep, NULL), "Fail to save CMO file");
|
//Assert(!ctx->Save("result.cmo", array, 0xFFFFFFFF, dep, NULL), "Fail to save CMO file");
|
||||||
|
|
||||||
DeleteCKObjectArray(array);
|
//DeleteCKObjectArray(array);
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "Press any key to exit..." << std::endl;
|
||||||
|
system("pause");
|
||||||
|
|
||||||
CKCloseContext(ctx);
|
CKCloseContext(ctx);
|
||||||
CKShutdown();
|
CKShutdown();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user