如何判断串口是否被监控 我做了一个小程序,向串口发送数据,如何才能判断我要发送数据的串口有没有被拦截,主要是不想让别人看见我发的数据,前问如何判断电脑上是否开了串口拦截软件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是 hook comm的 例子/*first call: "\\.\COM1 CreateFileW"then call: "\\.\COM1 CreateFileA"*/ HANDLE WINAPI myCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile){// unhook first g_HookApi.UnhookOneApi(&myapi_info[CREATEFILEA]); HANDLE handle=CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);// hook again g_HookApi.HookOneApi(&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(lpFileName,'\\'); if(CommPort) CommPort++; else CommPort=(char*)lpFileName; if(strnicmp(CommPort,"COM",3)==0) {//save handle and port name g_CommFile=handle; strcpy(g_CommStruc.CommName,CommPort);#ifdef _DEBUG SendData2Dialog(WM_CFA_MSG,(BYTE*)(g_CommStruc.CommName),strlen(g_CommStruc.CommName)+1);#endif } } } return handle;}//HANDLE WINAPI myCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile){// unhook first g_HookApi.UnhookOneApi(&myapi_info[CREATEFILEW]); HANDLE handle=CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);// hook again g_HookApi.HookOneApi(&myapi_info[CREATEFILEW]);// if(handle != INVALID_HANDLE_VALUE) { if(g_CommFile != handle) { char fname[MAX_PATH]={0};//'\\.\COM1' WideCharToMultiByte(CP_ACP, 0, lpFileName, -1, fname, MAX_PATH/2 ,NULL,NULL); char *CommPort=0; CommPort=strrchr(fname,'\\'); if(CommPort) CommPort++; else CommPort=fname; if(strnicmp(CommPort,"COM",3)==0) {//save handle and port name g_CommFile = handle; strcpy(g_CommStruc.CommName,CommPort);#ifdef _DEBUG SendData2Dialog(WM_CFW_MSG,(BYTE*)(g_CommStruc.CommName),strlen(g_CommStruc.CommName)+1);#endif } } } return handle;} https://download.csdn.net/download/schlafenhamster/5202391本程序 窥视 串口的 活动。主要 hook 了: {"KERNEL32.DLL", "CreateFileA","myCreateFileA",(FARPROC)myCreateFileA}, {"KERNEL32.DLL", "CreateFileW","myCreateFileW",(FARPROC)myCreateFileW}, {"KERNEL32.DLL", "GetCommState","myGetCommState",(FARPROC)myGetCommState}, {"KERNEL32.DLL", "ReadFile", "myReadFile", (FARPROC)myReadFile}, {"KERNEL32.DLL", "ReadFileEx", "myReadFileEx", (FARPROC)myReadFileEx}, {"KERNEL32.DLL", "WriteFile", "myWriteFile", (FARPROC)myWriteFile}, {"KERNEL32.DLL", "WriteFileEx","myWriteFileEx",(FARPROC)myWriteFileEx}, {"KERNEL32.DLL", "CloseHandle","myCloseHandle",(FARPROC)myCloseHandle}, 刚进公司,还在试用期内,有法律与道德问题请教 不知道什么问题,有可能是窗口之间的通信问题 这个怎么这么麻烦啊?????? vc++6.0能不能使用vc7中的STL库呢? 跪求解决方案,急啊!! 怎样才能在往ListView里面添加元素的时候,让ListView自动向下滚动,多谢了 问大侠们一个数据结构的小问题 不想干了,心里很难受 Shell_NotifyIcon失败,很神奇的问题 强烈建议CSDN成立SDK讨论区!!!!!!!!!!!!!!!!!!!!!!! MFC对话框的一个疑问 CRichEditCtrl 控件显示异常,怎么回事?
first call: "\\.\COM1 CreateFileW"
then call: "\\.\COM1 CreateFileA"
*/
HANDLE WINAPI myCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{// unhook first
g_HookApi.UnhookOneApi(&myapi_info[CREATEFILEA]);
HANDLE handle=CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes,
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
// hook again
g_HookApi.HookOneApi(&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(lpFileName,'\\');
if(CommPort) CommPort++;
else CommPort=(char*)lpFileName;
if(strnicmp(CommPort,"COM",3)==0)
{//save handle and port name
g_CommFile=handle;
strcpy(g_CommStruc.CommName,CommPort);
#ifdef _DEBUG
SendData2Dialog(WM_CFA_MSG,(BYTE*)(g_CommStruc.CommName),strlen(g_CommStruc.CommName)+1);
#endif
}
}
}
return handle;
}
//
HANDLE WINAPI myCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{// unhook first
g_HookApi.UnhookOneApi(&myapi_info[CREATEFILEW]);
HANDLE handle=CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes,
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
// hook again
g_HookApi.HookOneApi(&myapi_info[CREATEFILEW]);
//
if(handle != INVALID_HANDLE_VALUE)
{
if(g_CommFile != handle)
{
char fname[MAX_PATH]={0};//'\\.\COM1'
WideCharToMultiByte(CP_ACP, 0, lpFileName, -1, fname, MAX_PATH/2 ,NULL,NULL);
char *CommPort=0;
CommPort=strrchr(fname,'\\');
if(CommPort) CommPort++;
else CommPort=fname;
if(strnicmp(CommPort,"COM",3)==0)
{//save handle and port name
g_CommFile = handle;
strcpy(g_CommStruc.CommName,CommPort);
#ifdef _DEBUG
SendData2Dialog(WM_CFW_MSG,(BYTE*)(g_CommStruc.CommName),strlen(g_CommStruc.CommName)+1);
#endif
}
}
}
return handle;
}