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 


Can some1 tells me what's wrong with that code? (C++)
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 07, 2008 1:06 pm    Post subject: Reply with quote

Code:

#define IDC_HOTKEY1 100
#define IDC_HOTKEY2 101
#define IDC_HOTKEY3 102

//other coding

case WM_CREATE:
   RegisterHotKey(hWnd, IDC_HOTKEY1, NULL, 0x71);
   RegisterHotKey(hWnd, IDC_HOTKEY2, NULL, 0x72);
   RegisterHotKey(hWnd, IDC_HOTKEY3, NULL, 0x73);
   break;
case WM_HOTKEY:
   if(IDC_HOTKEY1) {
      //your code here
   }
   if(IDC_HOTKEY2) {
      //your code here
   }
   if(IDC_HOTKEY3) {
      //your code here
   }
   break;

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jun 07, 2008 1:10 pm    Post subject: Reply with quote

now whenever i click f2,f3,f4 it's turns on/off all of them in once
and wiccaan it's not the x's it was my tiping mistake :s
Edit: fixed it nvm all i needed to do is put it inside a switch block
Code:

switch (LOWORD(wParam))
     case IDC_HOTKEY1:
     // etc

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sat Jun 07, 2008 2:28 pm    Post subject: Reply with quote

Make sure you put in breaks if you are using cases.

Code:
case IDC_HOTKEY_1:
  // code
  break;
case IDC_HOTKEY_2:
  // code
  break;


And so on.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sat Jun 07, 2008 4:28 pm    Post subject: Reply with quote

About the mov edi, edi stuff.

They're the prologue to functions with __stdcall.

mov edi, edi: dereference edi pointer
push ebp: saves stack pointer
mov ebp, esp: creates a stack frame for the function

If you notice, at the end of the function, the is a sub esp, xxx. xxx is how many bytes of stack the function uses. Followed by a pop ebp. Then a ret. That's so the function can use its own stack frames and restore the original stack when returning to the caller.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 08, 2008 12:20 am    Post subject: Reply with quote

i'm having problem with my AC
here's the auto clicker thread:
Code:

void AutoClick()
{
   LoadUser32();
   bClk = TRUE;
   while (bClk)
   {
      POINT pt;
      GetCursorPosX(&pt);
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, (LPARAM)&pt);
      PostMessageX(hMS, WM_LBUTTONUP, MK_LBUTTON, (LPARAM)&pt);
      Sleep(10);
   }
   ExitThread(0);
}

when i turn it on it crushes i think the problem is in the GetCursorPos function which i bypassed too like postMessage
and when i send mouse clicks without the POINT (with NULL value)
it works but clicks at the left top corner of the screen

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sun Jun 08, 2008 12:33 am    Post subject: Reply with quote

WM_LBUTTONDOWN uses a word value for it's coords, not a point.

http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx

Quote:
lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.

The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.


Use the MAKELPARAM macro instead to accomplish what you need:

Code:
PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, (LPARAM)MAKELPARAM( pt.x, pt.y ));

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 08, 2008 12:38 am    Post subject: Reply with quote

but it still crushes cuz of the GetCursorPos function
i bypassed it like i did to PostMessage

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sun Jun 08, 2008 12:39 am    Post subject: Reply with quote

1qaz wrote:
but it still crushes cuz of the GetCursorPos function
i bypassed it like i did to PostMessage


If GetCusorPos is causing the crash then post the code for that. Can't really help without seeing what may be causing it to crash.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 08, 2008 12:42 am    Post subject: Reply with quote

it's exactly like postMessage
here:
Code:

void LoadUser32GetCurPos()
{
   hgcInst = LoadLibrary(L"User32.Dll");
   gcDLLFunc = NULL;
   if (hgcInst != NULL)
      gcDLLFunc = (DWORD)GetProcAddress(hgcInst,"GetCursorPos");
   if (gcDLLFunc != NULL)
      gcDLLFunc += 5;
}

__declspec(naked) BOOL WINAPI GetCursorPosX(LPPOINT pt)
{
   __asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[gcDLLFunc]
   }
}

_________________
Stylo
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sun Jun 08, 2008 2:30 am    Post subject: Reply with quote

You don't have to bypass GetCursorPos... its not hooked.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 08, 2008 2:52 am    Post subject: Reply with quote

i thought GG hooked all API in user32 and kernel .dll Confused
edit: it's not working too btw

_________________
Stylo
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 08, 2008 3:37 am    Post subject: Reply with quote

Shouldn't you call LoadUser32GetCursPos and LoadUser32 in your AC function? Oh w8, you load the library in there too. Ok take out this line of code:

Code:

//in LoadUsesr32GetCursPos()
hgcInst = LoadLibrary(L"User32.Dll"); //don't want to load the same library twice


And then chance your code to this:

Code:

void AutoClick()
{
   LoadUser32();
   LoadUser32GetCursPos();
   bClk = TRUE;
   while (bClk)
   {
      POINT pt;
      GetCursorPosX(&pt);
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, (LPARAM)MAKELPARAM( pt.x, pt.y ));
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, (LPARAM)MAKELPARAM( pt.x, pt.y ));
      Sleep(10);
   }
   ExitThread(0);
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 08, 2008 3:44 am    Post subject: Reply with quote

oh i haven't thought about this b4 i'll test it and post results
thanks though
edit: working good now but the mouse is jumping up and down few pixels
and it cant click on characters besides all that it's working great Very Happy thx

_________________
Stylo
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 08, 2008 3:53 am    Post subject: Reply with quote

Jumping up and down a few pixels, and can't click on characters...Not sure, but it could be the typecast. If you look in winuser.h where MAKELPARAM is defined...

Code:

#define MAKELPARAM(l, h)   ((LPARAM) MAKELONG(l, h))


It already returns it as an LPARAM:

#define MAKELPARAM(l, h) ((LPARAM) MAKELONG(l, h))

So try taking out the typecast. So change it to:

Code:

void AutoClick()
{
   LoadUser32();
   LoadUser32GetCursPos();
   bClk = TRUE;
   while (bClk)
   {
      POINT pt;
      GetCursorPosX(&pt);
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( pt.x, pt.y ));
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( pt.x, pt.y ));
      Sleep(10);
   }
   ExitThread(0);
}


EDIT:

Oh yeah, it could be you trying to restore the initial five bytes in GetCursPos. Because it's not actually hooked by GG, so the whole "GetCursPosX" thing isn't necessary. Try taking out this whole part:

Code:

void LoadUser32GetCurPos()
{
   hgcInst = LoadLibrary(L"User32.Dll");
   gcDLLFunc = NULL;
   if (hgcInst != NULL)
      gcDLLFunc = (DWORD)GetProcAddress(hgcInst,"GetCursorPos");
   if (gcDLLFunc != NULL)
      gcDLLFunc += 5;
}

__declspec(naked) BOOL WINAPI GetCursorPosX(LPPOINT pt)
{
   __asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[gcDLLFunc]
   }
}


And then change your AC function to:

Code:

void AutoClick()
{
   LoadUser32();
   bClk = TRUE;
   while (bClk)
   {
      POINT pt;
      GetCursorPos(&pt);
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( pt.x, pt.y ));
      PostMessageX(hMS, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( pt.x, pt.y ));
      Sleep(10);
   }
   ExitThread(0);
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 08, 2008 4:01 am    Post subject: Reply with quote

not helping but hey i dont think that's that matter most of Autoclickers for ms doing that (i think xD) i'll keep working on that thx.
_________________
Stylo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5  Next
Page 4 of 5

 
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