Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // dllmain.cpp: определяет точку входа для приложения DLL.
- #include "stdafx.h"
- Patcher * globalPatcher;
- PatcherInstance *patcher;
- int __stdcall CharPixelDraw(LoHook* h, HookContext* c)
- {
- int bg_r = *(unsigned short*)(c->edx) >> 11;
- int bg_g = (*(unsigned short*)(c->edx) >> 5) & 0x3F;
- int bg_b = *(unsigned short*)(c->edx) & 0x1F;
- int bg_r8 = bg_r << 3;
- int bg_g8 = bg_g << 2;
- int bg_b8 = bg_b << 3;
- int fnt_r = (unsigned short)(c->eax) >> 11;
- int fnt_g = ((unsigned short)(c->eax) >> 5) & 0x3F;
- int fnt_b = (unsigned short)(c->eax) & 0x1F;
- int fnt_r8 = fnt_r << 3;
- int fnt_g8 = fnt_g << 2;
- int fnt_b8 = fnt_b << 3;
- int pixel_type = *(unsigned char*)(c->esi - 1);
- float alpha[] = {1, 0,
- 4.0/256, 16.0/256, 24.0/256, 36.0/256, 44.0/256,
- 56.0/256, 64.0/256, 72.0/256, 84.0/256, 92.0/256,
- 104.0/256, 112.0/256, 124.0/256, 132.0/256, 144.0/256,
- 152.0/256, 164.0/256, 172.0/256, 180.0/256, 192.0/256,
- 200.0/256, 212.0/256, 220.0/256, 232.0/256, 240.0/256};
- *(unsigned short*)(c->edx) = (unsigned short)c->eax;
- if (pixel_type == 254)
- {
- *(unsigned short*)(c->edx) = RGB565_fromR8G8B8( bg_r8/2,
- bg_g8/2,
- bg_b8/2);
- }
- if(pixel_type >= 1 && pixel_type <=26)
- {
- *(unsigned short*)(c->edx) = RGB565_fromR8G8B8( (unsigned char)(fnt_r8 * alpha[pixel_type]),
- (unsigned char)(fnt_g8 * alpha[pixel_type]),
- (unsigned char)(fnt_b8 * alpha[pixel_type]) );
- }
- //*(short*)(c->edx) = rbo[c->edx/2%7];
- c->return_address = 0x4B4F88;
- return NO_EXEC_DEFAULT;
- }
- void __stdcall PatchIt2 (PEvent e)
- {
- patcher->WriteLoHook(0x4B4F79,(void*)CharPixelDraw);
- patcher->WriteCodePatch(0x4B4F6F,"%n",2);
- }
- BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- if (ul_reason_for_call == DLL_PROCESS_ATTACH)
- {
- globalPatcher = GetPatcher();
- patcher = globalPatcher->CreateInstance("h2sw_fonts");
- ConnectEra();
- RegisterHandler(PatchIt2,"OnAfterCreateWindow");
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement