mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-12-05 17:57:47 +00:00
Compare commits
58 Commits
v1.3.3
...
b2bd1e0835
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2bd1e0835 | ||
|
|
e2a5d96e10 | ||
|
|
8d4fa65e3b | ||
|
|
54226a0e56 | ||
|
|
1061c08829 | ||
|
|
c75cf561f7 | ||
|
|
3ea6050498 | ||
|
|
1551d7f1fd | ||
|
|
bf1d649bc1 | ||
|
|
71727a5197 | ||
|
|
530cd10466 | ||
|
|
978e251df8 | ||
|
|
cb96052638 | ||
|
|
9b217b20e3 | ||
|
|
136a723187 | ||
|
|
ad27dcb098 | ||
|
|
96acf0718e | ||
|
|
72f936e82a | ||
|
|
9a11ac82b3 | ||
|
|
8f36c271fd | ||
|
|
e952b8a0f7 | ||
|
|
f6d78fd815 | ||
|
|
cadcca22f9 | ||
|
|
c04a0a0d8c | ||
|
|
61706336ce | ||
|
|
eb08109392 | ||
|
|
b23cb2014b | ||
|
|
4d979bf659 | ||
|
|
206d06dc7d | ||
|
|
4d8af4bd45 | ||
|
|
46ab288488 | ||
|
|
dd8c1ff71e | ||
|
|
ed1ac62153 | ||
|
|
7f7fd016cf | ||
|
|
6c093888b5 | ||
|
|
1440760aa5 | ||
|
|
105c11a8b2 | ||
|
|
795f8ac162 | ||
|
|
6dd4d2651a | ||
|
|
b2f030f349 | ||
|
|
2690eeeece | ||
|
|
098bd21008 | ||
|
|
2f474e979f | ||
|
|
2ab4da0ad9 | ||
|
|
28c5594094 | ||
|
|
6525bbb8bf | ||
|
|
1a9e3dfb15 | ||
|
|
c62f1995e7 | ||
|
|
883e38ae58 | ||
|
|
1b2d4dbc46 | ||
|
|
7dfb35233e | ||
|
|
d842022056 | ||
|
|
0a8ebc3058 | ||
|
|
8ccae5ddec | ||
|
|
cfb143f0fd | ||
|
|
0281b5bef6 | ||
|
|
70a91b271d | ||
|
|
a7576ea765 |
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: gitsubmodule
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
45
.github/workflows/build.yml
vendored
Normal file
45
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
types: [opened, synchronize, reopened]
|
||||
jobs:
|
||||
build:
|
||||
name: Build binaries
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
matrix:
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
steps:
|
||||
- name: Check out files
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
lfs: false
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Generate project files
|
||||
run: tools/premake5 vs2022
|
||||
|
||||
- name: Set up problem matching
|
||||
uses: ammaraskar/msvc-problem-matcher@master
|
||||
|
||||
- name: Build ${{matrix.configuration}} binaries
|
||||
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@v4
|
||||
with:
|
||||
name: ${{matrix.configuration}} binaries
|
||||
path: |
|
||||
build/bin/${{matrix.configuration}}/iw5-gsc-utils.dll
|
||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -8,3 +8,12 @@
|
||||
path = deps/json
|
||||
url = https://github.com/nlohmann/json.git
|
||||
branch = develop
|
||||
[submodule "deps/gsc-tool"]
|
||||
path = deps/gsc-tool
|
||||
url = https://github.com/xensik/gsc-tool.git
|
||||
[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: c31a9ad5e8...b39e7e4b09
1
deps/gsc-tool
vendored
Submodule
1
deps/gsc-tool
vendored
Submodule
Submodule deps/gsc-tool added at b859638703
2
deps/json
vendored
2
deps/json
vendored
Submodule deps/json updated: e4643d1f1b...0457de21cf
2
deps/minhook
vendored
2
deps/minhook
vendored
Submodule deps/minhook updated: 423d1e45af...f5485b8454
1
deps/plutonium-sdk
vendored
Submodule
1
deps/plutonium-sdk
vendored
Submodule
Submodule deps/plutonium-sdk added at 17e9a0a4d5
62
deps/premake/gsc-tool.lua
vendored
Normal file
62
deps/premake/gsc-tool.lua
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
gsc_tool = {
|
||||
source = path.join(dependencies.basePath, "gsc-tool"),
|
||||
}
|
||||
|
||||
function gsc_tool.import()
|
||||
links { "xsk-gsc-iw5-pc", "xsk-gsc-utils" }
|
||||
gsc_tool.includes()
|
||||
end
|
||||
|
||||
function gsc_tool.includes()
|
||||
includedirs {
|
||||
path.join(gsc_tool.source, "include"),
|
||||
}
|
||||
end
|
||||
|
||||
function gsc_tool.project()
|
||||
project "xsk-gsc-utils"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
path.join(gsc_tool.source, "include/xsk/utils/*.hpp"),
|
||||
path.join(gsc_tool.source, "src/utils/*.cpp"),
|
||||
}
|
||||
|
||||
includedirs {
|
||||
path.join(gsc_tool.source, "include"),
|
||||
}
|
||||
|
||||
zlib.includes()
|
||||
|
||||
project "xsk-gsc-iw5-pc"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
|
||||
filter "action:vs*"
|
||||
buildoptions "/Zc:__cplusplus"
|
||||
filter {}
|
||||
|
||||
files {
|
||||
path.join(gsc_tool.source, "include/xsk/stdinc.hpp"),
|
||||
|
||||
path.join(gsc_tool.source, "include/xsk/gsc/engine/iw5_pc.hpp"),
|
||||
path.join(gsc_tool.source, "src/gsc/engine/iw5_pc.cpp"),
|
||||
|
||||
path.join(gsc_tool.source, "src/gsc/engine/iw5_pc_code.cpp"),
|
||||
path.join(gsc_tool.source, "src/gsc/engine/iw5_pc_func.cpp"),
|
||||
path.join(gsc_tool.source, "src/gsc/engine/iw5_pc_meth.cpp"),
|
||||
path.join(gsc_tool.source, "src/gsc/engine/iw5_pc_token.cpp"),
|
||||
|
||||
path.join(gsc_tool.source, "src/gsc/*.cpp"),
|
||||
|
||||
path.join(gsc_tool.source, "src/gsc/common/*.cpp"),
|
||||
path.join(gsc_tool.source, "include/xsk/gsc/common/*.hpp"),
|
||||
}
|
||||
|
||||
includedirs {
|
||||
path.join(gsc_tool.source, "include"),
|
||||
}
|
||||
end
|
||||
|
||||
table.insert(dependencies, gsc_tool)
|
||||
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)
|
||||
39
deps/premake/zlib.lua
vendored
Normal file
39
deps/premake/zlib.lua
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
zlib = {
|
||||
source = path.join(dependencies.basePath, "zlib"),
|
||||
}
|
||||
|
||||
function zlib.import()
|
||||
links { "zlib" }
|
||||
zlib.includes()
|
||||
end
|
||||
|
||||
function zlib.includes()
|
||||
includedirs {
|
||||
zlib.source
|
||||
}
|
||||
|
||||
defines {
|
||||
"ZLIB_CONST",
|
||||
}
|
||||
end
|
||||
|
||||
function zlib.project()
|
||||
project "zlib"
|
||||
language "C"
|
||||
|
||||
zlib.includes()
|
||||
|
||||
files {
|
||||
path.join(zlib.source, "*.h"),
|
||||
path.join(zlib.source, "*.c"),
|
||||
}
|
||||
|
||||
defines {
|
||||
"_CRT_SECURE_NO_DEPRECATE",
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, zlib)
|
||||
1
deps/zlib
vendored
Submodule
1
deps/zlib
vendored
Submodule
Submodule deps/zlib added at 5c42a230b7
@@ -1,3 +1,3 @@
|
||||
@echo off
|
||||
call git submodule update --init --recursive
|
||||
tools\windows\premake5.exe vs2022
|
||||
tools\premake5.exe vs2022
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace gsc
|
||||
{
|
||||
std::string method_name(unsigned int id)
|
||||
{
|
||||
const auto& map = *game::plutonium::method_map_rev;
|
||||
const auto& map = (*game::plutonium::gsc_ctx)->meth_map();
|
||||
|
||||
for (const auto& function : map)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace gsc
|
||||
|
||||
std::string function_name(unsigned int id)
|
||||
{
|
||||
const auto& map = *game::plutonium::function_map_rev;
|
||||
const auto& map = (*game::plutonium::gsc_ctx)->func_map();
|
||||
|
||||
for (const auto& function : map)
|
||||
{
|
||||
@@ -248,11 +248,21 @@ namespace gsc
|
||||
{
|
||||
void add(const std::string& name, const script_function& func)
|
||||
{
|
||||
const auto index = function_map_start++;
|
||||
auto index = 0u;
|
||||
auto& ctx = (*game::plutonium::gsc_ctx);
|
||||
|
||||
if (ctx->func_exists(name))
|
||||
{
|
||||
printf("[iw5-gsc-utils] Warning: function '%s' already defined\n", name.data());
|
||||
index = ctx->func_id(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
index = function_map_start++;
|
||||
ctx->func_add(name, index);
|
||||
}
|
||||
|
||||
functions[index] = func;
|
||||
const auto name_view = utils::memory::get_allocator()->duplicate_string(name);
|
||||
(*game::plutonium::function_map_rev)[name_view] = index;
|
||||
functions.insert(std::make_pair(index, func));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,11 +270,26 @@ namespace gsc
|
||||
{
|
||||
void add(const std::string& name, const script_method& func)
|
||||
{
|
||||
const auto index = method_map_start++;
|
||||
if (true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methods[index] = func;
|
||||
const auto name_view = utils::memory::get_allocator()->duplicate_string(name);
|
||||
(*game::plutonium::method_map_rev)[name_view] = index;
|
||||
auto index = 0u;
|
||||
auto& ctx = (*game::plutonium::gsc_ctx);
|
||||
|
||||
if (ctx->meth_exists(name))
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,25 +299,13 @@ namespace gsc
|
||||
const std::function<scripting::script_value(unsigned int entnum)>& getter,
|
||||
const std::function<void(unsigned int entnum, const scripting::script_value&)>& setter)
|
||||
{
|
||||
uint16_t token_id{};
|
||||
auto& token_map = *game::plutonium::token_map_rev;
|
||||
if (token_map.find(name) != token_map.end())
|
||||
{
|
||||
token_id = token_map.at(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
token_id = token_map_start++;
|
||||
token_map.insert(std::make_pair(name, token_id));
|
||||
}
|
||||
|
||||
const auto offset = field_offset_start++;
|
||||
custom_fields[classnum][offset] = {name, getter, setter};
|
||||
|
||||
post_load_callbacks.push_back([classnum, name, token_id, offset]()
|
||||
post_load_callbacks.push_back([=]()
|
||||
{
|
||||
const auto name_str = game::SL_GetString(name.data(), 0);
|
||||
game::Scr_AddClassField(classnum, name_str, token_id, offset);
|
||||
game::Scr_AddClassField(classnum, name_str, game::SL_GetCanonicalString(name.data()), offset);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
@@ -61,38 +68,25 @@ namespace signatures
|
||||
return find_string_ptr({bytes, 4});
|
||||
}
|
||||
|
||||
bool process_maps()
|
||||
bool process_gsc_ctx()
|
||||
{
|
||||
const auto string_ref = find_string_ref("couldn't resolve builtin function id for name '%s'!");
|
||||
OutputDebugString("HELLOOO");
|
||||
|
||||
const auto string_ref = find_string_ref("in call to builtin %s \"%s\"");
|
||||
if (!string_ref)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto map_ptr = *reinterpret_cast<size_t*>(string_ref - 0x2B);
|
||||
game::plutonium::function_map_rev.set(map_ptr);
|
||||
game::plutonium::method_map_rev.set(map_ptr + 0x20);
|
||||
game::plutonium::token_map_rev.set(map_ptr + 0xBC);
|
||||
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);
|
||||
game::plutonium::printf.set(string_ref + 4 + 5 + offset);
|
||||
|
||||
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()
|
||||
{
|
||||
load_function_tables();
|
||||
return process_printf() && process_maps();
|
||||
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
|
||||
|
||||
@@ -7,51 +7,20 @@ namespace scripting
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::unordered_map<std::string, uint16_t> lowercase_map(
|
||||
const std::unordered_map<std::string_view, uint16_t>& old_map)
|
||||
{
|
||||
std::unordered_map<std::string, uint16_t> new_map{};
|
||||
for (auto& entry : old_map)
|
||||
{
|
||||
new_map[utils::string::to_lower(entry.first.data())] = entry.second;
|
||||
}
|
||||
|
||||
return new_map;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, uint16_t>& get_methods()
|
||||
{
|
||||
static auto methods = lowercase_map(*game::plutonium::method_map_rev);
|
||||
return methods;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, uint16_t>& get_functions()
|
||||
{
|
||||
static auto function = lowercase_map(*game::plutonium::function_map_rev);
|
||||
return function;
|
||||
}
|
||||
|
||||
int find_function_index(const std::string& name, const bool prefer_global)
|
||||
int find_function_index(const std::string& name, [[maybe_unused]] const bool prefer_global)
|
||||
{
|
||||
const auto target = utils::string::to_lower(name);
|
||||
auto const& first = (*game::plutonium::gsc_ctx)->func_map();
|
||||
auto const& second = (*game::plutonium::gsc_ctx)->meth_map();
|
||||
|
||||
const auto& primary_map = prefer_global
|
||||
? get_functions()
|
||||
: get_methods();
|
||||
const auto& secondary_map = !prefer_global
|
||||
? get_functions()
|
||||
: get_methods();
|
||||
|
||||
auto function_entry = primary_map.find(target);
|
||||
if (function_entry != primary_map.end())
|
||||
if (const auto itr = first.find(name); itr != first.end())
|
||||
{
|
||||
return function_entry->second;
|
||||
return static_cast<int>(itr->second);
|
||||
}
|
||||
|
||||
function_entry = secondary_map.find(target);
|
||||
if (function_entry != secondary_map.end())
|
||||
if (const auto itr = second.find(name); itr != second.end())
|
||||
{
|
||||
return function_entry->second;
|
||||
return static_cast<int>(itr->second);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -73,16 +42,7 @@ namespace scripting
|
||||
|
||||
std::string find_token(unsigned int id)
|
||||
{
|
||||
const auto& token_map = *game::plutonium::token_map_rev;
|
||||
for (const auto& token : token_map)
|
||||
{
|
||||
if (token.second == id)
|
||||
{
|
||||
return token.first;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
return (*game::plutonium::gsc_ctx)->token_name(id);
|
||||
}
|
||||
|
||||
std::string find_file(unsigned int id)
|
||||
@@ -92,21 +52,16 @@ namespace scripting
|
||||
|
||||
int find_token_id(const std::string& name)
|
||||
{
|
||||
const auto& token_map = *game::plutonium::token_map_rev;
|
||||
const auto result = token_map.find(name);
|
||||
|
||||
if (result != token_map.end())
|
||||
{
|
||||
return result->second;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return (*game::plutonium::gsc_ctx)->token_id(name);
|
||||
}
|
||||
|
||||
script_function find_function(const std::string& name, const bool prefer_global)
|
||||
{
|
||||
const auto index = find_function_index(name, prefer_global);
|
||||
if (index < 0) return nullptr;
|
||||
if (index < 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return get_function_by_index(index);
|
||||
}
|
||||
|
||||
@@ -86,10 +86,7 @@ namespace game
|
||||
|
||||
namespace plutonium
|
||||
{
|
||||
WEAK symbol<std::unordered_map<std::string_view, std::uint16_t>> function_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string_view, std::uint16_t>> method_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> token_map_rev{0};
|
||||
WEAK symbol<int(const char* fmt, ...)> printf{0};
|
||||
WEAK symbol<std::unique_ptr<xsk::gsc::iw5_pc::context>> gsc_ctx{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();
|
||||
}
|
||||
@@ -8,6 +8,8 @@
|
||||
#pragma warning(disable: 4996)
|
||||
#pragma warning(disable: 26812)
|
||||
|
||||
#include <xsk/gsc/engine/iw5_pc.hpp>
|
||||
|
||||
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
@@ -37,6 +39,7 @@ using namespace std::literals;
|
||||
#include <gsl/gsl>
|
||||
#include <MinHook.h>
|
||||
|
||||
|
||||
#include "utils/memory.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "utils/hook.hpp"
|
||||
@@ -46,4 +49,4 @@ using namespace std::literals;
|
||||
#include "utils/http.hpp"
|
||||
|
||||
#include "game/structs.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "game/game.hpp"
|
||||
|
||||
BIN
tools/premake5.exe
Normal file
BIN
tools/premake5.exe
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user