flat assembler
Message board for the users of flat assembler.

Index > Windows > Question about GetWindowRect

Author
Thread Post new topic Reply to topic
upsurt



Joined: 14 Jan 2014
Posts: 51
upsurt
Hi

I try to get the position and the height/width of an window with GetWindowRect.

rc RECT
hwnd dd 0
left dq 0
top dq 0
width dq 0
height dq 0

invoke GetWindowRect,[hwnd],rc
mov dword[left],rc.left
mov dword[top],rc.top
mov dword[width],rc.right-rc.left
mov dword[height],rc.bottom-rc.top

while [rc.left], [rc.right], [rc.top] and [rc.bottom] contain the correct data, [left], [top], [width] and [height] contain complete sensless data.

I'm sure it's my fault and that I mess sth up with the data types. Can someone please point me the direction?
What I need is width and height of the window.

New to ASM and didn't find an usefull explanation of data types in ASM by now.

Thank you very much!


Last edited by upsurt on 28 Jul 2014, 13:27; edited 1 time in total
Post 28 Jul 2014, 13:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17248
Location: In your JS exploiting you and your system
revolution
You need to load the value from the structure:
Code:
mov eax,[rc.left]
mov [left],eax    
Post 28 Jul 2014, 13:26
View user's profile Send private message Visit poster's website Reply with quote
upsurt



Joined: 14 Jan 2014
Posts: 51
upsurt
I did this before, but I get an "operand sizes do not match (mov [left],eax)" error.
Post 28 Jul 2014, 13:29
View user's profile Send private message Reply with quote
upsurt



Joined: 14 Jan 2014
Posts: 51
upsurt
Ok, I got it working with your help! Thank you, revolution.

Code:
  invoke GetWindowRect,[hwnd],rc
  ;x
  mov eax,[rc.left]
  mov dword[left],eax
  ;y
  mov eax,[rc.top]
  mov dword[top],eax
  ;width
  mov eax,[rc.right]
  mov dword[width],eax
  mov eax,[rc.left]
  sub dword[width],eax
  ;height
  mov eax,[rc.bottom]
  mov dword[height],eax
  mov eax,[rc.top]
  sub dword[height],eax  
    


now I get the correct data in dword[left], dword[top], dword[width] and dword[height]

But is this the correct way to do it, or is there a better way?
Post 28 Jul 2014, 13:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17248
Location: In your JS exploiting you and your system
revolution
You can use the matching size for the values then you don't need the 'dword' overrides:
Code:
left dd ?    
Post 28 Jul 2014, 14:01
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.