Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Windows 64bit > Setting Dirty Flag without fsutil.exe from my code,...

Reply
Thread Tools

Setting Dirty Flag without fsutil.exe from my code,...

 
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-03-2007
Hi,

is there a way, to set a ntfs volumes "dirty" flag without
the fsutil.exe tool. I want to integrate this functionality of
setting a dirty flag on a volume into my application.Where
and what do i have to modify on the drive/registry to enforce
a drive check after a system reboot. Is this applicable to
other drives like FAT(32). I think it should be, as far as i know
from fsutil.exe.


TIA

Best regards

Kerem Gümrükcü


 
Reply With Quote
 
 
 
 
Rafael R. [Live Butterfly]
Guest
Posts: n/a
 
      04-03-2007
I reverse engineered fsutil.exe for you (Windows Server 2003)
Your mileage may vary. I'm not responsible if your computer is turned
into cheese.

Sample code:

--- snip ---
/* Undocumented volume management control code */
#define FSCTL_SET_DIRTY_BIT 0x90030

DWORD bytesReturned = 0x00;

HANDLE hVol = CreateFile(
_T("\\\\.\\I:"),
GENERIC_WRITE
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);

BOOL bitSet = DeviceIoControl(
hVol,
FSCTL_SET_DIRTY_BIT,
0x00,
0x00,
0x00,
0x00,
&bytesReturned,
0);

if( bitSet )
printf( _T("dirty bit set.\n") );

--- snip ---


- Rafael

Kerem Gümrükcü wrote:
> Hi,
>
> is there a way, to set a ntfs volumes "dirty" flag without
> the fsutil.exe tool. I want to integrate this functionality of
> setting a dirty flag on a volume into my application.Where
> and what do i have to modify on the drive/registry to enforce
> a drive check after a system reboot. Is this applicable to
> other drives like FAT(32). I think it should be, as far as i know
> from fsutil.exe.
>
>
> TIA
>
> Best regards
>
> Kerem Gümrükcü
>
>

 
Reply With Quote
 
 
 
 
Rafael R. [Live Butterfly]
Guest
Posts: n/a
 
      04-03-2007
.... and no, it doesn't appear the bit can be set on non-NTFS volumes
using fsutil.exe methods. You may have to drill down into the BIOS
parameter block on disk... Sounds like a pain.

- Rafael

Kerem Gümrükcü wrote:
> Hi,
>
> is there a way, to set a ntfs volumes "dirty" flag without
> the fsutil.exe tool. I want to integrate this functionality of
> setting a dirty flag on a volume into my application.Where
> and what do i have to modify on the drive/registry to enforce
> a drive check after a system reboot. Is this applicable to
> other drives like FAT(32). I think it should be, as far as i know
> from fsutil.exe.
>
>
> TIA
>
> Best regards
>
> Kerem Gümrükcü
>
>

 
Reply With Quote
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-03-2007
Hi Rafael,

thanks for the example. It is always the DeviceIOControl
that makes such things possible. Accessing NTFS Volumes
is just enough. I found interessting informations here:
http://www.ntfs.com/

But i think i will let the Drivers do the work for me since i dont
want to risk to damage a drive. Ill will do some tests on some
virtual systems on my machine and see what i can achieve...

Thank you very much,...

Best regards

Kerem Gümrükcü


"Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb im
Newsbeitrag news:e$m%(E-Mail Removed)...
> ... and no, it doesn't appear the bit can be set on non-NTFS volumes using
> fsutil.exe methods. You may have to drill down into the BIOS parameter
> block on disk... Sounds like a pain.
>
> - Rafael
>
> Kerem Gümrükcü wrote:
>> Hi,
>>
>> is there a way, to set a ntfs volumes "dirty" flag without
>> the fsutil.exe tool. I want to integrate this functionality of
>> setting a dirty flag on a volume into my application.Where
>> and what do i have to modify on the drive/registry to enforce
>> a drive check after a system reboot. Is this applicable to
>> other drives like FAT(32). I think it should be, as far as i know
>> from fsutil.exe.
>>
>>
>> TIA
>>
>> Best regards
>>
>> Kerem Gümrükcü
>>


 
Reply With Quote
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-03-2007
By the Way,

> Your mileage may vary. I'm not responsible if your computer is turned into
> cheese.


I like Cheeese,...


Best regards

Kerem Gümrükcü


 
Reply With Quote
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-03-2007
Hi Rafael,

when i try to gain access to my Windows Drive ("C:") with the given
Parameters
for the DeviceIOControl with the CreateFile function i get a "Invalid
Handle", all
other drives work fine. Do you have any idea why?


Best regards

Kerem Gümrükcü


"Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb im
Newsbeitrag news:e$m%(E-Mail Removed)...
> ... and no, it doesn't appear the bit can be set on non-NTFS volumes using
> fsutil.exe methods. You may have to drill down into the BIOS parameter
> block on disk... Sounds like a pain.
>
> - Rafael
>
> Kerem Gümrükcü wrote:
>> Hi,
>>
>> is there a way, to set a ntfs volumes "dirty" flag without
>> the fsutil.exe tool. I want to integrate this functionality of
>> setting a dirty flag on a volume into my application.Where
>> and what do i have to modify on the drive/registry to enforce
>> a drive check after a system reboot. Is this applicable to
>> other drives like FAT(32). I think it should be, as far as i know
>> from fsutil.exe.
>>
>>
>> TIA
>>
>> Best regards
>>
>> Kerem Gümrükcü
>>


 
Reply With Quote
 
Rafael R. [Live Butterfly]
Guest
Posts: n/a
 
      04-03-2007
I'm assuming you meant DeviceIoControl() returns 0 and GetLastError()
returns INVALID_HANDLE. Does CreateFile( \\.\C:, ... ) return a proper
handle?

I'll check fsutil.exe again but I don't recall seeing any special
handling for the system volume. Try using the volume names (i.e.
\\?\Volume{475977c3-578a-11da-8cd6-806e6f6e6963}\)?

- Rafael

Kerem Gümrükcü wrote:
> Hi Rafael,
>
> when i try to gain access to my Windows Drive ("C:") with the given
> Parameters
> for the DeviceIOControl with the CreateFile function i get a "Invalid
> Handle", all
> other drives work fine. Do you have any idea why?
>
>
> Best regards
>
> Kerem Gümrükcü
>
>
> "Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb im
> Newsbeitrag news:e$m%(E-Mail Removed)...
>> ... and no, it doesn't appear the bit can be set on non-NTFS volumes using
>> fsutil.exe methods. You may have to drill down into the BIOS parameter
>> block on disk... Sounds like a pain.
>>
>> - Rafael
>>
>> Kerem Gümrükcü wrote:
>>> Hi,
>>>
>>> is there a way, to set a ntfs volumes "dirty" flag without
>>> the fsutil.exe tool. I want to integrate this functionality of
>>> setting a dirty flag on a volume into my application.Where
>>> and what do i have to modify on the drive/registry to enforce
>>> a drive check after a system reboot. Is this applicable to
>>> other drives like FAT(32). I think it should be, as far as i know
>>> from fsutil.exe.
>>>
>>>
>>> TIA
>>>
>>> Best regards
>>>
>>> Kerem Gümrükcü
>>>

>

 
Reply With Quote
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-03-2007
Hi Rafael,

yes, DeviceIOControl returns FALSE and GetLastError says "Invalid Handle".
What could cause that return code, sure a invalid handle, but how does this
happen.
How do i get volume names? I work with GetLogicalDriveStrings(...) to
retrieve
the logical volumes. How to get volume names?

When i tried to open the the A: Floppy i got something like "Wrong
Parameter"
from DeviceIOControl = FALSE and GetLastError() following it. Ok Floppy A:
is empty and no disk inserted,...

Best regards

Kerem Gümrükcü

"Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb im
Newsbeitrag news:%(E-Mail Removed)...
> I'm assuming you meant DeviceIoControl() returns 0 and GetLastError()
> returns INVALID_HANDLE. Does CreateFile( \\.\C:, ... ) return a proper
> handle?
>
> I'll check fsutil.exe again but I don't recall seeing any special handling
> for the system volume. Try using the volume names (i.e.
> \\?\Volume{475977c3-578a-11da-8cd6-806e6f6e6963}\)?
>
> - Rafael
>
> Kerem Gümrükcü wrote:
>> Hi Rafael,
>>
>> when i try to gain access to my Windows Drive ("C:") with the given
>> Parameters
>> for the DeviceIOControl with the CreateFile function i get a "Invalid
>> Handle", all
>> other drives work fine. Do you have any idea why?
>>
>>
>> Best regards
>>
>> Kerem Gümrükcü
>>
>>
>> "Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb
>> im Newsbeitrag news:e$m%(E-Mail Removed)...
>>> ... and no, it doesn't appear the bit can be set on non-NTFS volumes
>>> using fsutil.exe methods. You may have to drill down into the BIOS
>>> parameter block on disk... Sounds like a pain.
>>>
>>> - Rafael
>>>
>>> Kerem Gümrükcü wrote:
>>>> Hi,
>>>>
>>>> is there a way, to set a ntfs volumes "dirty" flag without
>>>> the fsutil.exe tool. I want to integrate this functionality of
>>>> setting a dirty flag on a volume into my application.Where
>>>> and what do i have to modify on the drive/registry to enforce
>>>> a drive check after a system reboot. Is this applicable to
>>>> other drives like FAT(32). I think it should be, as far as i know
>>>> from fsutil.exe.
>>>>
>>>>
>>>> TIA
>>>>
>>>> Best regards
>>>>
>>>> Kerem Gümrükcü
>>>>

>>



 
Reply With Quote
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-03-2007
> How do i get volume names? I work with GetLogicalDriveStrings(...) to
> retrieve
> the logical volumes. How to get volume names?



Ok, i got it:
GetVolumeNameForVolumeMountPoint


 
Reply With Quote
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      04-05-2007
Hi Rafael,

i cant set the dirty bit on the system volume. Do you have
any idea why?

Best regards

Kerem Gümrükcü


"Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb im
Newsbeitrag news:%(E-Mail Removed)...
> I'm assuming you meant DeviceIoControl() returns 0 and GetLastError()
> returns INVALID_HANDLE. Does CreateFile( \\.\C:, ... ) return a proper
> handle?
>
> I'll check fsutil.exe again but I don't recall seeing any special handling
> for the system volume. Try using the volume names (i.e.
> \\?\Volume{475977c3-578a-11da-8cd6-806e6f6e6963}\)?
>
> - Rafael
>
> Kerem Gümrükcü wrote:
>> Hi Rafael,
>>
>> when i try to gain access to my Windows Drive ("C:") with the given
>> Parameters
>> for the DeviceIOControl with the CreateFile function i get a "Invalid
>> Handle", all
>> other drives work fine. Do you have any idea why?
>>
>>
>> Best regards
>>
>> Kerem Gümrükcü
>>
>>
>> "Rafael R. [Live Butterfly]" <"[myfirstname]"@fromvistatoxp.com> schrieb
>> im Newsbeitrag news:e$m%(E-Mail Removed)...
>>> ... and no, it doesn't appear the bit can be set on non-NTFS volumes
>>> using fsutil.exe methods. You may have to drill down into the BIOS
>>> parameter block on disk... Sounds like a pain.
>>>
>>> - Rafael
>>>
>>> Kerem Gümrükcü wrote:
>>>> Hi,
>>>>
>>>> is there a way, to set a ntfs volumes "dirty" flag without
>>>> the fsutil.exe tool. I want to integrate this functionality of
>>>> setting a dirty flag on a volume into my application.Where
>>>> and what do i have to modify on the drive/registry to enforce
>>>> a drive check after a system reboot. Is this applicable to
>>>> other drives like FAT(32). I think it should be, as far as i know
>>>> from fsutil.exe.
>>>>
>>>>
>>>> TIA
>>>>
>>>> Best regards
>>>>
>>>> Kerem Gümrükcü
>>>>

>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Follow Up Flag & Due Date Setting for Outlook MSG Files in Java Apps sherazam Java 0 09-14-2012 07:37 AM
How keep python socket alive for ever by setting Keep alive flag. hisan Python 1 06-25-2012 05:30 PM
Setting bit flag enum value in aspx file ? Moe Sisko ASP .Net 1 01-02-2008 10:00 PM
Setting low level flag for Serial Port in Java Homer Java 1 07-16-2007 10:30 PM
Setting "User Cannot Change Password" Flag from ASP.NET/C# John Beard ASP .Net 1 09-06-2006 06:07 PM



Advertisments