[2.4.3][C++][Injection] Injecting a c++ dll cause lagging the client. menu

User Tag List

Results 1 to 4 of 4
  1. #1
    tutrakan's Avatar Contributor
    Reputation
    134
    Join Date
    Feb 2013
    Posts
    175
    Thanks G/R
    124/52
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [2.4.3][C++][Injection] Injecting a c++ dll cause lagging the client.

    I have such a weird behavior.

    When i inject any c++ code in the tbc(2.4.3) client - it starts chopping/lagging the video.

    Remarks:

    1. When the video settings details are on max - the more the chopping is noticeable (only happens on 2.4.3 and c++ dll injection).
    2. It only happens on the 2.4.3 client. The 1.12.1 and 3.3.5a are never concerned.
    3. The .net clr injection is working fine too and never cause problems neither.

    I googled and i tried, tried and googled again, but since I'm still a beginner, i need your help guys.

    Here is my injected code that causes lag on the 2.4.3 client:
    Code:
    #ifndef WIN32
    #define WIN32
    #endif
    #include <WinSock2.h>
    
    HINSTANCE instanceDLL = nullptr;
    
    void MainThread()
    {	
    	while (!GetAsyncKeyState(VK_NUMPAD7)) {}
    	
    	FreeLibraryAndExitThread((HMODULE)instanceDLL, 0);
    	return;
    }
    
    BOOL APIENTRY DllMain(HINSTANCE instDLL, DWORD reason, LPVOID /* reserved */)
    {
    	if (reason == DLL_PROCESS_ATTACH)
    	{
    		instanceDLL = instDLL;
    		DisableThreadLibraryCalls(instDLL);
    
    		CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&MainThread, NULL, 0, NULL);
    	}
    	else if (reason == DLL_PROCESS_DETACH) {}
    	return TRUE;
    }
    Thanks in advance!

    [2.4.3][C++][Injection] Injecting a c++ dll cause lagging the client.
  2. #2
    badusername1234's Avatar Active Member
    Reputation
    26
    Join Date
    Apr 2017
    Posts
    47
    Thanks G/R
    18/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    while (!GetAsyncKeyState(VK_NUMPAD7)) {}

  3. #3
    namreeb's Avatar Legendary

    Reputation
    658
    Join Date
    Sep 2008
    Posts
    1,023
    Thanks G/R
    7/215
    Trade Feedback
    0 (0%)
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tutrakan View Post
    I have such a weird behavior.

    When i inject any c++ code in the tbc(2.4.3) client - it starts chopping/lagging the video.

    Remarks:

    1. When the video settings details are on max - the more the chopping is noticeable (only happens on 2.4.3 and c++ dll injection).
    2. It only happens on the 2.4.3 client. The 1.12.1 and 3.3.5a are never concerned.
    3. The .net clr injection is working fine too and never cause problems neither.

    I googled and i tried, tried and googled again, but since I'm still a beginner, i need your help guys.

    Here is my injected code that causes lag on the 2.4.3 client:
    Code:
    #ifndef WIN32
    #define WIN32
    #endif
    #include <WinSock2.h>
    
    HINSTANCE instanceDLL = nullptr;
    
    void MainThread()
    {	
    	while (!GetAsyncKeyState(VK_NUMPAD7)) {}
    	
    	FreeLibraryAndExitThread((HMODULE)instanceDLL, 0);
    	return;
    }
    
    BOOL APIENTRY DllMain(HINSTANCE instDLL, DWORD reason, LPVOID /* reserved */)
    {
    	if (reason == DLL_PROCESS_ATTACH)
    	{
    		instanceDLL = instDLL;
    		DisableThreadLibraryCalls(instDLL);
    
    		CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&MainThread, NULL, 0, NULL);
    	}
    	else if (reason == DLL_PROCESS_DETACH) {}
    	return TRUE;
    }
    Thanks in advance!
    The only explanation I can think for this is that the affinity of the newly created thread places it on the same CPU as the main thread, and given that you never sleep your newly created thread, it uses up 100% available CPU.

    Try changing the loop in 'MainThread' to something like this:

    Code:
    while (!GetAsyncKeyState(VK_NUMPAD7)) { std::this_thread::sleep_for(std::chrono::milliseconds(250)); }

  4. Thanks tutrakan, Jansi (2 members gave Thanks to namreeb for this useful post)
  5. #4
    tutrakan's Avatar Contributor
    Reputation
    134
    Join Date
    Feb 2013
    Posts
    175
    Thanks G/R
    124/52
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, thank you a lot!
    I was about to get crazy wondering why the heck this happens only in c++ and only on 2.4.3.
    But the true is that I still look at it as a "black box" and I'm missing the logic.
    Thanks Namreeb.

    Edit:

    I just found another TBC anomaly - When I inject my c# dll and do the same graphics I do on the other clients, the video is lagging again.
    The remedy I found, is to check "Vertical Sync" in the video options, thus way the fps don't goes up to 1000, but max 250.
    Last edited by tutrakan; 04-14-2017 at 10:25 PM.

Similar Threads

  1. [Guide] Model Injection Guide
    By Glitchy in forum WoW ME Tools & Guides
    Replies: 109
    Last Post: 05-27-2010, 08:16 AM
  2. [Model Injection] Bobble Head
    By Glitchy in forum World of Warcraft Model Editing
    Replies: 16
    Last Post: 02-18-2008, 08:17 PM
  3. Packet Injecting Items
    By yungen2003 in forum World of Warcraft General
    Replies: 7
    Last Post: 08-07-2007, 07:02 AM
  4. Using DLL's to inject values without CE.
    By Matsy in forum World of Warcraft Bots and Programs
    Replies: 7
    Last Post: 06-29-2007, 02:26 PM
  5. [Bot] Anti-AFK Bot (No Injection & Focus not Needed)
    By Cypher in forum World of Warcraft Bots and Programs
    Replies: 12
    Last Post: 09-10-2006, 11:14 AM
All times are GMT -5. The time now is 09:09 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search