www.pudn.com > PCIConf.rar > test.cpp
#include "stdafx.h" #include#include #include #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; }