flat assembler
Message board for the users of flat assembler.

Index > Windows > wrong hInstance, bad parameters passing,still working?

Author
Thread Post new topic Reply to topic
daluca



Joined: 05 Nov 2005
Posts: 86
daluca
Hello:
I have 2 computers: one new with windows XP nsp and this one,older
with windows ME. generally i work in the new one,and in there i compiled
a simplewindow program from the izcelion tutorials. and every thing worked fine. but when i copyed that program an runed it in windows ME it didn't work
and analyzing the source i found the problem:

Code:

 invoke GetCommandLine,0      
        mov [wc.hInstance],eax
        invoke GetCommandLine       
        mov [CommandLine],eax

      

so i repeated the GetCommandLine function, i corrected the error and the
program runs in Windows ME.

so why passing a invalid instance handle to Registerclass and createwindow
dosn't produce any error in xp?
and why calling GetCommandline pushing 0 on the stack neither produce
an error? this function do not take any parameters, shouldn't be the stack unbalanced?

Is windows XP more error-tolerant?
or is because i use the nsp version? (nsp = no service pack)

using: invoke GetCommandLine,0 in windows ME doesn't produce any
error neither
Post 14 Sep 2006, 07:03
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
Garthower
Your question to answer precisely developers of these two OS can only Smile . Most likely it's connected by that kernels of OS of a NT-basis and a 9x-basis very strongly from each other differ, both realization, and internal logic.
Post 14 Sep 2006, 07:45
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Using invoke GetCommandLine,0 alone cannot raise an error because it's no different from preserving values before you call a function e.g.

Code:
mov eax,0
push eax
invoke GetCommandLine
;...
    

I'm not entirely sure about how each one handles the stack...but I would have thought excess entries on the stack aren't a problem, but should be avoided.

As for XP running with "wrong" hInstance, maybe GetCommandLine returned a valid hInstance value OR XP detects invalid hInstance and uses the calling hInstance Question
Post 14 Sep 2006, 11:58
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
analyzing the source i found the problem

problem is that iczlion teach people not to check for errors returned by API

AND, winXP is tolerant against fuckedup'd stack sometimes. And sometimes you procedure entry/exit code looks like this:

Code:
;entry
push ebp
mov ebp, esp
sub esp,size_of_locals

;destroy stack
push eax

;return code
mov esp, ebp
pop ebp
ret
    

so leaving something on stack is not a problem. That's also why you don't see "add esp, size_of_locals" at end of procedure-you don't need to
Post 14 Sep 2006, 12:15
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
the hInstance of your programme is not the command line, it is the handle of your module, which is taught in the iczelion tutorials

Code:
xor edx, edx
push edx
call [GetModuleHandleA]  
mov [wc.hInstance], eax
    

_________________
redghost.ca
Post 14 Sep 2006, 19:09
View user's profile Send private message AIM Address MSN Messenger 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.