[Problem]Start CLRHost in a Bootstrap menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    bouh2's Avatar Active Member
    Reputation
    28
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Problem]Start CLRHost in a Bootstrap

    Hi,

    I try to inject a managed dll into a process but it never works.

    First i tried http://www.mmowned.com/forums/wow-me...Inject+Managed from Shynd, but lpCLRHost->Start() return me an error code (-2147467259)

    Then I tried EasyHook, but when i run Config.Register it say that the dll hasn't a strong name (even if I add one)
    I have the same message with BabBot


    So I need help :/
    Has someone a project work ?


    Thank's

    [Problem]Start CLRHost in a Bootstrap
  2. #2
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by bouh2 View Post
    Hi,

    I try to inject a managed dll into a process but it never works.

    First i tried http://www.mmowned.com/forums/wow-me...Inject+Managed from Shynd, but lpCLRHost->Start() return me an error code (-2147467259)

    Then I tried EasyHook, but when i run Config.Register it say that the dll hasn't a strong name (even if I add one)
    I have the same message with BabBot


    So I need help :/
    Has someone a project work ?


    Thank's
    Are you sure you're doing it like this:
    Inject bootstrap into target process -> bootstrap starts CLR in target process -> bootstrap executes managed code in target process

    Also, be sure to read this on the topic.

    Taken from above article:
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  3. #3
    bouh2's Avatar Active Member
    Reputation
    28
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have readed, and readed again this topic.
    I inject my bootstrap in the target process (I'm sure, i can debug it) and it bug on starting of CLR.

    EDIT : Here is my code

    Code:
    #include <windows.h>
    #include "MSCorEE.h"
    #pragma comment(lib, "mscoree")
    
    
    DWORD WINAPI StartTheDotNetRuntime( LPVOID lpParameter);
    
    DWORD WINAPI StartTheDotNetRuntime( LPVOID lpParameter)
    {
        ICLRRuntimeHost *pClrHost = NULL;
        HRESULT hr = CorBindToRuntimeEx(
            NULL, L"wks", 0, CLSID_CLRRuntimeHost,
            IID_ICLRRuntimeHost, (PVOID*)&pClrHost);
    
        hr = pClrHost->Start();
    
        DWORD dwRet = 0;
        hr = pClrHost->ExecuteInDefaultAppDomain(
            L".\\NetDll.dll",
            L"MyNamespace.MyClass", L"MyMethod", L"MyParameter", &dwRet);
    
        hr = pClrHost->Stop();
    
        pClrHost->Release();
    
        return FALSE;
    }
    
    
    INT APIENTRY DllMain( HWND hDLL, DWORD fdwReason, LPVOID lpvReserved )
    {
        switch ( fdwReason )
        {
        case DLL_PROCESS_ATTACH:
            DWORD dwThreadId;
            HANDLE hThread = CreateThread(0, 0, StartTheDotNetRuntime, NULL, 0, &dwThreadId);
            
            break;
        }
    
        return TRUE;
    }
    And my managed dll :

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace MyNamespace
    {
        public class MyClass
        {
            // This method will be called by native code inside the target process...
            public static int MyMethod(String pwzArgument)
            {
                MessageBox.Show("Hello World");
                return 0;
            }
    
        }
    }
    Now it's bug on ExecuteInDefaultAppDomain
    Last edited by bouh2; 11-14-2009 at 04:13 PM.

  4. #4
    LegacyAX's Avatar Active Member
    Reputation
    21
    Join Date
    Apr 2009
    Posts
    193
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a hint but I think your looking to deeply into "how" instead of "why", the answer seems to be right under your nose and is in your reach. Good luck on your project mate. let us know if you still cant fix it,

    also just curious what operating system are you using?

  5. #5
    bouh2's Avatar Active Member
    Reputation
    28
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see what you say.

    I'm under XP SP3 with .Net framework 3.5

    EDIT : Ok you had right, its work now
    +rep for you
    Last edited by bouh2; 11-14-2009 at 05:28 PM.

  6. #6
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry to use an old thread but this is very similar to how I'm calling my managed library and I'm having some issues trying to debug.

    I can't seem to find the way to step into the managed .dll within VS2008 to hit breakpoints after ExecuteInDefaultAppDomain() is called.

    My managed class library sets up hooks just fine and I can verify that they are indeed getting hit by logging each function call to a text file.

    I'm so sorry for posting here, I've been stuck on this for two weeks now... Any ideas?

  7. #7
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm pretty sure you can attach onto WoW(or whatever you're injecting into) and breakpoint on your function.

  8. #8
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use VS2k8 in this configuration (injected native, injected managed, debugging) all the time. You do have to manually attach after injection, of course, but that shouldn't be blocking you.

    What's the specific error?
    Don't believe everything you think.

  9. #9
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - The bootstrap and the managed module are in the same solution.
    - In VS2008, I attach my solution to wow before injecting it and on injection breakpoints in the native bootstrap are hit enabling me to step through and follow execution. (No biggy)
    - The bootstrap uses ExecuteInDefaultAppDomain() to call a function in the managed library which installs an endscene hook.
    - The native dll finishes up, The managed hook is installed and getting hit each frame (verified by writing to a text file each hit) but I can't figure out how to attach it in VS2008 to step in and get a breakpoint.

  10. #10
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting. My setup is almost identical except that the native is C++/CLI (so, mixed native and CLR) and stays resident. I don't do anything else differently.

    For me, all the breakpoints are hit. Not entirely sure what the magic is.
    Don't believe everything you think.

  11. #11
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, Thanks for the replies. At least now I know it works for you, I know that it's possible and I must just be doing something stupid..

  12. #12
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, mixed-mode debugging (debugging mixed native/managed code) is a bit of a black art, and doing it on an injected binary even more so. So in some ways, I'm more surprised when it works than when it fails. I was working on the visual studio team when they were first implementing that, and a lot of developers lost a lot of sleep trying to make it happen.

    Of course, that's no help to you...
    Don't believe everything you think.

  13. #13
    tanis2000's Avatar Active Member
    Reputation
    39
    Join Date
    Feb 2009
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been having your same problem opulent. I have a C# launcher that injects the C bootstrapper that in turn injects the C# dll and here's the line that I added to the injected C# dll in order to make it popup an exception and let me choose a debugger to use:

    Code:
    #if DEBUG
                // We break inside the start of the main thread in order to debug
                System.Diagnostics.Debug.Assert(true == false);
    #endif

  14. #14
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tanis2000 View Post
    I've been having your same problem opulent. I have a C# launcher that injects the C bootstrapper that in turn injects the C# dll and here's the line that I added to the injected C# dll in order to make it popup an exception and let me choose a debugger to use:

    Code:
    #if DEBUG
                // We break inside the start of the main thread in order to debug
                System.Diagnostics.Debug.Assert(true == false);
    #endif
    I'm no C# expert, but uhh, couldn't you just do:
    Assert(false)

    ?

  15. #15
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Suddenly seems strangely reminiscent of another thread...

    On topic, you could try having a separate instance of VS2k8 attached to the WoW exe once your main program has injected your runtime. I can't remember but I believe I had some success with this - didn't get too far with my endeavours in that area as I got too busy with uni / work.

    Out of curiosity, have you put specific breakpoints in your injected managed code to see if they are hit? Or are you trying to attach and add breakpoints once attached?

Page 1 of 2 12 LastLast

Similar Threads

  1. lucky bot problem starts to early
    By triranta in forum SWTOR Bots and Programs
    Replies: 3
    Last Post: 07-19-2012, 11:49 AM
  2. problem starting server
    By UnknownEncryption in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 08-12-2010, 01:47 AM
  3. [Repack] Problem starting up server
    By Four-Worlds in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 07-30-2010, 03:40 AM
  4. Problem Starting "ascent-realmserver"
    By absent XTC in forum WoW EMU Questions & Requests
    Replies: 17
    Last Post: 09-30-2008, 04:49 PM
  5. Problem starting wow with innerspace
    By deathbreakfast in forum World of Warcraft General
    Replies: 6
    Last Post: 07-19-2008, 09:19 PM
All times are GMT -5. The time now is 07:46 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