mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
[mod] Use injections enums. Group up injection sizes.
This commit is contained in:
parent
5cbb895bcf
commit
0cd7f72e25
3 changed files with 38 additions and 27 deletions
|
|
@ -1,13 +1,32 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// public enums
|
||||||
|
enum aim1_fix : uint32_t {
|
||||||
|
script_function__ISGLIDER = 0x0043A1F6,
|
||||||
|
trade_actions_weapon_checks = 0x004072FA,
|
||||||
|
setup_proper_weapon_slots_for_a_glider = 0x004D62E4,
|
||||||
|
put_weapon_into_the_right_slot_after_purchase = 0x00417A6D,
|
||||||
|
sell_correct_weapon = 0x004176BC,
|
||||||
|
empty_light_weapon_message = 0x004067C4,
|
||||||
|
empty_heavy_weapon_message = 0x0040688B,
|
||||||
|
can_leave_trade_window = 0x0040C20E,
|
||||||
|
};
|
||||||
|
// set different size if your injection takes more than default 5 bytes
|
||||||
|
uint32_t get_injection_size(uint32_t key) {
|
||||||
|
constexpr auto call_command_length = 5;
|
||||||
|
switch (key) {
|
||||||
|
case aim1_fix::script_function__ISGLIDER: return 10;
|
||||||
|
case aim1_fix::can_leave_trade_window: return 6;
|
||||||
|
default: return call_command_length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef INJECTED_DLL
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
/*struct char20 {
|
|
||||||
char string[20];
|
|
||||||
};*/
|
|
||||||
|
|
||||||
#define _BYTE uint8_t
|
#define _BYTE uint8_t
|
||||||
#define this
|
#define this
|
||||||
#define __unaligned
|
#define __unaligned
|
||||||
|
|
@ -19,16 +38,6 @@ using namespace std::literals;
|
||||||
|
|
||||||
constexpr auto call_command_length = 5;
|
constexpr auto call_command_length = 5;
|
||||||
|
|
||||||
enum aim1_fix : uint32_t {
|
|
||||||
script_function__ISGLIDER = 0x0043A1F6,
|
|
||||||
trade_actions_weapon_checks = 0x004072FA,
|
|
||||||
setup_proper_weapon_slots_for_a_glider = 0x004D62E4,
|
|
||||||
put_weapon_into_the_right_slot_after_purchase = 0x00417A6D,
|
|
||||||
sell_correct_weapon = 0x004176BC,
|
|
||||||
empty_light_weapon_message = 0x004067C4,
|
|
||||||
empty_heavy_weapon_message = 0x0040688B,
|
|
||||||
can_leave_trade_window = 0x0040C20E,
|
|
||||||
};
|
|
||||||
uint32_t known_caller;
|
uint32_t known_caller;
|
||||||
auto player_ptr = (Player **)0x005B7B38;
|
auto player_ptr = (Player **)0x005B7B38;
|
||||||
auto get_player_ptr() {
|
auto get_player_ptr() {
|
||||||
|
|
@ -440,3 +449,4 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) {
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ deps: pub.lzwdgc.Polygon4.Tools.aim1.mod_maker-master
|
||||||
#define AIM_TYPES_FILE_NAME "aim.exe.h"
|
#define AIM_TYPES_FILE_NAME "aim.exe.h"
|
||||||
#define INJECTIONS_FILE_NAME "aim.exe.fixes.h"
|
#define INJECTIONS_FILE_NAME "aim.exe.fixes.h"
|
||||||
|
|
||||||
|
#include INJECTIONS_FILE_NAME
|
||||||
#ifndef INJECTED_DLL
|
#ifndef INJECTED_DLL
|
||||||
#include "aim1_mod_maker.h"
|
#include "aim1_mod_maker.h"
|
||||||
|
|
||||||
|
|
@ -128,7 +129,7 @@ int main(int argc, char *argv[]) {
|
||||||
"IF(_ISGLIDER(GL_S2_PA_SINYGR)|_ISGLIDER(GL_S4_S_SINYGR))");
|
"IF(_ISGLIDER(GL_S2_PA_SINYGR)|_ISGLIDER(GL_S4_S_SINYGR))");
|
||||||
|
|
||||||
// patch note: * _ISGLIDER() function can check exact glider name now, for example _ISGLIDER(GL_M3_A_FIRST1) (lz)
|
// patch note: * _ISGLIDER() function can check exact glider name now, for example _ISGLIDER(GL_M3_A_FIRST1) (lz)
|
||||||
mod.make_injection(0x0043A1F6, 10);
|
mod.make_injection(aim1_fix::script_function__ISGLIDER);
|
||||||
// end of scripts section
|
// end of scripts section
|
||||||
// patch note:
|
// patch note:
|
||||||
|
|
||||||
|
|
@ -193,13 +194,13 @@ int main(int argc, char *argv[]) {
|
||||||
// patch note: double light weapons: GL_M2_PA_NARGOON and GL_S3_PS_FINDER1
|
// patch note: double light weapons: GL_M2_PA_NARGOON and GL_S3_PS_FINDER1
|
||||||
// patch note: double heavy weapons: GL_M3_PA_EYEDSTONE and GL_S3_PS_FINDER2
|
// patch note: double heavy weapons: GL_M3_PA_EYEDSTONE and GL_S3_PS_FINDER2
|
||||||
// patch note: (still have many bugs related)
|
// patch note: (still have many bugs related)
|
||||||
mod.make_injection(0x004072FA); // can trade for buy purposes
|
mod.make_injection(aim1_fix::trade_actions_weapon_checks);
|
||||||
mod.make_injection(0x004D62E4); // setup proper weapon slots for a glider
|
mod.make_injection(aim1_fix::setup_proper_weapon_slots_for_a_glider);
|
||||||
mod.make_injection(0x00417A6D); // put weapon into the right slot after purchase
|
mod.make_injection(aim1_fix::put_weapon_into_the_right_slot_after_purchase);
|
||||||
mod.make_injection(0x004176BC); // sell correct weapon
|
mod.make_injection(aim1_fix::sell_correct_weapon);
|
||||||
mod.make_injection(0x004067C4); // empty light weap
|
mod.make_injection(aim1_fix::empty_light_weapon_message);
|
||||||
mod.make_injection(0x0040688B); // empty heavy weap
|
mod.make_injection(aim1_fix::empty_heavy_weapon_message);
|
||||||
mod.make_injection(0x0040C20E, 6); // can_leave_trade_window
|
mod.make_injection(aim1_fix::can_leave_trade_window);
|
||||||
// patch note:
|
// patch note:
|
||||||
|
|
||||||
// test scripts
|
// test scripts
|
||||||
|
|
@ -285,7 +286,4 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // INJECTED_DLL
|
|
||||||
#include INJECTIONS_FILE_NAME
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,10 @@ struct mod_maker {
|
||||||
// all you need is to provide injection address (virtual) with size
|
// all you need is to provide injection address (virtual) with size
|
||||||
// handle the call instruction in 'dispatcher' symbol (naked) of your dll
|
// handle the call instruction in 'dispatcher' symbol (naked) of your dll
|
||||||
constexpr static inline auto call_command_length = 5;
|
constexpr static inline auto call_command_length = 5;
|
||||||
void make_injection(uint32_t virtual_address, uint32_t size = call_command_length) {
|
void make_injection(uint32_t virtual_address) {
|
||||||
|
make_injection(virtual_address, get_injection_size(virtual_address));
|
||||||
|
}
|
||||||
|
void make_injection(uint32_t virtual_address, uint32_t size) {
|
||||||
uint32_t len = size;
|
uint32_t len = size;
|
||||||
if (len < call_command_length) {
|
if (len < call_command_length) {
|
||||||
throw std::runtime_error{"jumppad must be 5 bytes atleast"};
|
throw std::runtime_error{"jumppad must be 5 bytes atleast"};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue