Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Api User-mode WriteFile block

Reply
Thread Tools Display Modes

Api User-mode WriteFile block

 
 
Mathieu
Guest
Posts: n/a

 
      11-03-2009
Hello, I just develop a process to map a logical drive in user-mode to
an image file (ex: e: \ td.raw) through a driver specific to me. When
the event of write request on the unit I use is called WriteFile
function of the Windows API. The problem is that the WriteFile on an
image file and not on the logical drive mapped, well at the time he
hangs up during such copying files to the logical drive mapped to
user-mode. I have to restart Windows for all blocking. Bizarre: When I
put the WriteFile in another thread and I await his execution is
completed, WriteFile no longer block. More bizarrre: I try to put in the
thread that writes the image file, and use the fprintf function which
writed another file (eg c: \ debugsecteur.txt) sector numbers. Well then
there is blockage in the fprintf or WriteFile function. I do not
understand. Explanation of the problem internally: When calling from
WriteFile on an image file (eg e: \ td.raw), Well's system will write
data on the logical drive mapped to user-mode, the driver returns on
STATUS_PENDING of IRP_MJ_WRITE because the called the event write
request is not completed. I try to remove the latency of the thread
writing the image file, ie the thread is created, the event of write
request returns OK on my driver and the WriteFile function is thread
releasing data at the time, but when I used my image file, gives me the
logical drive unformatted and unreadable! I'll retest! Already it is the
parameter of CreateFile should: ( nameraw char [] = "e: \ \ td.raw";
Hrawi = CreateFile (nameraw, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING | FILE_ATTRIBUTE_NORMAL, NULL); ) Can you help me
because after the debug logs on the OS windows is at fault! Conclusion:
The kernel of Windows will write some data in the logical drive mapped
to user-mode during the WriteFile function and as the data recorded are
not OK, the kernel decides to block. Why? Why in a thread does not block
at the function Writefile. In the event of write access i call the
DeviceIoControl function pour retreive and return data requested by my
driver ! As for the event read request: no problem! Can you help me?

WriteFile is sometimes block in case it works in the same thread or
there are functions DeviceIoControl for data retreived from my driver
for all application read / write about the logical drive.

Thank you.
 
Reply With Quote
 
 
 
 
David Craig
Guest
Posts: n/a

 
      11-03-2009
Why do you keep posting in newsgroup after newsgroup?

"Mathieu" <> wrote in message
news:4aef7870$0$923$...
> Hello, I just develop a process to map a logical drive in user-mode to an
> image file (ex: e: \ td.raw) through a driver specific to me. When the
> event of write request on the unit I use is called WriteFile function of
> the Windows API. The problem is that the WriteFile on an image file and
> not on the logical drive mapped, well at the time he hangs up during such
> copying files to the logical drive mapped to user-mode. I have to restart
> Windows for all blocking. Bizarre: When I put the WriteFile in another
> thread and I await his execution is completed, WriteFile no longer block.
> More bizarrre: I try to put in the thread that writes the image file, and
> use the fprintf function which writed another file (eg c: \
> debugsecteur.txt) sector numbers. Well then there is blockage in the
> fprintf or WriteFile function. I do not understand. Explanation of the
> problem internally: When calling from WriteFile on an image file (eg e: \
> td.raw), Well's system will write data on the logical drive mapped to
> user-mode, the driver returns on STATUS_PENDING of IRP_MJ_WRITE because
> the called the event write request is not completed. I try to remove the
> latency of the thread writing the image file, ie the thread is created,
> the event of write request returns OK on my driver and the WriteFile
> function is thread releasing data at the time, but when I used my image
> file, gives me the logical drive unformatted and unreadable! I'll retest!
> Already it is the parameter of CreateFile should: ( nameraw char [] = "e:
> \ \ td.raw"; Hrawi = CreateFile (nameraw, GENERIC_READ | GENERIC_WRITE,
> FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
> FILE_FLAG_NO_BUFFERING | FILE_ATTRIBUTE_NORMAL, NULL); ) Can you help me
> because after the debug logs on the OS windows is at fault! Conclusion:
> The kernel of Windows will write some data in the logical drive mapped to
> user-mode during the WriteFile function and as the data recorded are not
> OK, the kernel decides to block. Why? Why in a thread does not block at
> the function Writefile. In the event of write access i call the
> DeviceIoControl function pour retreive and return data requested by my
> driver ! As for the event read request: no problem! Can you help me?
>
> WriteFile is sometimes block in case it works in the same thread or there
> are functions DeviceIoControl for data retreived from my driver for all
> application read / write about the logical drive.
>
> Thank you.



 
Reply With Quote
 
Alexander Grigoriev
Guest
Posts: n/a

 
      11-03-2009
I don't quite understand your problem, but one thing you might want to
consider is to use FILE_FLAG_OVERLAPPED.

Do you have a kernel driver to create a volume on a file? Do you allow for
multiple simultaneous IO requests?

"Mathieu" <> wrote in message
news:4aef7870$0$923$...
> Hello, I just develop a process to map a logical drive in user-mode to an
> image file (ex: e: \ td.raw) through a driver specific to me. When the
> event of write request on the unit I use is called WriteFile function of
> the Windows API. The problem is that the WriteFile on an image file and
> not on the logical drive mapped, well at the time he hangs up during such
> copying files to the logical drive mapped to user-mode. I have to restart
> Windows for all blocking. Bizarre: When I put the WriteFile in another
> thread and I await his execution is completed, WriteFile no longer block.
> More bizarrre: I try to put in the thread that writes the image file, and
> use the fprintf function which writed another file (eg c: \
> debugsecteur.txt) sector numbers. Well then there is blockage in the
> fprintf or WriteFile function. I do not understand. Explanation of the
> problem internally: When calling from WriteFile on an image file (eg e: \
> td.raw), Well's system will write data on the logical drive mapped to
> user-mode, the driver returns on STATUS_PENDING of IRP_MJ_WRITE because
> the called the event write request is not completed. I try to remove the
> latency of the thread writing the image file, ie the thread is created,
> the event of write request returns OK on my driver and the WriteFile
> function is thread releasing data at the time, but when I used my image
> file, gives me the logical drive unformatted and unreadable! I'll retest!
> Already it is the parameter of CreateFile should: ( nameraw char [] = "e:
> \ \ td.raw"; Hrawi = CreateFile (nameraw, GENERIC_READ | GENERIC_WRITE,
> FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
> FILE_FLAG_NO_BUFFERING | FILE_ATTRIBUTE_NORMAL, NULL); ) Can you help me
> because after the debug logs on the OS windows is at fault! Conclusion:
> The kernel of Windows will write some data in the logical drive mapped to
> user-mode during the WriteFile function and as the data recorded are not
> OK, the kernel decides to block. Why? Why in a thread does not block at
> the function Writefile. In the event of write access i call the
> DeviceIoControl function pour retreive and return data requested by my
> driver ! As for the event read request: no problem! Can you help me?
>
> WriteFile is sometimes block in case it works in the same thread or there
> are functions DeviceIoControl for data retreived from my driver for all
> application read / write about the logical drive.
>
> Thank you.



 
Reply With Quote
 
Mathieu
Guest
Posts: n/a

 
      11-03-2009

My driver allows multiple access by returning STATUS_PENDING.
But it is a thread in the driver disk manager who basically control
access to both and calls the function of gender IoCompleteRequest.

The driver create a volume that the user process that manages the disk.

The process link with the driver with the API DeviceIoControl function
for the proper functioning of the disc.
And it is the function WriteFile blocking because OS will access the
disk set. Although safe in user-mode I do not use the WriteFile API for
writing on my drive (\ \. \ K otherwise it would create recursion, I
use the WriteFile API to write the image file that is my drive to create.

I use WriteFile on the same thread why use DeviceIoControl.

Alexander Grigoriev a écrit :
> I don't quite understand your problem, but one thing you might want to
> consider is to use FILE_FLAG_OVERLAPPED.
>
> Do you have a kernel driver to create a volume on a file? Do you allow for
> multiple simultaneous IO requests?
>
> "Mathieu" <> wrote in message
> news:4aef7870$0$923$...
>> Hello, I just develop a process to map a logical drive in user-mode to an
>> image file (ex: e: \ td.raw) through a driver specific to me. When the
>> event of write request on the unit I use is called WriteFile function of
>> the Windows API. The problem is that the WriteFile on an image file and
>> not on the logical drive mapped, well at the time he hangs up during such
>> copying files to the logical drive mapped to user-mode. I have to restart
>> Windows for all blocking. Bizarre: When I put the WriteFile in another
>> thread and I await his execution is completed, WriteFile no longer block.
>> More bizarrre: I try to put in the thread that writes the image file, and
>> use the fprintf function which writed another file (eg c: \
>> debugsecteur.txt) sector numbers. Well then there is blockage in the
>> fprintf or WriteFile function. I do not understand. Explanation of the
>> problem internally: When calling from WriteFile on an image file (eg e: \
>> td.raw), Well's system will write data on the logical drive mapped to
>> user-mode, the driver returns on STATUS_PENDING of IRP_MJ_WRITE because
>> the called the event write request is not completed. I try to remove the
>> latency of the thread writing the image file, ie the thread is created,
>> the event of write request returns OK on my driver and the WriteFile
>> function is thread releasing data at the time, but when I used my image
>> file, gives me the logical drive unformatted and unreadable! I'll retest!
>> Already it is the parameter of CreateFile should: ( nameraw char [] = "e:
>> \ \ td.raw"; Hrawi = CreateFile (nameraw, GENERIC_READ | GENERIC_WRITE,
>> FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
>> FILE_FLAG_NO_BUFFERING | FILE_ATTRIBUTE_NORMAL, NULL); ) Can you help me
>> because after the debug logs on the OS windows is at fault! Conclusion:
>> The kernel of Windows will write some data in the logical drive mapped to
>> user-mode during the WriteFile function and as the data recorded are not
>> OK, the kernel decides to block. Why? Why in a thread does not block at
>> the function Writefile. In the event of write access i call the
>> DeviceIoControl function pour retreive and return data requested by my
>> driver ! As for the event read request: no problem! Can you help me?
>>
>> WriteFile is sometimes block in case it works in the same thread or there
>> are functions DeviceIoControl for data retreived from my driver for all
>> application read / write about the logical drive.
>>
>> Thank you.

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Offline files fail to synchronize Bob Windows Vista File Management 19 04-30-2009 05:45 AM
User Accounts can't be set to Administrator Steve A. Windows Vista Administration 10 03-09-2008 07:35 AM
delete user accounts billmbrown Windows Vista Administration 7 11-20-2007 02:20 AM
Java works under one user but not the other? updated question rjboney Windows Vista Games 2 07-06-2007 08:05 AM
Re-configuring user accounts kira13 Windows Vista Administration 0 03-22-2007 08:37 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59