WinComm/vbx/mscomm.h
Scott Duensing d68405550d Fix COMM.DRV calling conventions and add ComDEB compatibility
Resolve GPFs in both USER.EXE and COMMTASK.DLL by correcting RETF
sizes for SETCOM and GETDCB, confirmed by disassembling CyberCom.DRV.
Add stock-compatible ComDEB structure so third-party code (ProComm
COMMTASK.DLL) can safely access internal fields at known offsets per
Microsoft KB Q101417.

COMM.DRV changes:
- SETCOM (ord 2): RETF 4, takes DCB FAR * only (not commId + DCB*)
- GETDCB (ord 15): RETF 2, takes commId, returns DCB FAR * in DX:AX
- Add 40-byte ComDebT matching stock COMM.DRV internal layout
  (evtWord at +0, MSR shadow at +35, queue counts at +8/+18)
- cevt returns pointer to ComDebT for third-party compatibility
- Sync ComDEB fields in ISR dispatch, reccom, sndcom, cflush, setque
- Move WEP to ordinal 16, add ordinal 101 stub (match stock/CyberCom)
- Default DBG_ENABLED to 0 (set to 1 to re-enable debug logging)

VBX control fixes:
- Fix SETBREAK/CLRBREAK constants (use numeric 8/9, not undefined macros)
- Fix serialEnableNotify return type (BOOL, not int16_t)
- Fix mscomm.h to work with RC compiler (#ifndef RC_INVOKED)
- Fix vbapi.h USHORT typedef and MODEL.flWndStyle type
- Add vbapi.lib dependency to makefile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 20:03:34 -06:00

145 lines
5.8 KiB
C

// mscomm.h - MSComm VBX control definitions
//
// Property/event IDs, comm event constants, and control instance data.
#ifndef MSCOMM_H
#define MSCOMM_H
// -----------------------------------------------------------------------
// Resource IDs
// -----------------------------------------------------------------------
#define IDB_MSCOMM 8000
#ifndef RC_INVOKED
#include "vbapi.h"
#include "serial.h"
// -----------------------------------------------------------------------
// stdint types for MSVC 1.52 (shared with serial.h)
// -----------------------------------------------------------------------
#ifndef _STDINT_DEFINED
typedef short int16_t;
typedef unsigned short uint16_t;
typedef long int32_t;
typedef unsigned long uint32_t;
typedef unsigned char uint8_t;
typedef signed char int8_t;
#define _STDINT_DEFINED
#endif
// -----------------------------------------------------------------------
// Property indices (position in npproplist array)
// -----------------------------------------------------------------------
#define IPROP_CTLNAME 0
#define IPROP_INDEX 1
#define IPROP_TAG 2
#define IPROP_COMMPORT 3
#define IPROP_SETTINGS 4
#define IPROP_PORTOPEN 5
#define IPROP_INPUT 6
#define IPROP_OUTPUT 7
#define IPROP_INBUFFERSIZE 8
#define IPROP_OUTBUFFERSIZE 9
#define IPROP_INBUFFERCOUNT 10
#define IPROP_OUTBUFFERCOUNT 11
#define IPROP_RTHRESHOLD 12
#define IPROP_STHRESHOLD 13
#define IPROP_HANDSHAKING 14
#define IPROP_INPUTLEN 15
#define IPROP_INPUTMODE 16
#define IPROP_DTRENABLE 17
#define IPROP_RTSENABLE 18
#define IPROP_CDHOLDING 19
#define IPROP_CTSHOLDING 20
#define IPROP_DSRHOLDING 21
#define IPROP_BREAK 22
#define IPROP_COMMEVENT 23
#define IPROP_NULLDISCARD 24
#define IPROP_EOFENABLE 25
#define IPROP_PARITYREPLACE 26
// -----------------------------------------------------------------------
// Event indices (position in npeventlist array)
// -----------------------------------------------------------------------
#define IEVENT_ONCOMM 0
// -----------------------------------------------------------------------
// CommEvent constants - Communication events
// -----------------------------------------------------------------------
#define COM_EV_RECEIVE 1 // Received RThreshold bytes
#define COM_EV_SEND 2 // Transmit buffer has SThreshold space
#define COM_EV_CTS 3 // CTS line changed
#define COM_EV_DSR 4 // DSR line changed
#define COM_EV_CD 5 // CD (RLSD) line changed
#define COM_EV_RING 6 // Ring indicator detected
#define COM_EV_EOF 7 // EOF character received
// -----------------------------------------------------------------------
// CommEvent constants - Error events
// -----------------------------------------------------------------------
#define COM_EVT_BREAK 1001 // Break signal received
#define COM_EVT_FRAME 1004 // Framing error
#define COM_EVT_OVERRUN 1006 // Hardware overrun
#define COM_EVT_RXOVER 1008 // Receive buffer overflow
#define COM_EVT_RXPARITY 1009 // Parity error
#define COM_EVT_TXFULL 1010 // Transmit buffer full
// -----------------------------------------------------------------------
// Handshaking enum values
// -----------------------------------------------------------------------
#define HS_NONE 0
#define HS_XONXOFF 1
#define HS_RTSCTS 2
#define HS_BOTH 3
// -----------------------------------------------------------------------
// InputMode enum values
// -----------------------------------------------------------------------
#define INPUT_TEXT 0
#define INPUT_BINARY 1
// -----------------------------------------------------------------------
// Control instance data
//
// Allocated by VB as cbCtlExtra bytes per control instance.
// Accessed via VBDerefControl(hctl).
// -----------------------------------------------------------------------
typedef struct {
int16_t commId; // OpenComm handle (-1 = closed)
HWND hwndNotify; // Hidden notification window
int16_t commPort; // COM port number (1-16)
HSZ hszSettings; // Settings string "baud,parity,data,stop"
int16_t inBufferSize; // Receive buffer size in bytes
int16_t outBufferSize; // Transmit buffer size in bytes
int16_t rThreshold; // Receive event threshold (0=disabled)
int16_t sThreshold; // Send event threshold (0=disabled)
int16_t handshaking; // Handshaking mode (HS_*)
int16_t inputLen; // Bytes to read per Input (0=all)
int16_t inputMode; // Input mode (INPUT_TEXT/INPUT_BINARY)
int16_t commEvent; // Last comm event code
BOOL portOpen; // Port open state
BOOL dtrEnable; // DTR line enable
BOOL rtsEnable; // RTS line enable
BOOL breakState; // Break signal active
BOOL nullDiscard; // Discard null characters
BOOL eofEnable; // Watch for EOF character
BOOL ctsState; // Shadow state: CTS line level
BOOL dsrState; // Shadow state: DSR line level
BOOL cdState; // Shadow state: CD (RLSD) line level
HSZ hszParityReplace; // Parity error replacement character
} MsCommDataT;
// -----------------------------------------------------------------------
// Hidden notification window class name
// -----------------------------------------------------------------------
#define NOTIFY_CLASS "MsCommNotify"
// -----------------------------------------------------------------------
// Global instance handle (set in LibMain)
// -----------------------------------------------------------------------
extern HANDLE ghInstance;
#endif // RC_INVOKED
#endif // MSCOMM_H