I'm a little bit confused regarding windows.inc and the DCB structure. In the windows.inc file teh declaration is the following:
BITRECORD RECORD fBinary:1,fParity:1,fOutxCtsFlow:1,fOutxDsrFlow:1,fDtrControl:2,fDsrSensitivity:1,fTXContinueOnXoff:1,fOutX:1,fInX:1,fErrorChar:1,fNull:1,fRtsControl:2,fAbortOnError:1,fDummy2:17

  DCBlength    DWORD      ?
  BaudRate      DWORD      ?
  fbits        BITRECORD      <>
  wReserved    WORD      ?
  XonLim        WORD          ?
  XoffLim      WORD        ?
  ByteSize      BYTE        ?
  Parity        BYTE          ?
  StopBits      BYTE        ?
  XonChar      BYTE        ?
  XoffChar      BYTE        ?
  ErrorChar    BYTE      ?
  EofChar      BYTE        ?
  EvtChar      BYTE        ?
  wReserved1    WORD      ?

The problem is with the BITRECORD, because it's totally mirrored in comparison with the MSDN description:
typedef struct _DCB {
  DWORD DCBlength;
  DWORD BaudRate;
  DWORD fBinary  :1;
  DWORD fParity  :1;
  DWORD fOutxCtsFlow  :1;
  DWORD fOutxDsrFlow  :1;
  DWORD fDtrControl  :2;
  DWORD fDsrSensitivity  :1;
  DWORD fTXContinueOnXoff  :1;
  DWORD fOutX  :1;
  DWORD fInX  :1;
  DWORD fErrorChar  :1;
  DWORD fNull  :1;
  DWORD fRtsControl  :2;
  DWORD fAbortOnError  :1;
  DWORD fDummy2  :17;
  WORD wReserved;
  WORD XonLim;
  WORD XoffLim;
  BYTE ByteSize;
  BYTE Parity;
  BYTE StopBits;
  char XonChar;
  char XoffChar;
  char ErrorChar;
  char EofChar;
  char EvtChar;
  WORD wReserved1;
} DCB;

In C++ a bitfield starts with the LSB. So fBinary is on the first bit position. In Assembly language a RECORD starts with the MSB, wich is totally opposed to the C++.
MASK fBinary is equal with 8000 0000h and it should be equal with 0000 0001h.
The correct line would be:
BITRECORD RECORD fDummy2:17,fAbortOnError:1,fRtsControl:2,fNull:1,fErrorChar:1,fInX:1,fOutX:1,fTXContinueOnXoff:1,fDsrSensitivity:1,fDtrControl:2,fOutxDsrFlow:1,fOutxCtsFlow:1,fParity:1,fBinary:1

I think It would be great to change this in the future releases of the windows.inc.
BTW i'm using the MASM package.
Posted on 2005-05-04 13:27:27 by bszente