News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Win32Inc with ML v9

Started by Tron2.0, January 15, 2010, 03:36:08 PM

Previous topic - Next topic

Tron2.0

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?

dedndave

see attached file...

Tron2.0

Dedndave, thank you for the help, but the error show up with Japhet's Win32Inc, not with the Masm32 include package.... :red

dedndave

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

japheth

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.

Tron2.0

#5
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)

dedndave

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

Tron2.0

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.

japheth

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