CreateFile problem with SCSI miniport driver

Hi all:
I have a problem with using CreateFile to communicate with my SCSI Miniport
driver. In all cases I logged in as administrator to perform the test.

References:
HANDLE CreateFile(
LPCTSTR lpFileName, // file name
DWORD dwDesiredAccess, // access mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle to template file
);

BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
LPVOID lpInBuffer,
DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped);

Problem A:

In the driver:

#define ADMA_DEVICE_NAME L"adma"

ULONG DriverEntry(
IN PVOID DriverObject,
IN PVOID Argument2
)
{
UNICODE_STRING symbolName;

pDriverObj = DriverObject;
RtlInitUnicodeString(&symbolName, ADMA_DEVICE_NAME);
yError = IoCreateSymbolicLink(&symbolName,
&(((PDRIVER_OBJECT)DriverObject)->DriverName));

The driver successfully created the symbolic link “adma”. QueryDosDevice()
API shows “adma” has been recognized.

In the application:

hDevice = CreateFile(“\\.\adma”,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);

CreateFile return INVALID_HANDLE_VALUE.
I got stuck on this problem and tried a different appoach as follow:

Problem B:

In the application:
#define FILE_DEVICE_ADMA 33333

#define EXPERIMENT_IOCTL_CODE \
CTL_CODE( FILE_DEVICE_ADMA, 0xA00, METHOD_BUFFERED, FILE_READ_ACCESS)

hDevice = CreateFile(“\\.\PhysicalDrive0”,
0,
FILE_SHARE_READ |FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
CreateFile now returns successfully.

if (DeviceIoControl(hDevice, EXPERIMENT_IOCTL_CODE, &input, sizeof(input),
&output, sizeof(output), &bufLen, NULL)) {

}
else {
lastError = GetLastError();
}

DeviceIoControl fails and lastError returns with access denied (code 5). I
logged in as administrator.

Please help,

Much appreciated

Don


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Don,

I wonder why don’t you use just \.\Scsi%u as most people do? And use
IOCTL_SCSI_MINIPORT to communicate with your miniport driver.

Regards,
Anton

I have a problem with using CreateFile to communicate with my SCSI Miniport
driver. In all cases I logged in as administrator to perform the test.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Use IOCTL_SCSI_MINIPORT to do such things.
Also use \.\Scsi%d: instead of \.\adma

Max

----- Original Message -----
From: Don Doan
To: NT Developers Interest List
Sent: Friday, August 31, 2001 2:06 AM
Subject: [ntdev] CreateFile problem with SCSI miniport driver

Hi all:

I have a problem with using CreateFile to communicate with my SCSI Miniport driver. In all cases I logged in as administrator to perform the test.

References:

HANDLE CreateFile(

LPCTSTR lpFileName, // file name

DWORD dwDesiredAccess, // access mode

DWORD dwShareMode, // share mode

LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD

DWORD dwCreationDisposition, // how to create

DWORD dwFlagsAndAttributes, // file attributes

HANDLE hTemplateFile // handle to template file

);

BOOL DeviceIoControl(

HANDLE hDevice,

DWORD dwIoControlCode,

LPVOID lpInBuffer,

DWORD nInBufferSize,

LPVOID lpOutBuffer,

DWORD nOutBufferSize,

LPDWORD lpBytesReturned,

LPOVERLAPPED lpOverlapped);

Problem A:

In the driver:

#define ADMA_DEVICE_NAME L"adma"

ULONG DriverEntry(

IN PVOID DriverObject,

IN PVOID Argument2

)

{

UNICODE_STRING symbolName;

pDriverObj = DriverObject;

RtlInitUnicodeString(&symbolName, ADMA_DEVICE_NAME);

yError = IoCreateSymbolicLink(&symbolName, &(((PDRIVER_OBJECT)DriverObject)->DriverName));

The driver successfully created the symbolic link “adma”. QueryDosDevice() API shows “adma” has been recognized.

In the application:

hDevice = CreateFile(“\\.\adma”,

GENERIC_READ,

FILE_SHARE_READ,

NULL,

OPEN_EXISTING,

0,

NULL);

CreateFile return INVALID_HANDLE_VALUE.

I got stuck on this problem and tried a different appoach as follow:

Problem B:

In the application:

#define FILE_DEVICE_ADMA 33333

#define EXPERIMENT_IOCTL_CODE \

CTL_CODE( FILE_DEVICE_ADMA, 0xA00, METHOD_BUFFERED, FILE_READ_ACCESS)

hDevice = CreateFile(“\\.\PhysicalDrive0”,

0,

FILE_SHARE_READ |FILE_SHARE_WRITE,

NULL,

OPEN_EXISTING,

0,

NULL);

CreateFile now returns successfully.

if (DeviceIoControl(hDevice, EXPERIMENT_IOCTL_CODE, &input, sizeof(input), &output, sizeof(output), &bufLen, NULL)) {

}

else {

lastError = GetLastError();

}

DeviceIoControl fails and lastError returns with access denied (code 5). I logged in as administrator.

Please help,

Much appreciated

Don


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Anton and Max:

Thanks for the suggestion. I am able to make it work now with \.\Scsi%u and
IOCTL_SCSI_MINIPORT.

Don

-----Original Message-----
From: xxxxx@hotmail.com [mailto:xxxxx@hotmail.com]

Sent: Friday, August 31, 2001 12:13 AM
To: NT Developers Interest List
Subject: [ntdev] Re: CreateFile problem with SCSI miniport driver

Hi Don,

I wonder why don’t you use just \.\Scsi%u as most people do? And use
IOCTL_SCSI_MINIPORT to communicate with your miniport driver.

Regards,
Anton

I have a problem with using CreateFile to communicate with my SCSI
Miniport
driver. In all cases I logged in as administrator to perform the test.


You are currently subscribed to ntdev as: xxxxx@PacificDigital.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com