Reparse File.

Hi.

I am having a problem with Redirecting filenames for my own application firewall.

Can someone help?

I have everything needed. As mentioned around every source I can seem to find.

If I alter the filename but keep it the same length, everything is ok and filea.bat is loaded instead of file.bat. If I change the file length, the file cannot be found. Is there something I am missing?

pFileObject = pData->Iopb->TargetFileObject;

// pFileObject->FileName.MaximumLength is 92 in this case.

RtlCopyMemory (pFileObject->FileName.Buffer, L"\Device\HarddiskVolume1\file.bat", 64);
pFileObject->FileName.Length = 64;

IoStatus.Status = STATUS_REPARSE;
IoStatus.Information = IO_REPARSE;

FltSetCallbackDataDirty(pData);

return PREOP_SUCCESS_NO_CALLBACK;

For example:

If the original file was \Device\HarddiskVolume1\fila.bat this would work. If it were \Device\HarddiskVolume1\filea.bat it would not.

Thanks.

Hello ,

if you change
RtlCopyMemory (pFileObject->FileName.Buffer,
L"\Device\HarddiskVolume1\file.bat", 64);
pFileObject->FileName.Length = 64;

to

RtlCopyMemory (pFileObject->FileName.Buffer,
L"\Device\HarddiskVolume1\filea.bat", 66);
pFileObject->FileName.Length = 66;

does it work?

thanks,
–rc

No. Unfortunately not.

Hello,

can you also do
RtlZeroMemory(pFileObject->FileName.Buffer,92)
before
RtlCopyMemory (pFileObject->FileName.Buffer,
L"\Device\HarddiskVolume1\filea.bat", 66);

thanks,
–rc

On Wed, Jan 13, 2010 at 2:38 PM, wrote:
> No. Unfortunately not.
>
> —
> 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
>

Why do you use RtlCopyMemory not RtlCopyUnicodeString? RtlCopyUnicodeString in your case would be better.

Igor Sharovar

Because I have become so accustomed to using RtlCopyMemory.

If I ever carry on writing minidrivers for myself I?ll try and use Unicode instead. Thanks.

Thankyou both, the filelength was the problem.

If I wanted to make a file readonly and alert the user that it is readonly whenever they attempt to write to the file. How would I do it? I would prefer to write it as a driver so the setting cannot be overruled.