mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-12-04 09:17:48 +00:00
update
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -14,3 +14,6 @@
|
||||
[submodule "deps/zlib"]
|
||||
path = deps/zlib
|
||||
url = https://github.com/madler/zlib.git
|
||||
[submodule "deps/plutonium-sdk"]
|
||||
path = deps/plutonium-sdk
|
||||
url = https://github.com/plutoniummod/plutonium-sdk.git
|
||||
|
||||
18
deps/premake/plutonium-sdk.lua
vendored
Normal file
18
deps/premake/plutonium-sdk.lua
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
plutonium_sdk = {
|
||||
source = path.join(dependencies.basePath, "plutonium-sdk"),
|
||||
}
|
||||
|
||||
function plutonium_sdk.import()
|
||||
plutonium_sdk.includes()
|
||||
end
|
||||
|
||||
function plutonium_sdk.includes()
|
||||
includedirs {
|
||||
plutonium_sdk.source,
|
||||
}
|
||||
end
|
||||
|
||||
function plutonium_sdk.project()
|
||||
end
|
||||
|
||||
table.insert(dependencies, plutonium_sdk)
|
||||
@@ -270,6 +270,11 @@ namespace gsc
|
||||
{
|
||||
void add(const std::string& name, const script_method& func)
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto index = 0u;
|
||||
auto& ctx = (*game::plutonium::gsc_ctx);
|
||||
|
||||
|
||||
@@ -179,4 +179,4 @@ namespace io
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(io::component)
|
||||
//REGISTER_COMPONENT(io::component)
|
||||
|
||||
@@ -194,4 +194,4 @@ namespace json
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(json::component)
|
||||
//REGISTER_COMPONENT(json::component)
|
||||
|
||||
@@ -71,4 +71,4 @@ namespace notifies
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(notifies::component)
|
||||
//REGISTER_COMPONENT(notifies::component)
|
||||
|
||||
@@ -144,4 +144,4 @@ namespace scheduler
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(scheduler::component)
|
||||
//REGISTER_COMPONENT(scheduler::component)
|
||||
|
||||
@@ -136,4 +136,4 @@ namespace scripting
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(scripting::component)
|
||||
//REGISTER_COMPONENT(scripting::component)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace signatures
|
||||
std::string mask(string.size(), 'x');
|
||||
const auto base = reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
|
||||
utils::hook::signature signature(base, get_image_size() - base);
|
||||
|
||||
OutputDebugString(utils::string::va("%p %p\n", base, get_image_size()));
|
||||
auto found = false;
|
||||
signature.add({
|
||||
string,
|
||||
@@ -70,37 +70,23 @@ namespace signatures
|
||||
|
||||
bool process_gsc_ctx()
|
||||
{
|
||||
OutputDebugString("HELLOOO");
|
||||
|
||||
const auto string_ref = find_string_ref("in call to builtin %s \"%s\"");
|
||||
if (!string_ref)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto gsc_ctx_ptr = *reinterpret_cast<size_t*>(string_ref - 0xAD);
|
||||
const auto gsc_ctx_ptr = *reinterpret_cast<size_t*>(string_ref + 215);
|
||||
OutputDebugString(utils::string::va("gsc_ctx_ptr: %p\n", gsc_ctx_ptr));
|
||||
game::plutonium::gsc_ctx.set(gsc_ctx_ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process_printf()
|
||||
{
|
||||
const auto string_ref = find_string_ref("A critical exception occured!\n");
|
||||
if (!string_ref)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto offset = *reinterpret_cast<size_t*>(string_ref + 5);
|
||||
const auto printf_ptr = string_ref + 4 + 5 + offset;
|
||||
OutputDebugString(utils::string::va("printf_ptr: %p\n", printf_ptr));
|
||||
game::plutonium::printf.set(printf_ptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process()
|
||||
{
|
||||
load_function_tables();
|
||||
return process_printf() && process_gsc_ctx();
|
||||
return process_gsc_ctx();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ namespace string
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(string::component)
|
||||
//REGISTER_COMPONENT(string::component)
|
||||
|
||||
@@ -193,4 +193,4 @@ namespace userinfo
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(userinfo::component)
|
||||
//REGISTER_COMPONENT(userinfo::component)
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
#include <stdinc.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "component/signatures.hpp"
|
||||
#include "plugin.hpp"
|
||||
|
||||
PLUTONIUM_API plutonium::sdk::plugin* PLUTONIUM_CALLBACK on_initialize()
|
||||
{
|
||||
return plugin::get();
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
if (!signatures::process())
|
||||
{
|
||||
MessageBoxA(NULL,
|
||||
"This version of iw5-gsc-utils is outdated.\n" \
|
||||
"Download the latest dll from here: https://github.com/fedddddd/iw5-gsc-utils/releases",
|
||||
"ERROR", MB_ICONERROR);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (game::plutonium::printf.get() != nullptr)
|
||||
{
|
||||
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
|
||||
}
|
||||
|
||||
component_loader::post_unpack();
|
||||
if (ul_reason_for_call == DLL_PROCESS_DETACH)
|
||||
{
|
||||
component_loader::pre_destroy();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -212,8 +212,6 @@ namespace scripting
|
||||
{
|
||||
return this->get(key.as<std::string>());
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
script_value array::get(const std::string& key) const
|
||||
|
||||
@@ -87,7 +87,6 @@ namespace game
|
||||
namespace plutonium
|
||||
{
|
||||
WEAK symbol<std::unique_ptr<xsk::gsc::iw5_pc::context>> gsc_ctx{0};
|
||||
WEAK symbol<int(const char* fmt, ...)> printf{0};
|
||||
WEAK symbol<void*> function_table{0};
|
||||
WEAK symbol<void*> method_table{0};
|
||||
}
|
||||
|
||||
84
src/plugin.cpp
Normal file
84
src/plugin.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include <stdinc.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "plugin.hpp"
|
||||
|
||||
#include "component/signatures.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
namespace plugin
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void printf_stub(const char* fmt, ...)
|
||||
{
|
||||
char buffer[0x2000] = {};
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
get()->get_interface()->logging()->info(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t plugin::plugin_version()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* plugin::plugin_name()
|
||||
{
|
||||
return "iw5-gsc-utils";
|
||||
}
|
||||
|
||||
bool plugin::is_game_supported([[maybe_unused]] plutonium::sdk::game game)
|
||||
{
|
||||
return game == plutonium::sdk::game::iw5;
|
||||
}
|
||||
|
||||
void plugin::on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game)
|
||||
{
|
||||
this->interface_ = interface_ptr;
|
||||
this->game_ = game;
|
||||
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), printf_stub);
|
||||
|
||||
if (!signatures::process())
|
||||
{
|
||||
MessageBoxA(NULL,
|
||||
"This version of iw5-gsc-utils is outdated.\n" \
|
||||
"Download the latest dll from here: https://github.com/alicealys/iw5-gsc-utils/releases",
|
||||
"ERROR", MB_ICONERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
component_loader::post_unpack();
|
||||
}
|
||||
}
|
||||
|
||||
void plugin::on_shutdown()
|
||||
{
|
||||
component_loader::pre_destroy();
|
||||
}
|
||||
|
||||
plutonium::sdk::iinterface* plugin::get_interface()
|
||||
{
|
||||
return this->interface_;
|
||||
}
|
||||
|
||||
plutonium::sdk::game plugin::get_game()
|
||||
{
|
||||
return this->game_;
|
||||
}
|
||||
|
||||
plugin* get()
|
||||
{
|
||||
static plugin instance;
|
||||
return &instance;
|
||||
}
|
||||
}
|
||||
30
src/plugin.hpp
Normal file
30
src/plugin.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <plutonium_sdk.hpp>
|
||||
|
||||
namespace plugin
|
||||
{
|
||||
class plugin : public plutonium::sdk::plugin
|
||||
{
|
||||
public:
|
||||
~plugin() = default;
|
||||
|
||||
std::uint32_t plugin_version() override;
|
||||
const char* plugin_name() override;
|
||||
|
||||
bool is_game_supported([[maybe_unused]] plutonium::sdk::game game) override;
|
||||
|
||||
void on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game) override;
|
||||
void on_shutdown() override;
|
||||
|
||||
plutonium::sdk::iinterface* get_interface();
|
||||
plutonium::sdk::game get_game();
|
||||
|
||||
private:
|
||||
plutonium::sdk::iinterface* interface_{};
|
||||
plutonium::sdk::game game_{};
|
||||
|
||||
};
|
||||
|
||||
plugin* get();
|
||||
}
|
||||
Reference in New Issue
Block a user