News:

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

Struc

Started by Rage9, February 16, 2007, 10:22:26 PM

Previous topic - Next topic

Rage9

I have a struc



sClient STRUC

param1 OVERLAPPED <>
param2 WSABUF <>

param3 DWORD ?
.
.
.
.

sClient        ENDS



and another variable


vAccept WSAEVENT <>



Fore some reason or another the compiler doesn't like the WSAEVENT and WSABUF data types.  Is there something I have to include to get these to work right?  Maybe some definition file?


Furthermore I pass this Struct to a couple procedures, however the compiler doesn't like:


AddClient proto stdcall :sClient


Instead compiler returns errors:


(40) : error A2006: undefined symbol : sClient
(40) : error A2195: parameter or local cannot have void type
(40) : error A2131: VARARG parameter requires C calling convention



Any help would be awesome.

Thanks in advance.

hutch--

Try it with the MASM form STRUCT. From memory STRUC is a TASM leftover.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rage9

Changed it to STRUCT makes no difference as it still doesn't like that WSABUF

Rage9

Here are my includes just in case your wondering if I have something included


include  c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\ws2_32.inc ; the winsock 2 include

includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\ws2_32.lib ; the winsock 2 library

hutch--

What you need to do is see if the structures you are calling exist. It would appear that your "sClient" structure is defining other structures which may not be available.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

WSABUF and WSAEVENT are declared in winsock2.h

#define WSAEVENT                HANDLE
typedef struct _WSABUF {
    u_long      len;     /* the length of the buffer */
    char FAR *  buf;     /* the pointer to the buffer */
} WSABUF, FAR * LPWSABUF;


AddClient proto stdcall :sClient
should be
AddClient proto stdcall :PTR sClient
or just
AddClient proto stdcall :DWORD
Light travels faster than sound, that's why some people seem bright until you hear them.

Rage9

Thanks so much sinsi, I just put :PTR in and it worked like a charm.

However still not understanding what I need to do to get WSABUF and WSAEVENT to work correctly.

Am I suppose to include winsock2.h?

Thanks in advance.

TNick

Hello!

WSABUF STRUCT
  len    DWORD   ?
  buf   DWORD   ?
WSABUF ENDS

WSAEVENT  TEXTEQU   <DWORD>


You should add this to your code. I can't seem to find those in masm32 include files ...

Regards,
Nick

Rage9

Thanks much TNick!

Having a few more problems yet:

I have a global array:

gClientArray sClient MAX_CLIENTS dup (<?>)


Of course sClient is the STRUCT and MAX_CLIENTS equ 10000.

2 questions on this,
1.  Why am I getting errors on compile about this?

(82) : error A2181: initializer must be a string or single item
(82) : error A2138: invalid data initializer


2.  Is there a way to make this dynamic?  Thus no need to set a max amount?


-----------------


I've got this is a situation:


local lClient:sClient,
       lpKey:DWORD

ASSUME ebx:PTR sClient

lea ebx, lClient
lea edx, gClientArray ;array of sClient STRUCT


lpKey will hold a key that will identify a client
ecx holds our counter

need to test gClientArray[ecx].mkey to lpKey
would it be like this

cmp (sClient PTR [edx][ecx]).mKey, lpKey


Not sure why I ask if it's right, because the compiler does not like it.

Then I need to move the entry, when found, from the global array to the local

-------------


Finally at some point and time I need to remove the clients info when they disconnect.

I just pass the number of it's global array position, but what would be the best way to zero it out?  Xor?  RtlZeroMemory?



Thanks much.




Rage9

I figured out everything except that first part with gClientArray.  For some reason or another.

Rage9

Played around with it, took out the ? and it worked WOOO! :U