Sorry for any misgivings . I discribe my problem again

A ISA driver , the AddDevice( ) function is below,

/******************************************************************************************************/

#define NT_DEVICE_NAME L"\Device\KDISA"
#define DOS_DEVICE_NAME L"\DosDevices\KDISA"

NTSTATUS AddDevice( IN PDRIVER_OBJECT pDriverObject ,
IN PDEVICE_OBJECT pdo )

{

KdPrint( (“\n\n”) );
KdPrint(( “Enter ISADispatchCreateDevice . \n\n”));

NTSTATUS status = STATUS_SUCCESS;

PDEVICE_OBJECT fdo;
PISA_DEVICE_EXTENSION pdx;

/**********************************************************************/
// Initialise NT and Symbolic link names
UNICODE_STRING ntDeviceName ;
UNICODE_STRING win32DeviceName ;

RtlInitUnicodeString( &ntDeviceName , NT_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 ) ) ;

}

// Next, make the device accessible from user-mode applications.
// Note that this name can be either the same or different from
// the native “kernel mode” name of the device object, given above.
//

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 reinstalled the XP, and made a pure clean OS system.

I install the ISA.sys , and can find “KDISA” both in dirver folder and in device folder in the “WinObj.exe”

Then I run my APP as follows.

**********************************************************************/
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

Try:
??? HANDLE hPhdIo = CreateFile( “\\.\Global\KDISA”,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? GENERIC_READ|GENERIC_WRITE,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NULL,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OPEN_EXISTING,? //OPEN_EXISTING
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? FILE_ATTRIBUTE_NORMAL,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NULL);

Lijun


From: “xxxxx@gmail.com
To: Windows System Software Devs Interest List
Sent: Sun, March 21, 2010 1:08:31 AM
Subject: [ntdev] Sorry for any misgivings . I discribe my problem again

? A ISA driver ,? the? AddDevice( ) function is below,

//

#define??? NT_DEVICE_NAME??? L"\Device\KDISA"
#define DOS_DEVICE_NAME L"\DosDevices\KDISA"?

NTSTATUS AddDevice( IN PDRIVER_OBJECT pDriverObject ,? ? ? ? ? ???
??? ??? ??? ??? ? ? IN PDEVICE_OBJECT pdo )??? ??? ??? ??? ??? ???
??? ??? ??? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
{

??? KdPrint( (“\n\n”) );
??? KdPrint(( “Enter ISADispatchCreateDevice . \n\n”));

??? NTSTATUS status = STATUS_SUCCESS;

??? PDEVICE_OBJECT??? ??? ??? fdo;
??? PISA_DEVICE_EXTENSION??? pdx;

??? /
/
??? // Initialise NT and Symbolic link names
??? UNICODE_STRING ntDeviceName ;
??? UNICODE_STRING win32DeviceName ;

???
??? RtlInitUnicodeString( &ntDeviceName , NT_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 ) ) ;???

??? }

??? // Next, make the device accessible from user-mode applications.
??? // Note that this name can be either the same or different from
??? // the native “kernel mode” name of the device object, given above.
??? //

??? 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 reinstalled the XP, and made a pure clean OS system.

? I install the ISA.sys , and can find? “KDISA”? both in dirver folder and in device folder in the “WinObj.exe”?

? Then I run my APP as follows.

/
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

?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer