CodePudding user response:
The following are examples of hook comm
/*
First call: \ \. \ "COM1 CreateFileW"
Then call: \ \. \ "COM1 CreateFileA"
*/
HANDLE WINAPI myCreateFileA (LPCSTR lpFileName, dwords dwDesiredAccess DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes dwords dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{//unhook first
G_HookApi. UnhookOneApi (& amp; Myapi_info [CREATEFILEA]);
HANDLE HANDLE=CreateFileA (lpFileName dwDesiredAccess, dwShareMode, lpSecurityAttributes,
DwCreationDisposition dwFlagsAndAttributes, hTemplateFile);
//hook again
G_HookApi. HookOneApi (& amp; Myapi_info [CREATEFILEA]);
//
If (handle!=INVALID_HANDLE_VALUE)
{//handle
If (g_CommFile!=handle)//not comes
{//because first call: "\ \. \ COM1 CreateFileW"
Char * CommPort=0;
CommPort=STRRCHR (" c: "(lpFileName, '\' \ ');
If (CommPort) CommPort++;
The else CommPort=lpFileName (char *);
If (strnicmp (CommPort, "COM", 3)==0)
{//save the handle and the port name
G_CommFile=handle;
Strcpy (g_CommStruc.Com mName, CommPort);
# ifdef _DEBUG
SendData2Dialog (WM_CFA_MSG, (BYTE *) mName (g_CommStruc.Com), strlen (g_CommStruc.Com mName) + 1);
# endif
}
}
}
Return the handle.
}
//
HANDLE WINAPI myCreateFileW (LPCWSTR lpFileName, dwords dwDesiredAccess DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes dwords dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{//unhook first
G_HookApi. UnhookOneApi (& amp; Myapi_info [CREATEFILEW]);
HANDLE HANDLE=CreateFileW (lpFileName dwDesiredAccess, dwShareMode, lpSecurityAttributes,
DwCreationDisposition dwFlagsAndAttributes, hTemplateFile);
//hook again
G_HookApi. HookOneApi (& amp; Myapi_info [CREATEFILEW]);
//
If (handle!=INVALID_HANDLE_VALUE)
{
If (g_CommFile!=handle)
{
Char fname [MAX_PATH]={0}; COM1//'\ \ \'
WideCharToMultiByte (lpFileName CP_ACP, 0, 1, fname, MAX_PATH/2, NULL, NULL);
Char * CommPort=0;
CommPort=STRRCHR (" c: "(fname, '\' \ ');
If (CommPort) CommPort++;
The else CommPort=fname;
If (strnicmp (CommPort, "COM", 3)==0)
{//save the handle and the port name
G_CommFile=handle;
Strcpy (g_CommStruc.Com mName, CommPort);
# ifdef _DEBUG
SendData2Dialog (WM_CFW_MSG, (BYTE *) mName (g_CommStruc.Com), strlen (g_CommStruc.Com mName) + 1);
# endif
}
}
}
Return the handle.
}
CodePudding user response:
You can receive encrypted emailCodePudding user response:
If somebody else outside and put through a serial port to receive, how do you monitor?CodePudding user response: