Last active
February 16, 2018 16:47
-
-
Save aaaddress1/f7f16504d70cf48351746e8c1abd2ee4 to your computer and use it in GitHub Desktop.
C++ 樣板化函數指標呼叫
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @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