2323#define TARGET_MACHINE_CODE_V146 0x48 , 0x8D , 0x4D , 0xFF , 0x49 , 0x83 , 0xFE , 0x10 , 0x48 , 0x0F , 0x43 , 0xCE , 0x48 , 0x83 , 0xFB , 0x0B , 0x75 , 0x17 , 0x4C , 0x8B , 0xC3
2424#define TARGET_MACHINE_CODE_V168 0x48 , 0x8D , 0x4D , 0xDF , 0x49 , 0x83 , 0xFE , 0x10 , 0x48 , 0x0F , 0x43 , 0xCF , 0x48 , 0x83 , 0xFB , 0x0B , 0x75 , 0x17 , 0x4C , 0x8B , 0xC3
2525#define TARGET_MACHINE_CODE_V186 0x48 , 0x8D , 0x4D , 0xC0 , 0x49 , 0x83 , 0xFE , 0x10 , 0x48 , 0x0F , 0x43 , 0xCF , 0x48 , 0x83 , 0xFB , 0x0B , 0x75 , 0x17 , 0x4C , 0x8B , 0xC3
26+ #define TARGET_MACHINE_CODE_V194 0x48 , 0x8D , 0x4D , 0x00 , 0x48 , 0x83 , 0xFE , 0x0F , 0x48 , 0x0F , 0x47 , 0xCF , 0x48 , 0x83 , 0xFB , 0x0B , 0x75 , 0x17 , 0x4C , 0x8B , 0xC3
2627#define PATCH_MACHINE_CODE 0x32 , 0xC0
2728#define REPLACEMENT_MACHINE_CODE 0xB0 , 0x01
2829// HOOK_MACHINE_CODE is the byte sequence of code to be replaced by injected code that is close to and after the found target code
3132#define HOOK_MACHINE_CODE_V146 0x41 , 0x88 , 0x44 , 0x24 , 0x28 , 0x4D , 0x8B , 0x64 , 0x24 , 0x08
3233#define HOOK_MACHINE_CODE_V168 0x41 , 0x88 , 0x44 , 0x24 , 0x28 , 0x4D , 0x8B , 0x64 , 0x24 , 0x08
3334#define HOOK_MACHINE_CODE_V186 0x41 , 0x88 , 0x44 , 0x24 , 0x28 , 0x4D , 0x8B , 0x64 , 0x24 , 0x08
35+ #define HOOK_MACHINE_CODE_V194 0x41 , 0x88 , 0x47 , 0x28 , 0x49 , 0x8B , 0x7F , 0x08
3436// #define CAVE_MACHINE_CODE_V100 0x5D, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC // 13 bytes minimum (after displacement)
3537// #define CAVE_MACHINE_CODE_DISP_V100 2
3638#define MAX_PATCH_CODE_DISP 0x20
@@ -49,12 +51,14 @@ constexpr byte logioptions_target_code_V100[] = { TARGET_MACHINE_CODE_V100 };
4951constexpr byte logioptions_target_code_V146[] = { TARGET_MACHINE_CODE_V146 };
5052constexpr byte logioptions_target_code_V168[] = { TARGET_MACHINE_CODE_V168 };
5153constexpr byte logioptions_target_code_V186[] = { TARGET_MACHINE_CODE_V186 };
54+ constexpr byte logioptions_target_code_V194[] = { TARGET_MACHINE_CODE_V194 };
5255constexpr byte logioptions_hook_code_V100[] = { HOOK_MACHINE_CODE_V100 };
5356constexpr byte logioptions_hook_code_V146[] = { HOOK_MACHINE_CODE_V146 };
5457constexpr byte logioptions_hook_code_V168[] = { HOOK_MACHINE_CODE_V168 };
5558constexpr byte logioptions_hook_code_V186[] = { HOOK_MACHINE_CODE_V186 };
56- const byte *logioptions_target_code = logioptions_target_code_V186;
57- const byte *logioptions_hook_code = logioptions_hook_code_V186;
59+ constexpr byte logioptions_hook_code_V194[] = { HOOK_MACHINE_CODE_V194 };
60+ const byte *logioptions_target_code = logioptions_target_code_V194;
61+ const byte *logioptions_hook_code = logioptions_hook_code_V194;
5862#ifdef CODE_CAVE
5963// constexpr byte logioptions_cave_code_V100[] = { CAVE_MACHINE_CODE_V100 };
6064// constexpr size_t logioptions_cave_code_disp_V100 = CAVE_MACHINE_CODE_DISP_V100;
@@ -72,11 +76,13 @@ extern "C"
7276 extern bool target_handler_V146 (const char * name, size_t length);
7377 extern bool target_handler_V168 (const char * name, size_t length);
7478 extern bool target_handler_V186 (const char * name, size_t length);
79+ extern bool target_handler_V194 (const char * name, size_t length);
7580
7681 extern void injected_handler_V100 ();
7782 extern void injected_handler_V146 ();
7883 extern void injected_handler_V168 ();
7984 extern void injected_handler_V186 ();
85+ extern void injected_handler_V194 ();
8086
8187 bool patched_switch_foreground_process_handler (const char * name, size_t length, bool previous_check)
8288 {
@@ -373,7 +379,13 @@ void hook_current_process()
373379 size_t target_code_size, hook_code_size;
374380 void (*injected_handler)();
375381 byte* found_addr;
376- if (find_data (memory, bytes_count, logioptions_target_code_V186, target_code_size = sizeof logioptions_target_code_V186, found_addr))
382+ if (find_data (memory, bytes_count, logioptions_target_code_V194, target_code_size = sizeof logioptions_target_code_V194, found_addr))
383+ {
384+ injected_handler = injected_handler_V194;
385+ hook_code = logioptions_hook_code_V194;
386+ hook_code_size = sizeof logioptions_hook_code_V194;
387+ }
388+ else if (find_data (memory, bytes_count, logioptions_target_code_V186, target_code_size = sizeof logioptions_target_code_V186, found_addr))
377389 {
378390 injected_handler = injected_handler_V186;
379391 hook_code = logioptions_hook_code_V186;
@@ -465,7 +477,7 @@ int main()
465477 // patch_another_process();
466478 read_config ();
467479 hook_current_process ();
468- const bool result = target_handler_V186 (PROGRAM_NAME_CHARS , sizeof PROGRAM_NAME_CHARS );
480+ const bool result = target_handler_V194 (PROGRAM_NAME_CHARS , sizeof PROGRAM_NAME_CHARS );
469481 std::cout << " Handler result = " << static_cast <int >(result) << ' \n ' ;
470482 return 0 ;
471483}
0 commit comments