Skip to content

Instantly share code, notes, and snippets.

@aaaddress1
Last active February 16, 2018 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaaddress1/f7f16504d70cf48351746e8c1abd2ee4 to your computer and use it in GitHub Desktop.
Save aaaddress1/f7f16504d70cf48351746e8c1abd2ee4 to your computer and use it in GitHub Desktop.
C++ 樣板化函數指標呼叫
/* @file: brainFuckCppCall.cpp
* @author: aaaddress1@chroot.org
*/
#include <stdio.h>
#include <Windows.h>
template<class T> struct func {
explicit func(FARPROC ptr) : _ptr(ptr) {}
operator T() { return reinterpret_cast<T>(_ptr); }
FARPROC _ptr;
};
int main(void) {
func<decltype(&MessageBoxA)> msgbox(GetProcAddress(LoadLibraryA("user32"), "MessageBoxA"));
msgbox(0, "hi", "info", 0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment