| View previous topic :: View next topic |
| Author |
Message |
skyw4rrior Advanced Cheater
Reputation: 0
Joined: 21 Aug 2005 Posts: 67
|
Posted: Sun Mar 05, 2006 7:08 pm Post subject: Injecting Code |
|
|
I ll try to explain (sry.. my english is terrible)
It assumes that I have two Processes : 1° - Notepad
2° - My Project
and my Dll.
-----
I Want to do something like Inject my Dll into Notepad. Then My Project Send a message to my dll inside Notepad. My dll receives the message and call the appropriate procedure that modify a value from Notepad memory (at the address especiefied as parameter in the message). Is there anyway to do this?
I looked on google for it and found many people saying that a process can't send a message to a dll. So I tryed to create a form in runtime, from my dll, when it is injected at Notepad (this way i supposedly had a window handle that receives the messages from My Project and have the same process handle of Notepad). Yes.. it created the window.. but.. it shows for some msecs and disappears! I Put a Sleep command to check if the window was really created and yes.. it was.. and after the sleep time it desapears... Can someone help me about it ? (plz.. don't say to use findwindow, openprocess, writeprocessmemory, etc.. i know it.. but I don't want to use apis)
Here is how i created the form from the initiallization of the dll:
library MyDll;
...
var frmx:tform;
...
begin
FrmX:=TForm1.Create(Application);
FrmX.Show;
FrmX.Position:=poScreenCenter;
sleep(6000); // <--- the verification
end.
Last edited by skyw4rrior on Tue Mar 07, 2006 8:26 am; edited 1 time in total |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Sun Mar 05, 2006 11:43 pm Post subject: |
|
|
let it create a new thread (using a global variable) and in that thread create the window. (and just do FrmX.showmodal in that thread)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
XanSama How do I cheat?
Reputation: 0
Joined: 07 Sep 2005 Posts: 4
|
Posted: Mon Mar 06, 2006 6:03 am Post subject: |
|
|
| or just use madCodeHook [www.madshi.net] and it's crazy communication methods.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Mon Mar 06, 2006 6:39 am Post subject: |
|
|
I prefer using shared memory objects and/or thread events
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
skyw4rrior Advanced Cheater
Reputation: 0
Joined: 21 Aug 2005 Posts: 67
|
Posted: Mon Mar 06, 2006 8:05 am Post subject: |
|
|
| Dark Byte wrote: | | let it create a new thread (using a global variable) and in that thread create the window. (and just do FrmX.showmodal in that thread) |
Oh.. ty..
But there's only a problem.. I Think that I Don't know how to do this ''^^..
I Created a thread:
| Code: |
type
SkyHook = class(TThread)
protected
procedure Execute; override;
end;
implementation
{ SkyHook }
procedure SkyHook.Execute;
begin
Form1.ShowModal;
end;
|
the dll:
| Code: |
...
var MyThread:SkyHook;
...
begin
MyThread:=SkyHook.create(true);
MyThread.resume;
end.
|
I Tryed it but nothing happened..
Is it correctly? If Not How can I do it? (sry.. but I never worket with threads in delphi)...
Last edited by skyw4rrior on Mon Mar 06, 2006 8:45 am; edited 2 times in total |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Mon Mar 06, 2006 8:08 am Post subject: |
|
|
yes thats correct and then between the begin and end of the dll add the code:
| Code: |
SkyHook.create(false);
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
skyw4rrior Advanced Cheater
Reputation: 0
Joined: 21 Aug 2005 Posts: 67
|
Posted: Mon Mar 06, 2006 8:39 am Post subject: |
|
|
wow.. Ty Dark Byte.. worked fine..
Let me do just another 2 questions:
1°- I injected the dll into Notepad. My Window showed correctly. But when i close Notepad it gives an error. Why?
2° - Is there anyway to annex my window to the one of Notepad. e.g: Make my window a piece of the Notepad Window, fixed on it base for example?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Mon Mar 06, 2006 9:12 am Post subject: |
|
|
1:try writing a finalize section that gets executed when the dll unloads
in there add code that tells the window to close and terminate the tread (and wait for the thread to terminate) and then exit
2: perhaps you can make your window a child window inside the notepad window, but somehow i doubt it'll work.
(else just write code to find the main window that isn't your window and adjust your windows's size and location to it)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
skyw4rrior Advanced Cheater
Reputation: 0
Joined: 21 Aug 2005 Posts: 67
|
Posted: Mon Mar 06, 2006 9:42 am Post subject: |
|
|
| Dark Byte wrote: | 1:try writing a finalize section that gets executed when the dll unloads
in there add code that tells the window to close and terminate the tread (and wait for the thread to terminate) and then exit |
look:
| Code: |
UnitIniEnd //this unit is just for the initialization and finalization code
...
var
MyThread:SkyHook;
implementation
...
initialization
begin
end;
finalization
begin
showmessage('Test'); {<-- the code didn't works.. so I put this to check if the finalization is being called so.. and yes.. it is}
if Form1<>nil then MyForm.Close;
while not TerminateThread(mythread.Handle,0) do
sleep(100);
end;
end.
|
is it correct? Its not working =\
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Mon Mar 06, 2006 9:55 am Post subject: |
|
|
don't call showmessage. It;s not threadsafe and certainly onot in the context of a foreign process. Use messagebox(0,'test','my app',mb_ok); instead
and use mythread.waitfor; to wait till it terminates
Oh, and MyThread isn't nil right ?
In the start of the dll have it:
MyThread:=SkyHook.create(false);
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
skyw4rrior Advanced Cheater
Reputation: 0
Joined: 21 Aug 2005 Posts: 67
|
Posted: Mon Mar 06, 2006 10:04 am Post subject: |
|
|
| Dark Byte wrote: | don't call showmessage. It;s not threadsafe and certainly onot in the context of a foreign process. Use messagebox(0,'test','my app',mb_ok); instead
and use mythread.waitfor; to wait till it terminates
Oh, and MyThread isn't nil right ?
In the start of the dll have it:
MyThread:=SkyHook.create(false); |
yes. it is already on the start of the dll (MyThread:=SkyHook.create(false))..
look now:
| Code: |
finalization
begin
if Form1<>nil then Form1.Close;
MyThread.Terminate;
MyThread.WaitFor;
FreeAndNil(MyThread);
end;
|
it still giving 2 errors:
1° - Unknow Exception at address...
2° - Runtime Error 217 at address ...
=\
|
|
| Back to top |
|
 |
|