Created
May 23, 2015 22:42
-
-
Save kumatti1/bcafb5a4fb3269fd42c3 to your computer and use it in GitHub Desktop.
Nameステートメントを直で呼び出す
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 GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongPtr | |
Private Declare PtrSafe Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, ByVal lpProcName As String) As LongPtr | |
Private Declare PtrSafe _ | |
Function DispCallFunc Lib "OleAut32.dll" ( _ | |
ByVal pvInstance As LongPtr, _ | |
ByVal oVft As LongPtr, _ | |
ByVal cc_ As Long, _ | |
ByVal vtReturn As Integer, _ | |
ByVal cActuals As Long, _ | |
ByRef prgvt As Integer, _ | |
ByRef prgpvarg As LongPtr, _ | |
ByRef pvargResult As Variant _ | |
) As Long | |
Const CC_STDCALL = 4 | |
Sub hoge() | |
Dim proc As LongPtr | |
proc = GetModuleHandle("vbe7.dll") | |
If proc = 0 Then Exit Sub | |
Debug.Print Hex$(proc) | |
proc = proc + &H7D3F2 | |
Debug.Print Hex$(proc) | |
Dim hr As Long | |
Dim ret As Variant | |
Const src = | |
Const dst = | |
Dim pVar(0 To 1) As LongPtr | |
Dim v(0 To 1) As Variant | |
v(0) = StrPtr(dst) | |
v(1) = StrPtr(src) | |
pVar(0) = VarPtr(v(0)) | |
pVar(1) = VarPtr(v(1)) | |
Dim vt(0 To 1) As Integer | |
vt(0) = vbLong | |
vt(1) = vbLong | |
hr = DispCallFunc(0, proc, CC_STDCALL, vbLong, 2, vt(0), pVar(0), ret) | |
Debug.Print Hex$(hr), Hex$(ret) | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment