Hi all, I have just built a driver files(drv.sys) using DDK which can access I/O ports.
Then I build a program to run the _outpd/_inpd function via the driver under Win32.
And now I would like to make the driver included in the program and get a demo.exe file alone.When the program "demo.exe" is launched the program would use the driver which is contained in itself(driver is hidden).
How can it be?? Please help me and thanks a lot for any response.

The sample code is as follows:
Code:
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <winioctl.h>
using namespace std;
// Device type
#define FILE_DEVICE_MYPORT    0x0000f000

// I/O control code
#define MYPORT_IOCTL_BASE 0xf00
#define IOCTL_MYPORT_READ_DOUBLE   CTL_CODE(FILE_DEVICE_MYPORT, MYPORT_IOCTL_BASE, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_MYPORT_WRITE_DOUBLE  CTL_CODE(FILE_DEVICE_MYPORT, MYPORT_IOCTL_BASE+1, METHOD_BUFFERED, FILE_ANY_ACCESS)

const char p[]="drv.sys";		//My driver file is "drv.sys"
int loadsys(void)
{
....//process to load driver
}

int unloadsys(void)
{
....//process to unload driver
}

// Read DWORD from I/O port
// port: I/O port
DWORD Inportd(WORD port)
{
	//load drv.sys
	if(!loadsys())
	{
		cout<<"Load driver error!\n";
		exit(1);
	}
    ...
	HANDLE hFile=CreateFile(fp,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
	if(hFile!=INVALID_HANDLE_VALUE)
	{
		// Use IOCTL_MYPORT_READ_BYTE to read port
		DeviceIoControl(hFile,   // Device handle
        IOCTL_MYPORT_READ_DOUBLE,  // Control code
        buf, sizeof(buf),        // Input buffer
        buf, sizeof(buf),        // Output buffer
        &dwOutBytes,             // Output length
        (LPOVERLAPPED)NULL);     
		CloseHandle(hFile);
	}
	...//
	//Unload drv.sys
	if(!unloadsys())
	{
		cout<<"Unload driver Error!\n";
	}
	return buf[1];
}


// Write DWORD to I/O port
// port: I/O port
// data: Data
void Outportd(WORD port,DWORD data)
{
	//load drv.sys
	if(!loadsys())
	{
		cout<<"Load driver error!\n";
		exit(1);
	}
  ...//
	HANDLE hFile=CreateFile(fp,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
	if(hFile!=INVALID_HANDLE_VALUE)
	{
		DeviceIoControl(hFile,
        IOCTL_MYPORT_WRITE_DOUBLE,
        buf, sizeof(buf),
        buf, sizeof(buf),
        &dwOutBytes,
        (LPOVERLAPPED)NULL);	  
		CloseHandle(hFile);
	}
	...//
	//Unload drv.sys
	if(!unloadsys())
	{
		cout<<"Unload driver Error!\n";
	}
}
int main(void)
{
	DWORD data;
	Outportd(0xcf8,0x8000FA00);
	data=Inportd(0xcfc);
	cout<<"Offset: "<<data<<endl;
	return 0;
}