Exemplo n.º 1
0
DWORD DrvCtrl::Get_size(DWORD dwIoCode)
{
	DWORD dw = 0;
	if (!DeviceIoControl(m_hDriver, CTL_CODE_GEN(dwIoCode),
		0, 0, 0, 0, &dw, NULL))
	{
		PrintError();
		return 0;
	}
	_tprintf(L"Output Size:%d\n", dw);
	return dw;
}
Exemplo n.º 2
0
BOOL DrvCtrl::IoControl(DWORD dwIoCode, PVOID InBuff, DWORD InBufferLen,
	PVOID OutBuff, DWORD OutBuffLen)
{
	DWORD dw = 0;
	if (!DeviceIoControl(m_hDriver, CTL_CODE_GEN(dwIoCode),
		InBuff, InBufferLen, OutBuff, OutBuffLen, &dw, NULL))
	{
		PrintError();
		return 0;
	}
	_tprintf(L"Output Size:%d %p\n", dw, OutBuff);
	return 1;
}
Exemplo n.º 3
0
int SendMsgToDriver(int nCode)
{
	HANDLE device = NULL;
	ULONG ret_len;


	//打开设备
	device = CreateFile(CWK_DEV_SYM, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0);
	if (device == INVALID_HANDLE_VALUE)
	{
		ShowInfoInDlg(L"主线程:设备打开错误");
		return -1;
	}
	if (!DeviceIoControl(device, CTL_CODE_GEN(nCode), NULL, 0, NULL, 0, &ret_len, 0))//发送
	{
		ShowInfoInDlg(L"主线程:向驱动发送消息失败");
	}

	CloseHandle(device);
	return ret_len;
}
Exemplo n.º 4
0
PUCHAR GetPNbyET(UINT64 ethread)
{
	PUCHAR y = (PUCHAR)malloc(16);
	IoControl(hMyDrv ,CTL_CODE_GEN(0x7FF), &ethread, 8, y, 16);
	return y;
}
Exemplo n.º 5
0
void WKM(UINT64 Address, PVOID Buffer, SIZE_T Length)
{
	IoControl(hMyDrv ,CTL_CODE_GEN(0x809), &Address, 8, NULL, 0);		//address
	IoControl(hMyDrv ,CTL_CODE_GEN(0x80A), &Length, 8, NULL, 0);		//length
	IoControl(hMyDrv ,CTL_CODE_GEN(0x805), Buffer, Length, NULL, 0);	//set buffer
}