Last active
August 29, 2015 14:20
-
-
Save kumatti1/6b59eb5eeea154db8895 to your computer and use it in GitHub Desktop.
関数ポインタ実行すんねん(・∀・)
This file contains hidden or 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
Option Explicit | |
Private Declare PtrSafe _ | |
Function SE_GetProcAddressIgnoreIncExc Lib "apphelp.dll" ( _ | |
ByRef arg1 As Long, _ | |
ByVal arg2 As LongPtr, _ | |
ByRef arg3 As String _ | |
) As Long | |
Private Declare PtrSafe _ | |
Function SE_GetProcAddressForCaller Lib "apphelp.dll" ( _ | |
ByVal arg1 As LongPtr, _ | |
ByVal arg2 As LongPtr, _ | |
ByVal arg3 As LongPtr, _ | |
ByVal arg4 As LongPtr, _ | |
ByVal arg5 As LongPtr _ | |
) As LongPtr | |
Private Declare PtrSafe Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongPtr | |
Sub hoge() | |
Dim hDll As LongPtr | |
'hDll = GetModuleHandle("user32.dll") | |
'Debug.Print hDll | |
Dim ptr As LongPtr | |
ptr = VBA.CLngPtr(AddressOf func) | |
Dim ret As LongPtr | |
ret = SE_GetProcAddressForCaller(ptr, 0, 0, 0, 0) | |
Debug.Print Hex$(ret), Hex$(ptr) | |
End Sub | |
Sub func() | |
MsgBox "" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment