flat assembler
Message board for the users of flat assembler.
Index
> Windows > MSDN discrepancies... |
Author |
|
bitRAKE 02 Jul 2008, 20:37
Just traced down one of those stupid typo errors to find that RegisterClassEx errors when AX is zero - I have assumed MSDN means EAX equal zero is an error:
Quote: If the function fails, the return value is zero. (Maybe someone else has other pitfalls to note?) _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
02 Jul 2008, 20:37 |
|
LocoDelAssembly 02 Jul 2008, 20:51
WinDef.h:
Code: typedef unsigned short WORD; . . . typedef WORD ATOM; Considering that, why do you think it is a typo error from MSDN? |
|||
02 Jul 2008, 20:51 |
|
vid 02 Jul 2008, 21:55
Quote: Guess it's slightly better than just assuming success on all API functions, lol. Congratulations Yeah, using C docs for Asm can sometimes cause problems like this. I probably wouldn't notice this one too :/ |
|||
02 Jul 2008, 21:55 |
|
asmcoder 03 Jul 2008, 09:02
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:57; edited 1 time in total |
|||
03 Jul 2008, 09:02 |
|
bitRAKE 03 Jul 2008, 10:50
The upper word of EAX is not zero on my Windows when this API fails. Yet, the lower word is zero. YWMV (your windows may vary).
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
03 Jul 2008, 10:50 |
|
asmcoder 03 Jul 2008, 11:43
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:57; edited 1 time in total |
|||
03 Jul 2008, 11:43 |
|
vid 03 Jul 2008, 12:25
asmcoder: Don't type bullshit if you don't know. Functions that return WORD return in AX, and functions that return BYTE return in AL.
|
|||
03 Jul 2008, 12:25 |
|
f0dder 03 Jul 2008, 12:55
asmcoder wrote: what windows u have? _________________ - carpe noctem |
|||
03 Jul 2008, 12:55 |
|
rxantos 04 Aug 2008, 00:30
Thank you for pointing this out. Although this has not yet bite me, I will be more carefull when checking what a function returns.
Altough, a good design should have some consistence. Guess Windows is not a good example of a good design. |
|||
04 Aug 2008, 00:30 |
|
f0dder 04 Aug 2008, 12:45
The NT kernel is an example of decent design, the WIN32 API less so (largely because of it's WIN16 legacy). But keep in mind that the API was written with C programmers and not assembly programmers in mind - thus you don't get exact lists of what an API changes and what it doesn't, only the general "expect these registers to be modified, and you're guaranteed those registers aren't".
This also means that if only a byte or a word is returned, you should only look at that part of EAX, and consider the rest to be undefined. Use movsx/movzx if this is too horrible for you |
|||
04 Aug 2008, 12:45 |
|
asmfan 04 Aug 2008, 14:17
Also have you noticed that some Win builds treat BOOL as al (1 byte) other as eax (4 bytes)? As i remember i stumbled this.
|
|||
04 Aug 2008, 14:17 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.