flat assembler
Message board for the users of flat assembler.

Index > Windows > Confusing jne...

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
If we suppose Windows is buggy (it is possible of course) why you think it will return exactly -1??? The buggy GetMessage can return everything (in EAX and [msg] as well), so processing this kind of errors is impossible by default.
Not necessarily. GetMessage may call a number of other functions and perhaps if one of those functions fails (and/or is buggy) then GetMessage will return the error of -1.
Post 29 Feb 2012, 12:03
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
http://msdn.microsoft.com/en-us/library/aa383751%28v=vs.85%29.aspx
Quote:
BOOL

A Boolean variable (should be TRUE or FALSE).

This type is declared in WinDef.h as follows:

typedef int BOOL;
BOOLEAN

A Boolean variable (should be TRUE or FALSE).

This type is declared in WinNT.h as follows:

typedef BYTE BOOLEAN;
BYTE

A byte (8 bits).

This type is declared in WinDef.h as follows:

typedef unsigned char BYTE;
It says "should be", but not "must be" Wink

JohnFound, I think that the documentation leaves the possibility for other kinds of errors open:
Quote:
If there is an error, the return value is -1. *For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.
* i.e. it is commenting about ONE possible source of error, but doesn't tell it is the only one possible.
Post 29 Feb 2012, 15:10
View user's profile Send private message Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
revolution wrote:
Since we are wasting time trying to optimise this, then let's do it properly. Wink
Code:
...
  test eax,eax
  jz end_loop
  js error_handler
...    
What about when eax =0x80000000 to 0xfffffffe ?

What if you just test for -1, ignore eax = 0 and process WM_QUIT outside the loop?
Post 29 Feb 2012, 17:59
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
mindcooler wrote:
@shutdownall
"handle the error and possibly exit"


Yes possibly exit.
It depends on the error.
It is not fine if a program autocloses (possibly exit = WM_QUIT in your example) with no hint at all. In this case there is no difference between a crash. At least program should give a MessageBox to alert the autoclose due to an error. Maybe give someone the chance to save some modified data. Or maybe program could stop and cleanup some other processes which may cause data loss or something. Wink
Post 29 Feb 2012, 21:58
View user's profile Send private message Send e-mail Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Well, as I don't know what could possibly cause a such an error in my program, I don't have a strategy for recovery, so I just make it quit. It is as good indication as anything else for my purposes. As the others are saying, the most probably cause for getting an error like this is errors in the parameters, and I don't have any programs that deal with savable data yet Smile
Post 29 Feb 2012, 22:46
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
mindcooler wrote:
and I don't have any programs that deal with savable data yet Smile

When you have, you should take care of data. Maybe an editor is crashing, would be nice to have at least a copy of the contents before quitting program. This could be done in a temporary file and let the user decide after, if content seems to be valid or not.

One example is the firefox browser with tabbed browsing. Not long time ago I closed accidently a tab with some well typed text in a window on a website (forum). That was at least half an hour of work. The function "restore closed tab" saved my ass in this way. Wink
Post 01 Mar 2012, 01:20
View user's profile Send private message Send e-mail Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Code:
        xor     eax, eax
        jz      continue

; what if the CPU have bug in the ALU?
; Handle the error and exit!
        call    [ExitProcess]


continue: 

    
Post 01 Mar 2012, 06:11
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
Code:
        xor     eax, eax
        jz      continue

; what if the CPU have bug in the ALU?
; Handle the error and exit!
        call    [ExitProcess]


continue: 

    
Heh, funny you should mention this. Some time back I used to work on Olivetti systems that had discrete TTL chips making up the CPU. And the test code was pretty much exactly that. Checking that all the various gates were functioning correctly. Even things like checking that the IP register could advance properly and handle the propagation of the carry to the next bit etc. Such memories are sometimes nice to recall, even though testing like that has long since become a thing of the past.
Post 01 Mar 2012, 06:47
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
shutdownall wrote:
mindcooler wrote:
and I don't have any programs that deal with savable data yet Smile

When you have, you should take care of data. Maybe an editor is crashing, would be nice to have at least a copy of the contents before quitting program.


When I have data, it's easy to change to jmp dumpandquit, which is a call save and ret. And/or use autosave.

Still, I'm unsure if I'm ever going to see the error in my lifetime Razz

_________________
This is a block of text that can be added to posts you make.
Post 01 Mar 2012, 12:49
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
mindcooler wrote:

Still, I'm unsure if I'm ever going to see the error in my lifetime Razz

I wouldn't bet on it. We are talking about MS software. Cool
Post 01 Mar 2012, 15:57
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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.