Private Const PATCH_05 As Long = 93 'Table B (before) entry count
Private Const PATCH_09 As Long = 137 'Table A (after) entry count
Private nMsgCntB As Long 'Before msg table entry count
Private nMsgCntA As Long 'After msg table entry count
Private aMsgTblB() As Long 'Before msg table array
Private aMsgTblA() As Long 'After msg table array
Private hWndSub As Long 'Handle of the window being subclassed
Private nAddrSubclass As Long 'The address of our WndProc
Private nAddrOriginal As Long 'The address of the existing WndProc
Public Enum enMsgWhen
MSG_AFTER = 1&
MSG_BEFORE = 2&
MSG_BEFORE_AND_AFTER = 3&
ALL_MESSAGES = &HFFFFFFFF
End Enum
'============================================
'Class creation/destruction
'============================================
'Build the subclass thunk into allocated memory
Private Sub Class_Initialize()
Const PATCH_01 As Long = 18 'Code buffer offset to the location of the relative address to EbMode
Const PATCH_03 As Long = 78 'Relative address of SetWindowsLong
Const PATCH_07 As Long = 121 'Relative address of CallWindowProc
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_SWL As String = "SetWindowLongA" '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 FUNC_CWP As String = "CallWindowProcA" 'We use CallWindowProc to call the original WndProc
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 SetWindowLong & CallWindowProc functions
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