| View previous topic :: View next topic |
| Author |
Message |
MyFeel Expert Cheater
Reputation: 0
Joined: 04 Jun 2007 Posts: 143
|
Posted: Tue Dec 04, 2007 4:32 am Post subject: |
|
|
| samuri25404 wrote: | Try this:
| Code: |
[System.Runtime.InteropServices.DLLImport("PMX.dll")]
private static extern void PostMessageX(IntPtr hWnd , UINT msg, IntPtr wParam, IntPtr lParam);
//Lalaa....
//Later...
System.Diagnostics.Process[] myprocs = System.Diagnostics.Process.GetByName("MyApp"); //I think that's how it is, it's been a little while
IntPtr hWnd = myprocs[0].ID; //First instance of the application
PostMessageX(hWnd,0x09,0,0); //I'm guessing that 0x09 is the message that you want to send
|
|
i have tried it but i still get errors =\
here the code what wrong
| Code: |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("PMX.DLL", EntryPoint = "PostMessageX")]
public static extern IntPtr PostMessageX(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
System.Diagnostics.Process[] myprocs = System.Diagnostics.Process.GetByName("MyApp");
IntPtr hWnd = myprocs[0].ID; //First instance of the application
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PostMessageX(hWnd, 0x41, 0, 0); //I'm guessing that 0x09 is the message that you want to send
}
}
}
|
|
|
| Back to top |
|
 |
rump Expert Cheater
Reputation: 0
Joined: 03 Oct 2007 Posts: 169
|
Posted: Tue Dec 04, 2007 12:30 pm Post subject: |
|
|
Have you tried the keybd_event function? _________________
C# boot camp, PM me if you want a simple application made and I'll give it a try! |
|
| Back to top |
|
 |
MyFeel Expert Cheater
Reputation: 0
Joined: 04 Jun 2007 Posts: 143
|
Posted: Tue Dec 04, 2007 12:33 pm Post subject: |
|
|
| yes.. it already detected.. |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Tue Dec 04, 2007 12:46 pm Post subject: |
|
|
myprocs[0].ID is the PROCESS ID, NOT THE WINDOW HANDLE! _________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Dec 04, 2007 12:48 pm Post subject: |
|
|
shoudnt your PostMessageX look like this?
| Code: |
private const int WM_KEYDOWN = 0x100;
....
PostMessageX(hWnd, WM_KEYDOWN, 0x41, 0); |
_________________
|
|
| Back to top |
|
 |
rump Expert Cheater
Reputation: 0
Joined: 03 Oct 2007 Posts: 169
|
Posted: Tue Dec 04, 2007 3:05 pm Post subject: |
|
|
ahh, dang... Keybd_event is nice :/ _________________
C# boot camp, PM me if you want a simple application made and I'll give it a try! |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Tue Dec 04, 2007 3:17 pm Post subject: |
|
|
| appalsap wrote: | :roll:
myprocs[0].ID is the PROCESS ID, NOT THE WINDOW HANDLE! |
My bad, I didn't finish it.
I haven't done this in a while;
API Calls:
| Code: |
[Flags]
public enum ProcessAccessType
{
PROCESS_TERMINATE = (0x0001),
PROCESS_CREATE_THREAD = (0x0002),
PROCESS_SET_SESSIONID = (0x0004),
PROCESS_VM_OPERATION = (0x0008),
PROCESS_VM_READ = (0x0010),
PROCESS_VM_WRITE = (0x0020),
PROCESS_DUP_HANDLE = (0x0040),
PROCESS_CREATE_PROCESS = (0x0080),
PROCESS_SET_QUOTA = (0x0100),
PROCESS_SET_INFORMATION = (0x0200),
PROCESS_QUERY_INFORMATION = (0x0400)
}
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
[DllImport("PMX.dll")]
private static extern void PostMessageX(IntPtr hWnd , UINT msg, IntPtr wParam, IntPtr lParam);
|
Your code:
| Code: |
System.Diagnostics.Process[] myprocs = System.Diagnostics.Process.GetByName("MyApp"); //I think that's how it is, it's been a little while
IntPtr id= myprocs[0].ID; //First instance of the application
IntPtr hWnd = OpenProcess(ProcessAccessType.Operation, 1, id);
PostMessageX(hWnd, 0x09, 0, 0);
|
_________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Tue Dec 04, 2007 4:10 pm Post subject: |
|
|
| samuri25404 wrote: |
My bad, I didn't finish it.
I haven't done this in a while;
API Calls:
|
nooo, you don't open the process either, hWnd is a handle to the Window, which you get from the FindWindow API call, not by process handle! _________________
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Tue Dec 04, 2007 6:13 pm Post subject: |
|
|
LOL ... wow... isn't this extremely basic... _________________
|
|
| Back to top |
|
 |
MyFeel Expert Cheater
Reputation: 0
Joined: 04 Jun 2007 Posts: 143
|
Posted: Wed Dec 05, 2007 2:35 am Post subject: |
|
|
| sponge wrote: | | LOL ... wow... isn't this extremely basic... |
hey spong,
can i ask for how calling the function in your dll? (hookHop)
and how to use it? can you give me an example?
thanks. |
|
| Back to top |
|
 |
jongwee Moderator
Reputation: 0
Joined: 28 Jun 2006 Posts: 1388 Location: Singapore
|
Posted: Wed Dec 05, 2007 3:32 am Post subject: |
|
|
| MyFeel wrote: | | sponge wrote: | | LOL ... wow... isn't this extremely basic... |
hey spong,
can i ask for how calling the function in your dll? (hookHop)
and how to use it? can you give me an example?
thanks. |
| Code: | function PostMessageA(
hWnd:HWND;
MSG:UINT;
WPARAM:wParam;
LPARAM:lParam):BOOL;stdcall;
external 'HookHop.dll' name 'PostMessageA'; |
I think. _________________
|
|
| Back to top |
|
 |
Aviram Grandmaster Cheater
Reputation: 0
Joined: 30 Jun 2006 Posts: 633
|
Posted: Wed Dec 05, 2007 7:20 am Post subject: |
|
|
| jongwee wrote: | | MyFeel wrote: | | sponge wrote: | | LOL ... wow... isn't this extremely basic... |
hey spong,
can i ask for how calling the function in your dll? (hookHop)
and how to use it? can you give me an example?
thanks. |
| Code: | function PostMessageA(
hWnd:HWND;
MSG:UINT;
WPARAM:wParam;
LPARAM:lParam):BOOL;stdcall;
external 'HookHop.dll' name 'PostMessageA'; |
I think. |
Its Delphi, He asked for C# |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Dec 05, 2007 6:05 pm Post subject: |
|
|
| Code: |
[DllImport("HookHop.dll")]
private static extern bool PostMessageA(IntPtr hWnd, uint MSG, IntPtr WPARAM, IntPtr LPARAM);
|
_________________
|
|
| Back to top |
|
 |
jongwee Moderator
Reputation: 0
Joined: 28 Jun 2006 Posts: 1388 Location: Singapore
|
Posted: Wed Dec 05, 2007 6:29 pm Post subject: |
|
|
Tested hookhop on my bot, works perfectly and the size of the dll is amazingly minimised. _________________
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Wed Dec 05, 2007 6:56 pm Post subject: |
|
|
If you look in my DEF file... you will see that the exported name for my "API" is hhPostMessageA.
I do not program in C# so I cannot tell you how to import it. _________________
|
|
| Back to top |
|
 |
|