flat assembler
Message board for the users of flat assembler.

Index > Windows > where dose getchar return to?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
FindAtom:
Code:
.text:7C830D06 ; ATOM __stdcall FindAtomA(LPCSTR lpString)
.text:7C830D06                 public _FindAtomA@4
.text:7C830D06 _FindAtomA@4    proc near
.text:7C830D06
.text:7C830D06 lpString        = dword ptr  8
.text:7C830D06
.text:7C830D06                 mov     edi, edi
.text:7C830D08                 push    ebp
.text:7C830D09                 mov     ebp, esp
.text:7C830D0B                 push    [ebp+lpString]
.text:7C830D0E                 push    0
.text:7C830D10                 push    1
.text:7C830D12                 call    _InternalFindAtom@12 ; InternalFindAtom(x,x,x)
.text:7C830D17                 pop     ebp
.text:7C830D18                 retn    4
.text:7C830D18 _FindAtomA@4    endp    
And when InternalFindAtom is about to return:
Code:
.text:7C830C77 loc_7C830C77:                           ; CODE XREF: InternalFindAtom(x,x,x)+121j
.text:7C830C77                 mov     [ebp+var_20], eax
.text:7C830C7A                 cmp     eax, ebx
.text:7C830C7C                 jl      short loc_7C830CC6
.text:7C830C7E
.text:7C830C7E loc_7C830C7E:                           ; CODE XREF: InternalFindAtom(x,x,x)+F4j
.text:7C830C7E                                         ; InternalFindAtom(x,x,x)+9CB5j
.text:7C830C7E                 or      [ebp+ms_exc.disabled], 0FFFFFFFFh
.text:7C830C82                 call    sub_7C830CB5
.text:7C830C87                 mov     ax, word ptr [ebp+var_1C] ; <<<<<<<<<< RETURN VALUE SET HERE. EAX PRE-STATE UNKNOWN
.text:7C830C8B
.text:7C830C8B loc_7C830C8B:                           ; CODE XREF: InternalFindAtom(x,x,x)+9C56j
.text:7C830C8B                                         ; InternalFindAtom(x,x,x)+9CA9j
.text:7C830C8B                 call    __SEH_epilog
.text:7C830C90                 retn    0Ch
.text:7C830C90 _InternalFindAtom@12 endp    
Post 27 Sep 2010, 16:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
So from that we should always make sure to check the return type and use movsx and movzx as appropriate. Thanks for pointing that out.

So how about boolean return values? I always just check eax against zero. Should I be checking al against zero instead?
Post 27 Sep 2010, 23:38
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
Best to check here. If by boolean you mean BOOL, then you are correct already. It is worth noting that the documentation defines the "true" value as TRUE and not non-zero, so watch out what you are passing as arguments and the returns values in your callbacks! Razz
Post 28 Sep 2010, 01:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Oh, bool and boolean are different! I had never noticed that before. C is so confusing.
Post 28 Sep 2010, 01:32
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
BOOL (as in Win32) is type: signed int
bool (as in C++) is type: unsigned char
Post 28 Sep 2010, 07:38
View user's profile Send private message Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 724
guignol
LocoDelAssembly
Very nice, of course, but I kinda meant the function operating on characters/strings & returning character.

P.S. Btw, don't forget that ATOM is a WORD, not int; that is precisely short int.
Post 28 Sep 2010, 12:27
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

that is precisely short int.
unsigned short int actually.

As for functions in MSVCRT or even in the WinAPI returning char, I don't remember any, it seems all of them are defined to either return a char pointer or an int.
Post 28 Sep 2010, 17:16
View user's profile Send private message Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 724
guignol
LocoDelAssembly wrote:
As for functions in MSVCRT, or even in [the] WinAPI, dealing with character(s) [...], it seems all of them are defined to either return a [char] pointer or an int.
...which are both 32 bits.
Good.


P.S. Now, be a good boy and stop MHajduking from now on.
You know, with all that "secret" knowledge, topic change, and banal jumble.
Post 29 Sep 2010, 16:15
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
guignol wrote:
P.S. Now, be a good boy and stop MHajduking from now on.
You know, with all that "secret" knowledge, topic change, and banal jumble.
Actually, it's characteristic for you, and rather should be called guignolling.
Post 29 Sep 2010, 16:19
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
guignol wrote:
LocoDelAssembly wrote:
As for functions in MSVCRT, or even in [the] WinAPI, dealing with character(s) [...], it seems all of them are defined to either return a [char] pointer or an int.
...which are both 32 bits.
Good.
Untrue.
Post 29 Sep 2010, 20:16
View user's profile Send private message Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 724
guignol
Fanael wrote:
Untrue.
Eh?
Post 30 Sep 2010, 12:18
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
guignol wrote:
Fanael wrote:
Untrue.
Eh?
You know, there's a thing called Win64, where pointers aren't 32 bits anymore.
Post 30 Sep 2010, 21:37
View user's profile Send private message Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 724
guignol
You know, you shan't think, falafel - it doesn't suit you.


P.S. MHajduk you are indeed contagious. Rolling Eyes
Post 01 Oct 2010, 07:04
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
guignol wrote:
P.S. MHajduk you are indeed contagious. Rolling Eyes
guignol, I don't know why but I like you anyway. Is it some kind of masochism? I don't know, maybe I just like all the people with an IQ much higher than average (but beware, don't cross the thin red line - you're only fragile wooden Lyonnaise marionette in fact Razz ).
Post 01 Oct 2010, 07:44
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
guignol wrote:
You know, you shan't think, falafel - it doesn't suit you.
Who (what?) are you talking about? Razz
Post 01 Oct 2010, 11:46
View user's profile Send private message 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 YouTube, Twitter.

Website powered by rwasa.