Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "Graphics.h"
  3. #include "Glow.h"
  4. #include "Fog.h"
  5. #include <stdio.h>
  6. #include <process.h>
  7. #include "Defines.h"
  8. #include "Offset.h"
  9. #include "Util.h"
  10.  
  11. #include "ServerInfo.h"
  12.  
  13. Graphics gGraphics;
  14.  
  15. Graphics::Graphics()
  16. {
  17. printf("Graphics::Graphics() Success.");
  18. }
  19.  
  20. DWORD gTmpEax;
  21. DWORD gTmpEcx;
  22. DWORD gTmpEdx;
  23. DWORD gTmpEbx;
  24. DWORD gTmpEsp;
  25. DWORD gTmpEbp;
  26. DWORD gTmpEsi;
  27. DWORD gTmpEdi;
  28. //
  29. DWORD gSelectEnter = 0x0040AB4A;
  30. DWORD gGraphicsEnter = 0x00777C8B;
  31. DWORD gSelectASMJmp00 = gSelectEnter+6;
  32. DWORD gGraphicsASM00Jmp00 = gGraphicsEnter+5;
  33.  
  34. Naked (gSelectASM00)
  35. {
  36. _asm
  37. {
  38. MOV gTmpEax,EAX
  39. MOV gTmpEsi,ESI
  40. MOV gTmpEdi,EDI
  41. MOV gTmpEcx,ECX
  42. MOV gTmpEdx,EDX
  43. MOV gTmpEbx,EBX
  44. MOV gTmpEsp,ESP
  45. MOV gTmpEbp,EBP
  46. }
  47. //----
  48. RenderScreenGlow();
  49. //----
  50. _asm
  51. {
  52. MOV EAX,gTmpEax
  53. MOV ESI,gTmpEsi
  54. MOV EDI,gTmpEdi
  55. MOV ECX,gTmpEcx
  56. MOV EDX,gTmpEdx
  57. MOV EBX,gTmpEbx
  58. MOV ESP,gTmpEsp
  59. MOV EBP,gTmpEbp
  60. ADD ECX,0x200
  61. //---
  62. JMP gSelectASMJmp00
  63. }
  64. }
  65.  
  66. Naked (gGraphicsASM00)
  67. {
  68. _asm
  69. {
  70. MOV gTmpEax,EAX
  71. MOV gTmpEsi,ESI
  72. MOV gTmpEdi,EDI
  73. MOV gTmpEcx,ECX
  74. MOV gTmpEdx,EDX
  75. MOV gTmpEbx,EBX
  76. MOV gTmpEsp,ESP
  77. MOV gTmpEbp,EBP
  78. }
  79. //----
  80. RenderScreenGlow();
  81. //----
  82. _asm
  83. {
  84. MOV EAX,gTmpEax
  85. MOV ESI,gTmpEsi
  86. MOV EDI,gTmpEdi
  87. MOV ECX,gTmpEcx
  88. MOV EDX,gTmpEdx
  89. MOV EBX,gTmpEbx
  90. MOV ESP,gTmpEsp
  91. MOV EBP,gTmpEbp
  92. PUSH 0x0
  93. MOV ECX,DWORD PTR SS:[EBP-0x4]
  94. //---
  95. JMP gGraphicsASM00Jmp00
  96. }
  97. }
  98.  
  99. void Graphics::Load()
  100. {
  101. if (gServerInfo.m_Graphics == 1)
  102. {
  103. SetCompleteHook(0xFF, oSelectDraw_Call, &this->SelectDraw);
  104. //---
  105. SetCompleteHook(0xE9,gSelectEnter,&gSelectASM00);
  106. //---
  107. SetCompleteHook(0xE9,gGraphicsEnter,&gGraphicsASM00);
  108. }
  109. //---
  110. this->InitOGLHook();
  111. //---
  112. ////console.Log(FUNC, "[Graphics]\t\tSuccessfully Loaded");
  113. }
  114.  
  115.  
  116. int Graphics::SelectDraw()
  117. {
  118. RenderScreenGlow();
  119. //---
  120. //printf("Graphics::SelectDraw() Success.\n");
  121. return pSelectDraw();
  122. }
  123.  
  124. //OGL Function Prototypes
  125. void (WINAPI *glEnable_original)(GLenum cap) = glEnable;
  126. void (WINAPI *glClearColor_original)(GLclampf r,GLclampf g,GLclampf b,GLclampf a) = glClearColor;
  127. // ----------------------------------------------------------------------------------------------
  128.  
  129. void WINAPI glEnable_hook(GLenum mode)
  130. {
  131. // ---
  132. if(gServerInfo.m_Anisotropy != 0)
  133. {
  134. glGetIntegerv(0x84FF,&gServerInfo.m_MaxAnisotropy);
  135. glTexParameteri(GL_TEXTURE_2D,0x84FE,gServerInfo.m_MaxAnisotropy-0.1);
  136. }
  137. if(gServerInfo.m_Linear != 0)
  138. {
  139. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  140. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  141. }
  142.  
  143. if (gServerInfo.m_Fog == 1)
  144. {
  145. CUSTOM_FOG* lpFog = gFog.GetFogByMap(pMapNumber);
  146.  
  147. if (lpFog != 0)
  148. {
  149. float rgba[4] = {lpFog->Red, lpFog->Green, lpFog->Blue, 1.0f}; gFog.toRGB(rgba);
  150.  
  151. if (mode == GL_BLEND || mode == GL_TEXTURE_2D || mode == GL_DEPTH_TEST)
  152. glDisable(GL_FOG);
  153.  
  154. glFogi(GL_FOG_MODE, GL_LINEAR);
  155. glFogf(GL_FOG_DENSITY, 0.25f);
  156. glFogfv(GL_FOG_COLOR, rgba);
  157. if(pMapNumber==74)
  158. {
  159. glFogf(GL_FOG_START, 4050);
  160. glFogf(GL_FOG_END, 4850);
  161. }
  162. else
  163. {
  164. glFogf(GL_FOG_START, 1650.0f);
  165. glFogf(GL_FOG_END, 2100.0f);
  166. }
  167. glHint(GL_FOG_HINT, GL_NICEST);
  168.  
  169. glEnable_original(GL_FOG);
  170.  
  171. if (mode == GL_BLEND || mode == GL_TEXTURE_2D || mode == GL_DEPTH_TEST)
  172. glDisable(GL_FOG);
  173.  
  174. if(!gFog.EnableFog)
  175. {
  176. glDisable(GL_FOG);
  177. }
  178. }
  179. }
  180. glEnable_original(mode);
  181. }
  182.  
  183. void WINAPI glClearColor_hook(GLclampf r,GLclampf g,GLclampf b,GLclampf a)
  184. {
  185. if(gFog.EnableFog && gServerInfo.m_Fog && *(DWORD*)(MAIN_SCREEN_STATE) == GameProcess)
  186. {
  187. CUSTOM_FOG* lpFog = gFog.GetFogByMap(pMapNumber);
  188. if (lpFog != 0)
  189. {
  190.  
  191. float rgba[4];
  192. rgba[0] = lpFog->Red;
  193. rgba[1] = lpFog->Green;
  194. rgba[2] = lpFog->Blue;
  195. rgba[3] = 1.0;
  196. gFog.toRGB(rgba);
  197.  
  198. glClearColor_original(rgba[0],rgba[1],rgba[2],rgba[3]);
  199. }
  200. }
  201. }
  202.  
  203. void Graphics::InitOGLHook()
  204. {
  205. //---- glEnable
  206. DetourTransactionBegin();
  207. DetourUpdateThread(GetCurrentThread());
  208. DetourAttach(&(PVOID &)glEnable_original,glEnable_hook);
  209. DetourTransactionCommit();
  210.  
  211. ////---- glClearColor
  212. //DetourTransactionBegin();
  213. //DetourUpdateThread(GetCurrentThread());
  214. //DetourAttach(&(PVOID &)glClearColor_original,glClearColor_hook);
  215. //DetourTransactionCommit();
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement