Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long
Private nAddrHook As Long 'Address of the hook thunk
Private hHook As Long 'Hook handle
'============================================
'Class creation/destruction
'============================================
'Build the hook thunk into allocated memory
Private Sub Class_Initialize()
Const PATCH_01 As Long = 17 'Code buffer offset to the location of the relative address to EbMode
Const PATCH_03 As Long = 71 'Relative address of UnhookWindowsHookEx
Const PATCH_05 As Long = 101 'Relative address of CallNextHookEx
Const FUNC_EBM As String = "EbMode" 'VBA's EbMode function allows the machine code thunk to know if the IDE has stopped or is on a breakpoint
Const FUNC_UWH As String = "UnhookWindowsHookEx" 'We use CallWindowProc to call the original WndProc
Const FUNC_CNH As String = "CallNextHookEx" 'SetWindowLong allows the cSubclasser machine code thunk to unsubclass the subclasser itself if it detects via the EbMode function that the IDE has stopped
Const MOD_VBA5 As String = "vba5" 'Location of the EbMode function if running VB5
Const MOD_VBA6 As String = "vba6" 'Location of the EbMode function if running VB6
Const MOD_USER As String = "user32" 'Location of the KillTimer function
Dim i As Long 'Loop index
Dim nLen As Long 'String lengths
Dim sHex As String 'Hex code string
Dim sCode As String 'Binary code string
'Store the hex pair machine code representation in sHex