Advertisement
Nihthelm

Untitled

Nov 7th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.15 KB | None | 0 0
  1. // dllmain.cpp: определяет точку входа для приложения DLL.
  2. #include "stdafx.h"
  3.  
  4.  
  5. Patcher * globalPatcher;
  6. PatcherInstance *patcher;
  7.  
  8. int __stdcall CharPixelDraw(LoHook* h, HookContext* c)
  9. {
  10.    
  11.  
  12.     int bg_r =  *(unsigned short*)(c->edx) >> 11;
  13.     int bg_g = (*(unsigned short*)(c->edx) >> 5) & 0x3F;
  14.     int bg_b =  *(unsigned short*)(c->edx) & 0x1F;
  15.  
  16.     int bg_r8 = bg_r << 3;
  17.     int bg_g8 = bg_g << 2;
  18.     int bg_b8 = bg_b << 3;
  19.  
  20.     int fnt_r =  (unsigned short)(c->eax) >> 11;
  21.     int fnt_g = ((unsigned short)(c->eax) >> 5) & 0x3F;
  22.     int fnt_b =  (unsigned short)(c->eax) & 0x1F;
  23.  
  24.     int fnt_r8 = fnt_r << 3;
  25.     int fnt_g8 = fnt_g << 2;
  26.     int fnt_b8 = fnt_b << 3;
  27.  
  28.     int pixel_type = *(unsigned char*)(c->esi - 1);
  29.  
  30.     float alpha[] = {1, 0,
  31.           4.0/256,  16.0/256,  24.0/256,  36.0/256,  44.0/256,
  32.          56.0/256,  64.0/256,  72.0/256,  84.0/256,  92.0/256,
  33.         104.0/256, 112.0/256, 124.0/256, 132.0/256, 144.0/256,
  34.         152.0/256, 164.0/256, 172.0/256, 180.0/256, 192.0/256,
  35.         200.0/256, 212.0/256, 220.0/256, 232.0/256, 240.0/256};
  36.  
  37.  
  38.  
  39.     *(unsigned short*)(c->edx) = (unsigned short)c->eax;
  40.  
  41.     if (pixel_type == 254)
  42.     {
  43.          *(unsigned short*)(c->edx) = RGB565_fromR8G8B8(    bg_r8/2,
  44.                                                             bg_g8/2,
  45.                                                             bg_b8/2);
  46.     }
  47.  
  48.     if(pixel_type >= 1 && pixel_type <=26)
  49.     {
  50.         *(unsigned short*)(c->edx) = RGB565_fromR8G8B8(     (unsigned char)(fnt_r8 * alpha[pixel_type]),
  51.                                                             (unsigned char)(fnt_g8 * alpha[pixel_type]),
  52.                                                             (unsigned char)(fnt_b8 * alpha[pixel_type])   );
  53.     }
  54.  
  55.  
  56.     //*(short*)(c->edx) = rbo[c->edx/2%7];
  57.  
  58.     c->return_address = 0x4B4F88;
  59.     return NO_EXEC_DEFAULT;
  60. }
  61.  
  62. void __stdcall PatchIt2 (PEvent e)
  63. {
  64.         patcher->WriteLoHook(0x4B4F79,(void*)CharPixelDraw);
  65.         patcher->WriteCodePatch(0x4B4F6F,"%n",2);
  66. }
  67.  
  68. BOOL APIENTRY DllMain( HMODULE hModule,
  69.                        DWORD  ul_reason_for_call,
  70.                        LPVOID lpReserved
  71.                      )
  72. {
  73.     if (ul_reason_for_call == DLL_PROCESS_ATTACH)
  74.     {
  75.         globalPatcher = GetPatcher();
  76.         patcher =  globalPatcher->CreateInstance("h2sw_fonts");
  77.         ConnectEra();
  78.  
  79.         RegisterHandler(PatchIt2,"OnAfterCreateWindow");
  80.     }
  81.     return TRUE;
  82. }
  83.  
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement