转载请标明是引用于 http://blog.csdn.net/chenyujing1234
在上一节讲FwProxy工程的COM使用方法时,讲到了与它联系紧密的接口
HRESULT KTdiDriverProxy::Init(KProcessInfoMgr* pProcessMgr, KModuleMgr* pModuleMgr, KUrlMonCfg* pUrlCfgMon)
其实不只它与FwProxy联系紧密。
这里我们讲它们通信的另一个函数,
在放入线程池的任务WaitResponseThread中调用了OnApplicationRequest_,它对线程及服务进行Exe检查,并加入
HRESULT KTdiDriverProxy::OnApplicationRequest( RESPONSE_APP_REQUEST_INFO *pAppRequestInfo )
{
// 如果KTdiDriverProxy还没初始化或已经反初始化了,那么给FwProxy一个回复
if (!IsInit(m_hEventInit))
{
if( pAppRequestInfo->pResponseContext != NULL )
m_pFwProxy->SendResponse( pAppRequestInfo->pResponseContext, Pass);
return S_OK;
}
WAIT_RESPONSE_INFO *waitResponseInfo = new WAIT_RESPONSE_INFO;
if( waitResponseInfo == NULL )
return E_FAIL;
memcpy((char*)&waitResponseInfo->appResponseInfo, (char*)pAppRequestInfo, sizeof(RESPONSE_APP_REQUEST_INFO) );
waitResponseInfo->pThis = (PVOID)this;
waitResponseInfo->hEventInit = m_hEventInit;
InterlockedIncrement(&m_nWorkItemCount);
// 将一个任务项WaitResponseThread排列到线程池中
QueueUserWorkItem( WaitResponseThread, (LPVOID)waitResponseInfo, WT_EXECUTELONGFUNCTION );
return S_OK;
}
KTdiDriverProxy除了与 FwProxy通信,也与以下三个类。
KTdiDriverProxy中有亲密联系的还有三个类:
KProcessInfoMgr* m_pProcessMgr;
KModuleMgr* m_pModuleMgr;
KUrlMonCfg* m_pUrlCfgMon;
初始化:
HRESULT KTdiDriverProxy::Init(KProcessInfoMgr* pProcessMgr, KModuleMgr* pModuleMgr, KUrlMonCfg* pUrlCfgMon)
{
kws_log(TEXT("KTdiDriverProxy::Init begin"));
m_pProcessMgr = pProcessMgr;
m_pModuleMgr = pModuleMgr;
m_pUrlCfgMon = pUrlCfgMon;
通过以上的接口来实现木马网络防火墙的驱动接口。
实现以上功能的还有另一个类 KDeviceNameMgr
用于针对L"\\Device\\"与L"\\SystemRoot\\"的设备名去查找相应的路径
class KDeviceNameMgr
{
public:
KDeviceNameMgr();
~KDeviceNameMgr();
// 针对L"\\Device\\"与L"\\SystemRoot\\"的设备名去查找相应的路径
INT FixDosPathToNormalPath(LPCWSTR strDevicePath, WCHAR path[MAX_PATH]);
private:
// 从设备名列表中查找是否有此设备路径的设备存在,有则返回
BOOL DevicePathToDosPath(LPCWSTR strDevicepath, WCHAR path[MAX_PATH]);
// 获得系统Root名字
LPCWSTR GetSystemRoot() ;
// 重新刷新设备列表
void Refresh();
private:
kis::KLock m_lock;
map<wstring, wstring> m_DeviceNameMap;
wstring m_strSystemRoot;
};