Is DLL injection useless ? menu

User Tag List

Results 1 to 7 of 7
  1. #1
    Lywbringer's Avatar Member
    Reputation
    11
    Join Date
    Sep 2022
    Posts
    14
    Thanks G/R
    2/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is DLL injection useless ?

    Today I translated a C# class to C++ to run functions on the main thread of a window of a game thanks to Windows API, and I thought that if you can run your own functions on the main thread this way, maybe DLL injection (which is about exploiting the address space of the targeted process) becomes useless since your functions will run in the same address space of the targeted process.

    First I'll share my code, then I'll illustrate an exemple of how I think it's possible to just use game's functions with this method:

    The header:
    Code:
    class ThreadSynchronizer {
    public:
        static void Init();
        static void RunOnMainThread(std::function<void()> action);
        static int WndProc(HWND hwnd, UINT Msg, WPARAM wparam, LPARAM lparam);
        static void SendUserMessage();
    
    private:
        static WNDPROC newCallback;
        static WNDPROC oldCallback;
        static HWND windowHandle;
        static std::vector<std::function<void()>> actionQueue;
    };
    The .cpp file:
    Code:
    WNDPROC ThreadSynchronizer::oldCallback;
    WNDPROC ThreadSynchronizer::newCallback;
    HWND ThreadSynchronizer::windowHandle;
    
    std::vector<std::function<void()>> ThreadSynchronizer::actionQueue;
    
    void ThreadSynchronizer::Init() {
        windowHandle = FindWindowW(NULL, L"World of Warcraft");
        newCallback = (WNDPROC)&WndProc;
        oldCallback = (WNDPROC)SetWindowLongW(windowHandle, GWL_WNDPROC, (LONG)newCallback);
    }
    
    void ThreadSynchronizer::RunOnMainThread(std::function<void()> action) {
        actionQueue.push_back(action);
        SendUserMessage();
    }
    
    int ThreadSynchronizer::WndProc(HWND hwnd, UINT Msg, WPARAM wparam, LPARAM lparam) {
        if (actionQueue.size() > 0) {
            std::invoke(actionQueue.back());
            actionQueue.pop_back();
        }
        return CallWindowProcW(oldCallback, hwnd, Msg, wparam, lparam);
    }
    
    void ThreadSynchronizer::SendUserMessage() {
        SendMessageW(windowHandle, WM_USER, 0, 0);
    }
    And this is how I use it for instance for my SetTarget() function, which needs a GUID as parameter:
    Code:
    void LocalPlayer::SetTarget(unsigned long long tguid) {
        typedef void __stdcall func(unsigned long long tguid);
        func* function = (func*)SET_TARGET_FUN_PTR;
        ThreadSynchronizer::RunOnMainThread( //Or KA-BOOM !
            [function, tguid]() { function(tguid); }
        );
    }
    Don't forget to initialise everything and you're good to go:
    Code:
    ThreadSynchronizer::Init();
    localPlayer.SetTarget(closestUnit.Guid);
    So by using this method my process which is controlling the bot doesn't even need to have a starting point written in the address space of the targeted process since I'll use my hook to do that for me.

    What do you think of that ? Am I wrong ?
    Last edited by Lywbringer; 09-24-2022 at 09:24 AM.

    Is DLL injection useless ?
  2. #2
    zys924's Avatar Active Member
    Reputation
    20
    Join Date
    Nov 2009
    Posts
    113
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A simple GetWindowLongW() check can easily reveal the address of your own "wndproc", outside the main module address space. The only reason you are not banned is BLZ now is not interested in updating its own Warden anymore, for the time being.

  3. Thanks Lywbringer (1 members gave Thanks to zys924 for this useful post)
  4. #3
    Razzue's Avatar Contributor Avid Ailurophile

    CoreCoins Purchaser Authenticator enabled
    Reputation
    379
    Join Date
    Jun 2017
    Posts
    588
    Thanks G/R
    186/268
    Trade Feedback
    2 (100%)
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by zys924 View Post
    A simple GetWindowLongW() check can easily reveal the address of your own "wndproc", outside the main module address space. The only reason you are not banned is BLZ now is not interested in updating its own Warden anymore, for the time being.
    Funny you say that right after a couple new scans were added but okay...
    "May all your bacon burn"

  5. #4
    aeo's Avatar Contributor
    Reputation
    127
    Join Date
    Apr 2007
    Posts
    270
    Thanks G/R
    84/62
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Razzue View Post
    Funny you say that right after a couple new scans were added but okay...
    Enlighten us . I think there are many legit modules that hook WndProc for various reasons.

  6. #5
    zys924's Avatar Active Member
    Reputation
    20
    Join Date
    Nov 2009
    Posts
    113
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, and those modules are easily identifiable by their hash/digital signatures, which you can't forge.

  7. #6
    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 zys924 View Post
    Yes, and those modules are easily identifiable by their hash/digital signatures, which you can't forge.
    Are you saying there is a whitelist and unknown modules constitute a detection? This is news to me.

  8. #7
    aeo's Avatar Contributor
    Reputation
    127
    Join Date
    Apr 2007
    Posts
    270
    Thanks G/R
    84/62
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by zys924 View Post
    Yes, and those modules are easily identifiable by their hash/digital signatures, which you can't forge.
    but you could find a way to make you callback appear inside one of those modules fairly easily ( if this was a concern)

Similar Threads

  1. [WoW] [C++] Hack Loader (DLL Injection Example)
    By Cypher in forum WoW Memory Editing
    Replies: 28
    Last Post: 07-06-2010, 11:41 PM
  2. Destructor's Tutorial: Managed .NET DLL Injection
    By ugkbunb in forum Programming
    Replies: 1
    Last Post: 07-30-2009, 05:15 PM
  3. [Tutorial] DLL Injection
    By jagged software in forum Programming
    Replies: 22
    Last Post: 04-21-2009, 03:27 AM
  4. DLL injection with windows SP3
    By Therrm in forum World of Warcraft Bots and Programs
    Replies: 3
    Last Post: 12-06-2008, 03:03 PM
  5. What are the risks with DLL injection?
    By object in forum WoW Memory Editing
    Replies: 14
    Last Post: 08-22-2008, 09:23 PM
All times are GMT -5. The time now is 04:44 AM. 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