2015-05-06 12:47:20 +00:00
|
|
|
/*
|
2015-07-06 12:41:06 +00:00
|
|
|
* PROJECT: ReactOS Local Port Monitor
|
2017-09-29 17:18:19 +00:00
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
2015-05-06 12:47:20 +00:00
|
|
|
* PURPOSE: Precompiled Header for all source files
|
2017-09-29 17:18:19 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 Colin Finck (colin@reactos.org)
|
2015-05-06 12:47:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PRECOMP_H
|
|
|
|
#define _PRECOMP_H
|
|
|
|
|
|
|
|
#define WIN32_NO_STATUS
|
2015-07-06 12:41:06 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-05-06 12:47:20 +00:00
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winreg.h>
|
|
|
|
#include <winspool.h>
|
|
|
|
#include <winsplp.h>
|
2015-07-06 12:41:06 +00:00
|
|
|
#include <winuser.h>
|
|
|
|
#include <ndk/rtlfuncs.h>
|
|
|
|
|
|
|
|
#include <spoolss.h>
|
2015-05-06 12:47:20 +00:00
|
|
|
|
|
|
|
#include <wine/debug.h>
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(localmon);
|
|
|
|
|
2015-07-06 12:41:06 +00:00
|
|
|
#include "resource.h"
|
|
|
|
|
2020-08-26 22:12:20 +00:00
|
|
|
#define SIGLCMMON 'FrCN'
|
|
|
|
#define SIGLCMPORT 'FrHK'
|
|
|
|
|
2015-07-06 12:41:06 +00:00
|
|
|
// Structures
|
2015-07-07 10:30:30 +00:00
|
|
|
/**
|
|
|
|
* Describes the monitor handle returned by InitializePrintMonitor2.
|
|
|
|
* Manages all available ports in this instance.
|
|
|
|
*/
|
|
|
|
typedef struct _LOCALMON_HANDLE
|
|
|
|
{
|
|
|
|
CRITICAL_SECTION Section; /** Critical Section for modifying or reading the ports. */
|
2020-08-26 22:12:20 +00:00
|
|
|
DWORD Sig;
|
2015-07-15 18:15:33 +00:00
|
|
|
LIST_ENTRY FilePorts; /** Ports created when a document is printed on FILE: and the user entered a file name. */
|
|
|
|
LIST_ENTRY RegistryPorts; /** Valid ports loaded from the local registry. */
|
2015-07-07 10:30:30 +00:00
|
|
|
LIST_ENTRY XcvHandles; /** Xcv handles created with LocalmonXcvOpenPort. */
|
|
|
|
}
|
|
|
|
LOCALMON_HANDLE, *PLOCALMON_HANDLE;
|
|
|
|
|
2015-07-06 12:41:06 +00:00
|
|
|
/**
|
|
|
|
* Describes the port handle returned by LocalmonOpenPort.
|
|
|
|
* Manages a legacy port (COM/LPT) or virtual FILE: port for printing as well as its associated printer and job.
|
|
|
|
*/
|
|
|
|
typedef struct _LOCALMON_PORT
|
|
|
|
{
|
|
|
|
LIST_ENTRY Entry;
|
2020-08-26 22:12:20 +00:00
|
|
|
PWSTR pwszPortName; /** The name of this port including the trailing colon. Empty for virtual file ports. */
|
|
|
|
PLOCALMON_HANDLE pLocalmon; /** Pointer to the parent LOCALMON_HANDLE structure. */
|
|
|
|
DWORD Sig;
|
2015-07-06 12:41:06 +00:00
|
|
|
enum {
|
2015-07-15 18:15:33 +00:00
|
|
|
PortType_Other = 0, /** Any port that doesn't belong into the other categories (default). */
|
|
|
|
PortType_FILE, /** A port created when a document is printed on FILE: and the user entered a file name. */
|
2015-07-06 12:41:06 +00:00
|
|
|
PortType_PhysicalCOM, /** A physical serial port (COM) */
|
2015-07-15 18:15:33 +00:00
|
|
|
PortType_PhysicalLPT /** A physical parallel port (LPT) */
|
2015-07-06 12:41:06 +00:00
|
|
|
}
|
|
|
|
PortType;
|
|
|
|
BOOL bStartedDoc; /** Whether a document has been started with StartDocPort. */
|
|
|
|
DWORD dwJobID; /** ID of the printing job we are processing (for later reporting progress using SetJobW). */
|
|
|
|
HANDLE hFile; /** Handle to the opened port or INVALID_HANDLE_VALUE if it isn't currently opened. */
|
|
|
|
HANDLE hPrinter; /** Handle to the printer for the job on this port (for using SetJobW). */
|
|
|
|
PWSTR pwszMapping; /** The current mapping of the DOS Device corresponding to this port at the time _CreateNonspooledPort has been called. */
|
|
|
|
}
|
|
|
|
LOCALMON_PORT, *PLOCALMON_PORT;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Describes the Xcv handle returned by LocalmonXcvOpenPort.
|
|
|
|
* Manages the required data for the Xcv* calls.
|
|
|
|
*/
|
|
|
|
typedef struct _LOCALMON_XCV
|
|
|
|
{
|
2015-07-07 10:30:30 +00:00
|
|
|
LIST_ENTRY Entry;
|
2015-07-06 12:41:06 +00:00
|
|
|
ACCESS_MASK GrantedAccess;
|
2015-07-07 10:30:30 +00:00
|
|
|
PLOCALMON_HANDLE pLocalmon;
|
2015-07-06 12:41:06 +00:00
|
|
|
PWSTR pwszObject;
|
|
|
|
}
|
|
|
|
LOCALMON_XCV, *PLOCALMON_XCV;
|
|
|
|
|
|
|
|
// main.c
|
|
|
|
extern DWORD cbLocalMonitor;
|
|
|
|
extern DWORD cbLocalPort;
|
|
|
|
extern PCWSTR pwszLocalMonitor;
|
|
|
|
extern PCWSTR pwszLocalPort;
|
|
|
|
void WINAPI LocalmonShutdown(HANDLE hMonitor);
|
|
|
|
|
|
|
|
// ports.c
|
|
|
|
BOOL WINAPI LocalmonClosePort(HANDLE hPort);
|
|
|
|
BOOL WINAPI LocalmonEndDocPort(HANDLE hPort);
|
|
|
|
BOOL WINAPI LocalmonEnumPorts(HANDLE hMonitor, PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned);
|
|
|
|
BOOL WINAPI LocalmonGetPrinterDataFromPort(HANDLE hPort, DWORD ControlID, PWSTR pValueName, PWSTR lpInBuffer, DWORD cbInBuffer, PWSTR lpOutBuffer, DWORD cbOutBuffer, PDWORD lpcbReturned);
|
|
|
|
BOOL WINAPI LocalmonOpenPort(HANDLE hMonitor, PWSTR pName, PHANDLE pHandle);
|
|
|
|
BOOL WINAPI LocalmonReadPort(HANDLE hPort, PBYTE pBuffer, DWORD cbBuffer, PDWORD pcbRead);
|
|
|
|
BOOL WINAPI LocalmonSetPortTimeOuts(HANDLE hPort, LPCOMMTIMEOUTS lpCTO, DWORD Reserved);
|
|
|
|
BOOL WINAPI LocalmonStartDocPort(HANDLE hPort, PWSTR pPrinterName, DWORD JobId, DWORD Level, PBYTE pDocInfo);
|
|
|
|
BOOL WINAPI LocalmonWritePort(HANDLE hPort, PBYTE pBuffer, DWORD cbBuf, PDWORD pcbWritten);
|
2020-08-26 22:12:20 +00:00
|
|
|
BOOL WINAPI LocalmonAddPort( HANDLE hMonitor, LPWSTR pName, HWND hWnd, LPWSTR pMonitorName );
|
|
|
|
BOOL WINAPI LocalmonAddPortEx( HANDLE hMonitor, LPWSTR pName, DWORD Level, LPBYTE lpBuffer, LPWSTR lpMonitorName );
|
|
|
|
BOOL WINAPI LocalmonConfigurePort( HANDLE hMonitor, LPWSTR pName, HWND hWnd, LPWSTR pPortName );
|
|
|
|
BOOL WINAPI LocalmonDeletePort( HANDLE hMonitor, LPWSTR pName, HWND hWnd, LPWSTR pPortName );
|
2015-07-06 12:41:06 +00:00
|
|
|
|
|
|
|
// tools.c
|
|
|
|
BOOL DoesPortExist(PCWSTR pwszPortName);
|
2017-10-30 21:43:47 +00:00
|
|
|
DWORD GetLPTTransmissionRetryTimeout(VOID);
|
2015-07-15 18:15:33 +00:00
|
|
|
DWORD GetPortNameWithoutColon(PCWSTR pwszPortName, PWSTR* ppwszPortNameWithoutColon);
|
2020-08-26 22:12:20 +00:00
|
|
|
DWORD GetTypeFromName(LPCWSTR name);
|
2015-07-06 12:41:06 +00:00
|
|
|
|
|
|
|
// xcv.c
|
|
|
|
BOOL WINAPI LocalmonXcvClosePort(HANDLE hXcv);
|
|
|
|
DWORD WINAPI LocalmonXcvDataPort(HANDLE hXcv, PCWSTR pszDataName, PBYTE pInputData, DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded);
|
|
|
|
BOOL WINAPI LocalmonXcvOpenPort(HANDLE hMonitor, PCWSTR pszObject, ACCESS_MASK GrantedAccess, PHANDLE phXcv);
|
|
|
|
|
2015-05-06 12:47:20 +00:00
|
|
|
#endif
|