Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTL Issues. CH 12 PG 424-426 #25

Open
Allevon412 opened this issue Sep 22, 2023 · 2 comments
Open

KTL Issues. CH 12 PG 424-426 #25

Allevon412 opened this issue Sep 22, 2023 · 2 comments

Comments

@Allevon412
Copy link

Pavel,

I am reaching out to you because I am getting an error with the following code:

Main.cpp
#include "pch.h"
#include "DriverMain.h"
#include "MiniFilter.h"

NTSTATUS OnCreateClose(PDEVICE_OBJECT, PIRP Irp);
void UnloadFunc(PDRIVER_OBJECT DriverObject);
NTSTATUS InitMiniFilter(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);

extern "C" NTSTATUS DriverEntry(In PDRIVER_OBJECT DriverObject, In PUNICODE_STRING)
{
****g_State = new (PoolType::NonPaged, DRIVER_TAG) FilterState; <- issue here

MiniFilter.h
#pragma once
#include <D:\Training\windowskernelprogrammingbook2e\ktl\ktl\ktl.h>

struct FilterState {
FilterState();
~FilterState();

PFLT_FILTER filter;
*********Vector<WString<PoolType::NonPaged>, PoolType::NonPaged> Files;** <- issue here
ExecutiveResource Lock;
PDRIVER_OBJECT DriverObject;

};

It appears that the overloading functions are generating errors that I am giving the functions the wrong inputs when I try to use them:
For WString it's saying I am giving it too few arguments.

For new it says no instance of overloaded function matches the argument list unsigned long long, PoolType.

I was able to overcome these issues by calling functions like so:
Vector<WString<PoolType::NonPaged, DRIVER_TAG>, PoolType::NonPaged, DRIVER_TAG> Files;
g_State = new (PoolType::NonPaged, DRIVER_TAG) FilterState;

However, now when i try to follow along with the book I have a new problem entirely!

in MiniFilter.h
UNICODE_STRING path;
auto status = FLT_PREOP_SUCCESS_WITH_CALLBACK;
{
SharedLocker locker(g_State->Lock);
for (auto& name : g_State->Files)
{
*******name.GetUnicodeString(path); <- issue here
}
}

no instance of overloaded function "BasicString<T, Pool, Tag>::GetUnicodeString [with T=wchar_t, Pool=PoolType::NonPaged, Tag=69UL]" matches the argument list and object (the object has type qualifiers that prevent a match) DirectoryHider DriverProjects\DirectoryHider\DirectoryHider\MiniFilter.cpp

@zodiacon
Copy link
Owner

Indeed, the correct way to work is to add your Tag as part of the field.
I'll check why GetUnicodeString fails to compile. I did some improvements to KTL that I may have not pushed yet.

@zodiacon
Copy link
Owner

Pushed updates to KTL.
See if that resolves the compiler error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants