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

📄 test.cpp

📁 配置PCI配置空间的驱动程序源代码
💻 CPP
字号:
#include "stdafx.h"
#include <winioctl.h>
#include <conio.h>
#include <tchar.h>
#include "install.h"
#include "..\sys\ioctls.h"

int main(int argc, char* argv[])
{
	int i;
	char szFullPathName[255];
	
	unsigned long PCIBuses[16];
	unsigned long PCIBuffer[2];
	int Bus, Device;

	GetCurrentDirectory(255, szFullPathName);
	strcat(szFullPathName, "\\PCIConf.inf");
	printf("%s\n", szFullPathName);
	i=InstallDriver(szFullPathName, _T("*WCO0904"));
	printf("InstallDriver = %d\n", i);
	HANDLE hdevice = CreateFile("\\\\.\\PCICONF", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
	if (hdevice == INVALID_HANDLE_VALUE)
	{
		printf("Unable to open IOCTL device - error %d\n", GetLastError());
		return 1;
	}
	DWORD junk;
	
	for(Bus=0; Bus<5; Bus++)
	{
		for(Device=0; Device<32; Device++)
		{
			PCIBuses[0]=Bus;
			PCIBuses[1]=Device;

			DeviceIoControl(hdevice, IOCTL_GET_PCI_BUF, PCIBuses, sizeof(unsigned int)*2, PCIBuffer, sizeof(unsigned long)*16, &junk, NULL);
			if(junk>5)
			{
				printf("\nBus=%x\tDevice=%x\n", Bus, Device);
				for(i=0; i<16; i++)
					printf("%x : %8lx\n", i, PCIBuffer[i]);
			}
		}
	}
	
	getch();

	CloseHandle(hdevice);
	i=RemoveDriver(_T("*WCO0904"));
	printf("RemoveDriver = %d\n", i);
	printf("Game Over!\n");
	printf("Press any key to exit...\n");
	getch();
	return 0;
}

⌨️ 快捷键说明

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