Guy's I am trying to use the windowfrompoint function, but i'm failling.

From previous posts I found that you actually need to post two parameters instead of the 1. but this hasnt soved the issue

I've tried the following
This doesn't work

call getcursorpos, offset pos
call windowfrompoint, pos.x, pos.y + 2

This doesnt work

call getcursorpos, offset pos
call ClientToScreen, offset pos ;also without offset
call windowfrompoint, pos.x, pos.y + 2

This doesnt work

call getcursorpos, offset pos
call ScreenToClient, offset pos ;also without offset
call windowfrompoint, pos.x, pos.y + 2

This does work

call getcursorpos, offset pos
call windowfrompoint, 500, 500


So it looks like an issue with my parameters, they look fine in OllyDBG, also the + 2 is becuase initially pos.y was just showing as 0 and adding to the 2 bytes to the memory put me correctly in pos.y

Thanks in advance
Posted on 2009-04-23 09:59:51 by sidey1234
Use add pos.y, 2 before using pos.y.
Posted on 2009-04-23 14:00:11 by JimmyClif
Jimmy thanks for the reply, but this didnt work eitehr.

It turns out I had the structure wrong. I was using dw instead of dword.  :shock:
Posted on 2009-04-24 05:23:31 by sidey1234
WindowFromPoint accepts one parameter that is the address of a X,Y structure. In Delphi the structure is like this:

  TPoint = packed record
    X: Longint;
    Y: Longint;
  end;


In C++ Builder the function is defined like this:

WindowFromPoint(__in POINT Point);


Tnd the POINT structure is defined like this:

typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT;


So yeah you have to pass the address of a structure that holds X as its first DWORD and Y as its second DWORD. The contents of the structure won't be changed by Windows and make sure the assembler won't pad your structure to align it.
Posted on 2009-04-24 07:07:11 by XCHG