The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Tron2.0 on January 15, 2010, 03:36:08 PM

Title: Win32Inc with ML v9
Post by: Tron2.0 on January 15, 2010, 03:36:08 PM
I'm trying to use ML9 with Win32Inc include files, but the assembler blocks and return with A1016 internal error (not documented, by the way....).

This is the code...

.686
.model      flat, stdcall
option      casemap:none

WIN32_LEAN_AND_MEAN   equ   1

include      WINDOWS.INC
includelib   USER32.LIB

.code
start:
      invoke   ExitProcess,0
end start

The assembler signals a C0000005 (access violation) exception.
Any ideas?
Title: Re: Win32Inc with ML v9
Post by: dedndave on January 15, 2010, 05:00:27 PM
see attached file...
Title: Re: Win32Inc with ML v9
Post by: Tron2.0 on January 15, 2010, 05:18:36 PM
Dedndave, thank you for the help, but the error show up with Japhet's Win32Inc, not with the Masm32 include package.... :red
Title: Re: Win32Inc with ML v9
Post by: dedndave on January 15, 2010, 05:24:45 PM
that was, in part, my point
you need to include kernel32.inc and includelib kernel32.lib
i am using a different version of assembler, but i don't think that is the problem
Japheth's Win32.inc is intended for use with JWasm   :bg
not sure that matters, because you are not using anything in windows.inc
basically, you need a prototype for ExitProcess, and the library that has the module
the prototype is in kernel32.inc
the module is in kernel32.lib

EDIT - you are not using anything from user32.lib, either
in fact, you don't really need the prototype in kernel32.inc, if you don't use INVOKE
you can call the function with a push, then you only need the LIB

        push    0
        call    ExitProcess
Title: Re: Win32Inc with ML v9
Post by: japheth on January 15, 2010, 05:50:23 PM
Hi Tron,

I replied in an email to the very same issue some weeks ago:

Quote
> Is there a known issue I should be aware of? Or am I totally screwing something up?

There's a bug in all versions of Masm. When

1. a structure is aligned to DWORD  AND
2. the current offset divided by 4 leaves a rest AND
3. an embedded union is following inside the struct

then Masm has problems. Masm v6.14/6.15 "usually" works, but Masm v9 "usually" crashes.

One location which causes such a problem can be found in WINCON.INC:


--------------------------------
INPUT_RECORD    struct 4
EventType    WORD ?
        WORD ?         ;<--- add this to make Masm v9 happy
union Event
KeyEvent    KEY_EVENT_RECORD    <>
MouseEvent    MOUSE_EVENT_RECORD    <>
WindowBufferSizeEvent    WINDOW_BUFFER_SIZE_RECORD    <>
MenuEvent    MENU_EVENT_RECORD    <>
FocusEvent    FOCUS_EVENT_RECORD    <>
ends
INPUT_RECORD    ends
--------------------------------


However, while the additional field will hopefully cure the problem, it also introduces a tiny incompatibility. For example, if someone has placed an initialized variable of type INPUT_RECORD in the data section:

v1   INPUT_RECORD <0,<>>

it will be rejected after the change because the value for the (new) second field is missing. This should be a rather rare case, though.

That's one of the reasons why JWasm is recommended to be used instead of Masm.


Btw, it's probably a good idea to ignore Dave's - usually very helpful - guesses in this case.
Title: Re: Win32Inc with ML v9
Post by: Tron2.0 on January 15, 2010, 05:57:28 PM
But i need the Japhet package because has include for DirectX9....
I'm getting crazy, because last year i have recoded some tutorials of DX9 using Win32Inc, but now don't assemble anything (with ML of Masm32 v10) and i don't remember HOW i did it......

Thanks to both of you.... :dance:

Update.... :U Gotcha!
Now works!
A suggestion...it's more prefereable to write:

EventType    WORD ?,?

to

EventType    WORD ?
        WORD ?         ;<--- add this to make Masm v9 happy

or are the same thing? (i have used the first one... :red)
Title: Re: Win32Inc with ML v9
Post by: dedndave on January 15, 2010, 07:09:06 PM
they are essentially the same thing
although, the second one is easier to notice

on DX9, you should be able to find the inc's you need to make it work with masm
(both masm and dx9 are ms, right ?)
what you need is the dx9 SDK - i bet UtillMasm has it   :U
Title: Re: Win32Inc with ML v9
Post by: Tron2.0 on January 19, 2010, 04:03:53 PM
I post this, just only to signal to Japhet.....

E:\DevsArea\MAsm32Extend\include\prsht.inc(69) : warning A6006:structure contains no members
E:\DevsArea\MAsm32Extend\include\prsht.inc(76) : warning A6006:structure contains no members
E:\DevsArea\MAsm32Extend\include\prsht.inc(78) : warning A6006:structure contains no members
E:\DevsArea\MAsm32Extend\include\ole2.inc(255) : warning A6006:structure contains no members

These include files (of Win32Inc package) contains empty structures.
Title: Re: Win32Inc with ML v9
Post by: japheth on January 20, 2010, 08:08:31 AM
Quote from: Tron2.0 on January 19, 2010, 04:03:53 PM
E:\DevsArea\MAsm32Extend\include\prsht.inc(69) : warning A6006:structure contains no members
E:\DevsArea\MAsm32Extend\include\prsht.inc(76) : warning A6006:structure contains no members
E:\DevsArea\MAsm32Extend\include\prsht.inc(78) : warning A6006:structure contains no members
E:\DevsArea\MAsm32Extend\include\ole2.inc(255) : warning A6006:structure contains no members

AFAICS this message occurs only if you set the -W3 option for Masm. Empty structures are valid. In this case, the following C header lines were translated by h2incX:


struct _PSP;

#ifndef MIDL_PASS
struct _PROPSHEETPAGEA;
struct _PROPSHEETPAGEW;
#endif