flat assembler
Message board for the users of flat assembler.

Index > Windows > fasm vs C, white backgrounds on STATIC windows

Author
Thread Post new topic Reply to topic
Jimmus



Joined: 13 Sep 2012
Posts: 3
Jimmus
A simple test app creates a window and places a static label on it. I built the thing in C and had the compiler generate assembly code. I converted the assembly code to fasm format and built the same app using fasm. When I run the app under WinXP, I get different results.

The C version gives me grey backgrounds for the static label. Grey is the default, and the rest of the window looks OK.

The fasm version gives me a white background for the static label. The rest of the main window has a grey background.

It's the exact same code, except the fasm version doesn't have all that unnecessary C header garbage that I never use. Well, I THOUGHT it was unnecessary. But it must be doing something that changes the background color of my static labels.

Initial search results get me conversations about how to handle messages in my message handler, but my C version isn't doing that. It must be something simpler than that. I can't be the only guy seeing this. Have you guys run into this and fixed it?
Post 14 Sep 2012, 16:24
View user's profile Send private message Reply with quote
fatygant



Joined: 12 Sep 2011
Posts: 30
Location: Poznan, Poland
fatygant
irrelevant answer. that's why deleted...


Last edited by fatygant on 16 Sep 2012, 11:10; edited 1 time in total
Post 14 Sep 2012, 17:54
View user's profile Send private message Reply with quote
Jimmus



Joined: 13 Sep 2012
Posts: 3
Jimmus
Never mind. I found it.

I can't use the exact same code that the c compiler gives me. You know that unnecessary garbage the c compiler puts in? Well one of them was a command line parameter to the main proc--the hInstance. If I don't use the C preludes, there are no parameters to my main proc. Once I used GetModuleHandle to give me the hInstance, and changed the references, it worked fine.

The thing on the stack it was using for the module handle was a return address into ntdll somewhere. As long as I used the same value of hInstance when I called RegisterClass and CreateWindowEx, it worked OK except for this weird background thing.
Post 14 Sep 2012, 21:08
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Jimmus wrote:
I can't use the exact same code that the c compiler gives me.
The C entrypoint (the language standard 'main' for console apps, WinMain for GUI apps) isn't the Portable Executable entrypoint - before your function calls, the C runtime startup code does a lot of (useful) stuff.

So yes, there's a bit more work needed for assembly Smile

_________________
Image - carpe noctem
Post 15 Sep 2012, 22:49
View user's profile Send private message Visit poster's website 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.