Advertisement
BaSs_HaXoR

How to do Engine Text! (As well as how to hook functions)

Oct 20th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. Well, it's spreading like wild fire, as well as privately being sold. Don't want the community to have to pay for such things, when to be honest it's not hard to do! This will work on any Call of Duty game, given you change the offsets and such.
  2.  
  3. Well I guess I can first explain how to do it. Engine text can only be drawn at certain times, this is why sometimes the game freezes if you try to draw it yourself. The only plausible method of drawing is hooking an in-game function that is executed each frame to your own code then you'll be able to draw the engine text. There are many possibly functions you can hook, I'll use CL_DrawText (greetz to droseum for telling me to hook this one) as an example, as I have a feeling the others may confuse you.
  4.  
  5. First off, add the PatchInJump code to your DLL:
  6. Code:
  7. VOID PatchInJump(DWORD* Address, DWORD Destination, BOOL Linked) {
  8. if(Destination & 0x8000)
  9. Address[0] = 0x3D600000 + (((Destination >> 16) & 0xFFFF) + 1);
  10. else
  11. Address[0] = 0x3D600000 + ((Destination >> 16) & 0xFFFF);
  12.  
  13. Address[1] = 0x396B0000 + (Destination & 0xFFFF);
  14. Address[2] = 0x7D6903A6;
  15.  
  16. if(Linked)
  17. Address[3] = 0x4E800421;
  18. else
  19. Address[3] = 0x4E800420;
  20. }
  21.  
  22. Next add the following definitions for engine text:
  23. Code:
  24. typedef void (__cdecl *R_AddCmdDrawText_t)(const char *text, int maxChars, void *font, float x, float y, float xScale, float yScale, float rotation, const float *color, int style);
  25. R_AddCmdDrawText_t R_AddCmdDrawText = (R_AddCmdDrawText_t)0x82350258;
  26.  
  27.  
  28. Pointers to font assets:
  29. Code:
  30. #define smallDevFont (0x82997604)
  31. #define consoleFont (0x8299761C)
  32. #define bigFont (0x82997634)
  33. #define smallFont (0x8299764C)
  34. #define boldFont (0x82997664)
  35. #define normalFont (0x8299767C)
  36. #define extraBigFont (0x82997694)
  37. #define objectiveFont (0x829976AC)
  38. #define hudBigFont (0x829976C4)
  39. #define hudSmallFont (0x829976DC)
  40. #define bigDevFont (0x829976F4)
  41.  
  42. Color definitions:
  43. Code:
  44. float colorBlue[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
  45. float colorWhite[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
  46.  
  47.  
  48.  
  49.  
  50. If you'd rather use the Font_s struct, use this definition:
  51.  
  52. Code:
  53. typedef void (__cdecl *R_AddCmdDrawText_t)(const char *text, int maxChars, Font_s *font, float x, float y, float xScale, float yScale, float rotation, const float *color, int style);
  54. R_AddCmdDrawText_t R_AddCmdDrawText = (R_AddCmdDrawText_t)0x82350258;
  55.  
  56.  
  57. Ok, now how do I do engine text?​
  58.  
  59. First off, somewhere in your DLL you need to use this code (I add it to the case DLL_PROCESS_ATTACH section)
  60. Code:
  61. PatchInJump((DWORD *)0x82146178, (DWORD)CL_DrawTextHook, false);
  62.  
  63. CL_DrawText is located at 0x82146178 in TU8, so this just has it branch to the CL_DrawTextHook function which you'll define in your dll.
  64.  
  65. Now for the function your hook branches to:
  66. Code:
  67. HRESULT CL_DrawTextHook(const char *text, int maxChars, void *font, float x, float y, float xScale, float yScale, const float *color, int style)
  68. {
  69. float rotation = 0;
  70. R_AddCmdDrawText(text, maxChars, font, x, y, xScale, yScale, rotation, color, style); // Draws the text the game is calling CL_DrawText to draw
  71. //Add your custom text below here
  72. R_AddCmdDrawText("Engine Text!", 0x7FFFFFFF, hudBigFont, 200, 200, 1, 1, 0, colorWhite, 0)
  73. return S_OK;
  74. }
  75.  
  76. The above code will draw the text "Engine Text!" white in color, at (200, 200).
  77.  
  78.  
  79. Conclusion:
  80. Hope this helps some of you who are struggling with hooking, and maybe we can get some decent mods out of this (ESP is nice!). You can use this research to draw things like shaders with R_AddCmdDrawStretchedPic as well.
  81.  
  82. also: http://pastebin.com/6eZLRjUj (This is an coordinate mapper which draws a rectangle, and you can edit the size of it and it prints coordinates on screen. Simply add "drawCoordinateMapper();" to your hook.
  83.  
  84. Some helper functions:
  85. Code:
  86. void DrawPicture(float x, float y, float width, float height, DWORD material, const float *color)
  87. {
  88. R_AddCmdDrawStretchPic(x, y, width, height, 0, 0, 1, 1, color, (void *)material);
  89. }
  90.  
  91. void DrawText(const char *text, float x, float y, DWORD font, float fontSize)
  92. {
  93. R_AddCmdDrawText(text, 0x7FFFFFFF, (void *)font, x, y, fontSize, fontSize, 0, colorWhite, 0);
  94. }
  95.  
  96. void DrawTextWithGlow(const char *text, float x, float y, DWORD font, float fontSize, const float *glowColor)
  97. {
  98. R_AddCmdDrawTextWithEffects(text, 0x7FFFFFFF, (void *)font, x, y, fontSize, fontSize, 0, colorWhite, 0, glowColor, (void *)fxMaterial, (void *)fxGlowMaterial, 9999, 100, 999999, 100);
  99. }
  100.  
  101. #define fxMaterial (0x829FDBB0)
  102. #define fxGlowMaterial (0x829FDC08)
  103.  
  104. SRC: (S7 Pro) https://www.se7ensins.com/forums/threads/how-to-do-engine-text-as-well-as-how-to-hook-functions.854574/
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement