-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathComProt.h
More file actions
89 lines (71 loc) · 1.97 KB
/
Copy pathComProt.h
File metadata and controls
89 lines (71 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "ComStruct.h"
#include "ReadProcess.h"
#define COM_PROT L"\\??\\COM2"
static HANDLE g_ComPortHandle = NULL;
static BOOLEAN g_StopComServer = FALSE;
class ComProt
{
public:
NTSTATUS StartComServer();
VOID StopComServer();
private:
NTSTATUS OpenComProt(OUT PHANDLE Handle, WCHAR * ComName = COM_PROT);
NTSTATUS SendComData(_In_ HANDLE hDevice,
_In_reads_bytes_opt_(nInBufferSize) PVOID lpInBuffer,
_In_ DWORD nInBufferSize);
NTSTATUS RecvComData(_In_ HANDLE hDevice,
_In_reads_bytes_opt_(nInBufferSize) PVOID lpInBuffer,
_In_ DWORD nInBufferSize);
private:
BOOLEAN DeviceIoControl(
_In_ HANDLE hDevice,
_In_ DWORD dwIoControlCode,
_In_reads_bytes_opt_(nInBufferSize) PVOID lpInBuffer,
_In_ DWORD nInBufferSize,
_Out_writes_bytes_to_opt_(nOutBufferSize, *lpBytesReturned) PVOID lpOutBuffer,
_In_ DWORD nOutBufferSize,
_Out_opt_ LPDWORD lpBytesReturned,
_Inout_opt_ LPOVERLAPPED lpOverlapped
);
private:
NTSTATUS SetupComm(IN HANDLE handle,
IN ULONG insize,
IN ULONG outsize);
BOOLEAN GetCommTimeouts(
_In_ HANDLE hFile,
_Out_ LPCOMMTIMEOUTS lpCommTimeouts
);
BOOLEAN SetCommTimeouts(
_In_ HANDLE hFile,
_In_ LPCOMMTIMEOUTS lpCommTimeouts
);
BOOLEAN GetCommState(
_In_ HANDLE hFile,
_Out_ LPDCB lpDCB
);
BOOLEAN SetCommState(
_In_ HANDLE hFile,
_In_ LPDCB lpDCB
);
BOOLEAN PurgeComm(
_In_ HANDLE hFile,
_In_ DWORD dwFlags
);
BOOLEAN ClearCommError(
_In_ HANDLE hFile,
_Out_opt_ LPDWORD lpErrors,
_Out_opt_ LPCOMSTAT lpStat
);
BOOLEAN SetCommMask(HANDLE handle,
DWORD evtmask);
BOOLEAN WaitCommEvent(
HANDLE hFile, /* [in] handle of comm port to wait for */
LPDWORD lpdwEvents, /* [out] event(s) that were detected */
LPOVERLAPPED lpOverlapped); /* [in/out] for Asynchronous waiting */
private:
static VOID ComServerWokerThread(__in PVOID Context);
private:
PETHREAD m_EThread = NULL;
ReadProcess m_ReadProcess;
};