Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
Hallo
I am not sure about scsi in particular but I am calling the ZwXxx
functions successfully from within the serial.sys serial port driver
for Windows 2000. You have to call this function while you are below
IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
DISPATCH_LEVEL). The dispatch functions are normally called at user
level which is acceptable to call the Zwxxx functions.
regards
Henko
-----Original Message-----
From: ? ? [mailto:xxxxx@hotmail.com]
Sent: 17 March 2003 14:23
To: NT Developers Interest List
Subject: [ntdev] About ZwCreateFile
Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
You are currently subscribed to ntdev as: xxxxx@telkom.co.za
To unsubscribe send a blank email to xxxxx@lists.osr.com
I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi miniport,
but Calling ZwCreateFile in the DriverEntry Routing just failed¡£
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 14:39:45 +0200
>
>Hallo
>
>I am not sure about scsi in particular but I am calling the ZwXxx
>functions successfully from within the serial.sys serial port driver
>for Windows 2000. You have to call this function while you are below
>IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
>DISPATCH_LEVEL). The dispatch functions are normally called at user
>level which is acceptable to call the Zwxxx functions.
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 14:23
>To: NT Developers Interest List
>Subject: [ntdev] About ZwCreateFile
>
>
>Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£ http://www.hotmail.com
Here is an example. You are not the first one to have suffered from
the seemingly innocent ZwCreateFile.
I am sure the IoStatusBlock.Information checks can be done more
elegant but this works for the interim
regards
Henko
irql = KeGetCurrentIrql();
if (irql < DISPATCH_LEVEL)
{
DbgPrint(“Current irql = %d is lower than dispatch
level\n”, irql);
}
else
{
// Here is trouble - equal or higher than dispatch
level
DbgPrint(“ERROR: Current irql = %d is equal or higher
than dispatch level\n”, irql);
}
// Add code to open file on disk to write circular buffer - Henko
RtlInitUnicodeString(&filename, L"\??\c:\driver3.txt");
InitializeObjectAttributes(&initializedAttributes, &filename,
OBJ_CASE_INSENSITIVE, NULL, NULL);
ntStatus =
ZwCreateFile
(
&fileHandle,
FILE_WRITE_DATA,
&initializedAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT, //
FILE_NON_DIRECTORY_FILE,
NULL,
0
);
if (NT_SUCCESS(ntStatus))
{
DbgPrint(“Zw Create file was successful”);
}
else
{
DbgPrint(“Zw Create file was NOT successful”);
}
if (IoStatusBlock.Information & FILE_CREATED)
{
DbgPrint(“ZwCreateFile result = FILE_CREATED”);
}
if (IoStatusBlock.Information & FILE_OPENED)
{
DbgPrint(“ZwCreateFile result = FILE_OPENED”);
}
if (IoStatusBlock.Information & FILE_OVERWRITTEN)
{
DbgPrint(“ZwCreateFile result = FILE_OVERWRITTEN”);
}
if (IoStatusBlock.Information & FILE_SUPERSEDED)
{
DbgPrint(“ZwCreateFile result = FILE_SUPERSEDED”);
}
if (IoStatusBlock.Information & FILE_EXISTS)
{
DbgPrint(“ZwCreateFile result = FILE_EXISTS”);
}
if (IoStatusBlock.Information & FILE_DOES_NOT_EXIST)
{
DbgPrint(“ZwCreateFile result = FILE_DOES_NOT_EXIST”);
}
// strcpy(buffer, “This is to test the driver writing
characters to a file”);
// size = strlen(buffer);
// size = 25;
sprintf(buf, “This is to test the driver writing characters to
a file”);
length = strlen(buf);
ntStatus = ZwWriteFile
(
fileHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
buf,
length,
NULL,
NULL
);
if (NT_SUCCESS(ntStatus))
{
DbgPrint(“ZwWrite file was successful”);
}
else
{
DbgPrint(“ZwWrite file was NOT successful”);
}
ntStatus = ZwClose(fileHandle);
// End - Add code to open file on disk to write circular buffer -
Henko
regards
Henko
-----Original Message-----
From: ? ? [mailto:xxxxx@hotmail.com]
Sent: 17 March 2003 16:13
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi
miniport,
but Calling ZwCreateFile in the DriverEntry Routing just failed??
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 14:39:45 +0200
>
>Hallo
>
>I am not sure about scsi in particular but I am calling the ZwXxx
>functions successfully from within the serial.sys serial port driver
>for Windows 2000. You have to call this function while you are below
>IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
>DISPATCH_LEVEL). The dispatch functions are normally called at user
>level which is acceptable to call the Zwxxx functions.
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 14:23
>To: NT Developers Interest List
>Subject: [ntdev] About ZwCreateFile
>
>
>Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
???ĵ???ʼ?ϵͳ?? MSN Hotmail?? http://www.hotmail.com
—
You are currently subscribed to ntdev as: xxxxx@telkom.co.za
To unsubscribe send a blank email to xxxxx@lists.osr.com
Let me try first!!!
thansk a lot!!
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 16:24:06 +0200
>
>Here is an example. You are not the first one to have suffered from
>the seemingly innocent ZwCreateFile.
>
>I am sure the IoStatusBlock.Information checks can be done more
>elegant but this works for the interim
>
>regards
>Henko
>
> irql = KeGetCurrentIrql();
> if (irql < DISPATCH_LEVEL)
> {
> DbgPrint(“Current irql = %d is lower than dispatch
>level\n”, irql);
> }
> else
> {
> // Here is trouble - equal or higher than dispatch
>level
> DbgPrint(“ERROR: Current irql = %d is equal or higher
>than dispatch level\n”, irql);
> }
>
> // Add code to open file on disk to write circular buffer - Henko
>
>
> RtlInitUnicodeString(&filename, L"\??\c:\driver3.txt");
> InitializeObjectAttributes(&initializedAttributes, &filename,
>OBJ_CASE_INSENSITIVE, NULL, NULL);
> ntStatus =
> ZwCreateFile
> (
> &fileHandle,
> FILE_WRITE_DATA,
> &initializedAttributes,
> &IoStatusBlock,
> 0,
> FILE_ATTRIBUTE_NORMAL,
> 0,
> FILE_OVERWRITE_IF,
> FILE_SYNCHRONOUS_IO_NONALERT, //
>FILE_NON_DIRECTORY_FILE,
> NULL,
> 0
> );
>
> if (NT_SUCCESS(ntStatus))
> {
> DbgPrint(“Zw Create file was successful”);
> }
> else
> {
> DbgPrint(“Zw Create file was NOT successful”);
> }
>
>
> if (IoStatusBlock.Information & FILE_CREATED)
> {
> DbgPrint(“ZwCreateFile result = FILE_CREATED”);
> }
> if (IoStatusBlock.Information & FILE_OPENED)
> {
> DbgPrint(“ZwCreateFile result = FILE_OPENED”);
> }
> if (IoStatusBlock.Information & FILE_OVERWRITTEN)
> {
> DbgPrint(“ZwCreateFile result = FILE_OVERWRITTEN”);
> }
> if (IoStatusBlock.Information & FILE_SUPERSEDED)
> {
> DbgPrint(“ZwCreateFile result = FILE_SUPERSEDED”);
> }
> if (IoStatusBlock.Information & FILE_EXISTS)
> {
> DbgPrint(“ZwCreateFile result = FILE_EXISTS”);
> }
> if (IoStatusBlock.Information & FILE_DOES_NOT_EXIST)
> {
> DbgPrint(“ZwCreateFile result = FILE_DOES_NOT_EXIST”);
> }
>
>
> // strcpy(buffer, “This is to test the driver writing
>characters to a file”);
> // size = strlen(buffer);
> // size = 25;
>
> sprintf(buf, “This is to test the driver writing characters to
>a file”);
> length = strlen(buf);
>
>
> ntStatus = ZwWriteFile
> (
> fileHandle,
> NULL,
> NULL,
> NULL,
> &IoStatusBlock,
> buf,
> length,
> NULL,
> NULL
> );
>
>
> if (NT_SUCCESS(ntStatus))
> {
> DbgPrint(“ZwWrite file was successful”);
> }
> else
> {
> DbgPrint(“ZwWrite file was NOT successful”);
> }
>
> ntStatus = ZwClose(fileHandle);
>
>// End - Add code to open file on disk to write circular buffer -
>Henko
>
>
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 16:13
>To: NT Developers Interest List
>Subject: [ntdev] RE: About ZwCreateFile
>
>
>I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi
>miniport,
>but Calling ZwCreateFile in the DriverEntry Routing just failed¡£
>
> >From: “Henko Gouws (H)”
> >Reply-To: “NT Developers Interest List”
> >To: “NT Developers Interest List”
> >Subject: [ntdev] RE: About ZwCreateFile
> >Date: Mon, 17 Mar 2003 14:39:45 +0200
> >
> >Hallo
> >
> >I am not sure about scsi in particular but I am calling the ZwXxx
> >functions successfully from within the serial.sys serial port driver
> >for Windows 2000. You have to call this function while you are below
> >IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
> >DISPATCH_LEVEL). The dispatch functions are normally called at user
> >level which is acceptable to call the Zwxxx functions.
> >
> >regards
> >Henko
> >
> >-----Original Message-----
> >From: ? ? [mailto:xxxxx@hotmail.com]
> >Sent: 17 March 2003 14:23
> >To: NT Developers Interest List
> >Subject: [ntdev] About ZwCreateFile
> >
> >
> >Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@telkom.co.za
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@hotmail.com
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£ http://www.hotmail.com
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
_________________________________________________________________
ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£ http://www.hotmail.com
Two problems:
-
You must be at PASSIVE_LEVEL to call ZwCreateFile or you may deadlock
the system. -
You should set the attribute OBJ_KERNEL_HANDLE when you call
InitializeObjectAttributes. When you fail to do this, the handle is
visible in the context in which you performed the open. If this is a
user process, the user can close the handle, close the handle and open
another file (that gets assigned the same handle).
-----Original Message-----
From: Henko Gouws (H) [mailto:xxxxx@telkom.co.za]
Sent: Monday, March 17, 2003 9:24 AM
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
Here is an example. You are not the first one to have suffered from
the seemingly innocent ZwCreateFile.
I am sure the IoStatusBlock.Information checks can be done more
elegant but this works for the interim
regards
Henko
irql = KeGetCurrentIrql();
if (irql < DISPATCH_LEVEL)
{
DbgPrint(“Current irql = %d is lower than dispatch
level\n”, irql);
}
else
{
// Here is trouble - equal or higher than dispatch
level
DbgPrint(“ERROR: Current irql = %d is equal or higher
than dispatch level\n”, irql);
}
// Add code to open file on disk to write circular buffer - Henko
RtlInitUnicodeString(&filename, L"\??\c:\driver3.txt");
InitializeObjectAttributes(&initializedAttributes, &filename,
OBJ_CASE_INSENSITIVE, NULL, NULL);
ntStatus =
ZwCreateFile
(
&fileHandle,
FILE_WRITE_DATA,
&initializedAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT, //
FILE_NON_DIRECTORY_FILE,
NULL,
0
);
if (NT_SUCCESS(ntStatus))
{
DbgPrint(“Zw Create file was successful”);
}
else
{
DbgPrint(“Zw Create file was NOT successful”);
}
if (IoStatusBlock.Information & FILE_CREATED)
{
DbgPrint(“ZwCreateFile result = FILE_CREATED”);
}
if (IoStatusBlock.Information & FILE_OPENED)
{
DbgPrint(“ZwCreateFile result = FILE_OPENED”);
}
if (IoStatusBlock.Information & FILE_OVERWRITTEN)
{
DbgPrint(“ZwCreateFile result = FILE_OVERWRITTEN”);
}
if (IoStatusBlock.Information & FILE_SUPERSEDED)
{
DbgPrint(“ZwCreateFile result = FILE_SUPERSEDED”);
}
if (IoStatusBlock.Information & FILE_EXISTS)
{
DbgPrint(“ZwCreateFile result = FILE_EXISTS”);
}
if (IoStatusBlock.Information & FILE_DOES_NOT_EXIST)
{
DbgPrint(“ZwCreateFile result = FILE_DOES_NOT_EXIST”);
}
// strcpy(buffer, “This is to test the driver writing
characters to a file”);
// size = strlen(buffer);
// size = 25;
sprintf(buf, “This is to test the driver writing characters to
a file”);
length = strlen(buf);
ntStatus = ZwWriteFile
(
fileHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
buf,
length,
NULL,
NULL
);
if (NT_SUCCESS(ntStatus))
{
DbgPrint(“ZwWrite file was successful”);
}
else
{
DbgPrint(“ZwWrite file was NOT successful”);
}
ntStatus = ZwClose(fileHandle);
// End - Add code to open file on disk to write circular buffer -
Henko
regards
Henko
-----Original Message-----
From: ? ? [mailto:xxxxx@hotmail.com]
Sent: 17 March 2003 16:13
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi
miniport,
but Calling ZwCreateFile in the DriverEntry Routing just failed??
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 14:39:45 +0200
>
>Hallo
>
>I am not sure about scsi in particular but I am calling the ZwXxx
>functions successfully from within the serial.sys serial port driver
>for Windows 2000. You have to call this function while you are below
>IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
>DISPATCH_LEVEL). The dispatch functions are normally called at user
>level which is acceptable to call the Zwxxx functions.
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 14:23
>To: NT Developers Interest List
>Subject: [ntdev] About ZwCreateFile
>
>
>Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
???ĵ???ʼ?ϵͳ?? MSN Hotmail?? http://www.hotmail.com
—
You are currently subscribed to ntdev as: xxxxx@telkom.co.za
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@nsisoftware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
No you cannot. These functions are PASSIVE_LEVEL only, and SCSI
miniport is called on DIRQL (except HwFindAdapter).
Max
----- Original Message -----
From: “? ?”
To: “NT Developers Interest List”
Sent: Monday, March 17, 2003 3:22 PM
Subject: [ntdev] About ZwCreateFile
> Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
> _________________________________________________________________
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
On Mon, 2003-03-17 at 06:39, Henko Gouws (H) wrote:
Hallo
I am not sure about scsi in particular but I am calling the ZwXxx
functions successfully from within the serial.sys serial port driver
for Windows 2000. You have to call this function while you are below
IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
DISPATCH_LEVEL).
This brings up an (admittedly pretty basic) question I’ve always had
in the back of my mind wrt KeGetCurrentIrql. If it returns PASSIVE_LEVEL,
does that mean that there can be a context switch out from under the
thread, and if so, is the thread absolutely guaranteed to be re-started
at PASSIVE_LEVEL again?
-sd
Depending on when your DriverEntry routine is called you might not be able
to use symbolic links in the path (i.e. ??\C:\file might not work for boot
time DriveEntries). Instead you need to use canonical
\Device\HarddiskVolume1\file path.
Vladimir
-----Original Message-----
From: ? ? [mailto:xxxxx@hotmail.com]
Sent: Monday, March 17, 2003 6:13 AM
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi miniport,
but Calling ZwCreateFile in the DriverEntry Routing just failed??
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 14:39:45 +0200
>
>Hallo
>
>I am not sure about scsi in particular but I am calling the ZwXxx
>functions successfully from within the serial.sys serial port driver
>for Windows 2000. You have to call this function while you are below
>IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
>DISPATCH_LEVEL). The dispatch functions are normally called at user
>level which is acceptable to call the Zwxxx functions.
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 14:23
>To: NT Developers Interest List
>Subject: [ntdev] About ZwCreateFile
>
>
>Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
???ĵ???ʼ?ϵͳ?? MSN Hotmail?? http://www.hotmail.com
—
You are currently subscribed to ntdev as: xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
There is also DriverEntry routine that is called at PASSIVE_LEVEL
And (as far as I understood) the original Q refers exactly to this entry
point.
Vladimir
-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Monday, March 17, 2003 5:47 AM
To: NT Developers Interest List
Subject: [ntdev] Re: About ZwCreateFile
No you cannot. These functions are PASSIVE_LEVEL only, and SCSI
miniport is called on DIRQL (except HwFindAdapter).
Max
----- Original Message -----
From: “? ?”
To: “NT Developers Interest List”
Sent: Monday, March 17, 2003 3:22 PM
Subject: [ntdev] About ZwCreateFile
> Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
> _________________________________________________________________
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
—
You are currently subscribed to ntdev as: xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Yes a context switch could occur. Yes, when the thread is scheduled
again it will be at the same IRQL.
IRQL changes in two cases
A) the code that thread is running requests an IRQL change directly (by
calling Ke[Raise|Lower]Irql) or indirectly (by calling something that
changes IRQL)
B) an asynchronous event occurs (interrupt) which preempts the thread on
that processor - in this case the preemting code will (almost always)
run at a higher IRQL but IRQL will be restored to the previous value
before restarting the preemted code.
-p
-----Original Message-----
From: Steve Dispensa [mailto:xxxxx@positivenetworks.net]
Sent: Monday, March 17, 2003 7:03 AM
To: NT Developers Interest List
On Mon, 2003-03-17 at 06:39, Henko Gouws (H) wrote:
Hallo
I am not sure about scsi in particular but I am calling the ZwXxx
functions successfully from within the serial.sys serial port driver
for Windows 2000. You have to call this function while you are below
IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
DISPATCH_LEVEL).
This brings up an (admittedly pretty basic) question I’ve always had in
the back of my mind wrt KeGetCurrentIrql. If it returns PASSIVE_LEVEL,
does that mean that there can be a context switch out from under the
thread, and if so, is the thread absolutely guaranteed to be re-started
at PASSIVE_LEVEL again?
-sd
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
RE
for most boot time drivers event \Device\HarddiskVolume1 may not be
setup yet.
-p
From: Vladimir Chtchetkine
[mailto:xxxxx@borland.com]
Sent: Monday, March 17, 2003 7:32 AM
To: NT Developers Interest List
Depending on when your DriverEntry routine is called you might
not be able to use symbolic links in the path (i.e. ??\C:\file might
not work for boot time DriveEntries). Instead you need to use canonical
\Device\HarddiskVolume1\file path.
Vladimir
-----Original Message-----
From: ? ? [mailto:xxxxx@hotmail.com]
Sent: Monday, March 17, 2003 6:13 AM
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi
miniport,
but Calling ZwCreateFile in the DriverEntry Routing just failed??
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 14:39:45 +0200
>
>Hallo
>
>I am not sure about scsi in particular but I am calling the
ZwXxx
>functions successfully from within the serial.sys serial port
driver
>for Windows 2000. You have to call this function while you are
below
>IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
>DISPATCH_LEVEL). The dispatch functions are normally called at
user
>level which is acceptable to call the Zwxxx functions.
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 14:23
>To: NT Developers Interest List
>Subject: [ntdev] About ZwCreateFile
>
>
>Can i call ZwCreateFile and ZwReadFile in my scsi miniport
driver?
>
>
>
>
>
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to
xxxxx@lists.osr.com
???ĵ???ʼ?ϵͳ?? MSN Hotmail?? http://www.hotmail.com
—
You are currently subscribed to ntdev as:
xxxxx@borland.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com
RE
Sure! But in this case ZwCreateFile will not be available (at least for disk
files) at all. What I remembered though (and was referring to) is that there
is a time gap between \Device\HarddiskVolumeX\ is set and its symb. link
counterpart is set. So, although you can access files via canonical path you
can’t use drive letters for that. Correct me if I’m wrong.
Vladimir
-----Original Message-----
From: Peter Wieland [mailto:xxxxx@windows.microsoft.com]
Sent: Monday, March 17, 2003 10:21 AM
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
for most boot time drivers event \Device\HarddiskVolume1 may not be
setup yet.
-p
From: Vladimir Chtchetkine
[mailto:xxxxx@borland.com]
Sent: Monday, March 17, 2003 7:32 AM
To: NT Developers Interest List
Depending on when your DriverEntry routine is called you might
not be able to use symbolic links in the path (i.e. ??\C:\file might
not work for boot time DriveEntries). Instead you need to use canonical
\Device\HarddiskVolume1\file path.
Vladimir
-----Original Message-----
From: ? ? [mailto:xxxxx@hotmail.com]
Sent: Monday, March 17, 2003 6:13 AM
To: NT Developers Interest List
Subject: [ntdev] RE: About ZwCreateFile
I found (KeGetCurrentIrql() < DISPATCH_LEVEL) is true in my scsi
miniport,
but Calling ZwCreateFile in the DriverEntry Routing just failed??
From: “Henko Gouws (H)”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: About ZwCreateFile
>Date: Mon, 17 Mar 2003 14:39:45 +0200
>
>Hallo
>
>I am not sure about scsi in particular but I am calling the
ZwXxx
>functions successfully from within the serial.sys serial port
driver
>for Windows 2000. You have to call this function while you are
below
>IRQ level = DISPATCH_LEVEL. Eg test: if (KeGetCurrentIrql() <
>DISPATCH_LEVEL). The dispatch functions are normally called at
user
>level which is acceptable to call the Zwxxx functions.
>
>regards
>Henko
>
>-----Original Message-----
>From: ? ? [mailto:xxxxx@hotmail.com]
>Sent: 17 March 2003 14:23
>To: NT Developers Interest List
>Subject: [ntdev] About ZwCreateFile
>
>
>Can i call ZwCreateFile and ZwReadFile in my scsi miniport
driver?
>
>
>
>
>
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@telkom.co.za
>To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to
xxxxx@lists.osr.com
???ĵ???ʼ?ϵͳ?? MSN Hotmail?? http://www.hotmail.com
—
You are currently subscribed to ntdev as:
xxxxx@borland.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com
RE
—
You are currently subscribed to ntdev as: xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
The direct answer is “No. You cannot call a non-SCSIPORT exported function
in a SCSI-miniport”. ZwXxxx functions are NOT defined in scsi.h, srb.h, or
miniport.h. The indirect answer is the one Max gave you. Yes, you can use
ZwXxxx and the remainder of the DDK if you generate a lateral-edge to your
miniport that includes ntddk or wdm.h. However, doing that is going provide
a plethora of questions and problems.
Chief amongst these questions is going to be when do you intend to use those
ZwXxxx calls, and how will you guarantee that you will be at PASSIVE_LEVEL?
Once at PASSIVE_LEVEL, how will you get back into DISPATCH_LEVEL to complete
an SRB? Miniport’s tend to load and start during boot time, before the file
system that the ZwXxxx functions depend upon have been established. So the
possiblilty of you using them during initialization and find-adapter are
remote. That leaves DriverEntry, which means you have to use some kind of
PASSIVE_LEVEL thread, and once in that thread, you now you have the problem
of getting back into SCSIPORT’S DPC and DISPATCH_LEVEL to do anything.
So the correct answer is No, Yes, and Maybe.
–
Gary G. Little
Have Computer, Will Travel …
909-698-3191
909-551-2105
http://www.wd-3.com
“? ?” wrote in message news:xxxxx@ntdev…
>
> Can i call ZwCreateFile and ZwReadFile in my scsi miniport driver?
>
>
>
>
>
> _________________________________________________________________
>
>
>
>
>
> in the back of my mind wrt KeGetCurrentIrql. If it returns
PASSIVE_LEVEL,
does that mean that there can be a context switch out from under the
thread, and if so, is the thread absolutely guaranteed to be
re-started
at PASSIVE_LEVEL again?
Yes.
Max