Please don't hate me: this is my first post concerning VC++ and it doesn't involve C++. :)

I am using VC++ 5 to output assembly listings in order to study them for Win32asm learning purposes.

But I've run into a problem going from a simple message box to a Window project. I can assemble the assembly file and link the object file with the libs in the VC++ lib directory producing an executable with no errors along the way. But the executable doesn't run (except in the Task Manager). I tried debugging the executable, but inexperienced as I am, I can only guess at what the problem is. The wrong starting address?

I hope someone doesn't mind looking things over and hopefully quickly spot an easy solution with little effort.

My VC++ command line used on the C source file to produce assembly file (for anyone who doesn't know how to do it):

cl /c /FAs /Fa /ID:\Dev\VS5\VC\Include /X $(FileName)

My ML command line:

ml /c /coff /Cp $(FileName)

My Link command line:

link @d:\masm32\bin\linkwin.txt $(FileNameNoExt).obj

where the response file, linkwin.txt, contains:

/ENTRY:WinMain /SUBSYSTEM:WINDOWS /LIBPATH:D:\Dev\VS5\VC\Lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib

(I've also tried /Entry:WinMain@16)

I've attached the original C source file, the asm file that VC++ outputs, the response file, and both the object and executable files created using my setup (zipped up). Oh yeah, the file included in the assembly file is a VC++ file which I have in my include path variable (also in the zip file attached). I'll could post the asm code as it looks pretty, but it's 300 lines so I'll save you the scrolling. :tongue:
Posted on 2003-05-08 04:27:20 by Masmer

I havent looked into your source, but you shouldnt use WinMain as entry point. This function should be called from inside the C startup code. So include library LIBC or MSVCRT. These will provide the C startup module.
Posted on 2003-05-08 05:29:16 by japheth
Thank you for your solution!

I added MSVCRT.lib to the response file and took out the /Entry:WinMain@16 and now the executable works. :alright:

I'm working my way through the Petzold (Win95) book and buckling down on learning the Win32 API.
Posted on 2003-05-08 05:40:58 by Masmer
Hi Masmer,

How are you?

The problem is solved.You will find a file named build3
in the attachment.Just,change the paths to libs etc.,and type
build3 wintemplate. :)

I am using my simple C start-up codes:

Use build filename to create GUI VC apps and buildc filename to build console apps.
Posted on 2003-05-08 05:47:21 by Vortex
You can even a smaller executable with the Digital Mars compiler(free)
VC:3072 bytes
DM:2560 bytes
Posted on 2003-05-08 06:05:34 by Vortex
Hi Vortex. I just got over a fever (not SARS, but pre-pnuemonia) and am doing great now.

Thank you for your work on this problem. I'm looking over the code and see you've added a few command line options I don't use. So I'll look up these options to see what they do.

I didn't know the /Z7 option created debug info for Ollydbg. Good info!
Posted on 2003-05-08 06:06:14 by Masmer

I hope you will recover soon.
Yes,I was playing with the switches of ml.exe and I found this /Z7 option.
Posted on 2003-05-08 06:24:14 by Vortex