C++ 指向带2个参数的WINAPI函数的Typedef指针

C++ 指向带2个参数的WINAPI函数的Typedef指针,c++,winapi,function-pointers,typedef,C++,Winapi,Function Pointers,Typedef,这是什么意思?我知道NTUNMPVIEWOFSection是一个指向Winapi函数的指针,该函数有两个参数和一个长返回值。我知道这个块正在将“GetProcAddress”及其参数强制转换为一个NtUnmapViewOfSection对象。但最后一排在干什么 typedef LONG (WINAPI * NtUnmapViewOfSection)(HANDLE ProcessHandle, PVOID BaseAddress); NtUnmapViewOfSection xNtUnmapVi

这是什么意思?我知道NTUNMPVIEWOFSection是一个指向Winapi函数的指针,该函数有两个参数和一个长返回值。我知道这个块正在将“GetProcAddress”及其参数强制转换为一个NtUnmapViewOfSection对象。但最后一排在干什么

typedef LONG (WINAPI * NtUnmapViewOfSection)(HANDLE ProcessHandle, PVOID BaseAddress);

NtUnmapViewOfSection xNtUnmapViewOfSection;
xNtUnmapViewOfSection = NtUnmapViewOfSection(GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtUnmapViewOfSection"));
xNtUnmapViewOfSection(Pinfo.hProcess, PVOID(dwImageBase)); // Pinfo is PROCESS_INFORMATION and dwImageBase is a pointer to DWORD
最后一排在干什么

最后一行是使用
GetProcAddress()
调用指针指向的函数-也就是说,它正在调用
NtUnmapViewOfSection()

最后一排在干什么


最后一行是用
GetProcAddress()
调用指针指向的函数-也就是说,它调用
NtUnmapViewOfSection()

可能重复的
xNtUnmapViewOfSection=NtUnmapViewOfSection(GetProcAddress(GetModuleHandleA(“ntdll.dll”),“NtUnmapViewOfSection”)是一种不寻常的演员扮演方式。如果它写为
xNtUnmapViewOfSection=(NtUnmapViewOfSection)GetProcAddress(GetModuleHandleA(“ntdll.dll”),“NtUnmapViewOfSection”)这可能更清楚,我们正在分配给函数指针(而不是像您天真地假设的那样调用函数)。可能重复
xNtUnmapViewOfSection=NtUnmapViewOfSection(GetProcAddress(GetModuleHandleA(“ntdll.dll”),“NtUnmapViewOfSection”)是一种不寻常的演员扮演方式。如果它写为
xNtUnmapViewOfSection=(NtUnmapViewOfSection)GetProcAddress(GetModuleHandleA(“ntdll.dll”),“NtUnmapViewOfSection”)这可能更清楚,我们正在分配给函数指针(而不是像您天真地假设的那样调用函数)。