flat assembler
Message board for the users of flat assembler.
Index
> Windows > WM_SETTEXT bug |
Author |
|
Vasilev Vjacheslav 26 Apr 2006, 07:09
on many text functions direction flag not checked
|
|||
26 Apr 2006, 07:09 |
|
Madis731 26 Apr 2006, 07:13
ARGHHHHH, and I though WHY, WHY, WHY!!! I always blaimed myself. You won't believe what workarounds/hacks I needed to do :@
I usually don't set directsion anywhere and assume its always clear... Thanks a BIG! |
|||
26 Apr 2006, 07:13 |
|
Tomasz Grysztar 26 Apr 2006, 07:31
This is not really a bug, the STDCALL convention requires you to clear DF when calling the function (and any STDCALL function must return with DF cleared).
Reference: MASM Manual |
|||
26 Apr 2006, 07:31 |
|
moriman 26 Apr 2006, 08:15
Thanks for the info Tomasz, I had never come across that before.
IMHO I would still class it as one of the numerous bugs in windoze. If I write code and don't check the DF (or any other flag) when necessary, if the app crashes, it's my error. If a windoze sub doesn't check it, it's their error |
|||
26 Apr 2006, 08:15 |
|
Tomasz Grysztar 26 Apr 2006, 08:30
If you provide an invalid pointer as a parameter, the app crashes too - and it's actually the same story. Since setting DF to 0 is a part of calling convention, then when you call function with DF set, it's like providing an invalid parameter.
So the only problem here is whether the API function should detect just allow an exceptions to happen on bad input, or detect all such cases and return back some error. As we can see, with both invalid pointer and invalid setting of DF the first solution has been chosen by Microsoft (so it actually leaves the parameters validity checking to the programmer). |
|||
26 Apr 2006, 08:30 |
|
moriman 26 Apr 2006, 10:01
While I understand what you are saying and completely agree with you from that perspective, my point is simply that there must be somewhere in the API call that uses MOVS, STOS CMPS etc, without checking the DF first. This is something that I (and I'm sure you also) would *never* do. A very quick
CLD REP MOVS or STD REP MOVS is all that is required to ensure the DF flag is as you require it. This applies equally to us mere mortals and the micro$oft employees. |
|||
26 Apr 2006, 10:01 |
|
Tomasz Grysztar 26 Apr 2006, 13:40
The code of API was probably generated by the C compiler, and the C compiler assumes everything conforms to the calling convention. Thus programmer may even have no idea that something like that happens there.
|
|||
26 Apr 2006, 13:40 |
|
moriman 26 Apr 2006, 16:43
Ah! I understand now
Thanks Tomasz |
|||
26 Apr 2006, 16:43 |
|
RedGhost 29 Apr 2006, 05:57
Tomasz Grysztar wrote: This is not really a bug, the STDCALL convention requires you to clear DF when calling the function (and any STDCALL function must return with DF cleared). useful link thanks Quote:
Code: macro stdcall proc,[arg] ; directly call STDCALL procedure { common if ~ arg eq reverse pushd arg common end if call proc } should this not be Code: macro stdcall proc,[arg] ; directly call STDCALL procedure { common cld if ~ arg eq reverse pushd arg common end if call proc } ? _________________ redghost.ca |
|||
29 Apr 2006, 05:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.