C++ in minifilter driver.

I have some compiled libraries I need to include with my minifilter driver
that make use of C++ code.

When I do this, I get all kinds of linker errors about unresolved symbols
(including the most basic new/delete calls). Is there something specific I
need to do to allow this linkage to occur? I’m working off the minispy
sample for a starting point.

Thanks,

Andrew

Andrew Cheyne

Senior Software Developer

GridIron Software

First question is what is in your C++ code? Most kernel C++ code is pretty
limited, so this can be part of the problem. You should read
http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx to understand if
you want C++ in the kernel.

If you want to proceed get the C++ runtime environment from
http://www.hollistech.com/ as a starting point.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
>I have some compiled libraries I need to include with my minifilter driver
> that make use of C++ code.
>
>
>
> When I do this, I get all kinds of linker errors about unresolved symbols
> (including the most basic new/delete calls). Is there something specific
> I
> need to do to allow this linkage to occur? I’m working off the minispy
> sample for a starting point.
>
>
>
> Thanks,
>
> Andrew
>
>
>
> –
>
> Andrew Cheyne
>
> Senior Software Developer
>
> GridIron Software
>
>
>
>

The Vista WDK has C++ support (as to how exactly it should be used,
check RAMDisk as, IMO, the best/easiest sample).
NT DDK and the IFS Kit do not have C++ support, you need to provide
your own C++ RTL. An NTFSD member has provided minimal C++ RTL, but I
cannot remember the link or member name :frowning: I would suggest Vista WDK
approach though!

It was previously possible to use Driver Studio’s DriverWorks for
C++ support (I’ve used it for that only). However, they no longer
support DriverStudio at all, and although the drivers work on Vista (I
repeat - I’ve used C++ RTL only, no driver classes, it was a plain
arithmetics driver), I’m sure it will soon be impossible.

Regards, Dejan.

Andrew Cheyne wrote:

I have some compiled libraries I need to include with my minifilter
driver
that make use of C++ code.

When I do this, I get all kinds of linker errors about unresolved
symbols
(including the most basic new/delete calls). Is there something
specific I
need to do to allow this linkage to occur? I’m working off the minispy

sample for a starting point.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

Is it possible to put the stuff I want access to through C++ into a DLL and
then access the components that are using C++ that way? Can a driver even
load a DLL?

Can a minifilter be built as a User-Mode driver?

Thanks,
Andrew

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: May 4, 2007 7:22 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] C++ in minifilter driver.

The Vista WDK has C++ support (as to how exactly it should be used,
check RAMDisk as, IMO, the best/easiest sample).
NT DDK and the IFS Kit do not have C++ support, you need to provide
your own C++ RTL. An NTFSD member has provided minimal C++ RTL, but I
cannot remember the link or member name :frowning: I would suggest Vista WDK
approach though!

It was previously possible to use Driver Studio’s DriverWorks for
C++ support (I’ve used it for that only). However, they no longer
support DriverStudio at all, and although the drivers work on Vista (I
repeat - I’ve used C++ RTL only, no driver classes, it was a plain
arithmetics driver), I’m sure it will soon be impossible.

Regards, Dejan.

Andrew Cheyne wrote:

I have some compiled libraries I need to include with my minifilter
driver
that make use of C++ code.

When I do this, I get all kinds of linker errors about unresolved
symbols
(including the most basic new/delete calls). Is there something
specific I
need to do to allow this linkage to occur? I’m working off the minispy

sample for a starting point.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

No, No, and No. You can build a kernel mode DLL, but it has to live with
all the rules of any other kernel component. You cannot use a user space
DLL in the kernel, and you cannot create a mini-filter in user-mode.

You can have a helper application to do some things, but this can be
extremely slow, and you have to be careful about what the helper
application does, or else not filtering calls from it.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
> Is it possible to put the stuff I want access to through C++ into a DLL
> and
> then access the components that are using C++ that way? Can a driver even
> load a DLL?
>
> Can a minifilter be built as a User-Mode driver?
>
> Thanks,
> Andrew
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
> Sent: May 4, 2007 7:22 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] C++ in minifilter driver.
>
>
> The Vista WDK has C++ support (as to how exactly it should be used,
> check RAMDisk as, IMO, the best/easiest sample).
> NT DDK and the IFS Kit do not have C++ support, you need to provide
> your own C++ RTL. An NTFSD member has provided minimal C++ RTL, but I
> cannot remember the link or member name :frowning: I would suggest Vista WDK
> approach though!
>
> It was previously possible to use Driver Studio’s DriverWorks for
> C++ support (I’ve used it for that only). However, they no longer
> support DriverStudio at all, and although the drivers work on Vista (I
> repeat - I’ve used C++ RTL only, no driver classes, it was a plain
> arithmetics driver), I’m sure it will soon be impossible.
>
> Regards, Dejan.
>
> Andrew Cheyne wrote:
>
>> I have some compiled libraries I need to include with my minifilter
>> driver
>> that make use of C++ code.
>>
>>
>>
>> When I do this, I get all kinds of linker errors about unresolved
>> symbols
>> (including the most basic new/delete calls). Is there something
>> specific I
>> need to do to allow this linkage to occur? I’m working off the minispy
>>
>> sample for a starting point.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

> Is there something specific I need to do to allow this linkage to occur?

Yeah; you need to lose the compiled for user mode libraries :wink:

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
I have some compiled libraries I need to include with my minifilter driver
that make use of C++ code.

When I do this, I get all kinds of linker errors about unresolved symbols
(including the most basic new/delete calls). Is there something specific I
need to do to allow this linkage to occur? I’m working off the minispy
sample for a starting point.

Thanks,
Andrew


Andrew Cheyne
Senior Software Developer
GridIron Software

Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
all the files are C files (at least in all the KMDF betas, and WDK 6000 and
the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it is
possible that the C++ support you are referring to is an artifact of that.
But this still won’t help the OP, since KMDF is not for file system
filters.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Dejan Maksimovic” wrote in message news:xxxxx@ntfsd…
>
> The Vista WDK has C++ support (as to how exactly it should be used,
> check RAMDisk as, IMO, the best/easiest sample).
> NT DDK and the IFS Kit do not have C++ support, you need to provide
> your own C++ RTL. An NTFSD member has provided minimal C++ RTL, but I
> cannot remember the link or member name :frowning: I would suggest Vista WDK
> approach though!
>
> It was previously possible to use Driver Studio’s DriverWorks for
> C++ support (I’ve used it for that only). However, they no longer
> support DriverStudio at all, and although the drivers work on Vista (I
> repeat - I’ve used C++ RTL only, no driver classes, it was a plain
> arithmetics driver), I’m sure it will soon be impossible.
>
> Regards, Dejan.

Thanks for all your help.

I’m beginning to regret being tasked with this driver work already!

Back to the drawing board…

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: May 4, 2007 12:56 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] C++ in minifilter driver.

No, No, and No. You can build a kernel mode DLL, but it has to live with
all the rules of any other kernel component. You cannot use a user space
DLL in the kernel, and you cannot create a mini-filter in user-mode.

You can have a helper application to do some things, but this can be
extremely slow, and you have to be careful about what the helper
application does, or else not filtering calls from it.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
> Is it possible to put the stuff I want access to through C++ into a DLL
> and
> then access the components that are using C++ that way? Can a driver even
> load a DLL?
>
> Can a minifilter be built as a User-Mode driver?
>
> Thanks,
> Andrew
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
> Sent: May 4, 2007 7:22 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] C++ in minifilter driver.
>
>
> The Vista WDK has C++ support (as to how exactly it should be used,
> check RAMDisk as, IMO, the best/easiest sample).
> NT DDK and the IFS Kit do not have C++ support, you need to provide
> your own C++ RTL. An NTFSD member has provided minimal C++ RTL, but I
> cannot remember the link or member name :frowning: I would suggest Vista WDK
> approach though!
>
> It was previously possible to use Driver Studio’s DriverWorks for
> C++ support (I’ve used it for that only). However, they no longer
> support DriverStudio at all, and although the drivers work on Vista (I
> repeat - I’ve used C++ RTL only, no driver classes, it was a plain
> arithmetics driver), I’m sure it will soon be impossible.
>
> Regards, Dejan.
>
> Andrew Cheyne wrote:
>
>> I have some compiled libraries I need to include with my minifilter
>> driver
>> that make use of C++ code.
>>
>>
>>
>> When I do this, I get all kinds of linker errors about unresolved
>> symbols
>> (including the most basic new/delete calls). Is there something
>> specific I
>> need to do to allow this linkage to occur? I’m working off the minispy
>>
>> sample for a starting point.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> Is it possible to put the stuff I want access to through C++ into a DLL and then

access the components that are using C++ that way? Can a driver even load a DLL?

Not as a user mode DLL, but yes as a kernel mode DLL (i.e. it must be a
driver, only not registered).

Can a minifilter be built as a User-Mode driver?

No.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

Ahh right KMDF. It can help if he puts the C++ code (I am assuming it is not
directly driver related) and export it as a kernel mode DLL for his mini-filter
(that’s what I do).

Don Burn wrote:

Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
all the files are C files (at least in all the KMDF betas, and WDK 6000 and
the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it is
possible that the C++ support you are referring to is an artifact of that.
But this still won’t help the OP, since KMDF is not for file system
filters.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

Nope, KMDF does not support kernel mode DLL’s at this time. He can develop
a helper driver, but not a DLL.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Dejan Maksimovic” wrote in message news:xxxxx@ntfsd…
>
> Ahh right KMDF. It can help if he puts the C++ code (I am assuming it
> is not
> directly driver related) and export it as a kernel mode DLL for his
> mini-filter
> (that’s what I do).
>
> Don Burn wrote:
>
>> Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
>> all the files are C files (at least in all the KMDF betas, and WDK 6000
>> and
>> the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it
>> is
>> possible that the C++ support you are referring to is an artifact of
>> that.
>> But this still won’t help the OP, since KMDF is not for file system
>> filters.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>

Do you have any examples of how to do this?

I have the source code for the C++ components. If I could put them in a
kernel mode DLL and then load that DLL, it would help me a lot. At the
moment, I’m looking at re-implementing in C.

Thanks,
Andrew

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: May 4, 2007 7:19 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] C++ in minifilter driver.

Ahh right KMDF. It can help if he puts the C++ code (I am assuming it is
not
directly driver related) and export it as a kernel mode DLL for his
mini-filter
(that’s what I do).

Don Burn wrote:

Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
all the files are C files (at least in all the KMDF betas, and WDK 6000
and
the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it
is
possible that the C++ support you are referring to is an artifact of that.
But this still won’t help the OP, since KMDF is not for file system
filters.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Andrew

Don has referred you to the msft note on c++ in kernel; and there is an
article on the osr site (search) about kernel dll-s. So you have some
reading for the weekend :slight_smile:

Best Wishes
Lyndon

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
> Do you have any examples of how to do this?
>
> I have the source code for the C++ components. If I could put them in a
> kernel mode DLL and then load that DLL, it would help me a lot. At the
> moment, I’m looking at re-implementing in C.
>
>
> Thanks,
> Andrew
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
> Sent: May 4, 2007 7:19 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] C++ in minifilter driver.
>
>
> Ahh right KMDF. It can help if he puts the C++ code (I am assuming it
> is
> not
> directly driver related) and export it as a kernel mode DLL for his
> mini-filter
> (that’s what I do).
>
> Don Burn wrote:
>
>> Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
>> all the files are C files (at least in all the KMDF betas, and WDK 6000
> and
>> the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it
> is
>> possible that the C++ support you are referring to is an artifact of
>> that.
>> But this still won’t help the OP, since KMDF is not for file system
>> filters.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

A driver that exports APIs to other drivers.
Considering such drivers are not registered and are not loaded before the caller
is loaded, I’d consider it a DLL - not that I care what it’s called;-)

Don Burn wrote:

Nope, KMDF does not support kernel mode DLL’s at this time. He can develop
a helper driver, but not a DLL.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

What components are you using? If you use basic C++ it should compile with KMDF
directly. (make a basic Driver Entry and Unload points that only initialize any
global variables, and you’re set).

Andrew Cheyne wrote:

Do you have any examples of how to do this?

I have the source code for the C++ components. If I could put them in a kernel mode
DLL and then load that DLL, it would help me a lot. At the moment, I’m looking at
re-implementing in C.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

Sorry a kernel mode DLL has a meaning for most of the community, namely it
is an export driver, built and started in a specific way. That is
currently not supported in KMDF.

So the OP could do a driver that starts before the caller, and provides
API’s for the caller through something like an IOCTL interface to get a set
of function pointers, but that sure is not a DLL.

Also, you stated in your first post that ramdisk is C++ but I find nothing
but C code in the version in the WDK. So I suspect you have a hacked
version.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Dejan Maksimovic” wrote in message news:xxxxx@ntfsd…
>
> A driver that exports APIs to other drivers.
> Considering such drivers are not registered and are not loaded before
> the caller
> is loaded, I’d consider it a DLL - not that I care what it’s called;-)
>
> Don Burn wrote:
>
>> Nope, KMDF does not support kernel mode DLL’s at this time. He can
>> develop
>> a helper driver, but not a DLL.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>

It will take the OP 10-15 minutes to try. Been there, done that!

Sorry a kernel mode DLL has a meaning for most of the community, namely it
is an export driver, built and started in a specific way. That is currently not
supported in KMDF.

So the OP could do a driver that starts before the caller, and provides API’s for
the caller through something like an IOCTL interface to get a set of function
pointers, but that sure is not a DLL.

Also, you stated in your first post that ramdisk is C++ but I find nothing
but C code in the version in the WDK. So I suspect you have a hacked
version.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

There are no kernel mode DLLs that come even close to the DLLs that exist in
user mode. Read the referenced documents about C++ in the kernel. Read
about writing helper/EXPORT drivers. One example of using an export driver
is found in the smartcard stack where smclib.sys is the Microsoft written
export driver that does most of the work in managing smartcard logic other
than the specifics of the reader/writer device. Source is not available,
AFAIK, but there are samples for the device specific driver that shows how
it can use an export driver.

I know of many drivers that use C++, but only in a limited way. Exceptions
cannot be used (C++) as only SEH is supported in the kernel.

Best advise is to read first then try an implementation that will be a throw
away. After you get it working, start over again with the overall design of
the driver. You have to implement or find an implementation of new and
delete that map to the standard kernel memory allocation functions. I
STRONGLY recommend that you use unique tags for each type of memory to help
in debugging memory leaks and errors.

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
> Do you have any examples of how to do this?
>
> I have the source code for the C++ components. If I could put them in a
> kernel mode DLL and then load that DLL, it would help me a lot. At the
> moment, I’m looking at re-implementing in C.
>
>
> Thanks,
> Andrew
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
> Sent: May 4, 2007 7:19 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] C++ in minifilter driver.
>
>
> Ahh right KMDF. It can help if he puts the C++ code (I am assuming it
> is
> not
> directly driver related) and export it as a kernel mode DLL for his
> mini-filter
> (that’s what I do).
>
> Don Burn wrote:
>
>> Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
>> all the files are C files (at least in all the KMDF betas, and WDK 6000
> and
>> the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it
> is
>> possible that the C++ support you are referring to is an artifact of
>> that.
>> But this still won’t help the OP, since KMDF is not for file system
>> filters.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

Thanks to everyone for all the help and suggestions.

I went back to the drawing board and completely redesigned the driver so
that the component that required C++ now sits in user-mode land. I already
had a user-mode component talking to my driver, so it wasn’t all that
difficult.

I have a new level of respect for understanding why drivers are sometimes
error prone and buggy when first released even after only being at this for
a short time.

Cheers,
Andrew

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David J. Craig
Sent: May 4, 2007 3:11 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] C++ in minifilter driver.

There are no kernel mode DLLs that come even close to the DLLs that exist in

user mode. Read the referenced documents about C++ in the kernel. Read
about writing helper/EXPORT drivers. One example of using an export driver
is found in the smartcard stack where smclib.sys is the Microsoft written
export driver that does most of the work in managing smartcard logic other
than the specifics of the reader/writer device. Source is not available,
AFAIK, but there are samples for the device specific driver that shows how
it can use an export driver.

I know of many drivers that use C++, but only in a limited way. Exceptions
cannot be used (C++) as only SEH is supported in the kernel.

Best advise is to read first then try an implementation that will be a throw

away. After you get it working, start over again with the overall design of

the driver. You have to implement or find an implementation of new and
delete that map to the standard kernel memory allocation functions. I
STRONGLY recommend that you use unique tags for each type of memory to help
in debugging memory leaks and errors.

“Andrew Cheyne” wrote in message
news:xxxxx@ntfsd…
> Do you have any examples of how to do this?
>
> I have the source code for the C++ components. If I could put them in a
> kernel mode DLL and then load that DLL, it would help me a lot. At the
> moment, I’m looking at re-implementing in C.
>
>
> Thanks,
> Andrew
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
> Sent: May 4, 2007 7:19 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] C++ in minifilter driver.
>
>
> Ahh right KMDF. It can help if he puts the C++ code (I am assuming it
> is
> not
> directly driver related) and export it as a kernel mode DLL for his
> mini-filter
> (that’s what I do).
>
> Don Burn wrote:
>
>> Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
>> all the files are C files (at least in all the KMDF betas, and WDK 6000
> and
>> the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it
> is
>> possible that the C++ support you are referring to is an artifact of
>> that.
>> But this still won’t help the OP, since KMDF is not for file system
>> filters.
>
> –
> Kind regards, Dejan
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@gridironsoftware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Dejan Maksimovic wrote:

Ahh right KMDF. It can help if he puts the C++ code (I am assuming it is not
directly driver related) and export it as a kernel mode DLL for his mini-filter
(that’s what I do).

Don Burn wrote:

> Where in the RamDisk sample? The only RamDisk sample’s are in KMDF, and
> all the files are C files (at least in all the KMDF betas, and WDK 6000 and
> the longhorn bets). Now, I know KMDF used C++ in a limited manor, so it is
> possible that the C++ support you are referring to is an artifact of that.
> But this still won’t help the OP, since KMDF is not for file system
> filters.


Kind regards, Dejan
http://www.alfasp.com
File system audit, security and encryption kits.

Putting your C++ code in a “kernel mode DLL” does not solve any
C+±related problems, it just adds a layer of complexity.

To use C++ in kernel mode you will need:

  1. Kernel mode implementations of any needed C++ runtime functions such
    as operator new and operator delete. This is trivial work and someone
    has already posted a link to one implementation you could use.

  2. Explicitly put extern “C” in front of any declarations whose names
    need to be known link-time or run-time to the C APIs in Windows. This
    is just like in user mode except that user mode C++ header files and
    class libraries tend to do this for you. If you already have the hard
    core low level mindset needed to work in kernel modem this should be
    second nature to you anyway.

  3. To keep complete mental track of every explicit or implicit memory
    allocation (including those done internally by STL and string classes),
    and explicitly decide on an allocation-by-allocation basis if you need
    that allocation to be in Paged, Non-Paged or Session pool. You need to
    do the same with every piece of code and data, including
    compiler-generated functions (such as implicit copy constructors,
    template instantiations and out-of-line copies of inline functions).

  4. Avoid anything to do with exceptions. Not because C++ is not SEH
    (C++ exceptions in user mode are implemented by the C++ runtime as SEH),
    but because the complex C++ runtime code to convert between SEH and C++
    is too big and complex to port to the incomplete SEH implementation in
    the kernel.


Jakob B?hm, M.Sc.Eng. * xxxxx@danware.dk * direct tel:+45-45-90-25-33
Danware Data A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax tel:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right