C# / MemorySharp: Injecting managed DLL into the WoW-Process? menu

User Tag List

Results 1 to 4 of 4
  1. #1
    mskc33's Avatar Member
    Reputation
    1
    Join Date
    Nov 2012
    Posts
    28
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C# / MemorySharp: Injecting managed DLL into the WoW-Process?

    I am looking to inject my managed DLL (build using .NET 4.0) into the WoW-Process and running my bot from there. MemorySharp seem to be the best tool to accomplish this.

    Code:
    var proc = Process.GetProcessesByName("Wow").FirstOrDefault();
    var ms = new MemorySharp(proc.Id);
    
    var module = ms.Modules.Inject(Path.Combine(Application.StartupPath, "LoadMe.dll"));
    var func = module.FindFunction("Init"); // Crashes here, cannot find the function with GetProcAddress
    
    func.Execute();
    
    module.Dispose();
    ms.Dispose();
    proc.Dispose();
    Code:
    public class LoadMe {
        public LoadMe() {
            MessageBox.Show(string.Format("Hello from constructor inside {0}", Process.GetCurrentProcess().ProcessName));
        }
    
        // static or not does not seem to make a difference
        public void Init() {
            MessageBox.Show(string.Format("Hello from Init inside {0}", Process.GetCurrentProcess().ProcessName));
        }
    }
    I can confirm that this DOES inject the module, but I am unable to create a new instance of my class "public class LoadMe" or call the static/non-static method "public void Init()".
    Do I have to spawn a new CLR/AppDomain in order to do this?
    (DomainWrapper/DomainWrapper at master * lolp1/DomainWrapper * GitHub)

    Has anybody done something similar and could help me out here? I'd appreciate it!
    Last edited by mskc33; 03-02-2017 at 08:32 AM.

    C# / MemorySharp: Injecting managed DLL into the WoW-Process?
  2. #2
    lolp1's Avatar Site Donator CoreCoins Purchaser
    Reputation
    190
    Join Date
    Feb 2013
    Posts
    210
    Thanks G/R
    43/77
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mskc33 View Post
    ...
    Do I have to spawn a new CLR/AppDomain in order to do this?

    You need to host the CLR and resolve your app domain.

  3. #3
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just use DllExports. It will load the CLR for you. Then you can load it via export call, just like you are trying to do.

    Code:
    [DllExport("Init", CallingConvention.WinApi)]
    public static void Init() {
        ...
    }

  4. #4
    mskc33's Avatar Member
    Reputation
    1
    Join Date
    Nov 2012
    Posts
    28
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Jadd View Post
    Just use DllExports. It will load the CLR for you. Then you can load it via export call, just like you are trying to do.

    Code:
    [DllExport("Init", CallingConvention.WinApi)]
    public static void Init() {
        ...
    }
    Thanks for the quick reply!
    Sadly, that does not seem to work. Actually I cannot even call the "MessageBoxW" function from "kernel32", it seems. There is an example on their website which doesnt work for me (Binarysharp :: Products - MemorySharp)

    For some reason, it seems like I cannot call any functions.

    Code:
    var proc = Process.GetProcessesByName("Wow").FirstOrDefault();
    var ms = new MemorySharp(proc.Id);
    
    // Neither of those work:
    var func = ms["user32"]["MessageBox"];
    // var func = ms["kernel32"]["MessageBoxW"];
    func.Execute(0, "Hey", "Title", 0);
    Code:
    An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in MemorySharp.dll
    Additional information: Couldn't get the function address of MessageBoxW.
    // Edit: I got it to "find" the MessageBoxW-Function by setting my build output to strictly x86. But now, once I call the function WoW crashes immediately:

    Code:
    0xC0000005 (ACCESS_VIOLATION) at 0023:1046FFDC
    
    The instruction at "0x1046FFDC" referenced memory at "0x1046FFDC".
    The memory could not be "written".
    Last edited by mskc33; 03-03-2017 at 08:20 AM.

Similar Threads

  1. Replies: 9
    Last Post: 08-08-2012, 01:27 PM
  2. How can you get into the WoW Cataclysm EU beta?
    By Illidan_000 in forum Community Chat
    Replies: 2
    Last Post: 07-03-2010, 10:32 AM
  3. [Question] Open the wow process, methodological issues
    By flyman90 in forum WoW Memory Editing
    Replies: 5
    Last Post: 03-24-2010, 07:45 AM
  4. How to programatically log into the WoW site
    By Apoc in forum Programming
    Replies: 10
    Last Post: 12-23-2008, 12:56 PM
  5. Integrate any WoW leveling guide into the game
    By Deranged in forum World of Warcraft Guides
    Replies: 14
    Last Post: 11-14-2008, 12:48 AM
All times are GMT -5. The time now is 04:15 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