42#define MAX_PORTNAME_LEN 20
58#define MAX_BUFFER_SIZE 4096
68 szMsgBuffer[
i] =
L'-';
164 DWORD dwKbdDelay, dwKbdSpeed;
212 pcsbi->dwSize.X * pcsbi->dwSize.Y,
215 pcsbi->dwSize.X * pcsbi->dwSize.Y,
246 Width = pcsbi->srWindow.
Right - pcsbi->srWindow.Left + 1;
247 Height = pcsbi->srWindow.Bottom - pcsbi->srWindow.Top + 1;
262 ConRect.
Left = ConRect.
Top = 0;
325 if (!argStr)
goto invalid_parameter;
329 while (*argStr ==
L' ') argStr++;
330 if (!*argStr)
goto Quit;
331 if (*argStr++ !=
L',')
goto invalid_parameter;
332 while (*argStr ==
L' ') argStr++;
336 if (!argStr)
goto invalid_parameter;
340 while (*argStr ==
L' ') argStr++;
341 if (*argStr)
goto invalid_parameter;
363 DWORD dwKbdDelay, dwKbdSpeed;
384 while (argStr && *argStr)
386 while (*argStr ==
L' ') argStr++;
389 if (!kbdMode &&
_wcsnicmp(argStr,
L"COLS=", 5) == 0)
395 if (!argStr)
goto invalid_parameter;
398 else if (!kbdMode &&
_wcsnicmp(argStr,
L"LINES=", 6) == 0)
404 if (!argStr)
goto invalid_parameter;
407 else if (!dispMode &&
_wcsnicmp(argStr,
L"RATE=", 5) == 0)
412 if (!argStr)
goto invalid_parameter;
414 else if (!dispMode &&
_wcsnicmp(argStr,
L"DELAY=", 6) == 0)
419 if (!argStr)
goto invalid_parameter;
456 UINT uOldCodePage, uNewCodePage;
458 if ( (
_wcsnicmp(argStr,
L"SELECT=", 7) == 0 && (argStr += 7)) ||
459 (
_wcsnicmp(argStr,
L"SEL=", 4) == 0 && (argStr += 4)) )
462 if (!argStr)
goto invalid_parameter;
465 while (*argStr ==
L' ') argStr++;
466 if (*argStr)
goto invalid_parameter;
475 uNewCodePage =
value;
577 static const LPCWSTR parity_strings[] =
585 static const LPCWSTR control_strings[] = {
L"OFF",
L"ON",
L"HANDSHAKE",
L"TOGGLE" };
586 static const LPCWSTR stopbit_strings[] = {
L"1",
L"1.5",
L"2" };
596 if (dcb.Parity >=
ARRAYSIZE(parity_strings))
601 if (dcb.StopBits >=
ARRAYSIZE(stopbit_strings))
621 control_strings[dcb.fOutX ? 1 : 0]);
623 control_strings[dcb.fOutxCtsFlow ? 1 : 0]);
625 control_strings[dcb.fOutxDsrFlow ? 1 : 0]);
627 control_strings[dcb.fDsrSensitivity ? 1 : 0]);
675 if (!argStr)
return NULL;
684 case 11:
case 15:
case 30:
case 60:
689 case 12:
case 24:
case 48:
case 96:
739 if (!argStr)
return NULL;
742 if (*ByteSize < 5 || *ByteSize > 8)
760 else if (*argStr ==
L'2')
789 if (!argStr)
return FALSE;
796 while (*argStr ==
L' ') argStr++;
797 if (!*argStr)
goto Quit;
798 if (*argStr++ !=
L',')
return FALSE;
799 while (*argStr ==
L' ') argStr++;
800 if (!*argStr)
goto Quit;
808 if (!argStr)
return FALSE;
811 while (*argStr ==
L' ') argStr++;
812 if (!*argStr)
goto Quit;
813 if (*argStr++ !=
L',')
return FALSE;
814 while (*argStr ==
L' ') argStr++;
815 if (!*argStr)
goto Quit;
823 if (!argStr)
return FALSE;
826 while (*argStr ==
L' ') argStr++;
827 if (!*argStr)
goto Quit;
828 if (*argStr++ !=
L',')
return FALSE;
829 while (*argStr ==
L' ') argStr++;
830 if (!*argStr)
goto Quit;
839 if (!argStr)
return FALSE;
843 while (*argStr ==
L' ') argStr++;
844 if (!*argStr)
goto Quit;
845 if (*argStr++ !=
L',')
return FALSE;
846 while (*argStr ==
L' ') argStr++;
847 if (!*argStr)
goto Quit;
855 pDCB->fOutxCtsFlow =
FALSE;
856 pDCB->fOutxDsrFlow =
FALSE;
864 pDCB->fOutxCtsFlow =
FALSE;
865 pDCB->fOutxDsrFlow =
FALSE;
873 pDCB->fOutxCtsFlow =
TRUE;
874 pDCB->fOutxDsrFlow =
TRUE;
883 if (*argStr) argStr++;
886 while (*argStr ==
L' ') argStr++;
887 if (*argStr)
return FALSE;
892 if (pDCB->BaudRate == 110)
917 while (argStr && *argStr)
919 while (*argStr ==
L' ') argStr++;
926 if (!argStr)
return FALSE;
928 else if (
_wcsnicmp(argStr,
L"PARITY=", 7) == 0)
932 if (!argStr)
return FALSE;
938 if (!argStr)
return FALSE;
945 if (!argStr)
return FALSE;
951 if (!argStr)
return FALSE;
954 pCommTimeouts->ReadTotalTimeoutConstant = 0;
955 pCommTimeouts->WriteTotalTimeoutConstant = 0;
959 pCommTimeouts->ReadTotalTimeoutConstant = 60000;
960 pCommTimeouts->WriteTotalTimeoutConstant = 60000;
970 if (!argStr)
return FALSE;
985 if (!argStr)
return FALSE;
987 pDCB->fOutxDsrFlow =
value;
995 if (!argStr)
return FALSE;
997 pDCB->fOutxCtsFlow =
value;
1005 if (!argStr)
return FALSE;
1007 pDCB->fDtrControl =
value;
1015 if (!argStr)
return FALSE;
1017 pDCB->fRtsControl =
value;
1021 else if (
_wcsnicmp(argStr,
L"IDSR=", 5) == 0)
1025 if (!argStr)
return FALSE;
1027 pDCB->fDsrSensitivity =
value;
1040 if (baud && pDCB->BaudRate == 110)
1091 *PortNum =
wcstol(argStr, &endptr, 10);
1092 if (endptr == argStr)
1149 if (!argStr || *argStr || nPortNum == -1)
1162 if (!argStr || *argStr || nPortNum == -1)
1242 while (*argStr ==
L' ') argStr++;
1253 while (*argStr !=
L' ') argStr++;
1255 while (*argStr ==
L' ') argStr++;
1259 goto invalid_parameter;
1266 if (!argStr || nPortNum == -1)
1267 goto invalid_parameter;
1269 if (*argStr ==
L':') argStr++;
1270 while (*argStr ==
L' ') argStr++;
1272 if (!*argStr ||
_wcsnicmp(argStr,
L"/STA", 4) == 0)
1275 ConPuts(
StdErr,
L"ERROR: LPT port redirection is not implemented!\n");
1282 if (!argStr || nPortNum == -1)
1283 goto invalid_parameter;
1285 if (*argStr ==
L':') argStr++;
1286 while (*argStr ==
L' ') argStr++;
1288 if (!*argStr ||
_wcsnicmp(argStr,
L"/STA", 4) == 0)
1298 if (*argStr ==
L':') argStr++;
1299 while (*argStr ==
L' ') argStr++;
1301 if (!*argStr ||
_wcsnicmp(argStr,
L"/STA", 4) == 0)
1305 else if ( (
_wcsnicmp(argStr,
L"CP", 2) == 0 && (argStr += 2)) ||
1306 (
_wcsnicmp(argStr,
L"CODEPAGE", 8) == 0 && (argStr += 8)) )
1308 while (*argStr ==
L' ') argStr++;
1310 if (!*argStr ||
_wcsnicmp(argStr,
L"/STA", 4) == 0)
#define IDS_COM_STATUS_BAUD
#define IDS_ERROR_INVALID_PARAMETER
#define IDS_CONSOLE_KBD_DELAY
#define IDS_QUERY_DOSDEV_FOUND
#define IDS_QUERY_PRINTER_FOUND
#define IDS_COM_STATUS_XON_XOFF
#define IDS_COM_STATUS_PARITY
#define IDS_CONSOLE_STATUS_COLS
#define IDS_PRINTER_OUTPUT_REROUTED_SERIAL
#define IDS_ERROR_ILLEGAL_DEVICE_NAME
#define IDS_CONSOLE_CODEPAGE
#define IDS_CONSOLE_KBD_RATE
#define IDS_ERROR_QUERY_DEVICES_FORM
#define IDS_ERROR_INVALID_PARITY_BITS
#define IDS_COM_STATUS_STOP_BITS
#define IDS_DEVICE_STATUS_HEADER
#define IDS_COM_STATUS_DSR_HANDSHAKING
#define IDS_ERROR_TIMEOUT_GET_DEVICE
#define IDS_COM_STATUS_DTR_CIRCUIT
#define IDS_ERROR_TIMEOUT_SET_DEVICE
#define IDS_CONSOLE_STATUS_LINES
#define IDS_ERROR_DEVICE_NOT_AVAILABLE
#define IDS_ERROR_INVALID_STOP_BITS
#define IDS_ERROR_STATUS_SET_DEVICE
#define IDS_COM_STATUS_DSR_SENSITIVITY
#define IDS_ERROR_SCREEN_LINES_COL
#define IDS_PRINTER_OUTPUT_NOT_REROUTED
#define IDS_COM_STATUS_TIMEOUT
#define IDS_COM_STATUS_CTS_HANDSHAKING
#define IDS_ERROR_INVALID_CODEPAGE
#define IDS_ERROR_STATUS_GET_DEVICE
#define IDS_COM_STATUS_RTS_CIRCUIT
#define IDS_COM_STATUS_DATA_BITS
BOOL WINAPI SetConsoleOutputCP(IN UINT wCodepage)
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
void ConPuts(FILE *fp, LPCWSTR psz)
#define ConInitStdStreams()
void ConPrintf(FILE *fp, LPCWSTR psz,...)
void ConResPrintf(FILE *fp, UINT nID,...)
void ConResPuts(FILE *fp, UINT nID)
#define ERROR_INSUFFICIENT_BUFFER
_Check_return_ _In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS _Out_ UINT _Out_ UINT * Height
_Check_return_ _In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS _Out_ UINT * Width
#define INVALID_HANDLE_VALUE
#define HeapFree(x, y, z)
#define ERROR_ACCESS_DENIED
BOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, CONST SMALL_RECT *lpConsoleWindow)
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP(UINT wCodePageID)
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW(IN HANDLE hConsoleOutput, IN WCHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
BOOL WINAPI DefineDosDeviceW(DWORD dwFlags, LPCWSTR lpDeviceName, LPCWSTR lpTargetPath)
DWORD WINAPI QueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax)
BOOL WINAPI SetCommTimeouts(HANDLE hComm, LPCOMMTIMEOUTS lptimeouts)
BOOL WINAPI SetCommState(HANDLE handle, LPDCB lpdcb)
BOOL WINAPI GetCommState(HANDLE handle, LPDCB lpdcb)
BOOL WINAPI GetCommTimeouts(HANDLE hComm, LPCOMMTIMEOUTS lptimeouts)
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP(void)
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(void)
_ACRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *,...)
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
int SetParallelState(INT nPortNum)
int SetSerialState(INT nPortNum, IN PCWSTR ArgStr)
static PCWSTR ParseModes(PCWSTR argStr, PBYTE Mode)
static PCWSTR ParseBaudRate(PCWSTR argStr, PDWORD BaudRate)
VOID __cdecl UnderlinedResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
static BOOL SerialPortQuery(INT nPortNum, LPDCB pDCB, LPCOMMTIMEOUTS pCommTimeouts, BOOL bWrite)
static VOID ClearScreen(IN HANDLE hConOut, IN PCONSOLE_SCREEN_BUFFER_INFO pcsbi)
static BOOL BuildNewCommDCB(OUT LPDCB pDCB, OUT LPCOMMTIMEOUTS pCommTimeouts, IN PCWSTR ArgStr)
int ShowConsoleCPStatus(VOID)
int SetConsoleCPState(IN PCWSTR ArgStr)
static PCWSTR FindPortNum(PCWSTR argStr, PINT PortNum)
int SetConsoleStateOld(IN PCWSTR ArgStr)
static BOOL BuildOldCommDCB(OUT LPDCB pDCB, IN PCWSTR ArgStr)
int ShowSerialStatus(INT nPortNum)
static PCWSTR ParseByteSize(PCWSTR argStr, PBYTE ByteSize)
int SetConsoleState(IN PCWSTR ArgStr)
static PCWSTR ParseStopBits(PCWSTR argStr, PBYTE StopBits)
int ShowParallelStatus(INT nPortNum)
static PCWSTR ParseNumber(PCWSTR argStr, PDWORD Number)
int EnumerateDevices(VOID)
static PCWSTR ParseParity(PCWSTR argStr, PBYTE Parity)
static BOOL ResizeTextConsole(IN HANDLE hConOut, IN OUT PCONSOLE_SCREEN_BUFFER_INFO pcsbi, IN COORD Resolution)
int ShowConsoleStatus(VOID)
#define _swprintf(buf, format,...)
#define show_status(counter, text)
INT ConResPrintfV(IN PCON_STREAM Stream, IN UINT uID, IN va_list args)
INT ConStreamWrite(IN PCON_STREAM Stream, IN PCTCH szStr, IN DWORD len)
#define SPI_SETKEYBOARDSPEED
#define SPIF_UPDATEINIFILE
#define SPI_GETKEYBOARDSPEED
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define SPI_GETKEYBOARDDELAY
#define SPI_SETKEYBOARDDELAY
#define ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage)
LANGID ConSetThreadUILanguage(IN LANGID LangId OPTIONAL)
DWORD WriteTotalTimeoutConstant
DWORD ReadTotalTimeoutConstant
#define STD_OUTPUT_HANDLE
#define RTS_CONTROL_ENABLE
#define DTR_CONTROL_HANDSHAKE
DWORD WINAPI GetLastError(void)
#define RTS_CONTROL_HANDSHAKE
#define DTR_CONTROL_ENABLE
#define DDD_REMOVE_DEFINITION
_IRQL_requires_same_ _In_ CLONG ByteSize