flat assembler
Message board for the users of flat assembler.

Index > Windows > [SOLVED] MoveWindow fails; what causes the problems?

Author
Thread Post new topic Reply to topic
pete



Joined: 20 Apr 2009
Posts: 110
pete
In the WM_INITDIALOG part of the window-procedure my program fires a MoveWindow call, with correct parameters as can be seen from the stack dump (copied out from OllyDbg):
Code:
0006FD28   003E0460  |hWnd = 003E0460 ('Mainwindow',class='#32770')
0006FD2C   00000000  |X = 0
0006FD30   00000000  |Y = 0
0006FD34   00000190  |Width = 190 (400.)
0006FD38   000000F0  |Height = F0 (240.)
0006FD3C   00000001  \Repaint = TRUE
    

The application never returns from the MoveWindow proc but fires an error and then quits it's execution.
Now i would like to know your suggestions what could cause this problem. The parameters seem to be correct; should i restore the registers ebp esi edi and ebx before i can call an api-function?


Last edited by pete on 27 May 2009, 08:34; edited 1 time in total
Post 20 May 2009, 10:05
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Doesn't look like it's the MoveWindow Function. Are you returning from the dialog procedure correctly?
Post 20 May 2009, 10:54
View user's profile Send private message Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
I'm following the program execution with OllyDbg, and the application always gets stuck inside MoveWindow; when i use SetWindowPos, everything runs just fine…
Post 20 May 2009, 11:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
You are setting the repaint flag, so windows is likely to call your paint function. Check your painting routines.
Post 20 May 2009, 11:49
View user's profile Send private message Visit poster's website Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
The program doesn't intercept the painting routine of the dialog box. I checked that already; 0 or 1 for the REPAINT flag both crashes the application.
Post 20 May 2009, 11:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
So what error do you get? Did you see where the crash happens in Olly?
Post 20 May 2009, 11:56
View user's profile Send private message Visit poster's website Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
MoveWindow does not return; when i step through the function with Olly, a lot of subroutines get called and somewhen in there the app crashes. I don't assume there's a bug in Windows XP (SP3), so i probably have to step through the MoveWindow function and it's subroutines again to find the part that harms the execution. Do you have any suggestions?
Post 20 May 2009, 12:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
But Olly will stop at the error. The you can see where it fails.

Also, does your dialogue box have some custom controls? The controls may get notified about the move.

There are so many things that could be wrong and without any code it is impossible to say what.

Try to minimise the code to the smallest possible that still causes it to fail and then post here. Although, I often find that just trying to minimise the problem is enough to reveal where the fault lies.
Post 20 May 2009, 12:20
View user's profile Send private message Visit poster's website Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Well madmatt, you were right. In one part that was used my multiple dialog procedures, the program was a mess. One dialog procedure reserved a DWORD on the stack and then jumped to this messy subpart of another dialog procedure that didn't put the DWORD off the stack.

Thanks for your tips, revolution; still one question remains:
Quote:

But Olly will stop at the error. The you can see where it fails.

Just how can i see where it fails? Olly stops somewhere in nowhere and i can't get one step back. How can one track the problem down then?
Post 20 May 2009, 13:13
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Hi pete,
Sometime's where the crash actually happened isn't going to be obvious. To debug further, I place a MessageBox function in my program to indicate success up to *this* point in my program. I continue to cut and paste MessageBox after each function and procedure call until the *crash*, no message box window. This may be a strange way to debug a program, but it works for me 95% of the time.
Post 21 May 2009, 10:19
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
madmatt: I use similar method of debugging as well.
Post 21 May 2009, 11:59
View user's profile Send private message Reply with quote
pal



Joined: 26 Aug 2008
Posts: 227
pal
Same. It is my primary method of debugging before using Ollydbg.
Post 21 May 2009, 16:27
View user's profile Send private message Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
I too used MessageBox, but it got annoying because i had to click "Ok" or something like that. The second problem i had with MessageBox was that an important window lost focus, which forced me to re-focus a window after closing a MessageBox.

When i found OutputDebugString it helped me much more; this function sends a string to the "debugger for the current application". While testing my apps, i run dbmon.exe (from the MS Platform SDK) in the background, which is the default debugger and catches all strings pushed by OutputDebugString. It is much more comfortable than MessageBox, at least for me.

The reason i used Olly instead of MessageBox or OutputDebugString in this case was that i simply had no clue about WHERE to output my debug strings…
Post 25 May 2009, 07:42
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
pete wrote:
Just how can i see where it fails? Olly stops somewhere in nowhere and i can't get one step back. How can one track the problem down then?
runtrace.

_________________
Previously known as The_Grey_Beast
Post 25 May 2009, 23:30
View user's profile Send private message Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Thank you Borsuc.
Post 26 May 2009, 05:45
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
No probs. Slow though, you'll need a fast CPU Wink
Post 27 May 2009, 02:21
View user's profile Send private message Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Yes, i recognized that already, hehe.
Post 27 May 2009, 06:54
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Have you found out the root cause of the problem? Can you share out the .exe file?
Post 27 May 2009, 07:39
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Yes, see 9th post from top!
Post 27 May 2009, 08:43
View user's profile Send private message 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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.