The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: vid on November 07, 2007, 05:35:47 PM

Title: more complicated structure declaration
Post by: vid on November 07, 2007, 05:35:47 PM
hi, how do i properly declare following types of structure members?

- pointer to another structure
- pointer to procedure

of course i can just make them DWORDS, but i wonder if there is better type (more explicit) for these.
Title: Re: more complicated structure declaration
Post by: Mark Jones on November 07, 2007, 07:24:23 PM
...
Title: Re: more complicated structure declaration
Post by: drizz on November 07, 2007, 10:23:30 PM
;; procedure prototype and pointer
myproc proto :dword,:dword
pmyproc typedef ptr myproc

;; structure definition and pointer
MYSTRUCT struct
MYSTRUCT ends
PMYSTRUCT typedef ptr MYSTRUCT
OTHERSTRUCT struct
  pmy PMYSTRUCT ?
  pp pmyproc ?
OTHERSTRUCT ends
POTHERSTRUCT typedef ptr OTHERSTRUCT

;;usage:
myother proc param:pmyproc
;; dummy code
invoke param,0,0 ;; this is why masm rocks
assume edi:POTHERSTRUCT
invoke [edi].pp,0,0 ;; this is why masm rocks

assume edi:nothing
ret
myother endp


Title: Re: more complicated structure declaration
Post by: Shell on November 08, 2007, 10:43:53 AM
Quote from: drizz on November 07, 2007, 10:23:30 PM
;; procedure prototype and pointer
myproc proto :dword,:dword
pmyproc typedef ptr myproc

;; structure definition and pointer
MYSTRUCT struct
MYSTRUCT ends
PMYSTRUCT typedef ptr MYSTRUCT
OTHERSTRUCT struct
  pmy PMYSTRUCT ?
  pp pmyproc ?
OTHERSTRUCT ends
POTHERSTRUCT typedef ptr OTHERSTRUCT

;;usage:
myother proc param:pmyproc
;; dummy code
invoke param,0,0 ;; this is why masm rocks
assume edi:POTHERSTRUCT
invoke [edi].pp,0,0 ;; this is why masm rocks

assume edi:nothing
ret
myother endp


:dazzled: OMG, you have no idea how invaluable this is for me at this very moment. Thank you once again drizz  :U
Title: Re: more complicated structure declaration
Post by: Vortex on November 08, 2007, 06:32:08 PM
assume edi:POTHERSTRUCT
invoke [edi].pp,0,0 ;; this is why masm rocks


or you could do without ASSUME :

invoke POTHERSTRUCT.pp[edi],0,0
Title: Re: more complicated structure declaration
Post by: vid on November 10, 2007, 04:43:17 PM
thanks drizz