Trying to convert old TASM code to MASM, I've run in yet another inexplicable bug :(
I've grown to suspect that windows simply doesn't like MASM. Check the attachment, it contains two identical source files, one for TASM (tbugtest.asm) and one for MASM (bugtest.asm). When assembled and linked, the TASM version works (simply showing a white window), while the MASM version fails (not updating the window). The call that fails is StretchDIBits, GetLastError says a parameter is wrong but I can't see how this is possible since the TASM version works. I've tried linking with different /SUBSYTEM:WINDOWS versions, but to no avail :( I've also traced both files in OllyDBG but I don't see a difference (except addresses)

Here are the assembler and linker options I use:

tasm32.exe /s /ml tbugtest.asm
Tlink32 -c -Tpe -aa tbugtest , , , import32.lib kernel32.lib

ML.EXE /c /coff /Cp /nologo /I"$I"
LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /LIBPATH:"$L"
(in RADASM with masm32v7, default paths)

Anybody sees something that is wrong? Do I use the wrong libraries? Wrong parameters?

I've also included the exe's in the zip.
They need a 32-bit desktop to run.
(I've tries to make the smallest file that
shows the problem, so the code is not very good: lots of hardcoded constants etc).

I'd like to know if:
- The tbugtest.exe works and the bugtest.exe fails for other people (if not, the problem must be a system lib or so)
- If you can compile the TASM and/or MASM file and get a result (work/failure) different from my exe's. If so, the problem must be some compile-time thing.

Any help would be greatly appreciated...
Posted on 2002-05-09 14:52:28 by james
Well, I've never done much more than play with TASM, so I'm not much help.

But I can assure you, Windows loves MASM. :grin:
Posted on 2002-05-09 19:11:40 by S/390
I tested them both, and they both arn't working right.

The DC on the TBugTest is just as screwed as the Masm one.

I will admit, off the start, the tasm version *looks* like its working, but if you move the window around a few times you see the DC is doing the same as the masm one. Only it starts off white first.

I will look deeper into it, i have a hunch i know whats going on. ;)
Posted on 2002-05-09 19:40:49 by NaN
What a nightmare!!!

I hope your dont intend to take up these coding practices?? It was very hard read/follow/debug. But anyways, i found it.

The problem is MASM doesnt like TASM. You said your trying to port it to MASM, but your really didnt change all too much.

The way your were formating and filling the Bitmap Info Header was not correct for a MASM format. I Commented it out and replaced it with more suitable code, and away it went. (you'll notice there is less typing in the correct format as well).

I also added a GlobalLock/Unlock, as i didnt think you should be playing on global data without. Seems as if it doesnt matter, but eh, its the way i grew up ;)

The DC problem i mentioned earlier is still there, I gave up even trying to decipher any more "code" once i got a ERROR_SUCCESS from ollydebug.

I dunno what your trying to do, but good luck...
:NaN:
Posted on 2002-05-09 21:08:18 by NaN
Thanks a lot Nan!

The "problem" with moving the window around is not a problem at all, the program simply does not react to repaint messages. Remember, this is a very minimal test program.

So, if I understand the problem correctly, the addressing of structs is not compatible between MASM and TASM. I'll take a look with a debugger to see which addresses the original buggy program actually writes too.

Again, thanks for saving the remains of my hair ;)
Posted on 2002-05-10 00:53:36 by james