News:

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

OOP Structure and PROTO + invoke

Started by Lupo1989, March 26, 2009, 11:57:19 AM

Previous topic - Next topic

Lupo1989

Hello MASM32 guys,

I have made sort of OOP structure with functions but right now i would like 2 call this function with a invoke. Is this possible or have i make my own macro for this?
I tried already to make a PROTO and call this function with invoke, but it didnt work
PERSOON_setGeboortedatum PROTO :DWORD, :DWORD

.code
invoke Persoon.Geboortedatum.set, 22, 05, 1989


My code how works already:
.486
.model flat, stdcall
option casemap: none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib


DATUM STRUCT ; Datum = Date
Dag DWORD ? ; Dag = Day
Maand DWORD ? ; Maand = Month
Jaar DWORD ? ; Jaar = Year

set dd PERSOON_setGeboortedatum
DATUM ENDS

PERSOON STRUCT
Geboortedatum DATUM <> ; Geboortedatum = Birthday

getInfo dd PERSOON_getInfo
PERSOON ENDS

.data
Persoon PERSOON <>

MenuName db "Structure Example", 0
TmpText db 20 dup (0)

.code
start:
;-----------------------------------------------------------------------------
push 1989
push 5
push 22
call Persoon.Geboortedatum.set
; How must i make a Invoke from this function? Or must i make a Macro for this?
;-----------------------------------------------------------------------------
call Persoon.getInfo
ret

PERSOON_setGeboortedatum proc varMaandDag:DWORD, varMaand:DWORD, varJaartal:DWORD
mov eax, varMaandDag
mov Persoon.Geboortedatum.Dag, eax
mov eax, varMaand
mov Persoon.Geboortedatum.Maand, eax
mov eax, varJaartal
mov Persoon.Geboortedatum.Jaar, eax
ret
PERSOON_setGeboortedatum endp

PERSOON_getInfo proc
LOCAL varMessage:DWORD
mov varMessage, offset TmpText
invoke dwtoa, Persoon.Geboortedatum.Dag, addr TmpText ; DWORD To String
invoke MessageBoxA, NULL, varMessage, offset MenuName, MB_OK
ret
PERSOON_getInfo endp

end start


Greeze , Lupo

drizz

Hi,

You need a type definition (TYPEDEF):
PERSOON_setGeboortedatum_TYPE TYPEDEF PROTO :DWORD, :DWORD, :DWORD
and a pointer to type definition (TYPEDEF PTR):
PERSOON_setGeboortedatum_POINTERTYPE TYPEDEF PTR PERSOON_setGeboortedatum_TYPE

DATUM STRUCT ; Datum = Date
Dag DWORD ? ; Dag = Day
Maand DWORD ? ; Maand = Month
Jaar DWORD ? ; Jaar = Year

set PERSOON_setGeboortedatum_POINTERTYPE PERSOON_setGeboortedatum
DATUM ENDS


PERSOON_getInfo_TYPE TYPEDEF PROTO
PERSOON_getInfo_POINTERTYPE TYPEDEF PTR PERSOON_getInfo_TYPE

PERSOON STRUCT
Geboortedatum DATUM <> ; Geboortedatum = Birthday
getInfo PERSOON_getInfo_POINTERTYPE PERSOON_getInfo
PERSOON ENDS

  invoke Persoon.Geboortedatum.set,1,2,3
  invoke Persoon.getInfo
The truth cannot be learned ... it can only be recognized.

Lupo1989

THX!! :D I understand now what to do, realy THX