This typedef declaration
typedef NTSTATUS (WINAPI * PFN_NTQUERYINFORMATIONFILE)(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
introduces an alias named
PFN_NTQUERYINFORMATIONFILE` for the type
NTSTATUS (WINAPI * )(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
that represents a pointer to function with 5 parameters and the return type NTSTATUS
.
Now you may use this name to declare pointers to functions of such a type
PFN_NTQUERYINFORMATIONFILE ptr;
You could get the same the following way that looks more clear
using PFN_NTQUERYINFORMATIONFILE =
NTSTATUS (WINAPI * )(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
Also consider the following simple example
#include <iostream>
int sum( int x, int y )
{
return x + y;
}
int product( int x, int y )
{
return x * y;
}
int division( int x, int y )
{
return x / y;
}
typedef int ( *fp )( int, int );
int main( )
{
for ( fp f : { sum, product, division } ) std::cout << f( 10, 2 ) << std::endl;
}
The output is
12
20
5
Take into account that function names implicitly are converted to pointers to functions when they are used in expressions.
So for example this statement with the function from the above demonstrative program is valid
std::cout << ( ***/* replace the comment with as many asterisks as you like */****sum )( 10, 20 ) << std::endl;
So if you are paid accordingly to the number of typed symbols in the program then you can use this trick with function calls.
(****************************************************sum )( 10, 20 );
This is restricted only by the compiler limits.
As for IN
and OUT
then they are macros used by Microsoft to make it clear what each parameter of a function is used for, whether it provides an input value or it serves as an output parameter.