Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Writting a .dll (C#)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Krähne
Expert Cheater
Reputation: 0

Joined: 06 Jun 2010
Posts: 108
Location: Inside of my Kernel

PostPosted: Sun Mar 06, 2011 12:59 am    Post subject: Writting a .dll (C#) Reply with quote

Hi... i'm making a .dll for inject into a process... the code for injection is not a problem but... i'm begining with the dll.

I have looking for a information, but... i doesn't find the way for do this:

When my .dll is injected, i want this show a formulary, where can i add buttons, etc... for specific things.

So... it's posible?, i mean... make a .dll for inject, and this show a form where can i manipulate the proces... by the concept "now is my own process too". I hoope this can be posible, in C#... because, in Delphi i have that.

if you want to know how delphi show a form from a .dll project, i'll post right here:

Code:
Library DllProject;

uses
  SysUtils, Classes, Windows,
  MainFRM in 'MainFRM.pas' {Form1};

{$R *.res}

Procedure ShowForm;
Begin
    Form1:=TForm1.Create(nil);
    Form1.ShowModal;
End;

Var
BeOwnProcess:THandle;
HandleID:Cardinal;

Begin
BeOwnProcess := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID);
CreateRemoteThread(BeOwnProcess, nil, 0, @ShowForm, @ShowForm, 0, HandleID);
End.


So... i have made this also in C#?, i mean... "CreateRemoteThread", etc...?.

Gruß.
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sun Mar 06, 2011 3:33 am    Post subject: Reply with quote

Yes, it's possible but it's more work then just injecting the DLL. Since C# compiles down to managed code, you have to load the .NET runtime in the target process before you can inject a managed module into it.

You'll need to create a bootstrap DLL to inject (C++ or other native language that can access API) to do the dirty work for you and load your managed DLL afterward which then you can do all your hacking etc in.

Here's an example of how to do it:
http://www.codingthewheel.com/archives/how-to-inject-a-managed-assembly-dll

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Krähne
Expert Cheater
Reputation: 0

Joined: 06 Jun 2010
Posts: 108
Location: Inside of my Kernel

PostPosted: Sun Mar 06, 2011 3:15 pm    Post subject: Reply with quote

Wiccaan wrote:
Yes, it's possible but it's more work then just injecting the DLL. Since C# compiles down to managed code, you have to load the .NET runtime in the target process before you can inject a managed module into it.

You'll need to create a bootstrap DLL to inject (C++ or other native language that can access API) to do the dirty work for you and load your managed DLL afterward which then you can do all your hacking etc in.


Thanks alot dude!, i made that and... WORKS!

But... i don't know if this is the correct way, for show my .dll form.

I mean... when i inject this "native .dll", and this "invoke" my ".NET .dll", i was need this show a windows forms, so... i made this:

Code:
        static Form1 F;

        public static int Start(String Args)
        {
            F = new Form1();
            F.ShowDialog();
            return 0;
        }


But i don't know if that is the best way for made it.

So... what you think about it?.

Gruß
Back to top
View user's profile Send private message MSN Messenger
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Sun Mar 06, 2011 6:26 pm    Post subject: Reply with quote

Pretty much that is the way. You are creating a new form which you have specified, then you are calling ShowDialog to the new form. About anything I've done in C# that created a form used this method.
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
Krähne
Expert Cheater
Reputation: 0

Joined: 06 Jun 2010
Posts: 108
Location: Inside of my Kernel

PostPosted: Sun Mar 06, 2011 7:44 pm    Post subject: Reply with quote

AhMunRa wrote:
Pretty much that is the way. You are creating a new form which you have specified, then you are calling ShowDialog to the new form. About anything I've done in C# that created a form used this method.


Nice man, thank you!... Anyways works perfect for me.

See yá.

Gruß.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites