Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- 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.
- First off, add the PatchInJump code to your DLL:
- Code:
- VOID PatchInJump(DWORD* Address, DWORD Destination, BOOL Linked) {
- if(Destination & 0x8000)
- Address[0] = 0x3D600000 + (((Destination >> 16) & 0xFFFF) + 1);
- else
- Address[0] = 0x3D600000 + ((Destination >> 16) & 0xFFFF);
- Address[1] = 0x396B0000 + (Destination & 0xFFFF);
- Address[2] = 0x7D6903A6;
- if(Linked)
- Address[3] = 0x4E800421;
- else
- Address[3] = 0x4E800420;
- }
- Next add the following definitions for engine text:
- Code:
- 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);
- R_AddCmdDrawText_t R_AddCmdDrawText = (R_AddCmdDrawText_t)0x82350258;
- Pointers to font assets:
- Code:
- #define smallDevFont (0x82997604)
- #define consoleFont (0x8299761C)
- #define bigFont (0x82997634)
- #define smallFont (0x8299764C)
- #define boldFont (0x82997664)
- #define normalFont (0x8299767C)
- #define extraBigFont (0x82997694)
- #define objectiveFont (0x829976AC)
- #define hudBigFont (0x829976C4)
- #define hudSmallFont (0x829976DC)
- #define bigDevFont (0x829976F4)
- Color definitions:
- Code:
- float colorBlue[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
- float colorWhite[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
- If you'd rather use the Font_s struct, use this definition:
- Code:
- 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);
- R_AddCmdDrawText_t R_AddCmdDrawText = (R_AddCmdDrawText_t)0x82350258;
- Ok, now how do I do engine text?
- First off, somewhere in your DLL you need to use this code (I add it to the case DLL_PROCESS_ATTACH section)
- Code:
- PatchInJump((DWORD *)0x82146178, (DWORD)CL_DrawTextHook, false);
- 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.
- Now for the function your hook branches to:
- Code:
- HRESULT CL_DrawTextHook(const char *text, int maxChars, void *font, float x, float y, float xScale, float yScale, const float *color, int style)
- {
- float rotation = 0;
- R_AddCmdDrawText(text, maxChars, font, x, y, xScale, yScale, rotation, color, style); // Draws the text the game is calling CL_DrawText to draw
- //Add your custom text below here
- R_AddCmdDrawText("Engine Text!", 0x7FFFFFFF, hudBigFont, 200, 200, 1, 1, 0, colorWhite, 0)
- return S_OK;
- }
- The above code will draw the text "Engine Text!" white in color, at (200, 200).
- Conclusion:
- 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.
- 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.
- Some helper functions:
- Code:
- void DrawPicture(float x, float y, float width, float height, DWORD material, const float *color)
- {
- R_AddCmdDrawStretchPic(x, y, width, height, 0, 0, 1, 1, color, (void *)material);
- }
- void DrawText(const char *text, float x, float y, DWORD font, float fontSize)
- {
- R_AddCmdDrawText(text, 0x7FFFFFFF, (void *)font, x, y, fontSize, fontSize, 0, colorWhite, 0);
- }
- void DrawTextWithGlow(const char *text, float x, float y, DWORD font, float fontSize, const float *glowColor)
- {
- R_AddCmdDrawTextWithEffects(text, 0x7FFFFFFF, (void *)font, x, y, fontSize, fontSize, 0, colorWhite, 0, glowColor, (void *)fxMaterial, (void *)fxGlowMaterial, 9999, 100, 999999, 100);
- }
- #define fxMaterial (0x829FDBB0)
- #define fxGlowMaterial (0x829FDC08)
- SRC: (S7 Pro) https://www.se7ensins.com/forums/threads/how-to-do-engine-text-as-well-as-how-to-hook-functions.854574/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement