using EXUNSUBSCRIBEWNFSTATECHANGE = NTSTATUS(PVOID Subscription);
// ==========================================================
// Global Function Pointers for WNF
// ==========================================================
The issue in your code primarily revolves around the incorrect definition of function pointer types using the using keyword. Let's break down the problems and how to fix them:
1. Function Type vs. Function Pointer Type
When you define a type using using (or typedef), it's crucial to specify whether you're defining a function type or a function pointer type. In your current definitions:
These definitions are for function types, not function pointer types. However, when you try to assign nullptr, you're implying that these are function pointers, which leads to a type mismatch.
2. Correcting the Definitions
To define function pointer types, you need to include the * in your using declarations. Here's how you can correct them:
Define Function Pointer Types Correctly: Ensure that your using declarations include the * to denote pointers.
Initialize Pointers Appropriately: Once the types are correctly defined as pointers, initializing them to nullptr becomes valid.
Consider Linkage Specifications: Use extern "C" if interfacing with C libraries or expecting C-style linkage.
By addressing these points, your code should compile without issues related to function pointer declarations.
Note: Always ensure that the function signatures match exactly with the functions you intend to point to, including calling conventions (e.g., __stdcall, __cdecl) if applicable.
The type definitions incorrectly declare function types instead of function pointer types. The using aliases should include a pointer (e.g., using EXSUBSCRIBEWNFSTATECHANGE = NTSTATUS (*)(PVOID, ULONG64, …)) so that the global pointers can be initialized to nullptr.