diff --git a/.gitignore b/.gitignore index 83412e3..62dff6e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ */bin/* */Release/* */Debug/* +*/.vs/* +*.pdb \ No newline at end of file diff --git a/Thumbs.db b/Thumbs.db deleted file mode 100644 index aef2ed0..0000000 Binary files a/Thumbs.db and /dev/null differ diff --git a/UGP.gmx/Thumbs.db b/UGP.gmx/Thumbs.db deleted file mode 100644 index e8ca42b..0000000 Binary files a/UGP.gmx/Thumbs.db and /dev/null differ diff --git a/UGP.gmx/UGP.project.gmx b/UGP.gmx/UGP.project.gmx index 62db03b..e0f2823 100644 --- a/UGP.gmx/UGP.project.gmx +++ b/UGP.gmx/UGP.project.gmx @@ -1,24 +1,10 @@ - - libeay32.dll - libeay32.dll - C:\Users\Li\Desktop\NuclearWar\UGP\UGP.gmx\\\datafiles\libeay32.dll - -1 - 1207808 - 2 - - 0 - -1 - 0 - -1 - datafiles\libeay32.dll - UGP.dll UGP.dll - C:\Users\Li\Desktop\NuclearWar\UGP\UGP.gmx\\\datafiles\UGP.dll + C:\Users\Li\Desktop\UGP\UGP\UGP.gmx\\\datafiles\UGP.dll -1 97280 2 @@ -32,7 +18,7 @@ ModuleDownloader.exe ModuleDownloader.exe - C:\Users\Li\Desktop\NuclearWar\UGP\UGP.gmx\\\datafiles\ModuleDownloader.exe + C:\Users\Li\Desktop\UGP\UGP\UGP.gmx\\\datafiles\ModuleDownloader.exe -1 2147328 2 @@ -43,19 +29,33 @@ -1 datafiles\ModuleDownloader.exe + + winspool.dll + winspool.dll + C:\Users\Li\Desktop\UGP\UGP\UGP.gmx\datafiles\winspool.dll + -1 + 75776 + 2 + + 0 + -1 + 0 + -1 + datafiles\winspool.dll + -1 - 0 + -1 0 0 - -1 + 0 0 0 0 0 0 - 0 + 6 0 0 0 @@ -84,18 +84,18 @@ 0 0 -1 - decompiler clan :police_car: :police_car: :police_car: - + Li + 1.5 44738.8179982292 1 0 0 0 - - - - + The Crystal System + Universal GameMaker Patcher + no + Patcher for GM5, 6, 8.1 HTML5 and Studio 1.4 <undefined> 0 @@ -159,11 +159,11 @@ - - + + @@ -205,7 +205,7 @@ objects\obj_checkmark_old objects\obj_checkmark_modules objects\obj_checkmark_updater - objects\obj_checkmark_libeay32 + objects\obj_checkmark_winspool objects\obj_checkmark_base diff --git a/UGP.gmx/datafiles/libeay32.dll b/UGP.gmx/datafiles/libeay32.dll deleted file mode 100644 index d0fcde4..0000000 Binary files a/UGP.gmx/datafiles/libeay32.dll and /dev/null differ diff --git a/UGP.gmx/datafiles/winspool.dll b/UGP.gmx/datafiles/winspool.dll new file mode 100644 index 0000000..bd597ec Binary files /dev/null and b/UGP.gmx/datafiles/winspool.dll differ diff --git a/UGP.gmx/help.rtf b/UGP.gmx/help.rtf index 81f48ad..274462b 100644 Binary files a/UGP.gmx/help.rtf and b/UGP.gmx/help.rtf differ diff --git a/UGP.gmx/objects/obj_checkmark_winspool.object.gmx b/UGP.gmx/objects/obj_checkmark_winspool.object.gmx new file mode 100644 index 0000000..f07cdc9 --- /dev/null +++ b/UGP.gmx/objects/obj_checkmark_winspool.object.gmx @@ -0,0 +1,19 @@ + + + spr_checkmark + 0 + -1 + 0 + 0 + obj_checkmark_base + <undefined> + + 0 + 0 + 0 + 0.5 + 0.100000001490116 + 0 + 0.100000001490116 + 0.100000001490116 + diff --git a/UGP.gmx/objects/obj_cursor.object.gmx b/UGP.gmx/objects/obj_cursor.object.gmx index d9d4ddc..e2d7d11 100644 --- a/UGP.gmx/objects/obj_cursor.object.gmx +++ b/UGP.gmx/objects/obj_cursor.object.gmx @@ -8,6 +8,30 @@ <undefined> <undefined> + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + x = mouse_x; +y = mouse_y; + + + + + 1 @@ -25,7 +49,7 @@ 1 - draw_sprite(spr_cursor, 0, mouse_x, mouse_y); + draw_sprite(spr_cursor, 0, window_mouse_get_x(), window_mouse_get_y()); diff --git a/UGP.gmx/objects/obj_go_gm81.object.gmx b/UGP.gmx/objects/obj_go_gm81.object.gmx index 1c3c2ae..149232a 100644 --- a/UGP.gmx/objects/obj_go_gm81.object.gmx +++ b/UGP.gmx/objects/obj_go_gm81.object.gmx @@ -97,7 +97,7 @@ image_index = 0; 1 error_occurred = 0; -license_gm81(obj_textinput_name.text, obj_textinput_key.text, obj_checkmark_libeay32.checked); +license_gm81(obj_textinput_name.text, obj_textinput_key.text, obj_checkmark_winspool.checked); obj_draw.back_down = true; if(!error_occurred) diff --git a/UGP.gmx/objects/obj_go_gmhtml5.object.gmx b/UGP.gmx/objects/obj_go_gmhtml5.object.gmx index 1f737d0..f6c133a 100644 --- a/UGP.gmx/objects/obj_go_gmhtml5.object.gmx +++ b/UGP.gmx/objects/obj_go_gmhtml5.object.gmx @@ -97,7 +97,7 @@ image_index = 0; 1 error_occurred = 0; -license_gmhtml5(obj_textinput_name.text, obj_textinput_key.text, obj_checkmark_libeay32.checked); +license_gmhtml5(obj_textinput_name.text, obj_textinput_key.text, obj_checkmark_winspool.checked); obj_draw.back_down = true; if(!error_occurred) diff --git a/UGP.gmx/objects/obj_go_studio.object.gmx b/UGP.gmx/objects/obj_go_studio.object.gmx index 650da9b..9665286 100644 --- a/UGP.gmx/objects/obj_go_studio.object.gmx +++ b/UGP.gmx/objects/obj_go_studio.object.gmx @@ -98,7 +98,7 @@ image_index = 0; error_occurred = 0; ///license_gmhtml5(name, answer, key, email, type, export_modules, do_libeay32, download_exports) -license_studio(obj_textinput_name.text, string(obj_textinput_answer.text), obj_textinput_key.text, obj_textinput_email.text, obj_textinput_type.text, global.export_modules, obj_checkmark_libeay32.checked, obj_checkmark_modules.checked, obj_checkmark_old.checked) +license_studio(obj_textinput_name.text, string(obj_textinput_answer.text), obj_textinput_key.text, obj_textinput_email.text, obj_textinput_type.text, global.export_modules, obj_checkmark_winspool.checked, obj_checkmark_modules.checked, obj_checkmark_old.checked) obj_draw.back_down = true; if(!error_occurred) { diff --git a/UGP.gmx/objects/obj_main.object.gmx b/UGP.gmx/objects/obj_main.object.gmx index 7d42fe5..9bce5b7 100644 --- a/UGP.gmx/objects/obj_main.object.gmx +++ b/UGP.gmx/objects/obj_main.object.gmx @@ -36,6 +36,46 @@ if(obj_draw.back_down == false && obj_draw.back_up == false) obj_draw.action += "game_end();"; } + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + ///setup views + +var display_height; +display_height = display_get_height() + +var display_width; +display_width = display_get_width() + +if(room_height > display_height || room_width > display_width){ + view_enabled = true; + view_visible[view_current] = true; + view_object[view_current] = obj_cursor; + view_hport[view_current] = room_height; + view_wport[view_current] = room_width; + view_hview[view_current] = room_height; + view_wview[view_current] = room_width; +} + @@ -61,7 +101,7 @@ if(obj_draw.back_down == false && obj_draw.back_up == false) external_free("UGP.dll"); file_delete("UGP.dll"); -file_delete("libeay32.dll"); +file_delete("winspool.dll"); file_delete("ModuleDownloader.exe"); @@ -85,7 +125,8 @@ file_delete("ModuleDownloader.exe"); 1 - //UGP.DLL imports + ///initalize +//UGP.DLL imports global.getMachineGuid = external_define("UGP.dll","GetMachineGuid",dll_cdecl,ty_string,0); global.MD5 = external_define("UGP.dll","MD5",dll_cdecl,ty_string,1,ty_string); global.setBinKey = external_define("UGP.dll","SetBinKey",dll_cdecl,ty_real,3,ty_string, ty_string, ty_string); diff --git a/UGP.gmx/rooms/rm_close.room.gmx b/UGP.gmx/rooms/rm_close.room.gmx index a6dd48d..25e63d8 100644 --- a/UGP.gmx/rooms/rm_close.room.gmx +++ b/UGP.gmx/rooms/rm_close.room.gmx @@ -40,7 +40,7 @@ - + diff --git a/UGP.gmx/rooms/rm_crack_gm8.room.gmx b/UGP.gmx/rooms/rm_crack_gm8.room.gmx index cbdb28f..c2dc4d9 100644 --- a/UGP.gmx/rooms/rm_crack_gm8.room.gmx +++ b/UGP.gmx/rooms/rm_crack_gm8.room.gmx @@ -40,7 +40,7 @@ - + diff --git a/UGP.gmx/rooms/rm_crack_studio.room.gmx b/UGP.gmx/rooms/rm_crack_studio.room.gmx index cbdb28f..c2dc4d9 100644 --- a/UGP.gmx/rooms/rm_crack_studio.room.gmx +++ b/UGP.gmx/rooms/rm_crack_studio.room.gmx @@ -40,7 +40,7 @@ - + diff --git a/UGP.gmx/rooms/rm_keygen_gm5.room.gmx b/UGP.gmx/rooms/rm_keygen_gm5.room.gmx index 3e43c39..51ff809 100644 --- a/UGP.gmx/rooms/rm_keygen_gm5.room.gmx +++ b/UGP.gmx/rooms/rm_keygen_gm5.room.gmx @@ -40,7 +40,7 @@ - + diff --git a/UGP.gmx/rooms/rm_product_select.room.gmx b/UGP.gmx/rooms/rm_product_select.room.gmx index f79311d..c482eb4 100644 --- a/UGP.gmx/rooms/rm_product_select.room.gmx +++ b/UGP.gmx/rooms/rm_product_select.room.gmx @@ -40,7 +40,7 @@ - + diff --git a/UGP.gmx/rooms/rm_result.room.gmx b/UGP.gmx/rooms/rm_result.room.gmx index a6dd48d..04feb84 100644 --- a/UGP.gmx/rooms/rm_result.room.gmx +++ b/UGP.gmx/rooms/rm_result.room.gmx @@ -40,7 +40,7 @@ - + diff --git a/UGP.gmx/scripts/create_gm81_menu.gml b/UGP.gmx/scripts/create_gm81_menu.gml index 0159b26..bc8e666 100644 --- a/UGP.gmx/scripts/create_gm81_menu.gml +++ b/UGP.gmx/scripts/create_gm81_menu.gml @@ -1,6 +1,6 @@ global.direction = 1; -instance_create(centerX-250, centerY-150, obj_checkmark_libeay32); +instance_create(centerX-250, centerY-150, obj_checkmark_winspool); //instance_create(centerX-250, centerY-90, obj_checkmark_updater); instance_create(centerX-290, centerY+20, obj_textinput_name); instance_create(centerX-290, centerY+110, obj_textinput_key); diff --git a/UGP.gmx/scripts/create_gmhtml5_menu.gml b/UGP.gmx/scripts/create_gmhtml5_menu.gml index a13b5a6..955fbbc 100644 --- a/UGP.gmx/scripts/create_gmhtml5_menu.gml +++ b/UGP.gmx/scripts/create_gmhtml5_menu.gml @@ -1,6 +1,6 @@ global.direction = 1; -instance_create(centerX-250, centerY-150, obj_checkmark_libeay32); +instance_create(centerX-250, centerY-150, obj_checkmark_winspool); instance_create(centerX-290, centerY+20, obj_textinput_name); instance_create(centerX-290, centerY+110, obj_textinput_key); instance_create(centerX, centerY+250, obj_go_gmhtml5); diff --git a/UGP.gmx/scripts/create_studio_menu.gml b/UGP.gmx/scripts/create_studio_menu.gml index 2a2a388..86d5531 100644 --- a/UGP.gmx/scripts/create_studio_menu.gml +++ b/UGP.gmx/scripts/create_studio_menu.gml @@ -1,6 +1,6 @@ global.direction = 1; -instance_create(centerX-250, centerY-150, obj_checkmark_libeay32); +instance_create(centerX-250, centerY-150, obj_checkmark_winspool); instance_create(centerX-250, centerY-90, obj_checkmark_modules); instance_create(centerX-290, centerY-30, obj_textinput_name); instance_create(centerX-290, centerY+15, obj_textinput_key); diff --git a/UGP.gmx/scripts/license_gm81.gml b/UGP.gmx/scripts/license_gm81.gml index 760f7c2..b6b6fd3 100644 --- a/UGP.gmx/scripts/license_gm81.gml +++ b/UGP.gmx/scripts/license_gm81.gml @@ -1,4 +1,4 @@ -///license_gm81(name, key, do_libeay32) +///license_gm81(name, key, do_winspool) var name; var key; var machineGuid; @@ -9,11 +9,10 @@ key = argument1; if(argument2) { - dll_path = global.APPDATA+"\GameMaker\libeay32.dll"; + dll_path = global.APPDATA+"\GameMaker\winspool.drv"; if(file_exists(dll_path)) file_delete(dll_path); - //export_include_file_location("libeay32.dll", dll_path); - file_copy("libeay32.dll", dll_path); + file_copy("winspool.dll", dll_path); } guid = external_call(global.getMachineGuid); diff --git a/UGP.gmx/scripts/license_gmhtml5.gml b/UGP.gmx/scripts/license_gmhtml5.gml index 66ec60e..780678e 100644 --- a/UGP.gmx/scripts/license_gmhtml5.gml +++ b/UGP.gmx/scripts/license_gmhtml5.gml @@ -1,4 +1,4 @@ -///license_gmhtml5(name, key, do_libeay32) +///license_gmhtml5(name, key, do_winspool) var name; var key; var machineGuid; @@ -9,11 +9,10 @@ key = argument1; if(argument2) { - dll_path = global.APPDATA+"\GameMaker-HTML5\libeay32.dll"; + dll_path = global.APPDATA+"\GameMaker-HTML5\winspool.drv"; if(file_exists(dll_path)) file_delete(dll_path); - //export_include_file_location("libeay32.dll", dll_path); - file_copy("libeay32.dll", dll_path); + file_copy("winspool.dll", dll_path); } diff --git a/UGP.gmx/scripts/license_studio.gml b/UGP.gmx/scripts/license_studio.gml index b6a4c8a..fc32fea 100644 --- a/UGP.gmx/scripts/license_studio.gml +++ b/UGP.gmx/scripts/license_studio.gml @@ -1,4 +1,4 @@ -///license_studio(name, answer, key, email, type, export_modules, do_libeay32, download_exports, old_version) +///license_studio(name, answer, key, email, type, export_modules, do_winspool, download_exports, old_version) var name; var key; var answer; @@ -15,17 +15,16 @@ email = argument3; type = argument4; export_modules = argument5; -do_libeay32 = argument6 +do_winspool = argument6 global.download_exports = argument7 old_version = argument8 -if(do_libeay32) +if(do_winspool) { - dll_path = global.APPDATA+"\GameMaker-Studio\libeay32.dll"; + dll_path = global.APPDATA+"\GameMaker-Studio\winspool.drv"; if(file_exists(dll_path)) file_delete(dll_path); - //export_include_file_location("libeay32.dll", dll_path); - file_copy("libeay32.dll", dll_path); + file_copy("winspool.dll", dll_path); } addons_string = ""; diff --git a/UGP.gmx/scripts/script20.gml b/UGP.gmx/scripts/script20.gml index 499c853..b2f5815 100644 --- a/UGP.gmx/scripts/script20.gml +++ b/UGP.gmx/scripts/script20.gml @@ -1,17 +1,12 @@ -///generate_gm6(name) -var name; -var new_name; -var start; -var encname; +///setup_views() -// Pad name out with "X" (if its < 5 chars long) -new_name = string_upper(pad(name, 5, "X")); +var display_height = display_get_height() +var display_width = display_get_width() -// Start 5 characters from the end -start = (string_length(new_name) - 5)+1; - -// Extract last 5 characters, into a 2 char and 3 char string -encname = string_copy(new_name, start, 2); - -external_call(global.generateGM6Key, argument0); +if(room_height > display_height){ + view_hview[view_current] = display_height; +} +if(room_width > display_width){ + view_hview[view_current] = display_width; +} diff --git a/UGP.gmx/scripts/setup_views.gml b/UGP.gmx/scripts/setup_views.gml new file mode 100644 index 0000000..c38194f --- /dev/null +++ b/UGP.gmx/scripts/setup_views.gml @@ -0,0 +1,27 @@ +///setup views() + +var display_height; +display_height = display_get_height() + +var display_width; +display_width = display_get_width() + + + +if(room_height > display_height){ + view_hview[view_current] = display_height; + view_hport[view_current] = display_height; +} +else{ + view_hview[view_current] = room_height; + view_hport[view_current] = room_height; +} +if(room_width > display_width){ + view_wview[view_current] = display_width; + view_wview[view_current] = display_width; +} +else{ + view_wview[view_current] = room_width; + view_wport[view_current] = room_width; +} + diff --git a/UGP.gmx/scripts/start_cracked_updater.gml b/UGP.gmx/scripts/start_cracked_updater.gml index 944f603..d777e9a 100644 --- a/UGP.gmx/scripts/start_cracked_updater.gml +++ b/UGP.gmx/scripts/start_cracked_updater.gml @@ -8,7 +8,6 @@ else{ file_delete(location+"\ModuleDownloader.exe"); } -//export_include_file_location("ModuleDownloader.exe", location+"\ModuleDownloader.exe"); file_copy("ModuleDownloader.exe", location+"\ModuleDownloader.exe"); execute_program(location+"\ModuleDownloader.exe","",false); diff --git a/UGP.gmx/sound/audio/snd_mus.ogg b/UGP.gmx/sound/audio/snd_mus.ogg index 3e64fa1..30bf056 100644 Binary files a/UGP.gmx/sound/audio/snd_mus.ogg and b/UGP.gmx/sound/audio/snd_mus.ogg differ diff --git a/UGP.gmx/sound/snd_mus.sound.gmx b/UGP.gmx/sound/snd_mus.sound.gmx index 08f2da0..ae92c29 100644 --- a/UGP.gmx/sound/snd_mus.sound.gmx +++ b/UGP.gmx/sound/snd_mus.sound.gmx @@ -2,7 +2,7 @@ 3 .mp3 - C:\Users\Li\Desktop\NuclearWar\UGP\UGP.gmx\\\sound\audio\snd_mus.mp3 + C:\Users\Li\Desktop\UGP\UGP\UGP.gmx\\\sound\audio\snd_mus.mp3 0 1 0 diff --git a/UGP.gmx/sprites/images/spr_menu_1.png b/UGP.gmx/sprites/images/spr_menu_1.png index 21de4ca..e1c711d 100644 Binary files a/UGP.gmx/sprites/images/spr_menu_1.png and b/UGP.gmx/sprites/images/spr_menu_1.png differ diff --git a/UGP.gmx/sprites/images/spr_menu_4.png b/UGP.gmx/sprites/images/spr_menu_4.png index 007405f..5857b62 100644 Binary files a/UGP.gmx/sprites/images/spr_menu_4.png and b/UGP.gmx/sprites/images/spr_menu_4.png differ diff --git a/UGP.gmx/sprites/images/spr_menu_5.png b/UGP.gmx/sprites/images/spr_menu_5.png index 282db6d..569cd61 100644 Binary files a/UGP.gmx/sprites/images/spr_menu_5.png and b/UGP.gmx/sprites/images/spr_menu_5.png differ diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch.sln b/Visual Studio Projects/LibeayPatch/LibeayPatch.sln new file mode 100644 index 0000000..4a4aedb --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibeayPatch", "LibeayPatch\LibeayPatch.vcxproj", "{122013EF-A5F6-40A0-A8E4-71F725C240A4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Debug|x64.ActiveCfg = Debug|x64 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Debug|x64.Build.0 = Debug|x64 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Debug|x86.ActiveCfg = Debug|Win32 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Debug|x86.Build.0 = Debug|Win32 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Release|x64.ActiveCfg = Release|x64 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Release|x64.Build.0 = Release|x64 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Release|x86.ActiveCfg = Release|Win32 + {122013EF-A5F6-40A0-A8E4-71F725C240A4}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {41A99AAD-D35F-4E17-A5BC-8DA7837843FE} + EndGlobalSection +EndGlobal diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/Dllmain.cpp b/Visual Studio Projects/LibeayPatch/LibeayPatch/Dllmain.cpp new file mode 100644 index 0000000..2cf4d43 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/Dllmain.cpp @@ -0,0 +1,39 @@ +#include +#include +#include "OpenSSLPatch.h" + +void createDebugConsole() { + FILE* fDummy; + AllocConsole(); + freopen_s(&fDummy, "CONIN$", "r", stdin); + freopen_s(&fDummy, "CONOUT$", "w", stderr); + freopen_s(&fDummy, "CONOUT$", "w", stdout); +} + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + +#ifdef _DEBUG + createDebugConsole(); +#endif + + PatchLibeay32(); + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + UnpatchLibeay32(); + break; + } + return TRUE; +} + diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/Hook.cpp b/Visual Studio Projects/LibeayPatch/LibeayPatch/Hook.cpp new file mode 100644 index 0000000..cc07a8e --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/Hook.cpp @@ -0,0 +1,183 @@ +/* +* Shamelessly stolen from: +* https://github.com/adamhlt/IAT-Hooking/tree/main +*/ + +#include "Hook.h" + +#include +#include +#include + +/** + * Function who retrieve the base address of the main module of the current process. + * \return : the base address if it's successfull else nullptr + */ +LPVOID IAT::GetCurrentProcessModule() +{ + char lpCurrentModuleName[MAX_PATH]; + + char lpImageName[MAX_PATH]; + + GetProcessImageFileNameA(GetCurrentProcess(), lpImageName, MAX_PATH); + + MODULEENTRY32 ModuleList{}; + ModuleList.dwSize = sizeof(ModuleList); + + const HANDLE hProcList = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0); + if (hProcList == INVALID_HANDLE_VALUE) + return nullptr; + + if (!Module32First(hProcList, &ModuleList)) + return nullptr; + + wcstombs_s(nullptr, lpCurrentModuleName, ModuleList.szModule, MAX_PATH); + lpCurrentModuleName[MAX_PATH - 1] = '\0'; + + if (strstr(lpImageName, lpCurrentModuleName) != nullptr) + return ModuleList.hModule; + + while (Module32Next(hProcList, &ModuleList)) + { + wcstombs_s(nullptr, lpCurrentModuleName, ModuleList.szModule, MAX_PATH); + lpCurrentModuleName[MAX_PATH - 1] = '\0'; + + if (strstr(lpImageName, lpCurrentModuleName) != nullptr) + return ModuleList.hModule; + } + + return nullptr; +} + +/** + * Function to hook functions in the IAT of a specified module. + * \param lpModuleName : name of the module wich contains the function you want to hook. + * \param lpFunctionName : name of the function you want to hook. + * \param lpFunction : pointer of the new function. + * \param lpTargetModuleName : name of the module you want to target. + * \return : the pointer of the original function or nullptr if it failed. + */ +LPVOID IAT::Hook(LPCSTR lpModuleName, LPCSTR lpFunctionName, const LPVOID lpFunction, LPCSTR lpTargetModuleName) +{ + const HANDLE hModule = GetModuleHandleA(lpTargetModuleName); + const auto lpImageDOSHeader = (PIMAGE_DOS_HEADER)(hModule); + if (lpImageDOSHeader == nullptr) + return nullptr; + + const auto lpImageNtHeader = (PIMAGE_NT_HEADERS)((DWORD_PTR)lpImageDOSHeader + lpImageDOSHeader->e_lfanew); + + const IMAGE_DATA_DIRECTORY ImportDataDirectory = lpImageNtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; + auto lpImageImportDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD_PTR)hModule + ImportDataDirectory.VirtualAddress); + + while (lpImageImportDescriptor->Characteristics != 0) + { + const auto lpCurrentModuleName = (LPSTR)((DWORD_PTR)lpImageDOSHeader + lpImageImportDescriptor->Name); + if (_stricmp(lpCurrentModuleName, lpModuleName) != 0) + { + lpImageImportDescriptor++; + continue; + } + + auto lpImageOrgThunkData = (PIMAGE_THUNK_DATA)((DWORD_PTR)lpImageDOSHeader + lpImageImportDescriptor->OriginalFirstThunk); + auto lpImageThunkData = (PIMAGE_THUNK_DATA)((DWORD_PTR)lpImageDOSHeader + lpImageImportDescriptor->FirstThunk); + + while (lpImageOrgThunkData->u1.AddressOfData != 0) + { + const auto lpImportData = (PIMAGE_IMPORT_BY_NAME)((DWORD_PTR)lpImageDOSHeader + lpImageOrgThunkData->u1.AddressOfData); + + if (strcmp(lpFunctionName, (char*)lpImportData->Name) == 0) + { + DWORD dwJunk = 0; + MEMORY_BASIC_INFORMATION mbi; + + VirtualQuery(lpImageThunkData, &mbi, sizeof(MEMORY_BASIC_INFORMATION)); + if (!VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &mbi.Protect)) + return nullptr; + + const auto lpOrgFunction = (LPVOID)lpImageThunkData->u1.Function; + +#if defined _M_IX86 + lpImageThunkData->u1.Function = (DWORD_PTR)lpFunction; +#elif defined _M_X64 + lpImageThunkData->u1.Function = (DWORD_PTR)lpFunction; +#endif + + if (VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &dwJunk)) + return lpOrgFunction; + } + + lpImageThunkData++; + lpImageOrgThunkData++; + } + + lpImageImportDescriptor++; + } + + return nullptr; +} + +/** + * Function to hook functions in the IAT of a the main module of the process. + * \param lpModuleName : name of the module wich contains the function. + * \param lpFunctionName : name of the function you want to hook. + * \param lpFunction : pointer of the new function. + * \return : the pointer of the original function or nullptr if it failed. + */ +LPVOID IAT::Hook(LPCSTR lpModuleName, LPCSTR lpFunctionName, const LPVOID lpFunction) +{ + const LPVOID hModule = GetCurrentProcessModule(); + const auto lpImageDOSHeader = (PIMAGE_DOS_HEADER)(hModule); + if (lpImageDOSHeader == nullptr) + return nullptr; + + const auto lpImageNtHeader = (PIMAGE_NT_HEADERS)((DWORD_PTR)lpImageDOSHeader + lpImageDOSHeader->e_lfanew); + + const IMAGE_DATA_DIRECTORY ImportDataDirectory = lpImageNtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; + auto lpImageImportDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD_PTR)hModule + ImportDataDirectory.VirtualAddress); + + while (lpImageImportDescriptor->Characteristics != 0) + { + const auto lpCurrentModuleName = (LPSTR)((DWORD_PTR)lpImageDOSHeader + lpImageImportDescriptor->Name); + if (_stricmp(lpCurrentModuleName, lpModuleName) != 0) + { + lpImageImportDescriptor++; + continue; + } + + auto lpImageOrgThunkData = (PIMAGE_THUNK_DATA)((DWORD_PTR)lpImageDOSHeader + lpImageImportDescriptor->OriginalFirstThunk); + auto lpImageThunkData = (PIMAGE_THUNK_DATA)((DWORD_PTR)lpImageDOSHeader + lpImageImportDescriptor->FirstThunk); + + while (lpImageOrgThunkData->u1.AddressOfData != 0) + { + const auto lpImportData = (PIMAGE_IMPORT_BY_NAME)((DWORD_PTR)lpImageDOSHeader + lpImageOrgThunkData->u1.AddressOfData); + + if (strcmp(lpFunctionName, (char*)lpImportData->Name) == 0) + { + DWORD dwJunk = 0; + MEMORY_BASIC_INFORMATION mbi; + + VirtualQuery(lpImageThunkData, &mbi, sizeof(MEMORY_BASIC_INFORMATION)); + if (!VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &mbi.Protect)) + return nullptr; + + const auto lpOrgFunction = (LPVOID)lpImageThunkData->u1.Function; + +#if defined _M_IX86 + lpImageThunkData->u1.Function = (DWORD_PTR)lpFunction; +#elif defined _M_X64 + lpImageThunkData->u1.Function = (DWORD_PTR)lpFunction; +#endif + + if (VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &dwJunk)) + return lpOrgFunction; + } + + lpImageThunkData++; + lpImageOrgThunkData++; + } + + lpImageImportDescriptor++; + } + + return nullptr; +} \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/Hook.h b/Visual Studio Projects/LibeayPatch/LibeayPatch/Hook.h new file mode 100644 index 0000000..50761b2 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/Hook.h @@ -0,0 +1,15 @@ +#ifndef IAT_HOOK_H +#define IAT_HOOK_H + +#include + +class IAT +{ +public: + static LPVOID Hook(LPCSTR lpModuleName, LPCSTR lpFunctionName, const LPVOID lpFunction, LPCSTR lpTargetModuleName); + static LPVOID Hook(LPCSTR lpModuleName, LPCSTR lpFunctionName, const LPVOID lpFunction); +private: + static LPVOID GetCurrentProcessModule(); +}; + +#endif \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj b/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj new file mode 100644 index 0000000..c3aed95 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj @@ -0,0 +1,186 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {122013ef-a5f6-40a0-a8e4-71f725c240a4} + winspoolstub + LibeayPatch + 7.0 + + + + DynamicLibrary + true + v141_xp + Unicode + + + DynamicLibrary + false + v141_xp + true + Unicode + + + DynamicLibrary + true + v141_xp + Unicode + + + DynamicLibrary + false + v141_xp + true + Unicode + + + + + + + + + + + + + + + + + + + + + winspool + $(SolutionDir)\..\..\UGP.gmx\datafiles + + + winspool + $(SolutionDir)\..\..\UGP.gmx\datafiles + + + winspool + $(SolutionDir)\..\..\UGP.gmx\datafiles + + + winspool + $(SolutionDir)\..\..\UGP.gmx\datafiles + + + + Level3 + true + WIN32;_DEBUG;WINSPOOLSTUB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + pch.h + MultiThreadedDebug + + + Windows + true + false + Psapi.lib;%(AdditionalDependencies) + Stub.def + + + + + Level3 + true + true + true + WIN32;NDEBUG;WINSPOOLSTUB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + pch.h + MultiThreaded + + + Windows + true + true + true + false + Psapi.lib;%(AdditionalDependencies) + Stub.def + + + + + Level3 + true + _DEBUG;WINSPOOLSTUB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + pch.h + MultiThreadedDebug + + + Windows + true + false + Psapi.lib;%(AdditionalDependencies) + Stub.def + + + + + Level3 + true + true + true + NDEBUG;WINSPOOLSTUB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + pch.h + MultiThreaded + + + Windows + true + true + true + false + Psapi.lib;%(AdditionalDependencies) + Stub.def + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj.filters b/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj.filters new file mode 100644 index 0000000..f19e2df --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj.user b/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/LibeayPatch.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/OpenSSLPatch.cpp b/Visual Studio Projects/LibeayPatch/LibeayPatch/OpenSSLPatch.cpp new file mode 100644 index 0000000..42d1997 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/OpenSSLPatch.cpp @@ -0,0 +1,96 @@ +#include "Hook.h" +#include + +// dllmain.cpp : Defines the entry point for the DLL application. + +// ripped from openssl +typedef struct bignum_st { + unsigned long* d; + int top; + int dmax; + int neg; + int flags; +} BIGNUM; + +typedef struct rsa_st { + void* unk1; + void* unk2; + void* unk3; + void* unk4; + BIGNUM* m; + BIGNUM* e; + void* unk5; + void* unk6; +} RSA; + +using openssl_rsa_public_decrypt_ptr = int(__cdecl*)(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, int padding); +static openssl_rsa_public_decrypt_ptr RsaPublicDecrypt = nullptr; + +using openssl_sha1_ptr = char* (__cdecl*)(const unsigned char* d, size_t n, unsigned char* md); +static openssl_sha1_ptr Sha1 = nullptr; + +const size_t SHA1_SZ = 0x14; + +char YOYO_LICENSE_PUBLIC_KEY[0x80] = { + 0x7B, 0x05, 0x78, 0xE0, 0x05, 0x50, 0xA4, 0xD6, 0xBA, 0xE9, 0x5E, 0x28, 0xF6, 0x74, 0x2A, 0x07, + 0x21, 0x08, 0xB8, 0xC0, 0x71, 0x38, 0xA3, 0x44, 0xCD, 0x87, 0xD0, 0xAB, 0x39, 0xA1, 0xF5, 0x56, + 0x94, 0x97, 0x3E, 0xF2, 0x03, 0x9C, 0xAD, 0x86, 0x37, 0x4B, 0x82, 0xC2, 0x8C, 0x40, 0x30, 0x85, + 0x39, 0x4F, 0x04, 0xBA, 0x4B, 0x65, 0xF6, 0x0E, 0x4B, 0x9A, 0x47, 0x59, 0xFE, 0xA0, 0xA6, 0x33, + 0xDC, 0x8A, 0x0C, 0x35, 0x58, 0xDF, 0x74, 0xDC, 0xB7, 0xFE, 0x57, 0x2C, 0x85, 0x14, 0xA6, 0xD2, + 0x34, 0x9E, 0x54, 0x7D, 0xCF, 0xEA, 0x08, 0x2D, 0x29, 0xB5, 0x0B, 0x01, 0x30, 0x14, 0x5A, 0x0C, + 0xBC, 0x28, 0xF2, 0x44, 0xAA, 0xA4, 0x59, 0xEF, 0xF4, 0x4A, 0x4D, 0xFE, 0x90, 0xF4, 0x19, 0x4D, + 0xAE, 0x9C, 0x8B, 0x26, 0x9B, 0x57, 0xE5, 0x7A, 0xFC, 0x93, 0x31, 0xE5, 0xA7, 0x43, 0xCA, 0xDD +}; + +static bool JustCheckedLicense = false; + +char* SHA1(const unsigned char* d, size_t n, unsigned char* md) { + // If the license was just checked, fake the SHA1 result as all 0xFF + if (md != nullptr && JustCheckedLicense) { + memset(md, 0xFF, SHA1_SZ); + JustCheckedLicense = false; + + return (char*)md; + } + + return Sha1(d, n, md); +} + +int RSA_public_decrypt(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, int padding) { + + // If the rsa key being used is the public key for license files, + // set 0xFF as the result + + int res = RsaPublicDecrypt(flen, from, to, rsa, padding); + + if ( res == SHA1_SZ && memcmp(rsa->m->d, YOYO_LICENSE_PUBLIC_KEY, rsa->m->dmax) == 0) { + memset(to, 0xFF, SHA1_SZ); + JustCheckedLicense = true; + } + + return res; +} + +// hook RSA Public Decrypt & SHA1 functions +void PatchLibeay32() { + + LPVOID pubdecPtr = IAT::Hook("libeay32.dll", "RSA_public_decrypt", &RSA_public_decrypt); + if (pubdecPtr == nullptr) + return; + + RsaPublicDecrypt = (openssl_rsa_public_decrypt_ptr)pubdecPtr; + + LPVOID shaPtr = IAT::Hook("libeay32.dll", "SHA1", &SHA1); + if (shaPtr == nullptr) + return; + + Sha1 = (openssl_sha1_ptr)shaPtr; + +} + +void UnpatchLibeay32() { + if(RsaPublicDecrypt != nullptr) + IAT::Hook("libeay32.dll", "RSA_public_decrypt", &RsaPublicDecrypt); + if(Sha1 != nullptr) + IAT::Hook("libeay32.dll", "SHA1", &Sha1); +} \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/OpenSSLPatch.h b/Visual Studio Projects/LibeayPatch/LibeayPatch/OpenSSLPatch.h new file mode 100644 index 0000000..ffd8c0c --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/OpenSSLPatch.h @@ -0,0 +1,2 @@ +void PatchLibeay32(); +void UnpatchLibeay32(); \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/Stub.c b/Visual Studio Projects/LibeayPatch/LibeayPatch/Stub.c new file mode 100644 index 0000000..cef85a3 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/Stub.c @@ -0,0 +1,43 @@ +void ClosePrinter(int a) { + +} + +void DocumentPropertiesW(int a, int b, int c, int d, int e, int f) { + +} + +void DocumentPropertiesA(int a, int b, int c, int d, int e, int f) { + +} + +void GetPrinterA(int a, int b, int c, int d, int e) { + +} + +void GetPrinterW(int a, int b, int c, int d, int e) { + +} + +void EnumPrintersW(int a, int b, int c, int d, int e, int f, int g) { + +} + +void EnumPrintersA(int a, int b, int c, int d, int e, int f, int g) { + +} + +void GetDefaultPrinterW(int a, int b) { + +} + +void GetDefaultPrinterA(int a, int b) { + +} + +void OpenPrinterA(int a, int b, int c) { + +} + +void OpenPrinterW(int a, int b, int c) { + +} \ No newline at end of file diff --git a/Visual Studio Projects/LibeayPatch/LibeayPatch/Stub.def b/Visual Studio Projects/LibeayPatch/LibeayPatch/Stub.def new file mode 100644 index 0000000..d63ab23 --- /dev/null +++ b/Visual Studio Projects/LibeayPatch/LibeayPatch/Stub.def @@ -0,0 +1,13 @@ +LIBRARY WINSPOOL +EXPORTS + ClosePrinter @144 + DocumentPropertiesW @189 + DocumentPropertiesA @188 + GetPrinterA @281 + GetPrinterW @294 + EnumPrintersW @248 + EnumPrintersA @247 + GetDefaultPrinterW @203 + GetDefaultPrinterA @201 + OpenPrinterA @302 + OpenPrinterW @308 \ No newline at end of file diff --git a/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj b/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj index b8f83bd..8674440 100644 --- a/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj +++ b/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj @@ -112,7 +112,7 @@ true true _CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;UNIVERSALGAMEMAKERPATCHERDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true + false NotUsing diff --git a/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj.user b/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/Visual Studio Projects/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll/UniversalGameMakerPatcher.dll.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file