⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app.c

📁 这是一本学习 window编程的很好的参考教材
💻 C
字号:
///////////////////////////////////////////////////////////////////////
// App.c
//
// Test application for CHIKAGO.VXD VxD.

#include "Windows.h"
#include <stdio.h>
#include <winioctl.h>
#include "..\VxD\Chikintr.h"
HANDLE hDevice;
struct APCDataXX
{
	
  DWORD dwThreadOrProcess; // Which one Thread or Process
  DWORD dwCreated; // What happened , created or destroyed
  DWORD dwIdDATA; // What PID /TID ??
} ;

void APCFunc(struct APCDataXX * data)
{
	if(data->dwThreadOrProcess==TRUE)
	{
		if(data->dwCreated==TRUE)
		{
			printf("Process Created %u\n",data->dwIdDATA);
		}
		else
		{
				printf("Process Destroyed %u\n",data->dwIdDATA);
		}
	}
	else
	{
		if(data->dwCreated ==TRUE)
		{	
			printf("Thread Created %u\n",data->dwIdDATA);
		}
		else
		{
			printf("Thread Destroyed %u\n",data->dwIdDATA);
		}
			

	}
		DeviceIoControl(hDevice, IOCTL_RELEASE, &data, sizeof(PVOID),0,0,0,0);
		//Call this to release the memory allocated in VXD.
}

int main()
{
	
	BOOL bRet;
	DWORD cbRet;
	char buf[80];

	PVOID inbuf;
	inbuf=APCFunc;
	// Open handle to VxD
	SetCurrentDirectory("..\\\\BIN");
	hDevice = CreateFile("\\\\.\\CHIKAGO.VXD",
				0,
				0, 
				NULL, 
				0,
				FILE_FLAG_DELETE_ON_CLOSE,
				NULL); 

	if (hDevice == INVALID_HANDLE_VALUE)
		printf("Failed to open handle to CHIKAGO.VXD\n");
	else
	{
		// Send the VxD a test IOCTL
		bRet = DeviceIoControl(hDevice,
					(DWORD)IOCTL_TEST,
					&inbuf,
					sizeof(PVOID),
					buf,
					sizeof(buf),
					&cbRet,
					NULL);

		// Display the return from the VxD
		if (bRet)
			printf("Press CTRL+C to terminate\n");
		else
			printf("IOCTL_TEST failed\n");

		while(1)
			SleepEx(-1,TRUE);
		
		CloseHandle(hDevice);
	}
				
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -