News:

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

MSDN

Started by joerbanno, February 09, 2007, 04:33:30 PM

Previous topic - Next topic

joerbanno

Hi,

I've just another question, it's Masm related.
I'm trying to access network interface information, like what network devices are presented, which of them are enabled and more.
I use the API GetIfTable returning me a


MIB_IFTABLE  struct
   dwNumEntries DWORD 0
   table MIB_IFROW ANY_SIZE dup(<>)
MIB_IFTABLE  ENDS


The entry table is of type MIB_IFROW

MIB_IFROW STRUCT
  wszName WORD MAX_INTERFACE_NAME_LEN dup(0)
  dwIndex DWORD 0
  dwType DWORD 0
  dwMtu DWORD 0
  dwSpeed DWORD 0
  dwPhysAddrLen DWORD 0
  bPhysAddr BYTE MAXLEN_PHYSADDR dup(0)
  .... abbreviated
  dwDescrLen DWORD 0
  bDescr BYTE MAXLEN_IFDESCR dup(0)
MIB_IFROW ENDS


The MSDN implements the wszName as unicode (16bits in windows) in the current implementation.
The MSDN says about wszName:
QuotewszName A pointer to a Unicode string that contains the name of the interface
If that's correct shouldn't wszName not be a DWORD? :dazzled:

What's the word on this?
The funny thing is if I check the length of the wszName string with ucLen, I always end up with 0 :red

jag

A pointer is always a DWORD (well on x86 architecture.)
Normally in a string, each character is 8-bits ( 1 byte ) so each character can have 256 different values.
Unicode lets each character have 16-bits (2 bytes) so that each character can 65535 different values.

Your POINTER to the unicode string will still be a dword though the string structure differs.

MichaelW

From lprtrmib.h in the SDK:

typedef struct _MIB_IFROW
{
    WCHAR   wszName[MAX_INTERFACE_NAME_LEN];
    DWORD    dwIndex;
    DWORD    dwType;
    DWORD    dwMtu;
    DWORD    dwSpeed;
...

wszName is a Unicode string, not a pointer. WCHAR is defined in the header files as an unsigned short, so for MASM it is a WORD, as it is defined in the MASM32 windows.inc.
eschew obfuscation