一个用VC的编写vxd的源代码

源代码在线查看: win32app.c

软件大小: 137 K
上传用户: simoncxl
关键词: vxd 编写 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include 
				#include 
				#include 
				#include "apcvxd.h"
				
				HANDLE	hDevice;     
				char     buf[80];
				DWORD WINAPI CallbackFromVxD(PVOID param);
				
				
				DWORD WINAPI CallbackFromVxD(PVOID param)
				{
				   VMINFO *pVmInfo = param;
				
				   printf("VM %08lx was %s\r\n", pVmInfo->hVM, 
				           pVmInfo->bVmCreated ? "created" : "destroyed" );
				   DeviceIoControl(hDevice, APCVXD_RELEASEMEM, pVmInfo, sizeof(pVmInfo),0,0,0,0);
				   return 0;
				}
				
				void main(int ac, char* av[])
				{
				   DWORD err;
					const PCHAR VxDName = "\\\\.\\APCVXD.VXD";
				
					hDevice = CreateFile(VxDName, 0,0,0,
				                        CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0);
				
					if (hDevice == INVALID_HANDLE_VALUE)
					{
						err = GetLastError();
				   	printf("Cannot load VxD, error=%08lx\n", err );
						if (err == ERROR_NOT_SUPPORTED)
						{
							DeleteFile("\\\\.\\DMABUF");
						}
					 	exit(1);
					}
				
					if ( !DeviceIoControl(hDevice, APCVXD_REGISTER,
				               &CallbackFromVxD, sizeof(void *),
				               NULL, 0, NULL, NULL))
					{
				   		printf("DeviceIoControl failed, error=%d\n", GetLastError() );
					}
				   else
				   {
				   	printf("press ctrl-C to exit . . .\n");
				
				   	while (TRUE)
				   	{
				   		SleepEx(-1, TRUE);
				   	}
				   }
				}
							

相关资源