C# interface with fltmgr ?

This might be an absard question !.

I’m trying to get the usr-kernel communication directly from C# (.net environment ). I can have a very thin c/c++ dll to interface with the fltmgr libs, but I would much rather be interested in having [Dllimports “”] and directly access those function(s) in those libs. So when I was trying to use the protypes WINAPI (FAR PASCAL) comes my way. Well, may be I can craft those typedef(s), but try not to do those …

Has anyone tried this?. Or do I need to capture entrypoint address dynamically ( similar to LoadLibray(), GetProcAddress() ).

PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge, (b) .NET’s managed module security.

SInce I’m at the very early stage of exploring this, and intellegent answer to “Why bother …” would be difficult for me.

-pro

Pro:

Yes, it can be done, albeit painfully. Here’s an excerpt of a couple
declarations:

using System.Runtime.InteropServices;

[DllImport(“fltlib”, CharSet=CharSet.Auto)]
static extern unsafe int FilterConnectCommunicationPort(
string lpPortName,
uint dwOptions,
uint lpContext,
uint dwSizeOfContext,
uint lpSecurityAttributes,
out IntPtr hPort
);

[DllImport(“fltlib”)]
static extern unsafe int FilterSendMessage(
IntPtr hPort,
void *lpInBuffer,
int dwInBufferSize,
void *lpOutBuffer,
int dwOutBufferSize,
out int lpBytesReturned
);

Of course, then you’re stuck with the pain-in-the-*ss issues of using
unmanaged routines in C#, but that’s another story…

HTH,
Ken


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Prokash Sinha
Sent: Tuesday, April 26, 2005 1:53 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] C# interface with fltmgr ?

This might be an absard question !.

I’m trying to get the usr-kernel communication directly from C# (.net
environment ). I can have a very thin c/c++ dll to interface with the fltmgr
libs, but I would much rather be interested in having [Dllimports “filtmgr library>”] and directly access those function(s) in those libs. So
when I was trying to use the protypes WINAPI (FAR PASCAL) comes my way.
Well, may be I can craft those typedef(s), but try not to do those …

Has anyone tried this?. Or do I need to capture entrypoint address
dynamically ( similar to LoadLibray(), GetProcAddress() ).

PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge, (b) .NET’s
managed module security.

SInce I’m at the very early stage of exploring this, and intellegent answer
to “Why bother …” would be difficult for me.

-pro

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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Ken,

I will apply to see … .

Yeah, that much I can live with trusting those ( c/c++ lib/dlls ). Well
then I would try to seal the port(s) with CHAP authentication for now :-).

-pro

----- Original Message -----
From: “Ken Cross”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, April 26, 2005 11:08 AM
Subject: RE: [ntfsd] C# interface with fltmgr ?

> Pro:
>
> Yes, it can be done, albeit painfully. Here’s an excerpt of a couple
> declarations:
>
>
> using System.Runtime.InteropServices;
> …
>
> [DllImport(“fltlib”, CharSet=CharSet.Auto)]
> static extern unsafe int FilterConnectCommunicationPort(
> string lpPortName,
> uint dwOptions,
> uint lpContext,
> uint dwSizeOfContext,
> uint lpSecurityAttributes,
> out IntPtr hPort
> );
>
> [DllImport(“fltlib”)]
> static extern unsafe int FilterSendMessage(
> IntPtr hPort,
> void *lpInBuffer,
> int dwInBufferSize,
> void *lpOutBuffer,
> int dwOutBufferSize,
> out int lpBytesReturned
> );
>
>
> Of course, then you’re stuck with the pain-in-the-*ss issues of using
> unmanaged routines in C#, but that’s another story…
>
> HTH,
> Ken
>
>
> ________________________________
>
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Prokash Sinha
> Sent: Tuesday, April 26, 2005 1:53 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] C# interface with fltmgr ?
>
>
> This might be an absard question !.
>
> I’m trying to get the usr-kernel communication directly from C# (.net
> environment ). I can have a very thin c/c++ dll to interface with the
> fltmgr
> libs, but I would much rather be interested in having [Dllimports “> filtmgr library>”] and directly access those function(s) in those libs. So
> when I was trying to use the protypes WINAPI (FAR PASCAL) comes my way.
> Well, may be I can craft those typedef(s), but try not to do those …
>
> Has anyone tried this?. Or do I need to capture entrypoint address
> dynamically ( similar to LoadLibray(), GetProcAddress() ).
>
>
> PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge, (b) .NET’s
> managed module security.
>
> SInce I’m at the very early stage of exploring this, and intellegent
> answer
> to “Why bother …” would be difficult for me.
>
> -pro
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> 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@garlic.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

IIRC .NET had a feature called “pinvoke” which allows it to call the C entry points from the usual DLLs. So, develop a C# class wrapper around this DLL and encapsulate all “pinvoke” stuff there. Then use it from the usual C# code.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: Prokash Sinha
To: Windows File Systems Devs Interest List
Sent: Tuesday, April 26, 2005 9:53 PM
Subject: [ntfsd] C# interface with fltmgr ?

This might be an absard question !.

I’m trying to get the usr-kernel communication directly from C# (.net environment ). I can have a very thin c/c++ dll to interface with the fltmgr libs, but I would much rather be interested in having [Dllimports “”] and directly access those function(s) in those libs. So when I was trying to use the protypes WINAPI (FAR PASCAL) comes my way. Well, may be I can craft those typedef(s), but try not to do those …

Has anyone tried this?. Or do I need to capture entrypoint address dynamically ( similar to LoadLibray(), GetProcAddress() ).

PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge, (b) .NET’s managed module security.

SInce I’m at the very early stage of exploring this, and intellegent answer to “Why bother …” would be difficult for me.

-pro

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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Max,

I got the start from Ken already. Now there must be something I’m still missing. But, for example, I was trying the following, and an explicit offset setting would give the comfort —

public unsafe struct _OVERLAPPED

{

int* Internal;

i nt* InternalHigh;

[StructLayout( LayoutKind.Explicit )]

public struct Union

{

//[FieldOffset(0)] <------- Compiler does not take this, ???

struct offset{

int Offset;

int OffsetHigh;

}

[FieldOffset(0)]

void * Pointer;

}

}

Need to look bit more to see …

-pro

----- Original Message -----
From: Maxim S. Shatskih
To: Windows File Systems Devs Interest List
Sent: Wednesday, April 27, 2005 1:06 AM
Subject: Re: [ntfsd] C# interface with fltmgr ?

IIRC .NET had a feature called “pinvoke” which allows it to call the C entry points from the usual DLLs. So, develop a C# class wrapper around this DLL and encapsulate all “pinvoke” stuff there. Then use it from the usual C# code.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: Prokash Sinha
To: Windows File Systems Devs Interest List
Sent: Tuesday, April 26, 2005 9:53 PM
Subject: [ntfsd] C# interface with fltmgr ?

This might be an absard question !.

I’m trying to get the usr-kernel communication directly from C# (.net environment ). I can have a very thin c/c++ dll to interface with the fltmgr libs, but I would much rather be interested in having [Dllimports “”] and directly access those function(s) in those libs. So when I was trying to use the protypes WINAPI (FAR PASCAL) comes my way. Well, may be I can craft those typedef(s), but try not to do those …

Has anyone tried this?. Or do I need to capture entrypoint address dynamically ( similar to LoadLibray(), GetProcAddress() ).

PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge, (b) .NET’s managed module security.

SInce I’m at the very early stage of exploring this, and intellegent answer to “Why bother …” would be difficult for me.

-pro

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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
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: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Pro:

If you need OVERLAPPED, .NET has a built-in structure:
System.Threading.NativeOverlapped.

Also, just FYI, http://pinvoke.net/ is an outstanding resource for migrating
from Win32 and other unmanaged APIs to C#. It has saved me many hours of
work.

Ken


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Prokash Sinha
Sent: Wednesday, April 27, 2005 5:30 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] C# interface with fltmgr ?

Max,

I got the start from Ken already. Now there must be something I’m still
missing. But, for example, I was trying the following, and an explicit
offset setting would give the comfort —

public unsafe struct _OVERLAPPED

{

int* Internal;

i nt* InternalHigh;

[StructLayout( LayoutKind.Explicit )]

public struct Union

{

//[FieldOffset(0)] <------- Compiler does not take this,
???

struct offset{

int Offset;

int OffsetHigh;

}

[FieldOffset(0)]

void * Pointer;

}

}

Need to look bit more to see …

-pro

----- Original Message -----
From: Maxim S. Shatskih mailto:xxxxx
To: Windows File Systems Devs Interest List
mailto:xxxxx
Sent: Wednesday, April 27, 2005 1:06 AM
Subject: Re: [ntfsd] C# interface with fltmgr ?

IIRC .NET had a feature called “pinvoke” which allows it to call
the C entry points from the usual DLLs. So, develop a C# class wrapper
around this DLL and encapsulate all “pinvoke” stuff there. Then use it from
the usual C# code.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: Prokash Sinha mailto:xxxxx
To: Windows File Systems Devs Interest List
mailto:xxxxx
Sent: Tuesday, April 26, 2005 9:53 PM
Subject: [ntfsd] C# interface with fltmgr ?

This might be an absard question !.

I’m trying to get the usr-kernel communication directly from
C# (.net environment ). I can have a very thin c/c++ dll to interface with
the fltmgr libs, but I would much rather be interested in having [Dllimports
“”] and directly access those function(s) in those
libs. So when I was trying to use the protypes WINAPI (FAR PASCAL) comes my
way. Well, may be I can craft those typedef(s), but try not to do those …

Has anyone tried this?. Or do I need to capture entrypoint
address dynamically ( similar to LoadLibray(), GetProcAddress() ).

PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge,
(b) .NET’s managed module security.

SInce I’m at the very early stage of exploring this, and
intellegent answer to “Why bother …” would be difficult for me.

-pro

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

You are currently subscribed to ntfsd as: unknown lmsubst
tag argument: ‘’
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: unknown lmsubst tag
argument: ‘’
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: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>

Great, and Thanks a lot.

-pro

----- Original Message -----
From: “Ken Cross”
To: “Windows File Systems Devs Interest List”
Sent: Wednesday, April 27, 2005 5:11 AM
Subject: RE: [ntfsd] C# interface with fltmgr ?

> Pro:
>
> If you need OVERLAPPED, .NET has a built-in structure:
> System.Threading.NativeOverlapped.
>
> Also, just FYI, http://pinvoke.net/ is an outstanding resource for
> migrating
> from Win32 and other unmanaged APIs to C#. It has saved me many hours of
> work.
>
> Ken
>
>
> ________________________________
>
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Prokash Sinha
> Sent: Wednesday, April 27, 2005 5:30 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] C# interface with fltmgr ?
>
>
> Max,
>
> I got the start from Ken already. Now there must be something I’m still
> missing. But, for example, I was trying the following, and an explicit
> offset setting would give the comfort —
>
> public unsafe struct _OVERLAPPED
>
> {
>
> int* Internal;
>
> i nt* InternalHigh;
>
> [StructLayout( LayoutKind.Explicit )]
>
> public struct Union
>
> {
>
> //[FieldOffset(0)] <------- Compiler does not take
> this,
> ???
>
> struct offset{
>
> int Offset;
>
> int OffsetHigh;
>
> }
>
> [FieldOffset(0)]
>
> void * Pointer;
>
> }
>
> }
>
> Need to look bit more to see …
>
> -pro
>
> ----- Original Message -----
> From: Maxim S. Shatskih mailto:xxxxx
> To: Windows File Systems Devs Interest List
> mailto:xxxxx
> Sent: Wednesday, April 27, 2005 1:06 AM
> Subject: Re: [ntfsd] C# interface with fltmgr ?
>
> IIRC .NET had a feature called “pinvoke” which allows it to call
> the C entry points from the usual DLLs. So, develop a C# class wrapper
> around this DLL and encapsulate all “pinvoke” stuff there. Then use it
> from
> the usual C# code.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: Prokash Sinha mailto:xxxxx
> To: Windows File Systems Devs Interest List
> mailto:xxxxx
> Sent: Tuesday, April 26, 2005 9:53 PM
> Subject: [ntfsd] C# interface with fltmgr ?
>
> This might be an absard question !.
>
> I’m trying to get the usr-kernel communication directly from
> C# (.net environment ). I can have a very thin c/c++ dll to interface with
> the fltmgr libs, but I would much rather be interested in having
> [Dllimports
> “”] and directly access those function(s) in those
> libs. So when I was trying to use the protypes WINAPI (FAR PASCAL) comes
> my
> way. Well, may be I can craft those typedef(s), but try not to do those
> …
>
> Has anyone tried this?. Or do I need to capture entrypoint
> address dynamically ( similar to LoadLibray(), GetProcAddress() ).
>
>
> PRIMARY REASON IS TO TAKE THE ADVANTAGE OF (a) C# langauge,
> (b) .NET’s managed module security.
>
> SInce I’m at the very early stage of exploring this, and
> intellegent answer to “Why bother …” would be difficult for me.
>
> -pro
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst
> tag argument: ‘’
> 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: unknown lmsubst tag
> argument: ‘’
> 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: unknown lmsubst tag argument: ‘’
> 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@garlic.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>