News:

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

WINDOWS.INC for ML.EXE Version 8.0

Started by hutch--, July 10, 2006, 01:34:59 PM

Previous topic - Next topic

hutch--

I have just finished editing the last of the old MASM format records out of the file and replacing them with the published structures from the PLATFORMSDK. This version of WINDOWS.INC should be compatible with ML Version 8.0.  Note that I have not added the extra equates that have been suggested as I have not had time to verify them yet.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi Hutch,

Thanks for this new release. I tested this new version of windows.inc with ml.exe and link.exe V8.0 , it works fine.

[attachment deleted by admin]

ToutEnMasm


There is just a littlle problem with macros that couldn't be placed before windows.inc and made an error at compiile time with windows.inc in a structure.Put them after and it is good.
With the last version,the macros should be before windows.inc.
                                       ToutEnMasm

                             

Vortex

Can you give information about those macros? Which ones are the cause of error messages emitted by the assembler?

ToutEnMasm

Hello,

Ok,following is a complete report of the error.

                           ToutEnMasm
Assembling: antispam.asm
\masm32\include\windows.inc(17536) : error A2191: cannot include structure in self

the lines of windows.inc

FPOProlog RECORD cbFrame  : 2, reserved : 1, fUseBP   : 1, fHasSEH  : 1, cbRegs   : 3, cbProlog : 8
FPO_DATA STRUCT
    ulOffStart    dd ?
    cbProcSize    dd ?
    cdwLocals    dd ?
    cdwParams    dw ?
    rProlog FPOProlog <>                 ;the line 17536
FPO_DATA ENDS


and the Macros








   HIWORD MACRO ParamFen
      mov eax,ParamFen
      shr eax,16
   ENDM
   LOWORD MACRO ParamFen
      mov eax,ParamFen
      and eax,0FFFFh
   ENDM

      FUNC MACRO parameters:VARARG
        invoke parameters
        EXITM <eax>
      ENDM

      PuPo MACRO M1, M2
        push M2
        pop  M1
      ENDM
   InsTxt MACRO Name, Text:VARARG
   LOCAL lbl
      jmp lbl
      Name db Text,0
   lbl:
   ENDM
   return MACRO valeur
      mov eax,valeur
      ret
   ENDM
   
   
      ZEROLOCALES MACRO dernierelocale:REQ
         mov ecx,ebp
         lea edx,dernierelocale
         sub ecx,edx
         .if ecx != 0
            push edi
            mov edi,edx
            mov al,0
            cld
            rep stosb
            pop edi         
         .endif
      ENDM


    ; --------------------------------------------------------
    ; Crée une donnée en data,renvoie l'étiquette de la chaine
    ; La création du nom de l'étiquette est facultatif
    ; la macro vérifie la syntaxe des chaines et étiquettes
    ; ---------------------------------------------------------
      CREDATA MACRO quoted_text:REQ,NomdeChaine
      LOCAL Local_Etiquette,verif
   IFNB <NomdeChaine>         ;present
      verif SUBSTR <NomdeChaine>,1,1
            IFIDN verif,<">            ;si le premier caractere est "
         .ERR  <ETIQUETTE SUPRIMER les " >         
      ENDIF
   Local_Etiquette TEXTEQU <NomdeChaine>      ;changer le nom d'étiquette
   ENDIF
   verif SUBSTR <quoted_text>,1,1            
   IFDIF verif,<">
      .ERR  <CHAINE AJOUTER LES " >
   ENDIF
   
      .data
      Local_Etiquette db quoted_text,0
      .code
      EXITM <Local_Etiquette>
      ENDM
    ; ----------------------------------------------------
    ; Sort l' adresse de la chaine créer, SADR("chaine")
    ; -----------------------------------------------------
         SADR MACRO quoted_text:REQ,NomdeChaine
           EXITM <ADDR CREDATA(quoted_text,NomdeChaine)>
         ENDM
    ; ----------------------------------------------------
    ; Sort l' offset de la chaine créer, SADR("chaine")
    ; -----------------------------------------------------
   SOFF MACRO quoted_text:REQ,NomdeChaine
           EXITM <Offset CREDATA(quoted_text,NomdeChaine)>
         ENDM   

  ; ---------------------------------------------------
  ; return an arguments specified in "num" from a macro
  ; argument list or "-1" if the number is out of range
  ; ---------------------------------------------------
    getarg MACRO num:REQ,args:VARARG
      LOCAL cnt, txt
      cnt = 0
      FOR arg, <args>
        cnt = cnt + 1
        IF cnt EQ num
          txt TEXTEQU <arg>     ;; set "txt" to content of arg num
          EXITM
        ENDIF
      ENDM
      IFNDEF txt
        txt TEXTEQU <-1>        ;; return -1 if num out of range
      ENDIF
      EXITM txt
    ENDM
   
  ; -----------------------------------------------
  ; count the number of arguments passed to a macro
  ; This is a slightly modified 1990 MASM 6.0 macro
  ; -----------------------------------------------
    argcount MACRO args:VARARG
      LOCAL cnt
      cnt = 0
      FOR item, <args>
        cnt = cnt + 1
      ENDM
      EXITM %cnt                ;; return as a number
    ENDM      
;la macro peut s'écrire plus simplement
;mais hélas,la boucle FOR ... génère un "internal error" lorsque le fichier inclus
;contient des macros,les macro argcount et getarg sont la pour y remédier
LIB  MACRO args:VARARG
   LOCAL acnt,buffer,var,boucle,buf1
   acnt = argcount(args)         ;macro argcount , nb d'arguments
   var = 1
   :boucle
   buffer equ getarg(var,args)      ;macro getarg

   buf1 CATSTR <include \masm32\include\>,buffer,<.inc>
   buf1

   buf1 CATSTR <includelib \masm32\lib\>,buffer,<.lib>
   buf1

   var = var + 1
   IF var LE acnt
   goto boucle
   ENDIF
ENDM



   comment µ
   lea edx,FindeProgramme
   invoke InstalleExceptions,SADR("c:\masm32\ref\dbghelp.dll"),\
         DebutdeProgramme,edx
   .if eax == 0
      jmp Findeminus
   .endif
   mov Hdbghelp,eax
   µ

;--------------- macro pour exception ------------------------------------------------
   ;usage
   ;EXCEPT ("je me trouve dans macro.inc"),Nomproc,Param1,Param2.....
   ;remplace: invoke Nomproc,Param1,Param2

   EXCEPT MACRO NomProc:REQ,parameters:VARARG
      LOCAL Local_Etiquette
      LOCAL localinvoke
      ;rajouter des push içi pour augmenter le nombre de renseignements      
      xor eax,eax   ;retour   
      push eax                        ;pointeur +24
      push EBP     ;sauvegarde ebp                 ;pointeur +20
      lea eax,localinvoke
      push eax                        ;pointeur +16 la pile
      
      mov eax,ADRESSE NomProc                  ;pointeur +12
               ;la phrase identifiant l'erreur
      push eax           ;
      lea eax,Local_Etiquette
      push eax                        ;pointeur +8
      lea eax,HANDLER   ;la nouvelle routine d'exceptions
      push eax                        ;pointeur +4
      assume FS:NOTHING
      push FS:[0]          ;conserve l'ancien pointeur sur ERR      ;pointeur +0
      mov FS:[0],esp         ;remplacer l'ancien pointeur sur ERR par le nouveau,--
      localinvoke:      ;---------------ce qui du meme coup sauvegarde esp
      invoke parameters   ;rajouter la ligne tel que
      mov [esp+24],eax   ;tout s'est bien passer,préserve la valeur de retour
      Local_Etiquette:      
      mov eax,[esp+24]   ;prend la valeur de retour ,modifié en cas d'exceptions
      pop FS:[0]             ;retablir l'ancien err quand la zone protégée est terminée
      add esp,24             ;6 dword en pile effacer
   ENDM
   
   ADRESSE MACRO bidule:REQ
      EXITM <offset CREDATA (bidule)>
   ENDM

   HAUTEUR MACRO Adrrect:REQ
      push ebx
      lea ebx,Adrrect
      mov     eax,(RECT ptr [ebx]).bottom                 ; y bas origine coin haut gauche 0,0
      sub     eax,(RECT ptr [ebx]).top              ; y haut   
      pop ebx
   EXITM <eax>
   ENDM
   LARGEUR MACRO Adrrect:REQ
      push ebx
      lea ebx,Adrrect
      mov     eax,(RECT ptr [ebx]).right       ; x coin droit bas  origine coin haut gauche 0,0
      sub     eax, (RECT ptr [ebx]).left      ; x coin gauche haut
      pop ebx
   EXITM <eax>
   ENDM









hutch--

Thanks for finding these left over records, I had not searched for RECORD in upper case so I missed it. Would you try this out to make sure it works OK.

Relpace the first commented out part with the new structure. I have copied it from the PLATFORMSDK and converted it to MASM format.


; FPOProlog RECORD cbFrame  : 2, reserved : 1, fUseBP   : 1, fHasSEH  : 1, cbRegs   : 3, cbProlog : 8
; FPO_DATA STRUCT
;     ulOffStart dd   ?
;     cbProcSize dd   ?
;     cdwLocals dd    ?
;     cdwParams dw    ?
; rProlog FPOProlog <>
; FPO_DATA ENDS

FPO_DATA STRUCT
    ulOffStart  dd ?
    cbProcSize  dd ?
    cdwLocals   dd ?
    cdwParams   dw ?
    cbProlog    dw ?
    cbRegs      dw ?
    fHasSEH     dw ?
    fUseBP      dw ?
    reserved    dw ?
    cbFrame     dw ?
FPO_DATA ENDS
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

japheth


Hi,

sizeof FPO_DATA is 16, so your new declaration can't be correct. Don't let yourself confuse by the C declaration of bitfields.

ToutEnMasm



I will kept the order for the two files,like that the size of the structure is save,seems to be bug.
one solution

FPOProlog RECORD cbFrame  : 2, reserved : 1, fUseBP   : 1, fHasSEH  : 1, cbRegs   : 3, cbProlog : 8
FPO_DATA STRUCT
    ulOffStart    dd  ?
    cbProcSize    dd  ?
    cdwLocals    dd  ?
    cdwParams    dw  ?
    rProlog                    dw  ?      ;FPOProlog <>
FPO_DATA ENDS

Like that it's not wrong


                                     ToutEnMasm

               

GregL

MASM 8.0 doesn't support RECORD? That sucks. They can be very handy.




japheth

Quote from: Greg on July 15, 2006, 08:37:59 PM
MASM 8.0 doesn't support RECORD? That sucks. They can be very handy.



who tells this? that's not true. masm 8 offers little new compared to previous versions, but why should they delete the record feature. This sample works:

----------------------------------------------------------
        .386
        .MODEL flat, stdcall
   option casemap:none

FPO_DATA   struct
ulOffStart   DWORD   ?
cbProcSize   DWORD   ?
cdwLocals   DWORD   ?
cdwParams   WORD   ?
FPO_DATA_R0   RECORD   cbProlog:8,cbRegs:3,fHasSEH:1,fUseBP:1,reserved:1,cbFrame:2
   FPO_DATA_R0 <>
FPO_DATA   ends

      .data

fpod   FPO_DATA <>

        .CODE

   mov eax, sizeof FPO_DATA             

        END
---------------------------------------------------------------------

the FPO_DATA structure declaration comes from a MASM32 competitor product, but I will allow Hutch to copy it for MASM32  :green2

GregL

japeth,

Sorry, I guess I misunderstood, I thought you guys were eliminating the RECORD statements.

I haven't been using MASM 8.0 much, 6.15 works very well and does everything I need to do.


hutch--

I confess its been so long since I have used MASM records I forget how they work.  :red What I did with the example was take it directly from the platformsdk and convert it to masm format but it looks like I have messed up the conversion.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm

Hello,

I confirm that the version following is of good size and don't create error message.
The record is also correct,that it is not in windows.inc.

FPO_DATA   struct
ulOffStart   DWORD   ?
cbProcSize   DWORD   ?
cdwLocals   DWORD   ?
cdwParams   WORD   ?
FPO_DATA_R0   RECORD   cbProlog:8,cbRegs:3,fHasSEH:1,fUseBP:1,reserved:1,cbFrame:2
   FPO_DATA_R0 <>
FPO_DATA   ends

japheth

> I confess its been so long since I have used MASM records I forget how they work

That's quite natural. Even at MS they seem to have forgotten them when they did develop MASM 6. While on previous versions structure member names must have been unique (thats why all member names in BITMAP have the "bm" prefix, for example), they changed this in MASM 6, but forgot to add this feature to RECORDs and this is still true with current versions.

hutch--

I have just done another hit at cleaning up the windows.inc file and about all I need done now is rewriting the RECORD listings that are used in some structures to have the file in very good shape.

This is the list of records that were in the file. The problem for me is I don't have any code that can test it so I need someone who is more familiar with the old RECORD format to rewrite the following and test them to make sure they work correctly.


;;;; record

COMRECORD RECORD fCtsHold:1, fDsrHold:1,fRlsdHold:1,fXoffHold:1,fXoffSent:1,fEof:1,fTxim:1,fReserved:25

COMSTAT STRUCT
  comrec    COMRECORD     <>
  cbInQue   DWORD       ?
  cbOutQue  DWORD      ?
COMSTAT ENDS

BITRECORD RECORD fBinary:1,fParity:1,fOutxCtsFlow:1,fOutxDsrFlow:1,fDtrControl:2,fDsrSensitivity:1,fTXContinueOnXoff:1,fOutX:1,fInX:1,fErrorChar:1,fNull:1,fRtsControl:2,fAbortOnError:1,fDummy2:17

DCB STRUCT
  DCBlength     DWORD      ?
  BaudRate      DWORD       ?
  fbits         BITRECORD      <>
  wReserved     WORD       ?
  XonLim        WORD          ?
  XoffLim       WORD         ?
  ByteSize      BYTE        ?
  Parity        BYTE          ?
  StopBits      BYTE        ?
  XonChar       BYTE         ?
  XoffChar      BYTE        ?
  ErrorChar     BYTE       ?
  EofChar       BYTE         ?
  EvtChar       BYTE         ?
  wReserved1    WORD       ?
DCB ENDS

LDTBits RECORD  rBaseHi:8, Granularity:1,Default_Big : 1,Reserved_0:1,Sys:1,LimitHi:4,Pres:1, Dpl:2, S_bit:1, Type1:4,rBaseMid:8

LDT_ENTRY STRUCT
    LimitLow dw ?
    BaseLow dw ?
    union HighWord1
        Bytes LDT_BYTES <>
        Bits LDTBits <>
    ends
LDT_ENTRY ENDS

ImportRec RECORD Reserved : 11,NameType : 3,Type2 : 2

IMPORT_OBJECT_HEADER STRUCT
    Sig1 dw     ?
    Sig2 dw     ?
    Version dw  ?
    Machine dw  ?
    TimeDateStamp dd ?
    SizeOfData dd   ?
    union
        Ordinal dw  ?
        Hint dw     ?
    ends
    rImport ImportRec <>
IMPORT_OBJECT_HEADER ENDS

SHELLFLAGSTATE record fShowAllObjects:1,fShowExtensions:1, fNoConfirmRecycle:1,fShowSysFiles:1,fShowCompColor:1,fDoubleClickInWebView:1,fDesktopHTML:1,fWin95Classic:1,fDontPrettyPath:1,fShowAttribCol:1,fMapNetDrvBtn:1,fShowInfoTip:1,fHideIcons:1, fRestFlags:3
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php