From 54f89ab8c92c5d05c35b9b0ede1a33f4e3aa424a Mon Sep 17 00:00:00 2001 From: Norbyte Date: Fri, 3 Nov 2023 15:47:26 +0100 Subject: [PATCH] Gang gang --- .../Extender/Client/ScriptExtenderClient.cpp | 13 +- .../Extender/Client/ScriptExtenderClient.h | 4 +- BG3Extender/Extender/ScriptExtender.cpp | 73 ++ BG3Extender/Extender/ScriptExtender.h | 3 + .../Extender/Server/ScriptExtenderServer.cpp | 2 +- .../Extender/Server/ScriptExtenderServer.h | 2 +- BG3Extender/Extender/Shared/Hooks.cpp | 2 +- BG3Extender/GameDefinitions/EntitySystem.cpp | 218 ++---- BG3Extender/GameDefinitions/EntitySystem.h | 6 - .../GameDefinitions/EntitySystemHelpers.h | 80 +-- BG3Extender/GameDefinitions/GameState.h | 11 + BG3Extender/GameDefinitions/Net.h | 2 + BG3Extender/GameDefinitions/Symbols.h | 13 +- BG3Extender/GameHooks/BinaryMappings.xml | 649 ++++++++---------- BG3Extender/GameHooks/DataLibraries.cpp | 8 +- BG3Extender/GameHooks/DataLibraries.h | 5 +- .../GameHooks/DataLibrariesBG3Game.cpp | 111 +-- BG3Extender/GameHooks/EngineHooks.inl | 2 +- BG3Updater/UpdaterBinaryMappings.xml | 160 ++--- BG3Updater/UpdaterSymbols.h | 1 + BG3Updater/Utils.cpp | 14 +- CoreLib/Base/BaseInterface.h | 2 + CoreLib/Base/BaseMemory.h | 4 +- CoreLib/Base/BaseString.h | 5 +- CoreLib/Base/BaseString.inl | 40 +- publish.ps1 | 4 +- 26 files changed, 659 insertions(+), 775 deletions(-) diff --git a/BG3Extender/Extender/Client/ScriptExtenderClient.cpp b/BG3Extender/Extender/Client/ScriptExtenderClient.cpp index f404dca6..4f9390eb 100644 --- a/BG3Extender/Extender/Client/ScriptExtenderClient.cpp +++ b/BG3Extender/Extender/Client/ScriptExtenderClient.cpp @@ -4,7 +4,6 @@ #define STATIC_HOOK(name) decltype(bg3se::ecl::ScriptExtender::name) * decltype(bg3se::ecl::ScriptExtender::name)::gHook; STATIC_HOOK(gameStateWorkerStart_) -STATIC_HOOK(gameStateChangedEvent_) STATIC_HOOK(gameStateMachineUpdate_) #include @@ -70,10 +69,6 @@ void ScriptExtender::Initialize() DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - if (lib.ecl__GameStateEventManager__ExecuteGameStateChangedEvent != nullptr) { - gameStateChangedEvent_.Wrap(lib.ecl__GameStateEventManager__ExecuteGameStateChangedEvent); - } - if (lib.ecl__GameStateThreaded__GameStateWorker__DoWork != nullptr) { gameStateWorkerStart_.Wrap(lib.ecl__GameStateThreaded__GameStateWorker__DoWork); } @@ -84,7 +79,6 @@ void ScriptExtender::Initialize() DetourTransactionCommit(); - gameStateChangedEvent_.SetPostHook(&ScriptExtender::OnGameStateChanged, this); gameStateWorkerStart_.SetWrapper(&ScriptExtender::GameStateWorkerWrapper, this); gameStateMachineUpdate_.SetPostHook(&ScriptExtender::OnUpdate, this); } @@ -122,13 +116,8 @@ bool IsLoadingState(GameState state) || state == GameState::ModReceiving; } -void ScriptExtender::OnGameStateChanged(void * self, GameState fromState, GameState toState) +void ScriptExtender::OnGameStateChanged(GameState fromState, GameState toState) { - if (self != *GetStaticSymbols().ecl__gGameStateEventManager) { - gExtender->GetServer().OnGameStateChanged(self, (esv::GameState)fromState, (esv::GameState)toState); - return; - } - if (gExtender->GetConfig().SendCrashReports) { // We need to initialize the crash reporter after the game engine has started, // otherwise the game will overwrite the top level exception filter diff --git a/BG3Extender/Extender/Client/ScriptExtenderClient.h b/BG3Extender/Extender/Client/ScriptExtenderClient.h index a080bf14..95c5bec4 100644 --- a/BG3Extender/Extender/Client/ScriptExtenderClient.h +++ b/BG3Extender/Extender/Client/ScriptExtenderClient.h @@ -57,14 +57,13 @@ class ScriptExtender : public ThreadedExtenderState void UpdateServerProgress(STDString const& status); void UpdateClientProgress(STDString const& status); + void OnGameStateChanged(GameState fromState, GameState toState); // HACK - we need to expose this so it can be added to the CrashReporter whitelist enum class GameStateWorkerStartTag {}; enum class GameStateMachcineUpdateTag {}; - enum class GameStateChangedEventTag {}; WrappableFunction gameStateWorkerStart_; WrappableFunction gameStateMachineUpdate_; - WrappableFunction gameStateChangedEvent_; private: ExtenderConfig& config_; @@ -78,7 +77,6 @@ class ScriptExtender : public ThreadedExtenderState NetworkManager network_; void OnBaseModuleLoaded(void * self); - void OnGameStateChanged(void * self, GameState fromState, GameState toState); void GameStateWorkerWrapper(void (*wrapped)(void*), void* self); void OnUpdate(void* self, GameTime* time); void OnIncLocalProgress(void* self, int progress, char const* state); diff --git a/BG3Extender/Extender/ScriptExtender.cpp b/BG3Extender/Extender/ScriptExtender.cpp index 91e5aa98..0dce90de 100644 --- a/BG3Extender/Extender/ScriptExtender.cpp +++ b/BG3Extender/Extender/ScriptExtender.cpp @@ -18,6 +18,7 @@ void ShutdownCrashReporting(); decltype(ScriptExtender::CoreLibInit)* decltype(ScriptExtender::CoreLibInit)::gHook; decltype(ScriptExtender::AppUpdatePaths)* decltype(ScriptExtender::AppUpdatePaths)::gHook; +decltype(ScriptExtender::AppLoadGraphicSettings)* decltype(ScriptExtender::AppLoadGraphicSettings)::gHook; std::unique_ptr gExtender; @@ -82,6 +83,11 @@ void ScriptExtender::Initialize() AppUpdatePaths.SetPostHook(&ScriptExtender::OnAppUpdatePaths, this); } + if (GetStaticSymbols().App__LoadGraphicSettings != nullptr) { + AppLoadGraphicSettings.Wrap(GetStaticSymbols().App__LoadGraphicSettings); + AppLoadGraphicSettings.SetPostHook(&ScriptExtender::OnAppLoadGraphicSettings, this); + } + DetourTransactionCommit(); #if !defined(OSI_NO_DEBUGGER) @@ -260,6 +266,73 @@ void ScriptExtender::OnAppUpdatePaths(void * self) } } +class ClientEventManagerHook +{ +public: + struct GameStates + { + ecl::GameState From; + ecl::GameState To; + }; + + virtual ~ClientEventManagerHook() + {} + + virtual bool OnGameStateChanged(GameStates& states) + { + gExtender->GetClient().OnGameStateChanged(states.From, states.To); + return true; + } + + virtual bool Unknown() + { + return false; + } + + uint64_t dummy{ 0 }; +}; + +class ServerEventManagerHook +{ +public: + struct GameStates + { + esv::GameState From; + esv::GameState To; + }; + + virtual ~ServerEventManagerHook() + {} + + virtual bool OnGameStateChanged(GameStates& states) + { + gExtender->GetServer().OnGameStateChanged(states.From, states.To); + return true; + } + + virtual bool Unknown() + { + return false; + } + + uint64_t dummy{ 0 }; +}; + +void ScriptExtender::OnAppLoadGraphicSettings(App * self) +{ + auto clientEvtMgr = GetStaticSymbols().ecl__gGameStateEventManager; + if (clientEvtMgr && *clientEvtMgr) { + auto client = GameAlloc(); + (*clientEvtMgr)->Callbacks.push_back(&client->dummy); + } + + auto serverEvtMgr = GetStaticSymbols().esv__gGameStateEventManager; + if (serverEvtMgr && *serverEvtMgr) { + auto server = GameAlloc(); + (*serverEvtMgr)->Callbacks.push_back(&server->dummy); + } +} + void ScriptExtender::OnBaseModuleLoaded(void * self) { } diff --git a/BG3Extender/Extender/ScriptExtender.h b/BG3Extender/Extender/ScriptExtender.h index 01db2c00..5f07793c 100644 --- a/BG3Extender/Extender/ScriptExtender.h +++ b/BG3Extender/Extender/ScriptExtender.h @@ -121,6 +121,8 @@ class ScriptExtender WrappableFunction CoreLibInit; enum class AppUpdatePathsTag {}; WrappableFunction AppUpdatePaths; + enum class AppLoadGraphicSettingsTag {}; + WrappableFunction AppLoadGraphicSettings; private: esv::ScriptExtender server_; @@ -149,6 +151,7 @@ class ScriptExtender void OnCoreLibInit(void * self); void OnAppUpdatePaths(void * self); + void OnAppLoadGraphicSettings(App* self); void OnBaseModuleLoaded(void * self); void OnModuleLoadStarted(TranslatedStringRepository* self); void OnStatsLoad(stats::RPGStats::LoadProc* wrapped, stats::RPGStats* mgr, Array* paths); diff --git a/BG3Extender/Extender/Server/ScriptExtenderServer.cpp b/BG3Extender/Extender/Server/ScriptExtenderServer.cpp index ecf3a74e..3c64a6d4 100644 --- a/BG3Extender/Extender/Server/ScriptExtenderServer.cpp +++ b/BG3Extender/Extender/Server/ScriptExtenderServer.cpp @@ -97,7 +97,7 @@ bool IsLoadingState(GameState state) || state == GameState::ReloadStory; } -void ScriptExtender::OnGameStateChanged(void * self, GameState fromState, GameState toState) +void ScriptExtender::OnGameStateChanged(GameState fromState, GameState toState) { #if defined(DEBUG_SERVER_CLIENT) DEBUG("esv::ScriptExtender::OnGameStateChanged(): %s -> %s", diff --git a/BG3Extender/Extender/Server/ScriptExtenderServer.h b/BG3Extender/Extender/Server/ScriptExtenderServer.h index 66c2a4b3..cb909048 100644 --- a/BG3Extender/Extender/Server/ScriptExtenderServer.h +++ b/BG3Extender/Extender/Server/ScriptExtenderServer.h @@ -28,7 +28,7 @@ class ScriptExtender : public ThreadedExtenderState void Initialize(); void PostStartup(); void Shutdown(); - void OnGameStateChanged(void* self, GameState fromState, GameState toState); + void OnGameStateChanged(GameState fromState, GameState toState); inline bool HasExtensionState() const { diff --git a/BG3Extender/Extender/Shared/Hooks.cpp b/BG3Extender/Extender/Shared/Hooks.cpp index 93c7be40..fe30ffb8 100644 --- a/BG3Extender/Extender/Shared/Hooks.cpp +++ b/BG3Extender/Extender/Shared/Hooks.cpp @@ -14,7 +14,7 @@ void Hooks::Startup() } auto& lib = gExtender->GetEngineHooks(); - lib.RPGStats__ParseStructureFolder.SetPostHook(&Hooks::OnParseStructureFolder, this); + lib.RPGStats__PreParseDataFolder.SetPreHook(&Hooks::OnParseStructureFolder, this); eocnet__ClientConnectMessage__Serialize.SetWrapper(&Hooks::OnClientConnectMessage, this); loaded_ = true; diff --git a/BG3Extender/GameDefinitions/EntitySystem.cpp b/BG3Extender/GameDefinitions/EntitySystem.cpp index 5e0d4340..d4e0a58c 100644 --- a/BG3Extender/GameDefinitions/EntitySystem.cpp +++ b/BG3Extender/GameDefinitions/EntitySystem.cpp @@ -172,43 +172,10 @@ EntitySystemHelpersBase::EntitySystemHelpersBase() : componentIndices_{ UndefinedComponent }, componentSizes_{ 0 }, replicationIndices_{ UndefinedReplicationComponent }, - handleIndices_{ UndefinedHandle }, queryIndices_{ UndefinedIndex }, - resourceManagerIndices_{ UndefinedIndex } + staticDataIndices_{ UndefinedIndex } {} -void EntitySystemHelpersBase::ComponentIndexMappings::Add(int32_t index, IndexSymbolType type) -{ - switch (type) { - case IndexSymbolType::Replication: - assert(ReplicationIndex == -1); - ReplicationIndex = index; - break; - - case IndexSymbolType::Handle: - assert(HandleIndex == -1); - HandleIndex = index; - break; - - case IndexSymbolType::Component: - assert(ComponentIndex == -1); - ComponentIndex = index; - break; - - case IndexSymbolType::EventComponent: - assert(EventComponentIndex == -1); - EventComponentIndex = index; - break; - - default: - assert(NumIndices < Indices.size()); - if (NumIndices < Indices.size()) { - Indices[NumIndices++] = index; - } - break; - } -} - STDString SimplifyComponentName(StringView name) { STDString key{ name }; @@ -298,7 +265,7 @@ void EntitySystemHelpersBase::NotifyReplicationFlagsDirtied() world->Replication->Dirty = true; } -void EntitySystemHelpersBase::BindSystemName(StringView name, int32_t systemId) +void EntitySystemHelpersBase::BindSystem(StringView name, int32_t systemId) { auto it = systemIndexMappings_.insert(std::make_pair(name, systemId)); if (systemTypeIdToName_.size() <= systemId) { @@ -308,7 +275,7 @@ void EntitySystemHelpersBase::BindSystemName(StringView name, int32_t systemId) systemTypeIdToName_[systemId] = &it.first->first; } -void EntitySystemHelpersBase::BindQueryName(StringView name, int32_t queryId) +void EntitySystemHelpersBase::BindQuery(StringView name, int32_t queryId) { auto it = queryMappings_.insert(std::make_pair(name, queryId)); if (queryTypeIdToName_.size() <= queryId) { @@ -318,88 +285,39 @@ void EntitySystemHelpersBase::BindQueryName(StringView name, int32_t queryId) queryTypeIdToName_[queryId] = &it.first->first; } -bool EntitySystemHelpersBase::TryUpdateSystemMapping(StringView name, ComponentIndexMappings& mapping) +void EntitySystemHelpersBase::BindStaticData(StringView name, int32_t id) { - if (mapping.NumIndices == 1 - && mapping.ReplicationIndex == -1 - && mapping.HandleIndex == -1 - && mapping.ComponentIndex == -1 - && mapping.EventComponentIndex == -1) { - if (name.starts_with("ecs::query::spec::Spec<")) { - BindQueryName(name, mapping.Indices[0]); - } else { - BindSystemName(name, mapping.Indices[0]); - } - return true; + auto it = staticDataMappings_.insert(std::make_pair(name, id)); + if (staticDataIdToName_.size() <= id) { + staticDataIdToName_.resize(id + 1); } - return false; + staticDataIdToName_[id] = &it.first->first; } -void EntitySystemHelpersBase::TryUpdateComponentMapping(StringView name, ComponentIndexMappings& mapping) +void EntitySystemHelpersBase::BindComponent(StringView name, int32_t id) { - std::sort(mapping.Indices.begin(), mapping.Indices.begin() + mapping.NumIndices, std::less()); - DEBUG_IDX("\t" << name << ": "); - - auto totalIndices = mapping.NumIndices - + ((mapping.ReplicationIndex != -1) ? 1 : 0) - + ((mapping.HandleIndex != -1) ? 1 : 0) - + ((mapping.ComponentIndex != -1) ? 1 : 0) - + ((mapping.EventComponentIndex != -1) ? 1 : 0); - - if (totalIndices == 1) { - assert(mapping.ReplicationIndex == -1); - assert(mapping.HandleIndex == -1); - - if (mapping.ComponentIndex == -1) { - mapping.ComponentIndex = mapping.Indices[0]; - } - } else if (totalIndices == 2) { - if (mapping.EventComponentIndex != -1) { - DEBUG_IDX("Event component, ignored."); - return; - } - - // Only Handle/ReplicationIndex and ComponentIndex, no replication - assert(mapping.ReplicationIndex == -1 || mapping.HandleIndex == -1); - - unsigned nextIndex{ 0 }; - if (mapping.ComponentIndex == -1) { - // Maybe this is a system? - if (name.find("Component") == StringView::npos) { - BindSystemName(name, mapping.Indices[0]); - } else { - mapping.ComponentIndex = mapping.Indices[nextIndex++]; - } - } - - if (mapping.ReplicationIndex == -1 && mapping.HandleIndex == -1) { - mapping.HandleIndex = mapping.Indices[nextIndex++]; - } - } else if (totalIndices == 3) { - unsigned nextIndex{ 0 }; - - if (mapping.ReplicationIndex == -1) { - mapping.ReplicationIndex = mapping.Indices[nextIndex++]; - } + STDString const* pName; + auto it = componentNameToIndexMappings_.find(STDString(name)); + if (it == componentNameToIndexMappings_.end()) { + auto iit = componentNameToIndexMappings_.insert(std::make_pair(name, IndexMappings{(ComponentTypeIndex)id, UndefinedReplicationComponent})); + pName = &iit.first->first; + } else { + it->second.ComponentIndex = (ComponentTypeIndex)id; + pName = &it->first; + } - if (mapping.ComponentIndex == -1) { - mapping.ComponentIndex = mapping.Indices[nextIndex++]; - } + componentIndexToNameMappings_.insert(std::make_pair(id, pName)); +} - if (mapping.HandleIndex == -1) { - mapping.HandleIndex = mapping.Indices[nextIndex++]; - } +void EntitySystemHelpersBase::BindReplication(StringView name, int32_t id) +{ + auto it = componentNameToIndexMappings_.find(STDString(name)); + if (it == componentNameToIndexMappings_.end()) { + componentNameToIndexMappings_.insert(std::make_pair(name, IndexMappings{UndefinedComponent, (ReplicationTypeIndex)id})); } else { - WARN("Component with strange configuration: %s", name.data()); - return; + it->second.ReplicationIndex = (ReplicationTypeIndex)id; } - - DEBUG_IDX("Repl " << mapping.ReplicationIndex << ", Handle " << mapping.HandleIndex << ", Comp " << mapping.ComponentIndex); - IndexMappings indexMapping{ (uint16_t)mapping.HandleIndex, (uint16_t)mapping.ComponentIndex, (uint16_t)mapping.ReplicationIndex }; - auto it = componentNameToIndexMappings_.insert(std::make_pair(name, indexMapping)); - componentIndexToNameMappings_.insert(std::make_pair(indexMapping.ComponentIndex, &it.first->first)); - handleIndexToNameMappings_.insert(std::make_pair(indexMapping.HandleIndex, &it.first->first)); } void EntitySystemHelpersBase::UpdateComponentMappings() @@ -408,44 +326,59 @@ void EntitySystemHelpersBase::UpdateComponentMappings() componentNameToIndexMappings_.clear(); componentIndexToNameMappings_.clear(); - handleIndexToNameMappings_.clear(); componentIndexToTypeMappings_.clear(); - handleIndexToTypeMappings_.clear(); - handleIndexToComponentMappings_.clear(); replicationIndexToTypeMappings_.clear(); componentIndices_.fill(UndefinedComponent); componentSizes_.fill(0); replicationIndices_.fill(UndefinedReplicationComponent); - handleIndices_.fill(UndefinedHandle); queryIndices_.fill(UndefinedIndex); - resourceManagerIndices_.fill(UndefinedIndex); + staticDataIndices_.fill(UndefinedIndex); + + std::unordered_map contexts; + for (auto const& context : GetStaticSymbols().IndexSymbolToContextMaps) { + auto name = ecs::SimplifyComponentName(context.second); + if (name == "ecs::OneFrameComponentTypeIdContext") { + contexts.insert(std::make_pair(context.first, TypeIdContext::OneFrameComponent)); + } else if (name == "ecs::ComponentTypeIdContext") { + contexts.insert(std::make_pair(context.first, TypeIdContext::Component)); + } else if (name == "ecs::EntityWorld::SystemsContext") { + contexts.insert(std::make_pair(context.first, TypeIdContext::System)); + } else if (name == "ecs::sync::ReplicatedTypeContext") { + contexts.insert(std::make_pair(context.first, TypeIdContext::Replication)); + } else if (name == "ls::ImmutableDataHeadmaster") { + contexts.insert(std::make_pair(context.first, TypeIdContext::ImmutableData)); + } + } auto const& symbolMaps = GetStaticSymbols().IndexSymbolToNameMaps; - - std::unordered_map mappings; for (auto const& mapping : symbolMaps) { - auto it = mappings.find(mapping.second.name); - if (it == mappings.end()) { - ComponentIndexMappings newMapping; - std::fill(newMapping.Indices.begin(), newMapping.Indices.end(), UndefinedIndex); - newMapping.Add(*mapping.first, mapping.second.type); - mappings.insert(std::make_pair(mapping.second.name, newMapping)); - } else { - it->second.Add(*mapping.first, mapping.second.type); + auto name = SimplifyComponentName(mapping.second.name); + if (name.starts_with("ecs::query::spec::Spec<")) { + BindQuery(name, *mapping.first); } - } - - std::vector> pendingMappings; - for (auto& map : mappings) { - auto componentName = SimplifyComponentName(map.first); - if (!TryUpdateSystemMapping(componentName, map.second)) { - pendingMappings.push_back({ std::move(componentName), map.second}); + else { + auto contextIt = contexts.find(mapping.second.context); + if (contextIt != contexts.end()) { + switch (contextIt->second) { + case TypeIdContext::System: + BindSystem(name, *mapping.first); + break; + + case TypeIdContext::ImmutableData: + BindStaticData(name, *mapping.first); + break; + + case TypeIdContext::Component: + BindComponent(name, *mapping.first); + break; + + case TypeIdContext::Replication: + BindReplication(name, *mapping.first); + break; + } + } } } - - for (auto& map : pendingMappings) { - TryUpdateComponentMapping(map.first, map.second); - } #if defined(DEBUG_INDEX_MAPPINGS) DEBUG_IDX("COMPONENT MAPPINGS:"); @@ -511,20 +444,11 @@ void EntitySystemHelpersBase::MapComponentIndices(char const* componentName, Ext if (it != componentNameToIndexMappings_.end()) { componentIndices_[(unsigned)type] = it->second.ComponentIndex; replicationIndices_[(unsigned)type] = it->second.ReplicationIndex; - handleIndices_[(unsigned)type] = it->second.HandleIndex; if (it->second.ComponentIndex != UndefinedComponent) { componentIndexToTypeMappings_.insert(std::make_pair(it->second.ComponentIndex, type)); } - if (it->second.HandleIndex != UndefinedHandle) { - handleIndexToTypeMappings_.insert(std::make_pair(it->second.HandleIndex, type)); - } - - if (it->second.HandleIndex != UndefinedHandle && it->second.ComponentIndex != UndefinedComponent) { - handleIndexToComponentMappings_.insert(std::make_pair(it->second.HandleIndex, it->second.ComponentIndex)); - } - if (it->second.ReplicationIndex != UndefinedReplicationComponent) { replicationIndexToTypeMappings_.insert(std::make_pair(it->second.ReplicationIndex, type)); } @@ -547,9 +471,9 @@ void EntitySystemHelpersBase::MapQueryIndex(char const* name, ExtQueryType type) void EntitySystemHelpersBase::MapResourceManagerIndex(char const* componentName, ExtResourceManagerType type) { - auto it = systemIndexMappings_.find(componentName); - if (it != systemIndexMappings_.end()) { - resourceManagerIndices_[(unsigned)type] = it->second; + auto it = staticDataMappings_.find(componentName); + if (it != staticDataMappings_.end()) { + staticDataIndices_[(unsigned)type] = it->second; } else { OsiWarn("Could not find index for resource manager: " << componentName); } @@ -625,7 +549,7 @@ EntityHandle EntitySystemHelpersBase::GetEntityHandle(Guid uuid) resource::GuidResourceBankBase* EntitySystemHelpersBase::GetRawResourceManager(ExtResourceManagerType type) { - auto index = resourceManagerIndices_[(unsigned)type]; + auto index = staticDataIndices_[(unsigned)type]; if (index == UndefinedIndex) { OsiError("No resource manager index mapping registered for " << type); return {}; diff --git a/BG3Extender/GameDefinitions/EntitySystem.h b/BG3Extender/GameDefinitions/EntitySystem.h index 3407a5d1..cf23b0b8 100644 --- a/BG3Extender/GameDefinitions/EntitySystem.h +++ b/BG3Extender/GameDefinitions/EntitySystem.h @@ -25,11 +25,6 @@ using ComponentTypeMask = std::array; using UnknownMask = std::array; using EntityTypeMask = std::array; - -// Handle type index, registered statically during game startup -// FIXME - delete all ComponentHandle logic! -enum class HandleTypeIndexTag {}; -using HandleTypeIndex = TypedIntegral; // Component type index, registered statically during game startup enum class ComponentTypeIndexTag {}; using ComponentTypeIndex = TypedIntegral; @@ -39,7 +34,6 @@ using ReplicationTypeIndex = TypedIntegral; static constexpr ReplicationTypeIndex UndefinedReplicationComponent{ 0xffff }; static constexpr ComponentTypeIndex UndefinedComponent{ 0xffff }; -static constexpr HandleTypeIndex UndefinedHandle{ 0xffff }; END_NS() diff --git a/BG3Extender/GameDefinitions/EntitySystemHelpers.h b/BG3Extender/GameDefinitions/EntitySystemHelpers.h index 092cac31..bfefe939 100644 --- a/BG3Extender/GameDefinitions/EntitySystemHelpers.h +++ b/BG3Extender/GameDefinitions/EntitySystemHelpers.h @@ -5,19 +5,19 @@ BEGIN_NS(ecs) -enum class IndexSymbolType +enum class TypeIdContext { - None, Replication, - Handle, Component, - EventComponent + OneFrameComponent, + System, + ImmutableData }; struct IndexSymbolInfo { char const* name; - IndexSymbolType type; + int32_t* context; }; class EntitySystemHelpersBase : public Noncopyable @@ -45,16 +45,6 @@ class EntitySystemHelpersBase : public Noncopyable } } - inline std::optional GetComponentName(HandleTypeIndex index) const - { - auto it = handleIndexToNameMappings_.find(index); - if (it != handleIndexToNameMappings_.end()) { - return it->second; - } else { - return {}; - } - } - inline std::optional GetComponentType(ComponentTypeIndex index) const { auto it = componentIndexToTypeMappings_.find(index); @@ -65,16 +55,6 @@ class EntitySystemHelpersBase : public Noncopyable } } - inline std::optional GetComponentType(HandleTypeIndex index) const - { - auto it = handleIndexToTypeMappings_.find(index); - if (it != handleIndexToTypeMappings_.end()) { - return it->second; - } else { - return {}; - } - } - inline std::optional GetComponentType(ReplicationTypeIndex index) const { auto it = replicationIndexToTypeMappings_.find(index); @@ -85,16 +65,6 @@ class EntitySystemHelpersBase : public Noncopyable } } - inline std::optional GetComponentIndex(HandleTypeIndex index) const - { - auto it = handleIndexToComponentMappings_.find(index); - if (it != handleIndexToComponentMappings_.end()) { - return ComponentTypeIndex(it->second); - } else { - return {}; - } - } - inline std::optional GetComponentIndex(ExtComponentType type) const { auto idx = componentIndices_[(unsigned)type]; @@ -110,16 +80,6 @@ class EntitySystemHelpersBase : public Noncopyable return componentSizes_[(unsigned)type]; } - std::optional GetHandleIndex(ExtComponentType type) const - { - auto idx = handleIndices_[(unsigned)type]; - if (idx != -1) { - return idx; - } else { - return {}; - } - } - std::optional GetReplicationIndex(ExtComponentType type) const { auto idx = replicationIndices_[(unsigned)type]; @@ -199,21 +159,8 @@ class EntitySystemHelpersBase : public Noncopyable void UpdateComponentMappings(); private: - struct ComponentIndexMappings - { - int32_t ReplicationIndex{ -1 }; - int32_t HandleIndex{ -1 }; - int32_t ComponentIndex{ -1 }; - int32_t EventComponentIndex{ -1 }; - std::array Indices; - std::size_t NumIndices{ 0 }; - - void Add(int32_t index, IndexSymbolType type); - }; - struct IndexMappings { - HandleTypeIndex HandleIndex{ UndefinedHandle }; ComponentTypeIndex ComponentIndex{ UndefinedComponent }; ReplicationTypeIndex ReplicationIndex{ UndefinedReplicationComponent }; }; @@ -221,28 +168,27 @@ class EntitySystemHelpersBase : public Noncopyable std::array componentIndices_; std::array componentSizes_; std::array replicationIndices_; - std::array handleIndices_; std::array queryIndices_; - std::array resourceManagerIndices_; + std::array staticDataIndices_; std::unordered_map componentNameToIndexMappings_; std::unordered_map componentIndexToNameMappings_; - std::unordered_map handleIndexToNameMappings_; std::unordered_map componentIndexToTypeMappings_; - std::unordered_map handleIndexToTypeMappings_; - std::unordered_map handleIndexToComponentMappings_; std::unordered_map replicationIndexToTypeMappings_; std::unordered_map systemIndexMappings_; std::vector systemTypeIdToName_; std::unordered_map queryMappings_; std::vector queryTypeIdToName_; + std::unordered_map staticDataMappings_; + std::vector staticDataIdToName_; bool initialized_{ false }; - bool TryUpdateSystemMapping(std::string_view name, ComponentIndexMappings& mapping); - void TryUpdateComponentMapping(std::string_view name, ComponentIndexMappings& mapping); - void BindSystemName(std::string_view name, int32_t systemId); - void BindQueryName(std::string_view name, int32_t systemId); + void BindSystem(std::string_view name, int32_t id); + void BindQuery(std::string_view name, int32_t id); + void BindStaticData(std::string_view name, int32_t id); + void BindComponent(std::string_view name, int32_t id); + void BindReplication(std::string_view name, int32_t id); void* GetRawComponent(char const* nameGuid, ExtComponentType type); void* GetRawComponent(FixedString const& guid, ExtComponentType type); resource::GuidResourceBankBase* GetRawResourceManager(ExtResourceManagerType type); diff --git a/BG3Extender/GameDefinitions/GameState.h b/BG3Extender/GameDefinitions/GameState.h index 78d58d13..32f8a90d 100644 --- a/BG3Extender/GameDefinitions/GameState.h +++ b/BG3Extender/GameDefinitions/GameState.h @@ -92,6 +92,17 @@ struct IEoCServerObject : public IGameObject BaseComponent Base; }; +struct GameStateEventManager +{ + void* VMT; + Array Callbacks; +}; + +struct App +{ + using LoadGraphicSettingsProc = void (App*); +}; + END_SE() BEGIN_NS(esv) diff --git a/BG3Extender/GameDefinitions/Net.h b/BG3Extender/GameDefinitions/Net.h index 4a719585..14cb88a4 100644 --- a/BG3Extender/GameDefinitions/Net.h +++ b/BG3Extender/GameDefinitions/Net.h @@ -190,6 +190,8 @@ struct AbstractPeerBase : ProtectedGameObject struct AbstractPeer : public AbstractPeerBase { void* VMT2; + void* VMT3; + void* VMT4; void* RakNetPeer; int SocketBindingType_M; int PeerAddressID; diff --git a/BG3Extender/GameDefinitions/Symbols.h b/BG3Extender/GameDefinitions/Symbols.h index 12a6709a..6a8e71d8 100644 --- a/BG3Extender/GameDefinitions/Symbols.h +++ b/BG3Extender/GameDefinitions/Symbols.h @@ -20,6 +20,7 @@ namespace bg3se struct StaticSymbols : Noncopyable { + std::unordered_map IndexSymbolToContextMaps; std::unordered_map IndexSymbolToNameMaps; std::unordered_map StaticStringRegistrantMaps; @@ -30,10 +31,10 @@ namespace bg3se uint32_t refs; }; - FixedString::CreateFromStringProc* ls__FixedString__CreateFromString{ nullptr }; FixedString::GetStringProc* ls__FixedString__GetString{ nullptr }; FixedString::IncRefProc* ls__FixedString__IncRef{ nullptr }; - FixedString::DecRefProc* ls__FixedString__DecRef{ nullptr }; + GlobalStringTable::MainTable::CreateFromStringProc* ls__GlobalStringTable__MainTable__CreateFromString{ nullptr }; + GlobalStringTable::MainTable::DecRefProc* ls__GlobalStringTable__MainTable__DecRef{ nullptr }; GlobalStringTable** ls__gGlobalStringTable{ nullptr }; FileReader::CtorProc* ls__FileReader__ctor{ nullptr }; @@ -49,12 +50,13 @@ namespace bg3se TranslatedStringRepository** ls__gTranslatedStringRepository{ nullptr }; - void** ecl__gGameStateEventManager{ nullptr }; - ecl::GameStateEventManager__ExecuteGameStateChangedEvent ecl__GameStateEventManager__ExecuteGameStateChangedEvent{ nullptr }; + GameStateEventManager** ecl__gGameStateEventManager{ nullptr }; + GameStateEventManager** esv__gGameStateEventManager{ nullptr }; ecl::GameStateThreaded__GameStateWorker__DoWork ecl__GameStateThreaded__GameStateWorker__DoWork{ nullptr }; esv::GameStateThreaded__GameStateWorker__DoWork esv__GameStateThreaded__GameStateWorker__DoWork{ nullptr }; ecl::GameStateMachine__Update ecl__GameStateMachine__Update{ nullptr }; esv::GameStateMachine__Update esv__GameStateMachine__Update{ nullptr }; + App::LoadGraphicSettingsProc* App__LoadGraphicSettings{ nullptr }; ecs::EntityWorld::UpdateProc* ecs__EntityWorld__Update{ nullptr }; @@ -90,7 +92,7 @@ namespace bg3se stats::RPGStats** gRPGStats{ nullptr }; stats::RPGStats::LoadProc* RPGStats__Load{ nullptr }; - stats::RPGStats::ParseStructureFolderProc* RPGStats__ParseStructureFolder{ nullptr }; + stats::RPGStats::ParseStructureFolderProc* RPGStats__PreParseDataFolder{ nullptr }; /*RPGStats::ParsePropertiesProc* RPGStats__ParseProperties{nullptr}; SkillPrototypeManager** eoc__SkillPrototypeManager{ nullptr }; StatusPrototypeManager** eoc__StatusPrototypeManager{ nullptr };*/ @@ -101,6 +103,7 @@ namespace bg3se std::map Libraries; + void* ls__gGlobalAllocator{ nullptr }; ls__GlobalAllocator__AllocProc* ls__GlobalAllocator__Alloc{ nullptr }; ls__GlobalAllocator__FreeProc* ls__GlobalAllocator__Free{ nullptr }; diff --git a/BG3Extender/GameHooks/BinaryMappings.xml b/BG3Extender/GameHooks/BinaryMappings.xml index 3c7e1a92..bc7c93c3 100644 --- a/BG3Extender/GameHooks/BinaryMappings.xml +++ b/BG3Extender/GameHooks/BinaryMappings.xml @@ -2,111 +2,124 @@ - c3 // retn - 48 85 db // test rbx, rbx - 74 0f // jz short loc_143858624 - 45 33 c0 // xor r8d, r8d - 48 8b cb // mov rcx, rbx - 41 8d 50 07 // lea edx, [r8+7] - @ref1 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Free - 41 b9 10 00 00 00 // mov r9d, 10h; alignment - 45 33 c0 // xor r8d, r8d; a3 - 33 c9 // xor ecx, ecx; size - 41 8d 51 f5 // lea edx, [r9-0Bh]; pool - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Alloc - 48 8b 5c 24 30 // mov rbx, [rsp+28h+arg_0] - 33 f6 // xor esi, esi - - - - - - 48 83 ec 28 // sub rsp, 28h - 4c 8b c1 // mov r8, rcx - 48 8d 54 24 38 // lea rdx, [rsp+28h+arg_8] - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool - 48 81 c1 00 c6 00 00 // add rcx, 0C600h - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalStringPool__CreateFromString - 8b 44 24 38 // mov eax, [rsp+28h+arg_8] - 48 83 c4 28 // add rsp, 28h - - - - - - 40 53 // push rbx + 48 89 6c 24 18 // mov [rsp+arg_10], rbp + 48 89 74 24 20 // mov [rsp+arg_18], rsi + 41 56 // push r14 48 83 ec 20 // sub rsp, 20h - 48 8b d9 // mov rbx, rcx - 89 54 24 38 // mov [rsp+28h+arg_8], edx - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool - 48 8d 54 24 38 // lea rdx, [rsp+28h+arg_8] - e8 ?? ?? ?? ?? // call sub_143866DA0 - 48 8d 50 18 // lea rdx, [rax+18h] - 8b 40 08 // mov eax, [rax+8] - 89 43 08 // mov [rbx+8], eax - 48 8b c3 // mov rax, rbx - 48 89 13 // mov [rbx], rdx - 48 83 c4 20 // add rsp, 20h - 5b // pop rbx - + 65 48 8b 04 25 58 00 00 00 // mov rax, gs:58h + @ref2 4c 8d 35 ?? ?? ?? ?? // lea r14, ls__gGlobalAllocator + ba 88 04 00 00 // mov edx, 488h + 48 8b 08 // mov rcx, [rax] + 8b 04 0a // mov eax, [rdx+rcx] + + + + + 83 79 0c 00 // cmp dword ptr [rcx+0Ch], 0 + 7e 07 // jle short loc_140572680 + c7 41 0c 00 00 00 00 // mov dword ptr [rcx+0Ch], 0 + 48 8b 39 // mov rdi, [rcx] + 48 85 ff // test rdi, rdi + 74 10 // jz short loc_140572698 + e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Get + 48 8b d7 // mov rdx, rdi; a2 + 48 8b c8 // mov rcx, rax; a1 + @ref2 e8 ?? ?? ?? ?? // call ls__GlobalMemoryManager__Free + e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Get + 48 c7 44 24 20 10 00 00 00 // mov [rsp+38h+alignment], 10h; alignment + 33 d2 // xor edx, edx; size + 48 8b c8 // mov rcx, rax; a1 + @ref4 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Alloc2 + + - 48 83 ec 28 // sub rsp, 28h - 89 4c 24 30 // mov [rsp+28h+arg_0], ecx - 48 8d 54 24 30 // lea rdx, [rsp+28h+arg_0] - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool + 83 f8 ff // cmp eax, 0FFFFFFFFh + 74 0b // jz short loc_140EC1A4F + 8b c8 // mov ecx, eax; a1 + @ref1 e8 ?? ?? ?? ?? // call ls__FixedString__AddRef + 8b 44 24 58 // mov eax, [rsp+48h+a1] + 8b 0b // mov ecx, [rbx] + 83 f9 ff // cmp ecx, 0FFFFFFFFh + 74 20 // jz short loc_140EC1A76 + 89 4c 24 20 // mov [rsp+48h+var_28], ecx + @ref2 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringTable 48 81 c1 00 c6 00 00 // add rcx, 0C600h - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalStringPool__AddRef - 48 83 c4 28 // add rsp, 28h - + 48 8d 54 24 20 // lea rdx, [rsp+48h+var_28] + @ref3 e8 ?? ?? ?? ?? // call ls__GlobalStringTable__MainTable__DecRef + + + - - 48 83 ec 28 // sub rsp, 28h - 89 4c 24 30 // mov dword ptr [rsp+28h+a2], ecx - 48 8d 54 24 30 // lea rdx, [rsp+28h+a2]; a2 - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool + + @str1 48 8d 05 ?? ?? ?? ?? // lea rax, aH8e3f9e82g8fda; "h8e3f9e82g8fdag437cg99c1g4988a6aeccff" + 48 89 44 24 28 // mov [rsp+58h+a3.Str], rax + c7 44 24 30 25 00 00 00 // mov [rsp+58h+a3.Length], 25h ; '%' + c7 44 24 78 ff ff ff ff // mov [rsp+58h+arg_18], 0FFFFFFFFh + c7 44 24 20 02 00 00 00 // mov [rsp+58h+var_38], 2 + 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringTable 48 81 c1 00 c6 00 00 // add rcx, 0C600h; a1 - e8 ?? ?? ?? ?? // call sub_143865FD0 - 48 83 c4 28 // add rsp, 28h - + 4c 8d 44 24 28 // lea r8, [rsp+58h+a3]; a3 + 48 8d 54 24 70 // lea rdx, [rsp+58h+a1]; a2 + @ref2 e8 ?? ?? ?? ?? // call ls__GlobalStringTable__MainTable__FromString + + - - - 48 8d 4c 24 40 // lea rcx, [rsp+0F8h+var_B8] + + 48 8d 54 24 40 // lea rdx, [rsp+58h+var_18]; a2 + 48 8b d8 // mov rbx, rax + @ref1 e8 ?? ?? ?? ?? // call ls__FixedString__ToString + 0f 10 07 // movups xmm0, xmmword ptr [rdi] + 0f 11 05 ?? ?? ?? ?? // movups cs:xmmword_145B17160, xmm0 + 0f 10 0b // movups xmm1, xmmword ptr [rbx] + 48 8b 5c 24 60 // mov rbx, [rsp+58h+arg_0] + + + + + 45 33 ed // xor r13d, r13d + 45 8b cd // mov r9d, r13d + 45 33 c0 // xor r8d, r8d + 48 8b d3 // mov rdx, rbx + 48 8d 4d c0 // lea rcx, [rbp+1B0h+var_1F0] @ref1 e8 ?? ?? ?? ?? // call ls__FileReader__ctor 90 // nop - 4c 8b ce // mov r9, rsi - 4c 8d 44 24 40 // lea r8, [rsp+0F8h+var_B8] - 48 8b d7 // mov rdx, rdi - 48 8b cb // mov rcx, rbx; struct __crt_stdio_stream * - e8 ?? ?? ?? ?? // call sub_1437F5200 - 0f b6 d8 // movzx ebx, al - 48 8d 4c 24 40 // lea rcx, [rsp+0F8h+var_B8] - @ref2 e8 ?? ?? ?? ?? // call ls__FileReader__dtor - 0f b6 c3 // movzx eax, bl - + 48 8d 55 90 // lea rdx, [rbp+1B0h+var_220] + 48 8b cb // mov rcx, rbx + e8 ?? ?? ?? ?? // call sub_143859020 + 0f 57 c0 // xorps xmm0, xmm0 - + + + + 48 63 c6 // movsxd rax, esi + 48 8d 1c c0 // lea rbx, [rax+rax*8] + 48 c1 e3 04 // shl rbx, 4 + 48 03 1f // add rbx, [rdi] + 48 8b cb // mov rcx, rbx + @ref1 e8 ?? ?? ?? ?? // call ls__FileReader__dtorIntenal + 48 8d 4b 28 // lea rcx, [rbx+28h]; a1 + e8 ?? ?? ?? ?? // call ls__ScratchBuffer__dtor + 8b 47 0c // mov eax, [rdi+0Ch] + ff c6 // inc esi + 3b f0 // cmp esi, eax + - 48 8b f0 // mov rsi, rax - 48 8d 55 bf // lea rdx, [rbp+57h+var_98]; a2 - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gPathRoots; a1 - @ref2 e8 ?? ?? ?? ?? // call ls__STDString__ToStringView - 48 63 5d c7 // movsxd rbx, [rbp+57h+var_98.Length] - 48 8d 55 cf // lea rdx, [rbp+57h+var_88]; a2 - 48 8b ce // mov rcx, rsi; a1 - @ref3 e8 ?? ?? ?? ?? // call ls__STDString__ToStringView - 48 63 55 d7 // movsxd rdx, [rbp+57h+var_88.Length] - 48 83 c2 02 // add rdx, 2 - 48 03 d3 // add rdx, rbx; a2 - 48 8d 4d f7 // lea rcx, [rbp+57h+Src]; a1 - @ref4 e8 ?? ?? ?? ?? // call ls__STDString__ctorSize - 90 // nop + c7 81 a4 00 00 00 00 00 04 00 // mov dword ptr [rcx+0A4h], 40000h + 48 89 b9 a8 00 00 00 // mov [rcx+0A8h], rdi + 89 b9 b0 00 00 00 // mov [rcx+0B0h], edi + 40 88 b9 b4 00 00 00 // mov [rcx+0B4h], dil + 66 89 b9 b8 00 00 00 // mov [rcx+0B8h], di + 89 b9 bc 00 00 00 // mov [rcx+0BCh], edi + 66 89 b9 c0 00 00 00 // mov [rcx+0C0h], di + 48 81 c1 c8 00 00 00 // add rcx, 0C8h ; 'È' + @ref1 48 8b 05 ?? ?? ?? ?? // mov rax, cs:ls__gPathRoots + 48 8b d0 // mov rdx, rax @@ -134,19 +147,16 @@ - 89 44 24 50 // mov [rsp+48h+arg_0], eax - e8 ?? ?? ?? ?? // call sub_143690CA0 - 48 8d 15 ?? ?? ?? ?? // lea rdx, unk_145787190 - 48 8b c8 // mov rcx, rax - e8 ?? ?? ?? ?? // call sub_143233510 - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ecl__gEoCClient - e8 ?? ?? ?? ?? // call sub_140666800 - 48 8b 8b ?? ?? ?? ?? // mov rcx, [rbx+170h] - e8 ?? ?? ?? ?? // call sub_14065EC00 - @ref2 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:esv__gEoCServer - e8 ?? ?? ?? ?? // call sub_140FB9F70 - - + 83 b8 44 07 00 00 02 // cmp dword ptr [rax+744h], 2 + 74 0f // jz short loc_140567F25 + 48 8b d3 // mov rdx, rbx + @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:esv__gEocServer + e8 ?? ?? ?? ?? // call sub_14072F540 + @ref2 48 8b 3d ?? ?? ?? ?? // mov rdi, cs:ecl__gEoCClient + 48 8b d3 // mov rdx, rbx + 48 8b 8f a8 00 00 00 // mov rcx, [rdi+0A8h] + + @@ -161,86 +171,111 @@ - 90 // nop - 4c 8b c8 // mov r9, rax 41 b0 01 // mov r8b, 1 48 8d 54 24 50 // lea rdx, [rsp+350h+var_300] - 48 8b cb // mov rcx, rbx + 48 8b cf // mov rcx, rdi @ref1 e8 ?? ?? ?? ?? // call ecl__EocClient__HandleError 90 // nop - 48 8d 4c 24 28 // lea rcx, [rsp+350h+var_328] - e9 af 00 00 00 // jmp loc_14086156B - 48 c7 44 24 70 05 00 00 00 // mov [rsp+350h+var_2E0], 5 + 48 8d 4c 24 28 // lea rcx, [rsp+350h+a1] + e9 e1 01 00 00 // jmp loc_142938339 + 48 c7 44 24 28 05 00 00 00 // mov qword ptr [rsp+350h+a1], 5 44 8b c8 // mov r9d, eax + @str1 4c 8d 05 ?? ?? ?? ?? // lea r8, a4x; "%.4x" + - - 41 8b d7 // mov edx, r15d - @ref0 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ecl__gGameStateEventManager - @ref1 e8 ?? ?? ?? ?? // call ecl__GameStateEventManager__ExecuteGameStateChangedEvent - 48 8b 0f // mov rcx, [rdi] - - - - - - - 4c 8b dc // mov r11, rsp - 55 // push rbp - 41 54 // push r12 - 49 8d 6b a1 // lea rbp, [r11-5Fh] - 48 81 ec f8 00 00 00 // sub rsp, 0F8h + + 48 8b d3 // mov rdx, rbx + 48 8b 8f a0 00 00 00 // mov rcx, [rdi+0A0h] + @ref1 e8 ?? ?? ?? ?? // call ecl__GameStateMachine__Update + 48 8b d3 // mov rdx, rbx + 48 8b 8f 68 01 00 00 // mov rcx, [rdi+168h] + e8 ?? ?? ?? ?? // call sub_143755470 + 48 8b 8f b8 00 00 00 // mov rcx, [rdi+0B8h] + 48 85 c9 // test rcx, rcx + - - 74 13 // jz short loc_140676B87 - 4c 8b c3 // mov r8, rbx + @str1 48 8d 15 ?? ?? ?? ?? // lea rdx, aClientStateSwa; "CLIENT STATE SWAP - from: %s, to: %s" + 48 8d 4c 24 38 // lea rcx, [rsp+3B0h+var_378] + e8 ?? ?? ?? ?? // call sub_1438650C0 + 45 84 f6 // test r14b, r14b + 74 00 // jz short $+2 + 44 89 6d b0 // mov dword ptr [rbp+2B0h+var_300], r13d + 8b 47 08 // mov eax, [rdi+8] + 89 45 b4 // mov dword ptr [rbp+2B0h+var_300+4], eax + @ref2 48 8b 05 ?? ?? ?? ?? // mov rax, cs:ecl__gGameStateEventManager - - - - - - 41 57 // push r15 - 48 81 ec 90 00 00 00 // sub rsp, 90h - 83 79 24 00 // cmp dword ptr [rcx+24h], 0 - 4c 8b fa // mov r15, rdx - + - - 74 14 // jz short loc_14102A7AE - 4c 8b c7 // mov r8, rdi + @str1 48 8d 15 ?? ?? ?? ?? // lea rdx, aServerStateSwa; "SERVER STATE SWAP - from: %s, to: %s\n" - 48 8d 4c 24 38 // lea rcx, [rsp+98h+var_60] + 48 8d 4c 24 30 // lea rcx, [rsp+98h+var_68] + e8 ?? ?? ?? ?? // call sub_1438650C0 + 40 84 ed // test bpl, bpl + 74 00 // jz short $+2 + 44 89 a4 24 a0 00 00 00 // mov [rsp+98h+arg_0], r12d + 8b 47 10 // mov eax, [rdi+10h] + 89 84 24 a4 00 00 00 // mov [rsp+98h+arg_4], eax + @ref2 48 8b 05 ?? ?? ?? ?? // mov rax, cs:esv__gGameStateEventManager - + + + + + 48 89 03 // mov [rbx], rax + 48 8b d3 // mov rdx, rbx + 48 8b ce // mov rcx, rsi + e8 ?? ?? ?? ?? // call esv__GameStateMachine__SetTargetState + 48 8d 15 ?? ?? ?? ?? // lea rdx, unk_145C9A298 + 48 8b 8f a0 00 00 00 // mov rcx, [rdi+0A0h] + @ref3 e8 ?? ?? ?? ?? // call esv__GameStateMachine__Update + 8b 05 ?? ?? ?? ?? // mov eax, cs:ls__AnimationBlueprintSystemID + 48 69 d0 f8 00 00 00 // imul rdx, rax, 0F8h + + + + + 48 89 5c 24 10 // mov [rsp+arg_8], rbx + 57 // push rdi + 48 83 ec 60 // sub rsp, 60h + 48 8b 05 ?? ?? ?? ?? // mov rax, cs:__security_cookie + 48 33 c4 // xor rax, rsp + 48 89 44 24 58 // mov [rsp+68h+var_10], rax + 48 8b f9 // mov rdi, rcx + ba 04 00 00 00 // mov edx, 4 + @str1 4c 8d 05 ?? ?? ?? ?? // lea r8, aGraphicsetting_0; "graphicSettings.lsx" + + - 48 89 5c 24 18 // mov [rsp-8+arg_10], rbx - 48 89 74 24 20 // mov [rsp-8+arg_18], rsi + 48 8b c4 // mov rax, rsp + 48 89 58 10 // mov [rax+10h], rbx + 48 89 70 18 // mov [rax+18h], rsi 55 // push rbp 57 // push rdi + 41 55 // push r13 + 41 56 // push r14 41 57 // push r15 - 48 8d ac 24 60 ff ff ff // lea rbp, [rsp-0A0h] - 48 81 ec a0 01 00 00 // sub rsp, 1A0h - 48 8b 99 e8 00 00 00 // mov rbx, [rcx+0E8h] + 48 8d 68 88 // lea rbp, [rax-78h] + 48 81 ec 50 01 00 00 // sub rsp, 150h + 0f 29 70 c8 // movaps xmmword ptr [rax-38h], xmm6 + 0f 29 78 b8 // movaps xmmword ptr [rax-48h], xmm7 48 8b f1 // mov rsi, rcx - 48 8d 4c 24 68 // lea rcx, [rsp+1B0h+a1]; a1 - @ref1 e8 ?? ?? ?? ?? // call ls__GetCurrentThreadId_ - 8b 10 // mov edx, [rax] - 89 93 a0 00 00 00 // mov [rbx+0A0h], edx + 48 8b 99 e8 00 00 00 // mov rbx, [rcx+0E8h] + @ref1 ff 15 ?? ?? ?? ?? // call cs:GetCurrentThreadId - - 40 55 // push rbp - 53 // push rbx - 56 // push rsi + 48 8b c4 // mov rax, rsp + 48 89 70 10 // mov [rax+10h], rsi + 48 89 78 18 // mov [rax+18h], rdi + @@ -418,10 +453,10 @@ @str1 48 8d 0d ?? ?? ?? ?? // lea rcx, aCreatingApp; "Creating App\n" @ref1 ff 15 ?? ?? ?? ?? // call cs:OutputDebugStringA - b9 ?? 01 00 00 // mov ecx, 1C0h; Size - @ref2 ff 15 ?? ?? ?? ?? // call cs:__imp_malloc - 48 8b c8 // mov rcx, rax - @ref3 48 89 05 ?? ?? ?? ?? // mov cs:ls__gApp, rax + b9 c8 01 00 00 // mov ecx, 1C8h + @ref2 ff 15 ?? ?? ?? ?? // call cs:malloc + 4c 8b e0 // mov r12, rax + @ref3 48 89 05 ?? ?? ?? ?? // mov cs:ls__gApp2, rax @@ -438,33 +473,30 @@ - 8b 78 18 // mov edi, [rax+18h] + 44 8b 40 18 // mov r8d, [rax+18h] @ref1 48 8b 05 ?? ?? ?? ?? // mov rax, cs:gRPGStats 48 85 c0 // test rax, rax - 74 1e // jz short loc_1408795F5 + 74 1e // jz short loc_143AF0CC3 48 8b 88 88 02 00 00 // mov rcx, [rax+288h] 48 85 c9 // test rcx, rcx - 74 12 // jz short loc_1408795F5 + 74 12 // jz short loc_143AF0CC3 @str1 48 8d 15 ?? ?? ?? ?? // lea rdx, fs_WisdomTierHigh - - 49 8d 4d 60 // lea rcx, [r13+60h] - 48 8b 01 // mov rax, [rcx] - ff 50 08 // call qword ptr [rax+8] - 49 8b 45 00 // mov rax, [r13+0] - 49 8b cd // mov rcx, r13 - ff 50 08 // call qword ptr [rax+8] - 48 8b d3 // mov rdx, rbx - 49 8b cd // mov rcx, r13 - @ref1 e8 ?? ?? ?? ?? // call RPGStats__ParseStructureFolder - + + 48 83 c6 18 // add rsi, 18h + 49 83 ee 01 // sub r14, 1 + 0f 85 ?? ?? ff ff // jnz loc_140EFD210 + 49 8b d5 // mov rdx, r13 + 49 8b cf // mov rcx, r15 + @ref1 e8 ?? ?? ?? ?? // call RPGStats__PreParseDataFolder + - 48 89 5c 24 10 // mov [rsp+arg_8], rbx + 48 89 5c 24 18 // mov [rsp-8+arg_10], rbx 55 // push rbp 56 // push rsi 57 // push rdi @@ -472,198 +504,113 @@ 41 55 // push r13 41 56 // push r14 41 57 // push r15 - 48 83 ec 20 // sub rsp, 20h - 48 8b da // mov rbx, rdx - 4c 8b e9 // mov r13, rcx - 48 8d 81 e8 03 00 00 // lea rax, [rcx+3E8h] - 48 89 44 24 70 // mov [rsp+58h+arg_10], rax - 33 ff // xor edi, edi + 48 8d 6c 24 d9 // lea rbp, [rsp-27h] + 48 81 ec d0 00 00 00 // sub rsp, 0D0h + @ref1 48 8b 05 ?? ?? ?? ?? // mov rax, cs:__security_cookie + 48 33 c4 // xor rax, rsp + 48 89 45 17 // mov [rbp+57h+var_40], rax + 4c 8b ea // mov r13, rdx + 4c 8b f9 // mov r15, rcx + 48 81 c1 e8 03 00 00 // add rcx, 3E8h + 48 89 4d a7 // mov [rbp+57h+var_B0], rcx - - + + + + + + @ref1 0f 11 05 ?? ?? ?? ?? // movups cs:xmmword_145B2D7A0, xmm0 + 48 8d 05 ?? ?? ?? ?? // lea rax, ls__ComponentIdInitTemp2 + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145B2D798, rax + 48 8d 05 ?? ?? ?? ?? // lea rax, qword_145BB7478 + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145B2D790, rax + 48 8b 05 ?? ?? ?? ?? // mov rax, cs:qword_145BB28B0 + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145B2D7B0, rax + 48 8d 05 ?? ?? ?? ?? // lea rax, qword_145B2D790 + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145BB28B0, rax + 48 8b 5c 24 40 // mov rbx, [rsp+38h+arg_0] + 48 83 c4 30 // add rsp, 30h + 5f // pop rdi + c3 // retn + 48 8d 0d ?? ?? ?? ?? // lea rcx, dword_145BB5A70 + e8 ?? ?? ?? ?? // call _Init_thread_header + 83 3d ?? ?? ?? ?? ff // cmp cs:dword_145BB5A70, 0FFFFFFFFh + 0f 85 7a ff ff ff // jnz loc_14002E90A + @str1 48 8d 05 ?? ?? ?? ?? // lea rax, aClassLsStringv_1; "class ls::_StringView... + + - @ref1 c7 05 ?? ?? ?? ?? ff ff ff 7f // mov cs:ecl__CharacterID, 7FFFFFFFh - 48 83 c4 40 // add rsp, 40h - 5b // pop rbx + @ref1 48 8b 05 ?? ?? ?? ?? // mov rax, cs:ecs__EntityWorld__SystemsContext + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145B2D018, rax + 48 8d 05 ?? ?? ?? ?? // lea rax, qword_145B2D000 + 48 89 05 ?? ?? ?? ?? // mov cs:ecs__EntityWorld__SystemsContext, rax + c7 05 ?? ?? ?? ?? ff ff ff 7f // mov cs:ls__InstancingSystemID, 7FFFFFFFh + 48 8b 5c 24 40 // mov rbx, [rsp+38h+arg_0] + 48 83 c4 30 // add rsp, 30h + 5f // pop rdi c3 // retn - 48 8d 0d ?? ?? ?? ?? // lea rcx, dword_14564DF98 - @ref2 e8 ?? ?? ?? ?? // call _Init_thread_header - 83 3d ?? ?? ?? ?? FF // cmp cs:dword_14564DF98, 0FFFFFFFFh - 75 a2 // jnz short loc_14005A287 - @str1 48 8d 05 ?? ?? ?? ?? // lea rax, xxx - 48 89 44 24 20 // mov qword ptr [rsp+48h+var_28], rax - c7 44 24 28 ?? ?? ?? ?? // mov dword ptr [rsp+48h+var_28+8], 4Fh ; 'O' - 0f 28 44 24 20 // movaps xmm0, [rsp+48h+var_28] - 66 0f 7f 44 24 20 // movdqa [rsp+48h+var_28], xmm0 - 48 8d 54 24 20 // lea rdx, [rsp+48h+var_28] - 48 8d 0d ?? ?? ?? ?? // lea rcx, stru_14564DF80; Src - @ref3 e8 ?? ?? ?? ?? // call ls__ComponentNameFromSymbolName + 48 8d 0d ?? ?? ?? ?? // lea rcx, dword_145BB51D0 + e8 ?? ?? ?? ?? // call _Init_thread_header + 83 3d ?? ?? ?? ?? ff // cmp cs:dword_145BB51D0, 0FFFFFFFFh + 75 90 // jnz short loc_14002F0A8 + @str1 48 8d 05 ?? ?? ?? ?? // lea rax, aClassLsStringv_7; "class ls::_StringView - @ref1 48 8b c3 // mov rax, rbx - 48 83 c4 30 // add rsp, 30h - 5b // pop rbx - c3 // retn - 48 8d 0d ?? ?? ?? ?? // lea rcx, dword_1456673FC - e8 ?? ?? ?? ?? // call _Init_thread_header - 83 3d ?? ?? ?? ?? FF // cmp cs:dword_1456673FC, 0FFFFFFFFh - 75 d3 // jnz short loc_1407CAACD - @str1 48 8d 05 ?? ?? ?? ?? // lea rax, aClassLsStringv_54 - 48 89 44 24 20 // mov [rsp+38h+var_18.Str], rax - c7 44 24 28 ?? ?? ?? ?? // mov [rsp+38h+var_18.Length], 60h ; '`' - 0f 28 44 24 20 // movaps xmm0, xmmword ptr [rsp+38h+var_18.Str] - 66 0f 7f 44 24 20 // movdqa xmmword ptr [rsp+38h+var_18.Str], xmm0 + @ref1 83 3d ?? ?? ?? ?? ff // cmp cs:dword_145C08178, 0FFFFFFFFh + 75 c2 // jnz short loc_141463440 + 48 8d 05 ?? ?? ?? ?? // lea rax, aClassLsStringv_4229; "class ls::_StringView... + 48 89 44 24 20 // mov qword ptr [rsp+38h+var_18], rax + c7 44 24 28 ?? ?? 00 00 // mov dword ptr [rsp+38h+var_18+8], 6Ch ; 'l' + 0f 28 44 24 20 // movaps xmm0, [rsp+38h+var_18] + 66 0f 7f 44 24 20 // movdqa [rsp+38h+var_18], xmm0 + 48 8d 54 24 20 // lea rdx, [rsp+38h+var_18] + 48 8b cb // mov rcx, rbx; Src + e8 ?? ?? ?? ?? // call ls__ComponentNameFromSymbolName + 48 8d 0d ?? ?? ?? ?? // lea rcx, sub_144BF5630; void (__cdecl *)() + e8 ?? ?? ?? ?? // call atexit + 90 // nop + @ref1 48 8d 05 ?? ?? ?? ?? // lea rax, ls__model__game__inventory__v0__WieldedComponentID2 48 8d 4c 24 20 // lea rcx, [rsp+38h+var_18] - 48 89 05 ?? ?? ?? ?? // mov cs:qword_14566E5F8, rax - @ref1 e8 ?? ?? ?? ?? // call ls__SV__xxx + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145B6FA28, rax + e8 ?? ?? ?? ?? // call ls__SV__ls__model__game__inventory__v0__WieldedComponent 0f 10 00 // movups xmm0, xmmword ptr [rax] - 48 8b 05 ?? ?? ?? ?? // mov rax, cs:qword_145645E88 - 48 89 05 ?? ?? ?? ?? // mov cs:qword_14566E610, rax - 48 8d 05 ?? ?? ?? ?? // lea rax, qword_14566E5F8 - 48 89 05 ?? ?? ?? ?? // mov cs:qword_145645E88, rax - 0f 11 05 ?? ?? ?? ?? // movups cs:xmmword_14566E600, xmm0 - @ref2 c7 05 ?? ?? ?? ?? ff ff ff 7f // mov cs:xxxID, 7FFFFFFFh + 48 8b 05 ?? ?? ?? ?? // mov rax, cs:ls__model__TypeIdContext + 48 89 05 ?? ?? ?? ?? // mov cs:qword_145B6FA40, rax + 48 8d 05 ?? ?? ?? ?? // lea rax, qword_145B6FA28 + 48 89 05 ?? ?? ?? ?? // mov cs:ls__model__TypeIdContext, rax + 0f 11 05 ?? ?? ?? ?? // movups cs:xmmword_145B6FA30, xmm0 + c7 05 ?? ?? ?? ?? ff ff ff 7f // mov cs:ls__model__game__inventory__v0__WieldedComponentID2, 7FFFFFFFh 48 83 c4 38 // add rsp, 38h c3 // retn + - 4c 8d 4c 24 ?? // lea r9, [rsp+120h+a2]; a4 - @ref1 44 8b 05 ?? ?? ?? ?? // mov r8d, cs:eoc__inventory__StackComponentID; a3 - 48 8b 54 24 ?? // mov rdx, [rsp+120h+var_C0]; a2 - 48 8b 4c 24 ?? // mov rcx, [rsp+120h+var_E0]; this - e8 ?? ?? ?? ?? // call ecs__ComponentReplication__RequestSync + @ref1 48 89 05 ?? ?? ?? ?? // mov cs:ecs__sync__ReplicatedTypeContext, rax + c7 05 ?? ?? ?? ?? ff ff ff 7f // mov cs:eoc__summon__ContainerComponentID, 7FFFFFFFh + 48 8b 5c 24 40 // mov rbx, [rsp+38h+arg_0] + 48 83 c4 30 // add rsp, 30h + 5f // pop rdi + c3 // retn + 48 8d 0d ?? ?? ?? ?? // lea rcx, dword_145BB9C48 + @ref3 e8 ?? ?? ?? ?? // call _Init_thread_header + 83 3d ?? ?? ?? ?? ff // cmp cs:dword_145BB9C48, 0FFFFFFFFh + 75 90 // jnz short loc_14004DF58 + @str1 48 8d 05 ?? ?? ?? ?? // lea rax, aClassLsStringv_309; "class ls::_StringView - - @ref1 44 0f b7 0d ?? ?? ?? ?? // movzx r9d, word ptr cs:xxxID - 48 8d 54 24 20 // lea rdx, [rsp+48h+var_28] - 48 8b 89 40 03 00 00 // mov rcx, [rcx+340h] - be ff 7f 00 00 // mov esi, 7FFFh - 66 44 23 ce // and r9w, si - e8 ?? ?? ?? ?? // call ecs__EntityComponents__TryGet - - - - - 8b 10 // mov edx, [rax] - @ref1 0f b7 05 ?? ?? ?? ?? // movzx eax, word ptr cs:eoc__SightRangeAdditiveBoostComponentID2 - 66 23 c1 // and ax, cx - 89 54 24 ?? // mov [rsp+88h+var_50], edx - 48 8b cf // mov rcx, rdi - 66 89 44 24 20 // mov [rsp+88h+var_68], ax - 48 8d 54 24 ?? // lea rdx, [rsp+88h+var_48] - e8 ?? ?? ?? ?? // call sub_14368B390 - - - - - 45 33 e4 // xor r12d, r12d - @ref1 0f b7 1d ?? ?? ?? ?? // movzx ebx, word ptr cs:eoc__controller__LocomotionComponentID - 41 bd ff 7f 00 00 // mov r13d, 7FFFh - 66 41 23 dd // and bx, r13w - 48 8d 4d c0 // lea rcx, [rbp+a3] - e8 ?? ?? ?? ?? // call ecs__ComponentRegistryEntry3__ctor - 90 // nop - - - - - 45 33 e4 // xor r12d, r12d - @ref1 0f b7 1d ?? ?? ?? ?? // movzx ebx, word ptr cs:eoc__spell_cast__FinishedEventOneFrameComponentID_2 - 41 be ff 7f 00 00 // mov r14d, 7FFFh - 66 41 23 de // and bx, r14w - 48 8d 4d c0 // lea rcx, [rbp+a3] - e8 ?? ?? ?? ?? // call ecs__ComponentRegistryEntry3__ctor - 90 // nop - - - - - be 00 80 00 00 // mov esi, 8000h - 48 8d 54 24 30 // lea rdx, [rsp+0A8h+a2]; a2 - 8b c6 // mov eax, esi - 48 83 c1 50 // add rcx, 50h ; 'P'; a1 - @ref1 66 0b 05 ?? ?? ?? ?? // or ax, word ptr cs:esv__item__UseEventsOneFrameComponentID_2 - 66 89 44 24 30 // mov [rsp+0A8h+a2], ax - - - - - 41 be 00 80 00 00 // mov r14d, 8000h - 41 8b f6 // mov esi, r14d - @ref1 66 0b 35 ?? ?? ?? ?? // or si, word ptr cs:ls__VisualChangeRequestOneFrameComponentID_2 - 48 8d 4d c0 // lea rcx, [rbp+a3] - e8 ?? ?? ?? ?? // call ecs__ComponentRegistryEntry3__ctor - 90 // nop - - - - - 45 33 ed // xor r13d, r13d - 41 be 00 80 00 00 // mov r14d, 8000h - 41 8b fe // mov edi, r14d - @ref1 66 0b 3d ?? ?? ?? ?? // or di, word ptr cs:esv__sight__StealthRollRequestOneFrameComponentID - 48 8d 4d c0 // lea rcx, [rbp+a3] - e8 ?? ?? ?? ?? // call ecs__ComponentRegistryEntry3__ctor - 90 // nop - - - - - 48 83 ec 20 // sub rsp, 20h - 48 8b d9 // mov rbx, rcx - 48 83 79 20 00 // cmp qword ptr [rcx+20h], 0 - 74 25 // jz short loc_14169FA09 - 48 83 c1 28 // add rcx, 28h ; '('; a1 - @ref1 e8 ?? ?? ?? ?? // call ls__BitSet__IsEmpty - 84 c0 // test al, al - 74 18 // jz short loc_14169FA09 - 4c 8d 4b 28 // lea r9, [rbx+28h]; a4 - @ref2 44 8b 05 ?? ?? ?? ?? // mov r8d, cs:eoc__lock__KeyComponentID; a3 - 48 8b 53 40 // mov rdx, [rbx+40h]; a2 - 48 8b 4b 20 // mov rcx, [rbx+20h]; this - @ref3 e8 ?? ?? ?? ?? // call ecs__ComponentReplication__RequestSync - 48 8d 4b 28 // lea rcx, [rbx+28h]; a1 - - - - - 48 83 ec 40 // sub rsp, 40h - 48 8b e9 // mov rbp, rcx - @ref1 48 63 3d ?? ?? ?? ?? // movsxd rdi, cs:eoc__spell_cast__CanBeTargetedComponentID - 33 d2 // xor edx, edx; a2 - 8d 4a 08 // lea ecx, [rdx+8]; size - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Alloc1 - 48 8b f0 // mov rsi, rax - - - - - 48 8d 6c 24 d9 // lea rbp, [rsp-27h] - 48 81 ec b0 00 00 00 // sub rsp, 0B0h - 4c 8b f1 // mov r14, rcx - 45 33 e4 // xor r12d, r12d - @ref1 48 63 3d ?? ?? ?? ?? // movsxd rdi, cs:dword_1455D3FEC - 33 d2 // xor edx, edx - 8d 4a 08 // lea ecx, [rdx+8] - e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Alloc1 - 48 8b f0 // mov rsi, rax - - - 48 8b 8f 88 02 00 00 // mov rcx, [rdi+288h] 48 8b d3 // mov rdx, rbx @@ -757,17 +704,19 @@ - @str1 48 8d 15 ?? ?? ?? ?? // lea rdx, fs_MaximumTotalTargetHP - 48 8b cb // mov rcx, rbx - e8 ?? ?? ?? ?? // call sub_142164A70 - 85 c0 // test eax, eax - 0f 9f c1 // setnle cl - 85 c0 // test eax, eax - 0f 8f 8f 00 00 00 // jg loc_1426BF7C0 - @ref1 4c 8b 05 ?? ?? ?? ?? // mov r8, cs:eoc__gGuidResourceManager - 49 63 40 08 // movsxd rax, dword ptr [r8+8] - + 48 83 ec 20 // sub rsp, 20h + @ref1 48 8b 3d ?? ?? ?? ?? // mov rdi, cs:ls__gGuidResourceManager + 48 8b f1 // mov rsi, rcx + 48 8b cf // mov rcx, rdi + e8 ?? ?? ?? ?? // call sub_140EC42E0 + 4c 8b d0 // mov r10, rax + 4c 8d 0d ?? ?? ?? ?? // lea r9, xmmword_145B288E0 + 44 8b 98 ac 00 00 00 // mov r11d, [rax+0ACh] + 45 85 db // test r11d, r11d + 74 3c // jz short loc_140EDF433 + @str1 44 8b 05 ?? ?? ?? ?? // mov r8d, cs:fs_MALE.ID + diff --git a/BG3Extender/GameHooks/DataLibraries.cpp b/BG3Extender/GameHooks/DataLibraries.cpp index 158b6fbc..f263c33b 100644 --- a/BG3Extender/GameHooks/DataLibraries.cpp +++ b/BG3Extender/GameHooks/DataLibraries.cpp @@ -13,12 +13,12 @@ namespace bg3se { void* BG3Alloc(std::size_t size) { - return GetStaticSymbols().ls__GlobalAllocator__Alloc(size, 2, 0, 8); + return GetStaticSymbols().ls__GlobalAllocator__Alloc(GetStaticSymbols().ls__gGlobalAllocator, size, 2, 0, 8); } void BG3Free(void* ptr) { - GetStaticSymbols().ls__GlobalAllocator__Free(ptr); + GetStaticSymbols().ls__GlobalAllocator__Free(GetStaticSymbols().ls__gGlobalAllocator, ptr); } LibraryManager::LibraryManager() @@ -65,10 +65,10 @@ namespace bg3se auto const& sym = GetStaticSymbols(); gCoreLibPlatformInterface.Alloc = &BG3Alloc; gCoreLibPlatformInterface.Free = &BG3Free; - gCoreLibPlatformInterface.ls__FixedString__CreateFromString = sym.ls__FixedString__CreateFromString; + gCoreLibPlatformInterface.ls__GlobalStringTable__MainTable__CreateFromString = sym.ls__GlobalStringTable__MainTable__CreateFromString; gCoreLibPlatformInterface.ls__FixedString__GetString = sym.ls__FixedString__GetString; gCoreLibPlatformInterface.ls__FixedString__IncRef = sym.ls__FixedString__IncRef; - gCoreLibPlatformInterface.ls__FixedString__DecRef = sym.ls__FixedString__DecRef; + gCoreLibPlatformInterface.ls__GlobalStringTable__MainTable__DecRef = sym.ls__GlobalStringTable__MainTable__DecRef; gCoreLibPlatformInterface.ls__gGlobalStringTable = sym.ls__gGlobalStringTable; return !CriticalInitFailed; diff --git a/BG3Extender/GameHooks/DataLibraries.h b/BG3Extender/GameHooks/DataLibraries.h index 4cbae79f..d7e66564 100644 --- a/BG3Extender/GameHooks/DataLibraries.h +++ b/BG3Extender/GameHooks/DataLibraries.h @@ -63,14 +63,11 @@ namespace bg3se { void RegisterLibraries(SymbolMapper& mapper); void RegisterSymbols(); bool BindApp(); + SymbolMapper::MappingResult BindECSContext(uint8_t const*); SymbolMapper::MappingResult BindECSIndex(uint8_t const*); SymbolMapper::MappingResult BindECSStaticStringConstructor(uint8_t const*); SymbolMapper::MappingResult BindECSStaticRegistrant(uint8_t const*); SymbolMapper::MappingResult BindComponentReplicationIDRef(uint8_t const*); - SymbolMapper::MappingResult BindComponentIDRef(uint8_t const*); - SymbolMapper::MappingResult BindComponentIDRef2(uint8_t const*); - SymbolMapper::MappingResult BindEventComponentIDRef(uint8_t const*); - SymbolMapper::MappingResult BindReplicationComponentIDRef(uint8_t const*); HMODULE GetAppHandle(); bool CanShowError(); diff --git a/BG3Extender/GameHooks/DataLibrariesBG3Game.cpp b/BG3Extender/GameHooks/DataLibrariesBG3Game.cpp index fc8b9d55..a5d59467 100644 --- a/BG3Extender/GameHooks/DataLibrariesBG3Game.cpp +++ b/BG3Extender/GameHooks/DataLibrariesBG3Game.cpp @@ -7,6 +7,12 @@ #include #include +BEGIN_NS(ecs) + +STDString SimplifyComponentName(StringView name); + +END_NS() + namespace bg3se { void LibraryManager::PreRegisterLibraries(SymbolMappingLoader & loader) @@ -25,40 +31,47 @@ namespace bg3se mapper.AddModule("Main", L"bg3_dx11.exe"); } + mapper.AddEngineCallback("BindECSContext", std::bind(&LibraryManager::BindECSContext, this, std::placeholders::_1)); mapper.AddEngineCallback("BindECSIndex", std::bind(&LibraryManager::BindECSIndex, this, std::placeholders::_1)); mapper.AddEngineCallback("BindECSStaticStringConstructor", std::bind(&LibraryManager::BindECSStaticStringConstructor, this, std::placeholders::_1)); mapper.AddEngineCallback("BindECSStaticRegistrant", std::bind(&LibraryManager::BindECSStaticRegistrant, this, std::placeholders::_1)); mapper.AddEngineCallback("BindComponentReplicationIDRef", std::bind(&LibraryManager::BindComponentReplicationIDRef, this, std::placeholders::_1)); - mapper.AddEngineCallback("BindComponentIDRef", std::bind(&LibraryManager::BindComponentIDRef, this, std::placeholders::_1)); - mapper.AddEngineCallback("BindComponentIDRef2", std::bind(&LibraryManager::BindComponentIDRef2, this, std::placeholders::_1)); - mapper.AddEngineCallback("BindEventComponentIDRef", std::bind(&LibraryManager::BindEventComponentIDRef, this, std::placeholders::_1)); - mapper.AddEngineCallback("BindReplicationComponentIDRef", std::bind(&LibraryManager::BindReplicationComponentIDRef, this, std::placeholders::_1)); + } + + SymbolMapper::MappingResult LibraryManager::BindECSContext(uint8_t const* ptr) + { + auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr + 7); + auto namePtr = (char const*)AsmResolveInstructionRef(ptr + 0x63); + GetStaticSymbols().IndexSymbolToContextMaps.insert(std::make_pair(indexPtr, namePtr)); + return SymbolMapper::MappingResult::TryNext; } SymbolMapper::MappingResult LibraryManager::BindECSIndex(uint8_t const* ptr) { - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); - auto namePtr = (char const*)AsmResolveInstructionRef(ptr + 0x25); - GetStaticSymbols().IndexSymbolToNameMaps.insert(std::make_pair(indexPtr, ecs::IndexSymbolInfo{ namePtr, ecs::IndexSymbolType::None })); + auto contextPtr = (int32_t*)AsmResolveInstructionRef(ptr); + auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr + 0x1C); + auto namePtr = (char const*)AsmResolveInstructionRef(ptr + 0x46); + GetStaticSymbols().IndexSymbolToNameMaps.insert(std::make_pair(indexPtr, ecs::IndexSymbolInfo{ namePtr, contextPtr })); return SymbolMapper::MappingResult::TryNext; } SymbolMapper::MappingResult LibraryManager::BindECSStaticStringConstructor(uint8_t const* ptr) { - auto funcPtr = ptr - 0x3C; - auto namePtr = (char const*)AsmResolveInstructionRef(ptr + 30); + auto funcPtr = ptr - 0x65; + auto namePtr = (char const*)AsmResolveInstructionRef(ptr + 9); GetStaticSymbols().StaticStringRegistrantMaps.insert(std::make_pair(funcPtr, namePtr)); return SymbolMapper::MappingResult::TryNext; } SymbolMapper::MappingResult LibraryManager::BindECSStaticRegistrant(uint8_t const* ptr) { - auto funcPtr = AsmResolveInstructionRef(ptr); - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr + 43); + auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); + auto funcPtr = AsmResolveInstructionRef(ptr + 0x13); + auto contextPtr = (int32_t*)AsmResolveInstructionRef(ptr + 0x1B); auto nameIt = GetStaticSymbols().StaticStringRegistrantMaps.find(funcPtr); if (nameIt != GetStaticSymbols().StaticStringRegistrantMaps.end()) { - GetStaticSymbols().IndexSymbolToNameMaps.insert(std::make_pair(indexPtr, ecs::IndexSymbolInfo{ nameIt->second, ecs::IndexSymbolType::None })); + GetStaticSymbols().IndexSymbolToNameMaps.insert(std::make_pair(indexPtr, ecs::IndexSymbolInfo{ nameIt->second, contextPtr })); } return SymbolMapper::MappingResult::TryNext; @@ -66,66 +79,10 @@ namespace bg3se SymbolMapper::MappingResult LibraryManager::BindComponentReplicationIDRef(uint8_t const* ptr) { - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); - - auto indexIt = GetStaticSymbols().IndexSymbolToNameMaps.find(indexPtr); - if (indexIt != GetStaticSymbols().IndexSymbolToNameMaps.end()) { - assert(indexIt->second.type == ecs::IndexSymbolType::None || indexIt->second.type == ecs::IndexSymbolType::Replication); - indexIt->second.type = ecs::IndexSymbolType::Replication; - } - - return SymbolMapper::MappingResult::TryNext; - } - - SymbolMapper::MappingResult LibraryManager::BindComponentIDRef(uint8_t const* ptr) - { - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); - - auto indexIt = GetStaticSymbols().IndexSymbolToNameMaps.find(indexPtr); - if (indexIt != GetStaticSymbols().IndexSymbolToNameMaps.end()) { - assert(indexIt->second.type == ecs::IndexSymbolType::None || indexIt->second.type == ecs::IndexSymbolType::Component); - indexIt->second.type = ecs::IndexSymbolType::Component; - } - - return SymbolMapper::MappingResult::TryNext; - } - - SymbolMapper::MappingResult LibraryManager::BindComponentIDRef2(uint8_t const* ptr) - { - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); - - auto indexIt = GetStaticSymbols().IndexSymbolToNameMaps.find(indexPtr); - if (indexIt != GetStaticSymbols().IndexSymbolToNameMaps.end()) { - assert(indexIt->second.type == ecs::IndexSymbolType::None || indexIt->second.type == ecs::IndexSymbolType::Component); - indexIt->second.type = ecs::IndexSymbolType::Component; - } - - return SymbolMapper::MappingResult::TryNext; - } - - SymbolMapper::MappingResult LibraryManager::BindEventComponentIDRef(uint8_t const* ptr) - { - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); - - auto indexIt = GetStaticSymbols().IndexSymbolToNameMaps.find(indexPtr); - if (indexIt != GetStaticSymbols().IndexSymbolToNameMaps.end()) { - assert(indexIt->second.type == ecs::IndexSymbolType::None || indexIt->second.type == ecs::IndexSymbolType::EventComponent); - indexIt->second.type = ecs::IndexSymbolType::EventComponent; - } - - return SymbolMapper::MappingResult::TryNext; - } - - SymbolMapper::MappingResult LibraryManager::BindReplicationComponentIDRef(uint8_t const* ptr) - { - auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr); - - auto indexIt = GetStaticSymbols().IndexSymbolToNameMaps.find(indexPtr); - if (indexIt != GetStaticSymbols().IndexSymbolToNameMaps.end()) { - assert(indexIt->second.type == ecs::IndexSymbolType::None || indexIt->second.type == ecs::IndexSymbolType::Replication); - indexIt->second.type = ecs::IndexSymbolType::Replication; - } - + auto contextPtr = (int32_t*)AsmResolveInstructionRef(ptr); + auto indexPtr = (int32_t*)AsmResolveInstructionRef(ptr + 0x7); + auto namePtr = (char const*)AsmResolveInstructionRef(ptr + 0x31); + GetStaticSymbols().IndexSymbolToNameMaps.insert(std::make_pair(indexPtr, ecs::IndexSymbolInfo{ namePtr, contextPtr })); return SymbolMapper::MappingResult::TryNext; } @@ -163,10 +120,10 @@ namespace bg3se void LibraryManager::RegisterSymbols() { - SYM_OFF(ls__FixedString__CreateFromString); + SYM_OFF(ls__GlobalStringTable__MainTable__CreateFromString); SYM_OFF(ls__FixedString__GetString); SYM_OFF(ls__FixedString__IncRef); - SYM_OFF(ls__FixedString__DecRef); + SYM_OFF(ls__GlobalStringTable__MainTable__DecRef); SYM_OFF(ls__gGlobalStringTable); SYM_OFF(ls__FileReader__ctor); @@ -181,11 +138,12 @@ namespace bg3se SYM_OFF(ls__gTranslatedStringRepository); SYM_OFF(ecl__gGameStateEventManager); - SYM_OFF(ecl__GameStateEventManager__ExecuteGameStateChangedEvent); + SYM_OFF(esv__gGameStateEventManager); SYM_OFF(ecl__GameStateThreaded__GameStateWorker__DoWork); SYM_OFF(esv__GameStateThreaded__GameStateWorker__DoWork); SYM_OFF(ecl__GameStateMachine__Update); SYM_OFF(esv__GameStateMachine__Update); + SYM_OFF(App__LoadGraphicSettings); SYM_OFF(ecs__EntityWorld__Update); @@ -221,11 +179,12 @@ namespace bg3se SYM_OFF(gRPGStats); SYM_OFF(RPGStats__Load); - SYM_OFF(RPGStats__ParseStructureFolder); + SYM_OFF(RPGStats__PreParseDataFolder); SYM_OFF(esv__SavegameManager); SYM_OFF(AppInstance); + SYM_OFF(ls__gGlobalAllocator); SYM_OFF(ls__GlobalAllocator__Alloc); SYM_OFF(ls__GlobalAllocator__Free); diff --git a/BG3Extender/GameHooks/EngineHooks.inl b/BG3Extender/GameHooks/EngineHooks.inl index 34d26dc6..d6193a51 100644 --- a/BG3Extender/GameHooks/EngineHooks.inl +++ b/BG3Extender/GameHooks/EngineHooks.inl @@ -34,7 +34,7 @@ HOOK_DEFN(Module__Hash, Module__Hash, Module::HashProc, WrappableFunction) HOOK_DEFN(App__OnInputEvent, App__OnInputEvent, App::VMT::OnInputEventProc, PreHookableFunction) */ HOOK_DEFN(RPGStats__Load, RPGStats__Load, stats::RPGStats::LoadProc) -HOOK_DEFN(RPGStats__ParseStructureFolder, RPGStats__ParseStructureFolder, stats::RPGStats::ParseStructureFolderProc) +HOOK_DEFN(RPGStats__PreParseDataFolder, RPGStats__PreParseDataFolder, stats::RPGStats::ParseStructureFolderProc) HOOK_DEFN(FileReader__ctor, ls__FileReader__ctor, FileReader::CtorProc) HOOK_DEFN(ecs__EntityWorld__Update, ecs__EntityWorld__Update, ecs::EntityWorld::UpdateProc) diff --git a/BG3Updater/UpdaterBinaryMappings.xml b/BG3Updater/UpdaterBinaryMappings.xml index 725ee6e9..e5f68a84 100644 --- a/BG3Updater/UpdaterBinaryMappings.xml +++ b/BG3Updater/UpdaterBinaryMappings.xml @@ -2,91 +2,95 @@ - c3 // retn - 48 85 db // test rbx, rbx - 74 0f // jz short loc_143858624 - 45 33 c0 // xor r8d, r8d - 48 8b cb // mov rcx, rbx - 41 8d 50 07 // lea edx, [r8+7] - @ref1 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Free - 41 b9 10 00 00 00 // mov r9d, 10h; alignment - 45 33 c0 // xor r8d, r8d; a3 - 33 c9 // xor ecx, ecx; size - 41 8d 51 f5 // lea edx, [r9-0Bh]; pool - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Alloc - 48 8b 5c 24 30 // mov rbx, [rsp+28h+arg_0] - 33 f6 // xor esi, esi - - + 48 89 6c 24 18 // mov [rsp+arg_10], rbp + 48 89 74 24 20 // mov [rsp+arg_18], rsi + 41 56 // push r14 + 48 83 ec 20 // sub rsp, 20h + 65 48 8b 04 25 58 00 00 00 // mov rax, gs:58h + @ref2 4c 8d 35 ?? ?? ?? ?? // lea r14, ls__gGlobalAllocator + ba 88 04 00 00 // mov edx, 488h + 48 8b 08 // mov rcx, [rax] + 8b 04 0a // mov eax, [rdx+rcx] + - - 48 83 ec 28 // sub rsp, 28h - 4c 8b c1 // mov r8, rcx - 48 8d 54 24 38 // lea rdx, [rsp+28h+arg_8] - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool - 48 81 c1 00 c6 00 00 // add rcx, 0C600h - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalStringPool__CreateFromString - 8b 44 24 38 // mov eax, [rsp+28h+arg_8] - 48 83 c4 28 // add rsp, 28h - - - - - - 40 53 // push rbx - 48 83 ec 20 // sub rsp, 20h - 48 8b d9 // mov rbx, rcx - 89 54 24 38 // mov [rsp+28h+arg_8], edx - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool - 48 8d 54 24 38 // lea rdx, [rsp+28h+arg_8] - e8 ?? ?? ?? ?? // call sub_143866DA0 - 48 8d 50 18 // lea rdx, [rax+18h] - 8b 40 08 // mov eax, [rax+8] - 89 43 08 // mov [rbx+8], eax - 48 8b c3 // mov rax, rbx - 48 89 13 // mov [rbx], rdx - 48 83 c4 20 // add rsp, 20h - 5b // pop rbx - + + 83 79 0c 00 // cmp dword ptr [rcx+0Ch], 0 + 7e 07 // jle short loc_140572680 + c7 41 0c 00 00 00 00 // mov dword ptr [rcx+0Ch], 0 + 48 8b 39 // mov rdi, [rcx] + 48 85 ff // test rdi, rdi + 74 10 // jz short loc_140572698 + e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Get + 48 8b d7 // mov rdx, rdi; a2 + 48 8b c8 // mov rcx, rax; a1 + @ref2 e8 ?? ?? ?? ?? // call ls__GlobalMemoryManager__Free + e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Get + 48 c7 44 24 20 10 00 00 00 // mov [rsp+38h+alignment], 10h; alignment + 33 d2 // xor edx, edx; size + 48 8b c8 // mov rcx, rax; a1 + @ref4 e8 ?? ?? ?? ?? // call ls__GlobalAllocator__Alloc2 + + - 48 83 ec 28 // sub rsp, 28h - 89 4c 24 30 // mov [rsp+28h+arg_0], ecx - 48 8d 54 24 30 // lea rdx, [rsp+28h+arg_0] - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool + 83 f8 ff // cmp eax, 0FFFFFFFFh + 74 0b // jz short loc_140EC1A4F + 8b c8 // mov ecx, eax; a1 + @ref1 e8 ?? ?? ?? ?? // call ls__FixedString__AddRef + 8b 44 24 58 // mov eax, [rsp+48h+a1] + 8b 0b // mov ecx, [rbx] + 83 f9 ff // cmp ecx, 0FFFFFFFFh + 74 20 // jz short loc_140EC1A76 + 89 4c 24 20 // mov [rsp+48h+var_28], ecx + @ref2 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringTable 48 81 c1 00 c6 00 00 // add rcx, 0C600h - @ref2 e8 ?? ?? ?? ?? // call ls__GlobalStringPool__AddRef - 48 83 c4 28 // add rsp, 28h - + 48 8d 54 24 20 // lea rdx, [rsp+48h+var_28] + @ref3 e8 ?? ?? ?? ?? // call ls__GlobalStringTable__MainTable__DecRef + + + - - 48 83 ec 28 // sub rsp, 28h - 89 4c 24 30 // mov dword ptr [rsp+28h+a2], ecx - 48 8d 54 24 30 // lea rdx, [rsp+28h+a2]; a2 - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringPool + + @str1 48 8d 05 ?? ?? ?? ?? // lea rax, aH8e3f9e82g8fda; "h8e3f9e82g8fdag437cg99c1g4988a6aeccff" + 48 89 44 24 28 // mov [rsp+58h+a3.Str], rax + c7 44 24 30 25 00 00 00 // mov [rsp+58h+a3.Length], 25h ; '%' + c7 44 24 78 ff ff ff ff // mov [rsp+58h+arg_18], 0FFFFFFFFh + c7 44 24 20 02 00 00 00 // mov [rsp+58h+var_38], 2 + 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ls__gGlobalStringTable 48 81 c1 00 c6 00 00 // add rcx, 0C600h; a1 - e8 ?? ?? ?? ?? // call sub_143865FD0 - 48 83 c4 28 // add rsp, 28h - + 4c 8d 44 24 28 // lea r8, [rsp+58h+a3]; a3 + 48 8d 54 24 70 // lea rdx, [rsp+58h+a1]; a2 + @ref2 e8 ?? ?? ?? ?? // call ls__GlobalStringTable__MainTable__FromString + + + + + + 48 8d 54 24 40 // lea rdx, [rsp+58h+var_18]; a2 + 48 8b d8 // mov rbx, rax + @ref1 e8 ?? ?? ?? ?? // call ls__FixedString__ToString + 0f 10 07 // movups xmm0, xmmword ptr [rdi] + 0f 11 05 ?? ?? ?? ?? // movups cs:xmmword_145B17160, xmm0 + 0f 10 0b // movups xmm1, xmmword ptr [rbx] + 48 8b 5c 24 60 // mov rbx, [rsp+58h+arg_0] + - 89 44 24 50 // mov [rsp+48h+arg_0], eax - e8 ?? ?? ?? ?? // call sub_143690CA0 - 48 8d 15 ?? ?? ?? ?? // lea rdx, unk_145787190 - 48 8b c8 // mov rcx, rax - e8 ?? ?? ?? ?? // call sub_143233510 - @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:ecl__gEoCClient - e8 ?? ?? ?? ?? // call sub_140666800 - 48 8b 8b ?? ?? ?? ?? // mov rcx, [rbx+170h] - e8 ?? ?? ?? ?? // call sub_14065EC00 - @ref2 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:esv__gEoCServer - e8 ?? ?? ?? ?? // call sub_140FB9F70 - + 83 b8 44 07 00 00 02 // cmp dword ptr [rax+744h], 2 + 74 0f // jz short loc_140567F25 + 48 8b d3 // mov rdx, rbx + @ref1 48 8b 0d ?? ?? ?? ?? // mov rcx, cs:esv__gEocServer + e8 ?? ?? ?? ?? // call sub_14072F540 + @ref2 48 8b 3d ?? ?? ?? ?? // mov rdi, cs:ecl__gEoCClient + 48 8b d3 // mov rdx, rbx + 48 8b 8f a8 00 00 00 // mov rcx, [rdi+0A8h] + + @@ -101,17 +105,17 @@ - 90 // nop - 4c 8b c8 // mov r9, rax 41 b0 01 // mov r8b, 1 48 8d 54 24 50 // lea rdx, [rsp+350h+var_300] - 48 8b cb // mov rcx, rbx + 48 8b cf // mov rcx, rdi @ref1 e8 ?? ?? ?? ?? // call ecl__EocClient__HandleError 90 // nop - 48 8d 4c 24 28 // lea rcx, [rsp+350h+var_328] - e9 af 00 00 00 // jmp loc_14086156B - 48 c7 44 24 70 05 00 00 00 // mov [rsp+350h+var_2E0], 5 + 48 8d 4c 24 28 // lea rcx, [rsp+350h+a1] + e9 e1 01 00 00 // jmp loc_142938339 + 48 c7 44 24 28 05 00 00 00 // mov qword ptr [rsp+350h+a1], 5 44 8b c8 // mov r9d, eax + @str1 4c 8d 05 ?? ?? ?? ?? // lea r8, a4x; "%.4x" + diff --git a/BG3Updater/UpdaterSymbols.h b/BG3Updater/UpdaterSymbols.h index ddc90642..acc268c0 100644 --- a/BG3Updater/UpdaterSymbols.h +++ b/BG3Updater/UpdaterSymbols.h @@ -32,6 +32,7 @@ struct UpdaterSymbols : Noncopyable TranslatedStringRepository** ls__gTranslatedStringRepository{ nullptr }; + void* ls__gGlobalAllocator{ nullptr }; ls__GlobalAllocator__AllocProc* ls__GlobalAllocator__Alloc{ nullptr }; ls__GlobalAllocator__FreeProc* ls__GlobalAllocator__Free{ nullptr }; diff --git a/BG3Updater/Utils.cpp b/BG3Updater/Utils.cpp index ec81f7d2..687a52fe 100644 --- a/BG3Updater/Utils.cpp +++ b/BG3Updater/Utils.cpp @@ -20,12 +20,20 @@ std::unique_ptr gGameHelpers; void* BG3Alloc(std::size_t size) { - return gGameHelpers->Symbols().ls__GlobalAllocator__Alloc(size, 2, 0, 8); + if (gGameHelpers->Symbols().ls__GlobalAllocator__Alloc && gGameHelpers->Symbols().ls__gGlobalAllocator) { + return gGameHelpers->Symbols().ls__GlobalAllocator__Alloc(gGameHelpers->Symbols().ls__gGlobalAllocator, size, 2, 0, 8); + } else { + return malloc(size); + } } void BG3Free(void* ptr) { - gGameHelpers->Symbols().ls__GlobalAllocator__Free(ptr); + if (gGameHelpers->Symbols().ls__GlobalAllocator__Free && gGameHelpers->Symbols().ls__gGlobalAllocator) { + gGameHelpers->Symbols().ls__GlobalAllocator__Free(gGameHelpers->Symbols().ls__gGlobalAllocator, ptr); + } else { + return free(ptr); + } } GameHelpers::GameHelpers() @@ -142,7 +150,7 @@ bool GameHelpers::ClientHandleError(char const * msg, bool exitGame) const // Update reference to new string auto originalRef = **tskRef; - **tskRef = LSStringView(str->data(), str->size()); + **tskRef = LSStringView(str->data(), (uint32_t)str->size()); symbols_.ecl__EoCClient__HandleError(*symbols_.ecl__EoCClient, ts, exitGame, ts); return true; diff --git a/CoreLib/Base/BaseInterface.h b/CoreLib/Base/BaseInterface.h index 357c53f3..4b0ff28f 100644 --- a/CoreLib/Base/BaseInterface.h +++ b/CoreLib/Base/BaseInterface.h @@ -15,6 +15,8 @@ struct CoreLibPlatformInterface FixedString::IncRefProc* ls__FixedString__IncRef{ nullptr }; FixedString::DecRefProc* ls__FixedString__DecRef{ nullptr }; GlobalStringTable** ls__gGlobalStringTable{ nullptr }; + GlobalStringTable::MainTable::CreateFromStringProc* ls__GlobalStringTable__MainTable__CreateFromString{ nullptr }; + GlobalStringTable::MainTable::DecRefProc* ls__GlobalStringTable__MainTable__DecRef{ nullptr }; void* StaticSymbols{ NULL }; HMODULE ThisModule{ NULL }; diff --git a/CoreLib/Base/BaseMemory.h b/CoreLib/Base/BaseMemory.h index df9ae447..10bd5522 100644 --- a/CoreLib/Base/BaseMemory.h +++ b/CoreLib/Base/BaseMemory.h @@ -6,8 +6,8 @@ namespace bg3se { - using ls__GlobalAllocator__AllocProc = void* (std::size_t size, int pool, int unused2, uint64_t alignment); - using ls__GlobalAllocator__FreeProc = void (void* ptr); + using ls__GlobalAllocator__AllocProc = void* (void* globalAllocator, std::size_t size, int pool, int unused2, uint64_t alignment); + using ls__GlobalAllocator__FreeProc = void (void* globalAllocator, void* ptr); void* GameAllocRaw(std::size_t size); void GameFree(void*); diff --git a/CoreLib/Base/BaseString.h b/CoreLib/Base/BaseString.h index e308c375..ca1ceb66 100644 --- a/CoreLib/Base/BaseString.h +++ b/CoreLib/Base/BaseString.h @@ -72,7 +72,7 @@ namespace bg3se struct FixedString { using CreateFromStringProc = uint32_t (LSStringView const&); - using GetStringProc = LSStringView * (LSStringView&, uint32_t index); + using GetStringProc = LSStringView * (FixedString const*, LSStringView&); using IncRefProc = void(uint32_t index); using DecRefProc = void(uint32_t index); @@ -222,6 +222,9 @@ namespace bg3se struct MainTable { + using DecRefProc = void (MainTable* self, FixedString* fs); + using CreateFromStringProc = FixedString* (MainTable* self, FixedString* fs, LSStringView* src); + SubTable::Element SomeTable[64]; uint64_t field_1000; uint64_t _Pad1[7]; diff --git a/CoreLib/Base/BaseString.inl b/CoreLib/Base/BaseString.inl index 305825d0..c05e5513 100644 --- a/CoreLib/Base/BaseString.inl +++ b/CoreLib/Base/BaseString.inl @@ -3,18 +3,31 @@ BEGIN_SE() FixedString::FixedString(StringView str) : Index(NullIndex) { - auto create = gCoreLibPlatformInterface.ls__FixedString__CreateFromString; - if (create) { - Index = create(LSStringView(str.data(), (uint32_t)str.size())); + auto createGlobal = gCoreLibPlatformInterface.ls__GlobalStringTable__MainTable__CreateFromString; + if (createGlobal) { + LSStringView sv(str.data(), (uint32_t)str.size()); + createGlobal(&(*gCoreLibPlatformInterface.ls__gGlobalStringTable)->Main, this, &sv); + } else { + auto create = gCoreLibPlatformInterface.ls__FixedString__CreateFromString; + if (create) { + Index = create(LSStringView(str.data(), (uint32_t)str.size())); + } } } FixedString::FixedString(char const* str) : Index(NullIndex) { - auto create = gCoreLibPlatformInterface.ls__FixedString__CreateFromString; - if (create) { - Index = create(LSStringView(str, (uint32_t)strlen(str))); + auto createGlobal = gCoreLibPlatformInterface.ls__GlobalStringTable__MainTable__CreateFromString; + if (createGlobal) { + LSStringView sv(str, (uint32_t)strlen(str)); + createGlobal(&(*gCoreLibPlatformInterface.ls__gGlobalStringTable)->Main, this, &sv); + } + else { + auto create = gCoreLibPlatformInterface.ls__FixedString__CreateFromString; + if (create) { + Index = create(LSStringView(str, (uint32_t)strlen(str))); + } } } @@ -24,7 +37,7 @@ char const* FixedString::GetPooledStringPtr() const auto getter = gCoreLibPlatformInterface.ls__FixedString__GetString; if (getter) { LSStringView sv; - getter(sv, Index); + getter(this, sv); return sv.data(); } } @@ -54,7 +67,7 @@ StringView FixedString::GetStringView() const auto getter = gCoreLibPlatformInterface.ls__FixedString__GetString; if (getter) { LSStringView sv; - getter(sv, Index); + getter(this, sv); return StringView(sv.data(), sv.size()); } } @@ -122,9 +135,14 @@ void FixedString::IncRef() void FixedString::DecRef() { if (Index != NullIndex) { - auto decRef = gCoreLibPlatformInterface.ls__FixedString__DecRef; - if (decRef) { - decRef(Index); + auto decRefGlobal = gCoreLibPlatformInterface.ls__GlobalStringTable__MainTable__DecRef; + if (decRefGlobal) { + decRefGlobal(&(*gCoreLibPlatformInterface.ls__gGlobalStringTable)->Main, this); + } else { + auto decRef = gCoreLibPlatformInterface.ls__FixedString__DecRef; + if (decRef) { + decRef(Index); + } } } } diff --git a/publish.ps1 b/publish.ps1 index 24999541..8ad019b2 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -35,10 +35,10 @@ $GameDebugAdapterBuildDir = Join-Path "$BuildRoot" "TempGameDebugAdapter" $EditorBuildDir = Join-Path "$BuildRoot" "TempEditorBuild" $PDBDir = Join-Path "$PDBRoot" "TempPDB" -$EditorMinVersion = "4.37.32.833" +$EditorMinVersion = "4.38.81.0" $EditorMaxVersion = "-" -$GameMinVersion = "4.37.32.833" +$GameMinVersion = "4.38.81.0" $GameMaxVersion = "-" function Build-Extender