[C#][Source] 4.0 CLR Injection no C++ stub menu

User Tag List

Results 1 to 8 of 8
  1. #1
    Valtharak's Avatar Master Sergeant
    Reputation
    51
    Join Date
    Feb 2011
    Posts
    105
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C#][Source] 4.0 CLR Injection no C++ stub

    Was messing around my injection code and decided to give back. not sure if it will be useful to anyone. Comments are welcome.

    Credit:

    JuJuBoSc/Mike_ : Original idea
    !@^^@! : Reflexion stuff
    Shynd : I stole some Blackmagic code.

    Goal, 1 source file, and no C++ stub dll to load the assembly.

    *Yes it use the FASM library, but if your gonna use inject .NET CLR might aswell have it close if you need to inject some asm later on.
    *If you realy do not want to use FASM as an additional library you'll have to generate the byte code with the .Assemble from FASM and add in the variables pointers. not hard just less practical.

    how to:

    -Just add DotNetInjector.cs to you project

    The only tricky part is the Reflexion part to get the Entrypoint. In your DLL to inject, add this attribute class and add the attribute to your entrypoint method.
    If you do not want to use this just change the Injection parameter to ask for the assembly path, the namespace.class and Method to call. The reflexion part include those 3.

    Code:
    namespace InjectedDll
    {
        [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] //We don't want this to be used in more than one place
        public class EntryPoint : Attribute
        {
        }
        
        public class Startup
        {
            [EntryPoint]
            [STAThread]
            public static int EntryPoint(String pwzArgument)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Main());
    
                return 1;
            }
        }
    }
    Then in the main app you get the Type of the entrypoint to pass it to the Inject function

    Code:
    public static readonly Type InjectedDllEntryPoint = typeof(InjectedDll.Startup);
    Then you can simply call the injection

    Code:
    DotNetInjector injector = new DotNetInjector(process);
    
    injector.InjectAndWait(InjectedDllEntryPoint, "I'm injected param"); //Will stop till the Assembly finish
    or
    injector.InjectAndForget(InjectedDllEntryPoint, "I'm injected param"); //Will not stop


    Mirror:
    https://mega.nz/#!lxUHTa4C!tsnbCXlnW...XPsgn9ohKpn21Y
    Attached Files Attached Files
    Last edited by Valtharak; 09-11-2015 at 12:15 AM.

    [C#][Source] 4.0 CLR Injection no C++ stub
  2. #2
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Good work, +7!

  3. #3
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice work
    Personally I would add some error checking in the assembly code in case any of the COM methods fail. Not that I have ever seen it fail, but I just like to be safe.
    But other than that very nice.

  4. #4
    Silvera's Avatar Member
    Reputation
    10
    Join Date
    Oct 2009
    Posts
    139
    Thanks G/R
    0/1
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm somewhat starting to get into programming, and find stuff like this very interesting.
    Personally I have no clue what it's actual usage is. Would you care to explain?
    + rep for sharing!

  5. #5
    Valtharak's Avatar Master Sergeant
    Reputation
    51
    Join Date
    Feb 2011
    Posts
    105
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This let you run C# code into any process.

    Normal way of doing this would be to inject a C++ dll that start a Dot net CLR in the process you want, that would then load your C# assembly.

    This way of doing it is simply to reduce the number of dll used by writing the code in ASM then launching it rather then injecting the C++ DLL to do the CLR init.

  6. #6
    tertle's Avatar Member
    Reputation
    1
    Join Date
    Aug 2007
    Posts
    17
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Attachment doesn't seem to work.

    Any chance I could get a mirror?
    Last edited by tertle; 03-20-2012 at 02:26 AM. Reason: Typo

  7. #7
    detkliarsomfan's Avatar Member
    Reputation
    1
    Join Date
    Jun 2015
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Attachment seems to be broken like above user stated. Where can I get this?

  8. #8
    Valtharak's Avatar Master Sergeant
    Reputation
    51
    Join Date
    Feb 2011
    Posts
    105
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i reuploaded to a new mirror. couple of people were asking for this

Similar Threads

  1. Limit FPS with injected clr app
    By Corthezz in forum WoW Memory Editing
    Replies: 13
    Last Post: 11-09-2015, 01:29 PM
  2. Replies: 1
    Last Post: 01-19-2012, 03:14 AM
  3. C# Lua Wrapper (No ASM, Requires injected CLR)
    By Apoc in forum WoW Memory Editing
    Replies: 29
    Last Post: 02-04-2011, 02:52 PM
  4. [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
  5. [Bot:Source] Acidic Bot Source Code
    By =sinister= in forum World of Warcraft Bots and Programs
    Replies: 10
    Last Post: 07-03-2006, 05:38 PM
All times are GMT -5. The time now is 02:38 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search