#define NT_DEVICE_NAME L"\Device\ISA"
#define DOS_DEVICE_NAME L"\DosDevices\ISA"
/**********************************************************************/
// Initialise NT and Symbolic link names
UNICODE_STRING ntDeviceName ;
UNICODE_STRING win32DeviceName ;
//???
RtlInitUnicodeString( &ntDeviceName , NT_DEVICE_NAME ) ;
//???
// RtlInitUnicodeString( &win32DeviceName , DOS_DEVICE_NAME );
RtlInitUnicodeString( &win32DeviceName , DOS_DEVICE_NAME );
// Create our device ???
KdPrint( ( " Call IoCreateDevice … \n\n") );
status = IoCreateDevice( pDriverObject ,
sizeof( ISA_DEVICE_EXTENSION ) ,
&ntDeviceName ,
FILE_DEVICE_UNKNOWN ,
0 ,
FALSE ,
&fdo ) ;
if ( !NT_SUCCESS( status ) ) // can’t create device object
{
KdPrint( ( "IoCreateDevice failed - %x … \n\n " , status ) ) ;
KdPrint( ( “Could not create device \n\n”) ) ;
return status;
}
else
{
KdPrint( ( “IoCreateDevice Success - %x\n\n\n” , status ) ) ;
}
status = IoCreateSymbolicLink( &win32DeviceName , &ntDeviceName ) ;
if (!NT_SUCCESS(status))
{
KdPrint( ( “IoCreateSymbolicLink failed. Status = 0x%x\n\n\n”, status )) ;
IoDeleteDevice( fdo );
// Indicate load failure to the I/O manager; driver image is deleted…
return status ;
}
else
{
KdPrint( ( “IoCreateSymbolicLink Success - %x\n\n\n” , status ) ) ;
}
/***************************************************************/
I have installed the dirver , and I can see it in the WinObj.exe ,
then I run the test APP
/**********************************************************************/
void CISATestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
int TestNo = 1;
DWORD error = 0 ;
printf(“\nTest\n”);
/////////////////////////////////////////////////////////////////////////
// Open device at IO ports 0x0378-0x37A and IRQ7
printf(“\nTest %d\n”,TestNo++);
HANDLE hPhdIo = CreateFile( “\\.\KDISA”,
GENERIC_READ|GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING, //OPEN_EXISTING
FILE_ATTRIBUTE_NORMAL,
NULL);
if( hPhdIo == INVALID_HANDLE_VALUE )
{
error = GetLastError() ;
printf(“XXX Could not open device\n”);
// AfxMessageBox(" Could not open device ");
int x = 0 ;
}
else
{
AfxMessageBox(" open device OK ");
}
}
/**********************************************************************/
the hPhdIo = 0XFFFFFFFF, and GetLastError( ) return 2
what is the problem ?