The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: gavin on September 08, 2005, 09:51:40 AM

Title: How do i make a structure (struct)
Post by: gavin on September 08, 2005, 09:51:40 AM
Hi guys .

I've read the masm32 about structures.
But i'm working on finding a file path and have to search the hdd .
How and where is a structure defined.

In the msdn the structure is like so.


ypedef struct _WIN32_FIND_DATA {
  DWORD dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD nFileSizeHigh;
  DWORD nFileSizeLow;
  DWORD dwReserved0;
  DWORD dwReserved1;
  TCHAR cFileName[MAX_PATH];
  TCHAR cAlternateFileName[14];
} WIN32_FIND_DATA,
*PWIN32_FIND_DATA,
*LPWIN32_FIND_DATA;


Thanks .
Title: Re: How do i make a structure (struct)
Post by: Tedd on September 08, 2005, 11:33:57 AM
That one is already in windows.inc

--- rip --- rip --- rip --- rip --- rip --- rip --- rip --- rip --- rip ---

WIN32_FIND_DATA STRUCT
  dwFileAttributes      DWORD      ?
  ftCreationTime        FILETIME <>
  ftLastAccessTime      FILETIME <>
  ftLastWriteTime       FILETIME <>
  nFileSizeHigh         DWORD      ?
  nFileSizeLow          DWORD      ?
  dwReserved0           DWORD      ?
  dwReserved1           DWORD      ?
  cFileName             BYTE MAX_PATH dup(?)
  cAlternate            BYTE 14 dup(?)
WIN32_FIND_DATA ENDS

--- rip --- rip --- rip --- rip --- rip --- rip --- rip --- rip --- rip ---
Title: Re: How do i make a structure (struct)
Post by: gavin on September 08, 2005, 12:52:08 PM
Thanks as always Tedd.

How would i use this struct.


.data?
Like WIN32_FIND_DATA STRUCT <>


I'm not sure on the use of them yet.
The explanation is not enough from the examples in the help file.
Thanks.
Title: Re: How do i make a structure (struct)
Post by: Jeff on September 08, 2005, 01:52:06 PM
yes that is fine but without the STRUCT, just the type is fine.  if you wanted it initialized, you could fill in its members like so:

.DATA?
Like WIN32_FIND_DATA <>     ;take the default values as defined in the structure

.DATA
This WIN32_FIND_DATA <23, , , ,0,213h, , ,"something.txt">
;first member gets 23
;take default value for the next 3 members
;file size is 0:00000213h
;next 2 members default
;file name is "something.txt"
;default for last member

SOME_STRUCT STRUCT
    member1 DWORD ?
    member2 DWORD 8000h
    member3 DWORD ?
SOME_STRUCT ENDS

that SOME_STRUCT <4000h, , 0C000h>
;the same as putting "that SOME_STRUCT <4000h,8000h,0C000h>"


hope that helps
Title: Re: How do i make a structure (struct)
Post by: Tedd on September 08, 2005, 05:22:13 PM
As for actual usage, an example might be a bit more helpful..

<attachment>

This shows how to reference a member of a structure (though there are other more direct ways)


[attachment deleted by admin]
Title: Re: How do i make a structure (struct)
Post by: P1 on September 08, 2005, 06:25:53 PM
l_Process_Information PROCESS_INFORMATION <>
I use the Structure Name with a l_ in front on it for simple stuff.  l_ is for local.

Regards,  P1  :8)
Title: Re: How do i make a structure (struct)
Post by: Mark Jones on September 08, 2005, 07:10:48 PM
Quote from: gavin on September 08, 2005, 12:52:08 PM
Thanks as always Tedd.

How would I use this struct?


.data?
    MyFile WIN32_FIND_DATA STRUCT<>


Hi Gavin, you should also be able to initialize the members like this:


include masm32rt.inc
.data?
    MyFile WIN32_FIND_DATA STRUCT<>
.code
    mov MyFile.dwfileAttributes,23
    mov MyFile.nFileSizeLow,213h
    m2m MyFile.cFileName,CHR$("somefile.txt",0)