Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- void cracking_hook_call(int from, const int to)
- {
- DWORD dwback;
- const int len = 5;
- VirtualProtect((LPVOID)from, len, PAGE_READWRITE, &dwback);
- int relative = to - (from + 5); // +5 is the position of next opcode
- memcpy((void *)(from + 1), &relative, 4); // set relative address with endian
- VirtualProtect((LPVOID)from, len, dwback, &dwback);
- }
- char static_text[128] = "\0";
- char *new_text = &static_text[0];
- int is_player, ptr_text;
- float score;
- void save_score()
- {
- score = atof((char*)ptr_text);
- }
- void change_death()
- {
- float death, kd;
- death = atof((char*)ptr_text);
- if (!score && !death)
- kd = 0;
- else if (!score && death)
- kd = -death;
- else if (score && !death)
- kd = score;
- else
- kd = score / death;
- sprintf_s<128>(static_text, "%s (%.1f)", (char*)ptr_text, kd);
- }
- bool draw_player()
- {
- return (**(byte**)is_player == 0);
- }
- bool cmp( char *txt )
- {
- return (strcmp(*(char**)is_player, txt) == 0);
- }
- bool draw_score()
- {
- return cmp("CGAME_SB_SCORE");
- }
- bool draw_death()
- {
- return cmp("CGAME_SB_DEATHS");
- }
- void __declspec(naked)Ui_DrawStatusBar()
- {
- _asm
- {
- add ebp, 0x4
- mov is_player, ebp
- sub ebp, 0x4
- }
- if (draw_score())
- {
- _asm
- {
- add esp, 0x4
- pop eax
- mov ptr_text, eax
- push eax
- sub esp, 0x4
- }
- save_score();
- }
- if (draw_death())
- {
- _asm
- {
- add esp, 0x4
- pop eax
- mov ptr_text, eax
- push eax
- sub esp, 0x4
- }
- change_death();
- _asm
- {
- add esp, 0x4
- pop eax
- push new_text
- sub esp, 0x4
- }
- }
- _asm
- {
- mov eax, 0x52BEF0
- jmp eax
- }
- }
- void _main()
- {
- while (GetModuleHandleA("gfx_d3d_mp_x86_s.dll") == 0)
- Sleep(100);
- cracking_hook_call((int)0x4D419A, (int)Ui_DrawStatusBar);
- }
- BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
- {
- DisableThreadLibraryCalls(hinstDLL);
- if (fdwReason == DLL_PROCESS_ATTACH)
- CreateThread(0, 0, (LPTHREAD_START_ROUTINE)_main, 0, 0, 0);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement