Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-14-2005, 04:06
lilmeanman
 
Posts: n/a
Talking Simulating a Button Push

Hello im currently working on cracking Typer Shark Deluxe 1.02.
The serial method is way long and so I've decided to brute-force it.

Here's what I've acomplished so far:
Make it accept all serials.
Remove the Length Check so you don't have to enter a serial.

Now what I need to know is if you can simulate a button push.
I know where the call starts, and everything, but if I jump to it say, right before the "Register" text shows up, or any other place i've tried, I get a read access error.

Is this possible?
Reply With Quote
  #2  
Old 02-14-2005, 04:35
dyn!o's Avatar
dyn!o dyn!o is offline
Friend
 
Join Date: Nov 2003
Location: Own mind
Posts: 214
Rept. Given: 1
Rept. Rcvd 1 Time in 1 Post
Thanks Given: 8
Thanks Rcvd at 0 Times in 0 Posts
dyn!o Reputation: 1
Of course you can do it: WM_LBUTTONDOWN/WM_LBUTTONUP.

Regards.
Reply With Quote
  #3  
Old 02-14-2005, 04:41
Satyric0n
 
Posts: n/a
I'm not sure I fully understand what you're asking, but.. If you know the window handle of the button, you can send it the BM_CLICK message -- "An application sends a BM_CLICK message to simulate the user clicking a button. This message causes the button to receive the WM_LBUTTONDOWN and WM_LBUTTONUP messages, and the button's parent window to receive a BN_CLICKED notification message."

hxxp://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/buttons/buttonreference/buttonmessages/bm_click.asp
Reply With Quote
  #4  
Old 02-14-2005, 05:41
AdamD
 
Posts: n/a
Easiest way would be to find the window using the windows API FindWindow and FindWindowEx. Then you should use something like

SendMessage(hwnd, WM_KEYDOWN,VK_RETURN,0);
SendMessage(hwnd, WM_KEYUP, VK_RETURN,0);
Reply With Quote
  #5  
Old 02-14-2005, 06:23
bart
 
Posts: n/a
in delphi

Code:
//
// symulacja klikniecia lewym kneflem myszki
//
procedure SingleClick(X: Integer; Y: Integer; SaveOriginal:Boolean = False);
var mousepos:TPoint;
begin

  // pobierz oryginalne polozenie kursora
  if SaveOriginal = True then GetCursorPos(mousepos);

  // ustaw pozycje kursora myszki
  SetCursorPos(X, Y);

  // symuluj nacisniecie lewego klawisza myszki
  mouse_event(mouseeventf_leftdown,0,0,0,0);

  // symuluj podniesienie lewego klawisza myszki po kliku
  mouse_event(mouseeventf_leftup,0,0,0,0);

  // przywroc oryginalne polozenie kursora
  if SaveOriginal = True then SetCursorPos(mousepos.X, mousepos.Y);

end;
Reply With Quote
  #6  
Old 02-14-2005, 06:37
dyn!o's Avatar
dyn!o dyn!o is offline
Friend
 
Join Date: Nov 2003
Location: Own mind
Posts: 214
Rept. Given: 1
Rept. Rcvd 1 Time in 1 Post
Thanks Given: 8
Thanks Rcvd at 0 Times in 0 Posts
dyn!o Reputation: 1
Bart: I suppose Lilmeanman asked abour more "generic" idea.

Your one is good... assuming we know the screen resolution and button box coordinates

"Knefel" = przycisk? Hmm....

Regards.
Reply With Quote
  #7  
Old 02-14-2005, 07:23
FEARHQ FEARHQ is offline
Friend
 
Join Date: Mar 2002
Posts: 73
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 1 Time in 1 Post
FEARHQ Reputation: 0
What I used to do in such a case is send a WM_COMMAND to the parent, but I had to have known the button id to accomplish this. It's no big deal to find it but it's not generic enough. the WM_MOUSE messages are good too, since they are relative (as I remember?) to the upper left of the parent window and do not steal mouse cursor. If you resize your window however, you are thourougly screwed. WM_CLICK seems perfect, as you can *easily* get the handle of the button, you just have to ask windows nicely for it I guess it pays to read the msdn library. Thanks Satyric0n!
Reply With Quote
  #8  
Old 02-15-2005, 03:48
lilmeanman
 
Posts: n/a
Sorry im such a newbie at all of this, but would I put the WM code at the end of the program?

And then jump to it when the program is at a safe place?

I'm not very good at ASM and most of the tutorials out there suck, so im sorry for being such a newb.
Reply With Quote
  #9  
Old 02-15-2005, 21:30
bilbo bilbo is offline
Friend
 
Join Date: Jul 2004
Posts: 103
Rept. Given: 36
Rept. Rcvd 15 Times in 12 Posts
Thanks Given: 15
Thanks Rcvd at 17 Times in 11 Posts
bilbo Reputation: 15
Hi, lilmeanman / FEARHQ,

here is a C program which will do the job...
Compile from DOS prompt with command "cl click.c"
Run the resulting CLICK.EXE from DOS prompt attaching the button name (e.g. "ok") as command parameter.

Code:
// CLICK.C -- written by bilbo -- 15feb05

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32")

#define WM_CLICK 0xF5

BOOL CALLBACK
EnumWindowsProc(HWND hwnd, LPARAM caption)
{
	char name[128];

	if (GetClassName(hwnd, name, 127) && !strcmp(name, "Button")) {
		GetWindowText(hwnd, name, 127);
		if (!stricmp(name, (LPSTR)caption)) {
			printf("Found Button with handle %x\n", hwnd);
			SendMessage(hwnd, WM_CLICK, 0, 0);
			return FALSE;  // done
			}
		}

	EnumChildWindows(hwnd, EnumWindowsProc, (WPARAM)caption);
	return TRUE;
}

void
main(int argc, char **argv)
{
	if (argc != 2) {
		printf("usage: %s button_caption\n", argv[0]);
		return;
		}

	EnumWindows(EnumWindowsProc, (LPARAM)argv[1]);
}
Strangely enough the message WM_CLICK is not defined in Microsoft includes!!!
So I have defined it at start of the program.

To test the program, you can run Calculator: in that app, each key is a different button... You can press calc keys remotely (e.g. "click 1" "click +")...

Regards, bilbo
Reply With Quote
  #10  
Old 02-16-2005, 00:29
JuneMouse
 
Posts: n/a
hehe thanks bilbo
for that equ
i had to wade through WM_USER+ the messages in the range of 0xb00
if the project was build with bcbuilder

to find the message that simulates a click on buttons
this equate makes the work easy

where did you dig it out from
coz sending two concurrent WM_LBUTTONDOWN AND WM_LBUTTONDOWN
OR WM_COMMAND to buttons failed many times and i
could never see this WM_CLICK anywhere
so i was forced to dig into many apps to find the exact message that handles
like 0xbd11 blah blah and send that message

i just transformed one of my masm template
Code:
.const 
WM_CLICK equ 0f5h

invoke PostMessage,NagButtonHandle,WM_CLICK,NULL,NULL
works flawlessly for a button that handled ony 0bd11h message

btw Doesnt SendMessage Create problems like not getting closed
till the original exe returns ???
i had problems with it and i converted my self to PostMessage

Last edited by JuneMouse; 02-16-2005 at 00:33.
Reply With Quote
  #11  
Old 02-16-2005, 01:10
bilbo bilbo is offline
Friend
 
Join Date: Jul 2004
Posts: 103
Rept. Given: 36
Rept. Rcvd 15 Times in 12 Posts
Thanks Given: 15
Thanks Rcvd at 17 Times in 11 Posts
bilbo Reputation: 15
Quote:
Originally Posted by JuneMouse
where did you dig it out from
I googled for WM_CLICK and only 141 hits came out, some of them with the equate. I don't know who discovered it (I browsed all the hits without success), and I'm surprised that that message has not yet been documented by Microsoft!

Quote:
Originally Posted by JuneMouse
Doesnt SendMessage Create problems like not getting closed till the original exe returns ???
I didn't find the problem you are reporting... Maybe BCBuilder sub-classes the standard button class???

Regards, bilbo
Reply With Quote
  #12  
Old 02-16-2005, 01:46
Jackal
 
Posts: n/a
You probably didn't get many hits because it's BM_CLICK not WM_CLICK See Satyric0n's post above.
Reply With Quote
  #13  
Old 02-16-2005, 03:24
JMI JMI is offline
Leader
 
Join Date: Jan 2002
Posts: 1,627
Rept. Given: 5
Rept. Rcvd 199 Times in 99 Posts
Thanks Given: 0
Thanks Rcvd at 98 Times in 96 Posts
JMI Reputation: 100-199 JMI Reputation: 100-199
He would have found only 281 hits for "BM_CLICK."

This one might be of interest:

http://www.minigui.com/api_ref/group__ctrl__button__msgs.html

and the part where it states:

Define Documentation

#define BM_CLICK 0xF0F5
Simulates the user clicking a button.

An application sends a BM_CLICK message to simulate the user clicking a button.

BM_CLICK

wParam = 0;
lParam = 0;

Definition at line 822 of file control.h.


That seems to make the "definition" of BM_CLICK and WM_CLICK seem somewhat similar. At least in this case.


Regards,
__________________
JMI
Reply With Quote
  #14  
Old 02-16-2005, 16:35
bilbo bilbo is offline
Friend
 
Join Date: Jul 2004
Posts: 103
Rept. Given: 36
Rept. Rcvd 15 Times in 12 Posts
Thanks Given: 15
Thanks Rcvd at 17 Times in 11 Posts
bilbo Reputation: 15
Thanks, Jackal / JMI,

that was another gross failure of my memory!

I would have known that, since a CLICK is a message specific to Buttons,
it must not be searched under WM_xxx (generic Windows messages),
but under BM_xxx (Button messages).

And that is in fact the place where it is documented by M$,
in their SDK, along with other:

Button Control Messages (BCM_GETIDEALSIZE, BCM_GETIMAGELIST, BCM_GETTEXTMARGIN,BCM_SETIMAGELIST, BCM_SETTEXTMARGIN)

Button Control Notifications (BCN_HOTITEMCHANGE)

Button Messages (BM_CLICK, BM_GETCHECK, BM_GETIMAGE, BM_GETSTATE,BM_SETCHECK, BM_SETIMAGE,BM_SETSTATE,
BM_SETSTYLE)


Button Notifications (BN_CLICKED,BN_DBLCLK, BN_DOUBLECLICKED, BN_KILLFOCUS,BN_SETFOCUS, BN_DISABLE, BN_HILITE, BN_PAINT,BN_PUSHED,BN_UNHILITE,BN_UNPUSHED)

BM_CLICK is defined in winuser.h (for MSVC) as
Code:
#define BM_CLICK           0x00F5
and in windows.inc (for MASM32) as
Code:
BM_CLICK                             equ 0F5h
Regards, bilbo

By the way, the site you dug out is very interesting, JMI!
They (our chinese colleagues) are offering a full GUI (with some sources) multi-platform and not depending on GDI32/WIN32K...

[EDIT JMI: Master bilbo: Slightly adjusted your post so that it didn't run outside the normal window view and all shows without the scroll sideways.]

[EDIT bilbo: Thanks, JMI, I do not how could it happen!]

Last edited by bilbo; 02-17-2005 at 16:21.
Reply With Quote
  #15  
Old 02-17-2005, 09:22
lilmeanman
 
Posts: n/a
Question

Ok this really isn't helping much because I get how you simulate it, yet I don't get how I can insert and run that C code when Typer Shark starts.

Maybe someone can download it and help me a bit (www.popcap.com)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the answered button? Dreamer General Discussion 0 05-07-2015 18:22
Does simulating click affect GetMessagePos()? BlackWhite General Discussion 10 02-14-2015 02:54


All times are GMT +8. The time now is 02:24.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )