tweaks to mule_peb_trample

This commit is contained in:
Ryan Fleury
2024-05-21 12:40:21 -07:00
parent b74db17375
commit b33559b081
2 changed files with 10 additions and 10 deletions
+3 -3
View File
@@ -110,9 +110,9 @@ if "%mule_main%"=="1" del vc*.pdb mule*.pdb && %compile_release
if "%mule_module%"=="1" %compile% ..\src\mule\mule_module.cpp %compile_link% %link_dll% %out%mule_module.dll || exit /b 1 if "%mule_module%"=="1" %compile% ..\src\mule\mule_module.cpp %compile_link% %link_dll% %out%mule_module.dll || exit /b 1
if "%mule_hotload%"=="1" %compile% ..\src\mule\mule_hotload_main.c %compile_link% %out%mule_hotload.exe & %compile% ..\src\mule\mule_hotload_module_main.c %compile_link% %link_dll% %out%mule_hotload_module.dll || exit /b 1 if "%mule_hotload%"=="1" %compile% ..\src\mule\mule_hotload_main.c %compile_link% %out%mule_hotload.exe & %compile% ..\src\mule\mule_hotload_module_main.c %compile_link% %link_dll% %out%mule_hotload_module.dll || exit /b 1
if "%mule_peb_trample%"=="1" ( if "%mule_peb_trample%"=="1" (
if exist mule_peb_trample_old.exe del mule_peb_trample_old.exe if exist mule_peb_trample.exe move mule_peb_trample.exe mule_peb_trample_old_%random%.exe
if exist mule_peb_trample.exe move mule_peb_trample.exe mule_peb_trample_old.exe %compile% ..\src\mule\mule_peb_trample.c %compile_link% %out%mule_peb_trample_new.exe || exit /b 1
%compile% ..\src\mule\mule_peb_trample.c %compile_link% %out%mule_peb_trample.exe || exit /b 1 move mule_peb_trample_new.exe mule_peb_trample.exe
) )
popd popd
+7 -7
View File
@@ -32,22 +32,23 @@ HideModuleFromWindowsReload(HMODULE ModuleToFlush)
} }
} }
__declspec(dllexport) void __declspec(dllexport) int
loop_iteration(int it) loop_iteration(int it)
{ {
printf("foobar iteration #%i\n", it); return it*it;
} }
int main(int argument_count, char **arguments) int main(int argument_count, char **arguments)
{ {
char *exe_name = arguments[0]; char *exe_name = arguments[0];
HANDLE last_module = GetModuleHandle(0); HANDLE last_module = GetModuleHandle(0);
void (*loop_iteration_function)(int it) = (void (*)(int))GetProcAddress(last_module, "loop_iteration"); int (*loop_iteration_function)(int it) = (int (*)(int))GetProcAddress(last_module, "loop_iteration");
FILETIME last_filetime = {0}; FILETIME last_filetime = {0};
int should_exit = 0; int should_exit = 0;
for(int it = 0; !should_exit; it += 1) for(int it = 0; !should_exit; it += 1)
{ {
loop_iteration_function(it); int result = loop_iteration_function(it);
printf("%i\n", result);
Sleep(50); Sleep(50);
FILETIME current_filetime = {0}; FILETIME current_filetime = {0};
HANDLE current_exe_file = CreateFile(exe_name, 0, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); HANDLE current_exe_file = CreateFile(exe_name, 0, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
@@ -56,9 +57,8 @@ int main(int argument_count, char **arguments)
if(it != 0 && CompareFileTime(&last_filetime, &current_filetime) < 0) if(it != 0 && CompareFileTime(&last_filetime, &current_filetime) < 0)
{ {
HideModuleFromWindowsReload(last_module); HideModuleFromWindowsReload(last_module);
//last_module = LoadLibrary(arguments[0]); last_module = LoadLibrary(arguments[0]);
last_module = LoadLibrary("foobar.exe"); loop_iteration_function = (int (*)(int))GetProcAddress(last_module, "loop_iteration");
loop_iteration_function = (void (*)(int))GetProcAddress(last_module, "loop_iteration");
} }
last_filetime = current_filetime; last_filetime = current_filetime;
} }