mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-12-05 17:57:47 +00:00
Compare commits
15 Commits
v1.3.5
...
b2bd1e0835
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2bd1e0835 | ||
|
|
e2a5d96e10 | ||
|
|
8d4fa65e3b | ||
|
|
54226a0e56 | ||
|
|
1061c08829 | ||
|
|
c75cf561f7 | ||
|
|
3ea6050498 | ||
|
|
1551d7f1fd | ||
|
|
bf1d649bc1 | ||
|
|
71727a5197 | ||
|
|
530cd10466 | ||
|
|
978e251df8 | ||
|
|
cb96052638 | ||
|
|
9b217b20e3 | ||
|
|
136a723187 |
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -19,14 +19,14 @@ jobs:
|
||||
- Release
|
||||
steps:
|
||||
- name: Check out files
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
lfs: false
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1.3
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Generate project files
|
||||
run: tools/premake5 vs2022
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:PlatformTarget=x86 build/iw5-gsc-utils.sln
|
||||
|
||||
- name: Upload ${{matrix.configuration}} binaries
|
||||
uses: actions/upload-artifact@v3.1.0
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{matrix.configuration}} binaries
|
||||
path: |
|
||||
|
||||
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
|
||||
|
||||
2
deps/GSL
vendored
2
deps/GSL
vendored
Submodule deps/GSL updated: e64c97fc2c...b39e7e4b09
2
deps/gsc-tool
vendored
2
deps/gsc-tool
vendored
Submodule deps/gsc-tool updated: 0e6238a6ab...b859638703
2
deps/json
vendored
2
deps/json
vendored
Submodule deps/json updated: 3780b41dd0...0457de21cf
1
deps/plutonium-sdk
vendored
Submodule
1
deps/plutonium-sdk
vendored
Submodule
Submodule deps/plutonium-sdk added at 17e9a0a4d5
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)
|
||||
2
deps/zlib
vendored
2
deps/zlib
vendored
Submodule deps/zlib updated: 643e17b749...5c42a230b7
@@ -248,16 +248,21 @@ namespace gsc
|
||||
{
|
||||
void add(const std::string& name, const script_function& func)
|
||||
{
|
||||
try
|
||||
auto index = 0u;
|
||||
auto& ctx = (*game::plutonium::gsc_ctx);
|
||||
|
||||
if (ctx->func_exists(name))
|
||||
{
|
||||
const auto index = function_map_start++;
|
||||
functions[index] = func;
|
||||
(*game::plutonium::gsc_ctx)->func_add(name, index);
|
||||
printf("[iw5-gsc-utils] Warning: function '%s' already defined\n", name.data());
|
||||
index = ctx->func_id(name);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
else
|
||||
{
|
||||
printf("[iw5-gsc-utils] failed to add function \"%s\": %s\n", name.data(), e.what());
|
||||
index = function_map_start++;
|
||||
ctx->func_add(name, index);
|
||||
}
|
||||
|
||||
functions.insert(std::make_pair(index, func));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,16 +270,26 @@ namespace gsc
|
||||
{
|
||||
void add(const std::string& name, const script_method& func)
|
||||
{
|
||||
try
|
||||
if (true)
|
||||
{
|
||||
const auto index = method_map_start++;
|
||||
methods[index] = func;
|
||||
(*game::plutonium::gsc_ctx)->meth_add(name, index);
|
||||
return;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
||||
auto index = 0u;
|
||||
auto& ctx = (*game::plutonium::gsc_ctx);
|
||||
|
||||
if (ctx->meth_exists(name))
|
||||
{
|
||||
printf("[iw5-gsc-utils] failed to add method \"%s\": %s\n", name.data(), e.what());
|
||||
printf("[iw5-gsc-utils] Warning: method '%s' already defined\n", name.data());
|
||||
index = ctx->meth_id(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
index = method_map_start++;
|
||||
ctx->meth_add(name, index);
|
||||
}
|
||||
|
||||
methods.insert(std::make_pair(index, func));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,12 +34,19 @@ 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,
|
||||
mask,
|
||||
[&](char* address)
|
||||
{
|
||||
if (found)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
found = true;
|
||||
string_ptr = address;
|
||||
}
|
||||
});
|
||||
@@ -63,38 +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);
|
||||
OutputDebugString(utils::string::va("string_ref: %p\n", string_ref));
|
||||
|
||||
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