Fixes for update

This commit is contained in:
fed 2024-02-07 18:52:23 +01:00
parent ad27dcb098
commit 978e251df8
No known key found for this signature in database
GPG Key ID: 1D2C630F04722996
7 changed files with 34 additions and 18 deletions

View File

@ -248,16 +248,21 @@ namespace gsc
{ {
void add(const std::string& name, const script_function& func) 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++; printf("[iw5-gsc-utils] Warning: function '%s' already defined\n", name.data());
functions[index] = func; index = ctx->func_id(name);
(*game::plutonium::gsc_ctx)->func_add(name, index);
} }
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,21 @@ namespace gsc
{ {
void add(const std::string& name, const script_method& func) void add(const std::string& name, const script_method& func)
{ {
try auto index = 0u;
auto& ctx = (*game::plutonium::gsc_ctx);
if (ctx->meth_exists(name))
{ {
const auto index = method_map_start++; printf("[iw5-gsc-utils] Warning: method '%s' already defined\n", name.data());
methods[index] = func; index = ctx->meth_id(name);
(*game::plutonium::gsc_ctx)->meth_add(name, index);
} }
catch (const std::exception& e) else
{ {
printf("[iw5-gsc-utils] failed to add method \"%s\": %s\n", name.data(), e.what()); index = method_map_start++;
ctx->meth_add(name, index);
} }
methods.insert(std::make_pair(index, func));
} }
} }

View File

@ -179,4 +179,4 @@ namespace io
}; };
} }
REGISTER_COMPONENT(io::component) REGISTER_COMPONENT(io::component)

View File

@ -194,4 +194,4 @@ namespace json
}; };
} }
REGISTER_COMPONENT(json::component) REGISTER_COMPONENT(json::component)

View File

@ -71,4 +71,4 @@ namespace notifies
}; };
} }
REGISTER_COMPONENT(notifies::component) REGISTER_COMPONENT(notifies::component)

View File

@ -136,4 +136,4 @@ namespace scripting
}; };
} }
REGISTER_COMPONENT(scripting::component) REGISTER_COMPONENT(scripting::component)

View File

@ -35,11 +35,18 @@ namespace signatures
const auto base = reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe")); const auto base = reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
utils::hook::signature signature(base, get_image_size() - base); utils::hook::signature signature(base, get_image_size() - base);
auto found = false;
signature.add({ signature.add({
string, string,
mask, mask,
[&](char* address) [&](char* address)
{ {
if (found)
{
return;
}
found = true;
string_ptr = address; string_ptr = address;
} }
}); });
@ -70,7 +77,6 @@ namespace signatures
} }
const auto gsc_ctx_ptr = *reinterpret_cast<size_t*>(string_ref - 0xAD); const auto gsc_ctx_ptr = *reinterpret_cast<size_t*>(string_ref - 0xAD);
OutputDebugString(utils::string::va("string_ref: %p\n", string_ref));
OutputDebugString(utils::string::va("gsc_ctx_ptr: %p\n", gsc_ctx_ptr)); OutputDebugString(utils::string::va("gsc_ctx_ptr: %p\n", gsc_ctx_ptr));
game::plutonium::gsc_ctx.set(gsc_ctx_ptr); game::plutonium::gsc_ctx.set(gsc_ctx_ptr);
return true; return true;

View File

@ -193,4 +193,4 @@ namespace userinfo
}; };
} }
REGISTER_COMPONENT(userinfo::component) REGISTER_COMPONENT(userinfo::component)