Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Developing a File System filter Driver

Reply
Thread Tools

Developing a File System filter Driver

 
 
noe
Guest
Posts: n/a
 
      05-26-2004
Hello all devs!!

Im a student and Im developing my Final Project in the University. I
have to develop a driver for Windows XP that work so:
I have a file in the HD (NTFS file system) of my PC and I want to copy it
to the floppy disk (FAT16 file system). But I need that the file data in
the floppy disk is modified (added 1 respect to the original value).
For example:

I have-> HD file data: hello
I need to obtain -> Floppy file data: ifmmp

I know I have to write a File System Filter Driver.
Im working about the sample code sfilter.c of IFS Kit.
I think that one of the routines which will be modified is this:

BOOLEAN
SfFastIoRead (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset,
IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)

{
PDEVICE_OBJECT nextDeviceObject;
PFAST_IO_DISPATCH fastIoDispatch;

PAGED_CODE();
VALIDATE_IRQL(Irp);

if (DeviceObject->DeviceExtension) {

ASSERT(IS_MY_DEVICE_OBJECT( DeviceObject ));

//
// Pass through logic for this type of Fast I/O
//

nextDeviceObject = ((PSFILTER_DEVICE_EXTENSION)
DeviceObject->DeviceExtension)->AttachedToDeviceObject;
ASSERT(nextDeviceObject);

fastIoDispatch = nextDeviceObject->DriverObject->FastIoDispatch;

if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoRead ))
{

return (fastIoDispatch->FastIoRead)(
FileObject,
FileOffset,
Length,
Wait,
LockKey,
Buffer,
IoStatus,
nextDeviceObject );
}
}
return FALSE;
}

I suppose what I have to modify is the parameter buffer but Im not sure
and I dont know how I have to do.

Its the first time I face a problem so serious because I have never
worked with drivers.
Please, could you help me?
Thanks a lot


 
Reply With Quote
 
 
 
 
Dan Pop
Guest
Posts: n/a
 
      05-26-2004
In <(E-Mail Removed) outprogramming.com> "noe" <(E-Mail Removed)> writes:

>BOOLEAN
>SfFastIoRead (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset,
> IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer,
>OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
>
>{
> PDEVICE_OBJECT nextDeviceObject;
> PFAST_IO_DISPATCH fastIoDispatch;
>
> PAGED_CODE();
> VALIDATE_IRQL(Irp);
>
> if (DeviceObject->DeviceExtension) {
>
> ASSERT(IS_MY_DEVICE_OBJECT( DeviceObject ));
>
> //
> // Pass through logic for this type of Fast I/O
> //
>
> nextDeviceObject = ((PSFILTER_DEVICE_EXTENSION)
>DeviceObject->DeviceExtension)->AttachedToDeviceObject;
> ASSERT(nextDeviceObject);
>
> fastIoDispatch = nextDeviceObject->DriverObject->FastIoDispatch;
>
> if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoRead ))
>{
>
> return (fastIoDispatch->FastIoRead)(
> FileObject,
> FileOffset,
> Length,
> Wait,
> LockKey,
> Buffer,
> IoStatus,
> nextDeviceObject );
> }
> }
> return FALSE;
>}


Please do not post garbage to this newsgroup. If I try to compile your
code, this is what I get:

fangorn:~/tmp 177> gcc -c test.c
test.c:2: error: parse error before "SfFastIoRead"
test.c:2: error: parse error before "PFILE_OBJECT"
test.c: In function `SfFastIoRead':
test.c:7: error: `PDEVICE_OBJECT' undeclared (first use in this function)
test.c:7: error: (Each undeclared identifier is reported only once
test.c:7: error: for each function it appears in.)
test.c:7: error: parse error before "nextDeviceObject"
test.c:8: error: `PFAST_IO_DISPATCH' undeclared (first use in this function)
test.c:11: error: `Irp' undeclared (first use in this function)
test.c:13: error: `DeviceObject' undeclared (first use in this function)
test.c:21: error: `nextDeviceObject' undeclared (first use in this function)
test.c:21: error: `PSFILTER_DEVICE_EXTENSION' undeclared (first use in this function)
test.c:22: error: parse error before "DeviceObject"
test.c:25: error: `fastIoDispatch' undeclared (first use in this function)
test.c:27: error: `FastIoRead' undeclared (first use in this function)
test.c:31: error: `FileObject' undeclared (first use in this function)
test.c:32: error: `FileOffset' undeclared (first use in this function)
test.c:33: error: `Length' undeclared (first use in this function)
test.c:34: error: `Wait' undeclared (first use in this function)
test.c:35: error: `LockKey' undeclared (first use in this function)
test.c:36: error: `Buffer' undeclared (first use in this function)
test.c:37: error: `IoStatus' undeclared (first use in this function)
test.c:41: error: `FALSE' undeclared (first use in this function)

Furthermore, none of these diagnostics could be fixed by the inclusion of
any standard header, so your code is beyond any hope in this newsgroup.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
noe
Guest
Posts: n/a
 
      05-26-2004
Obviously it's only a part of the sample code. If you want to see the
complete code you have to check "sfilter.c" from the samples of IFS Kit.



 
Reply With Quote
 
Mark A. Odell
Guest
Posts: n/a
 
      05-26-2004
"noe" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) lkaboutprogramming.com:

> Obviously it's only a part of the sample code. If you want to see the
> complete code you have to check "sfilter.c" from the samples of IFS Kit.


So what? This is system specific stuff - off-topic here.

--
- Mark ->
--
 
Reply With Quote
 
Jack Klein
Guest
Posts: n/a
 
      05-27-2004
On Wed, 26 May 2004 11:54:02 -0400, "noe" <(E-Mail Removed)> wrote
in comp.lang.c:

> Hello all devs!!
>
> Im a student and Im developing my Final Project in the University. I
> have to develop a driver for Windows XP that work so:
> I have a file in the HD (NTFS file system) of my PC and I want to copy it
> to the floppy disk (FAT16 file system). But I need that the file data in
> the floppy disk is modified (added 1 respect to the original value).
> For example:
>
> I have-> HD file data: hello
> I need to obtain -> Floppy file data: ifmmp


[snip vast amounts of off-topic code that look more like Visual Basic
than C]

There is no need whatsoever for this to be a driver program. Plain
old ordinary C FILE * streams will do this quite nicely.

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *fin, *fout;
int ch;

fin = fopen("source_file_name", "r");
fout = fopen("destination_file_name", "w");

if (!fin || !fout)
{
puts("error opening files!");
return EXIT_FAILURE;
}

while ((ch = fgetc(fin)) != EOF)
{
fputc(ch + 1, fout);
}
fclose(fin);
fclose(fout);
return EXIT_SUCCESS;
}

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      05-27-2004
In <(E-Mail Removed) outprogramming.com> "noe" <(E-Mail Removed)> writes:

>Obviously it's only a part of the sample code. If you want to see the
>complete code you have to check "sfilter.c" from the samples of IFS Kit.


1. How can you expect any advice without posting the complete code?

2. My point was that the code is not written in portable C, so you have
posted it in the wrong newsgroup.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: (E-Mail Removed)
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      05-27-2004
In <(E-Mail Removed)> Jack Klein <(E-Mail Removed)> writes:

>On Wed, 26 May 2004 11:54:02 -0400, "noe" <(E-Mail Removed)> wrote
>in comp.lang.c:
>
>> Hello all devs!!
>>
>> Im a student and Im developing my Final Project in the University. I
>> have to develop a driver for Windows XP that work so:
>> I have a file in the HD (NTFS file system) of my PC and I want to copy it
>> to the floppy disk (FAT16 file system). But I need that the file data in
>> the floppy disk is modified (added 1 respect to the original value).
>> For example:
>>
>> I have-> HD file data: hello
>> I need to obtain -> Floppy file data: ifmmp

>
> [snip vast amounts of off-topic code that look more like Visual Basic
>than C]
>
>There is no need whatsoever for this to be a driver program. Plain
>old ordinary C FILE * streams will do this quite nicely.


Not if you want the filtering to happen *transparently*. If the filter
must be hooked into the OS, it must fit into the hooks provided for this
purpose. This is what makes the post off topic here. Once the OS
interfacing issues are understood, the actual filtering is one of the
most trivial things one can imagine.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: (E-Mail Removed)
 
Reply With Quote
 
RoSsIaCrIiLoIA
Guest
Posts: n/a
 
      05-30-2004
On Wed, 26 May 2004 -0500, Jack Klein <(E-Mail Removed)> wrote:
>#include <stdio.h>
>#include <stdlib.h>
>
>int main(void)
>{
> FILE *fin, *fout;
> int ch;
>
> fin = fopen("source_file_name", "r");
> fout = fopen("destination_file_name", "w");
>
> if (!fin || !fout)
> {
> puts("error opening files!");
> return EXIT_FAILURE;
> }


if fin==NULL and fout!=NULL and no exit()
does it mean that "fout" is open afther the end of
the programme?

 
Reply With Quote
 
Michael Fyles
Guest
Posts: n/a
 
      05-30-2004
RoSsIaCrIiLoIA <(E-Mail Removed)> wrote:
> On Wed, 26 May 2004 -0500, Jack Klein <(E-Mail Removed)> wrote:
> >#include <stdio.h>
> >#include <stdlib.h>
> >
> >int main(void)
> >{
> > FILE *fin, *fout;
> > int ch;
> >
> > fin = fopen("source_file_name", "r");
> > fout = fopen("destination_file_name", "w");
> >
> > if (!fin || !fout)
> > {
> > puts("error opening files!");
> > return EXIT_FAILURE;
> > }

>
> if fin==NULL and fout!=NULL and no exit()
> does it mean that "fout" is open afther the end of
> the programme?


No, returning from main does the same thing as calling exit.

--
Michael
 
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
"rec.photo.digital.txt" Filter File Posted Online (for newsreadersthat can import a list of e-mail addresses to filter out) SMS 斯蒂文• 夏 Digital Photography 2 11-25-2007 11:00 AM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xffc Thread 0x228 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-30-2006 03:16 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 1 03-24-2006 04:20 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM
Developing a HELP system for asp.net pages SamIAm ASP .Net 0 10-21-2003 11:31 PM



Advertisments