Re: RE: [ntfsd] RE: [ntfsd] RE: [ntfsd] FilterAttach returns error code 0x80070002

No worries, I’m glad I could help. As a long time Windows developer I have
just as hard a time working on the Linux kernel, mostly struggling with the
lack of any documentation (I actually implemented my own atomic
single-linked list because I couldn’t guess the header file or function
names…) :). Oh, and don’t get me started on the kernel debugging tools…

But if things were easy we wouldn’t have any fun, right ?

Thanks,
Alex.

On Wed, Feb 12, 2014 at 12:06 AM, Jens Mittag wrote:

> Hi Alex,
>
> thank you for the clarification, I appreciate your time and efforts. I am
> also reading everything that looks relevant to me, but as a long-time Linux
> developer the minifilter project I am working on is the first Windows
> device driver project for me and also the first time that I am writing
> software for the Windows platform at all. Hence, not everything is 100%
> clear to me and it is sometimes difficult to identify which documentation
> is relevant and which is not (apart from the fact that the MSDN
> documentation is sometimes ambiguous). What is most struggling to me are
> the various different programming APIs that intend to do the same. One for
> kernel mode, one for user mode, some old APIs, several new APIs offering
> particular advantages, etc…
>
> Thanks a lot
> Jens
>
> From: xxxxx@lists.osr.com [mailto:
> xxxxx@lists.osr.com] On Behalf Of Alex Carp
> Sent: Tuesday, February 11, 2014 6:20 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] RE: [ntfsd] RE: [ntfsd] FilterAttach returns error
> code 0x80070002
>
> To be honest I often read multiple documentation pages for related issues,
> like . However, the line I quoted is from the documentation page for
> FilterAttach (
> http://msdn.microsoft.com/en-us/library/windows/hardware/ff540442(v=vs.85).aspx),
> but from the bottom part where the possible return values are listed…
>
> Anyway, you can specify an instance name but there must be a key with the
> instance name (for instance FOO you should
> have HKLM\CurrentControlSet\Services\YourFilter\Instances\FOO) with the
> instance attributes. In fact I’m willing to bet that the error that you
> get(ERROR_FILE_NOT_FOUND) comes from when FltMgr is trying to open that
> registry path (in your
> case HKLM\CurrentControlSet\Services\YourFilter\Instances\C: since you were
> specifying that name as the instance name).
>
> Anyway, I’m glad it works now.
>
> Thanks,
> Alex.
>
> On Mon, Feb 10, 2014 at 11:17 PM, Jens Mittag
> wrote:
> Hi Alex,
>
> it seems I should always read the documentation of the kernel equivalent
> then. :wink: Because the documentation of FilterAttach states: “lpInstanceName
> [in, optional]: Pointer to a null-terminated wide-character string
> containing the instance name for the new instance. This parameter is
> optional and can be NULL. If this parameter is NULL, the new instance
> receives the minifilter’s default instance name as described in the Remarks
> section for FltAttachVolume”. From that description it was not clear to me
> that the instance name cannot be chosen arbitrarily.
>
> Thanks,
> Jens
>
> From: xxxxx@lists.osr.com [mailto:
> xxxxx@lists.osr.com] On Behalf Of Alex Carp
> Sent: Tuesday, February 11, 2014 2:46 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] RE: [ntfsd] FilterAttach returns error code 0x80070002
>
> Hi Jens
>
> I’m not sure it’s that strange :). The documentation states that the
> function will fail with ERROR_FILE_NOT_FOUND If lpInstanceName is
> non-NULL, lpInstanceName does not match a registered filter instance name
> in the registry.
> So did you give the instance a name in the registry ? Is that name “C:” ?
>
> Thanks,
> Alex.
>
> On Mon, Feb 10, 2014 at 10:16 AM, Jens Mittag
> wrote:
> Hi Alex,
>
> ahhhh, thanks a lot. Without passing an instance name it works perfectly,
> thought it is strange that it doesn’t work with a name.
>
> Jens
>
> From: xxxxx@lists.osr.com [mailto:
> xxxxx@lists.osr.com] On Behalf Of Alex Carp
> Sent: Monday, February 10, 2014 7:09 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] FilterAttach returns error code 0x80070002
>
> Can you try calling it like so:
> status = FilterAttach(L"myminifilter",
> argv[2],
> NULL, // <- not argv[2]…
> NULL,
> NULL);
>
> Thanks,
> Alex.
>
> On Mon, Feb 10, 2014 at 7:09 AM, Jens Mittag
> wrote:
> Hi,
>
> I am working on a minifilter and it works without problems so far when I
> let it auto-attach to all volumes after successfully loading it. I have
> disabled the auto-attach behavior now and instead want to attach my
> minifilter from an own user space control daemon that is calling
> FilterAttach(). However, every time I get an error code of 0x80070002 as a
> result.
>
> Here is the relevant code:
>
> HRESULT status;
> TCHAR lpDosName[100];
>
> status = FilterGetDosName(argv[2], lpDosName, 100);
> if (status == S_OK)
> {
> printf(“Received the following dos name for volume ‘%ls’: %ls\n”,
> argv[2], lpDosName);
> }
> else
> {
> printf(“Operation failed with error 0x%08lx\n”, status);
> }
>
> status = FilterAttach(L"myminifilter",
> argv[2],
> argv[2],
> NULL,
> NULL);
>
> The filter is successfully loaded using the OpenSCManager() and
> OpenService() approach, and the application is executed in a terminal
> running as administrator. fltmc shows that the filter is loaded and has 0
> instances.
>
> When I run my application with “C:” as argv[2] then, I get the following
> output:
>
> Received the following dos name for volume ‘C:’: C:
> Error code: 0x80070002
>
> However, when I attach the filter to “C:” using fltmc everything works
> fine… What is my mistake? Insufficient access rights? According to the
> Microsoft Error Code tool 0x80070002 refers to an object or file not found
> error, which is strange because FilterGetDosName(…) can handle the input
> “C:”. I also tried other inputs for argv[2], but no success.
>
> In case it matters: my target platform is Win 8.1 32-bit in a virtual
> machine.
>
> Thanks for your help
> Jens
>
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system 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
>
> — NTFSD is sponsored by OSR OSR is hiring!! Info at
> http://www.osr.com/careers For our schedule of debugging and file system
> 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
>
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system 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
>
> — NTFSD is sponsored by OSR OSR is hiring!! Info at
> http://www.osr.com/careers For our schedule of debugging and file system
> 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
>
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system 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
>
> — NTFSD is sponsored by OSR OSR is hiring!! Info at
> http://www.osr.com/careers For our schedule of debugging and file system
> 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
>
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system 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
>