Well you create the name “ISA” but you are opening “KDISA”. So you are
not opening the device you think you are.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
-----Original Message-----
From: xxxxx@gmail.com [mailto:xxxxx@gmail.com]
Posted At: Saturday, March 20, 2010 2:33 PM
Posted To: ntdev
Conversation: Too much wired! CreateFile doesn’t works
Subject: Too much wired! CreateFile doesn’t works#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 hereint TestNo = 1;
DWORD error = 0 ;printf(“\nTest\n”);
////////////////////////////////////////////////////////////////////////
/
// Open device at IO ports 0x0378-0x37A and IRQ7printf(“\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 ?
__________ Information from ESET Smart Security, version of virus
signature
database 4961 (20100320) __________The message was checked by ESET Smart Security.