Click here to Skip to main content
15,919,341 members
Home / Discussions / COM
   

COM

 
GeneralRe: Registration Free Com in Excel Pin
Richard Deeming20-Oct-16 2:00
mveRichard Deeming20-Oct-16 2:00 
GeneralRe: Registration Free Com in Excel Pin
Member 1233692920-Oct-16 2:36
Member 1233692920-Oct-16 2:36 
GeneralRe: Registration Free Com in Excel Pin
Richard Deeming20-Oct-16 11:20
mveRichard Deeming20-Oct-16 11:20 
QuestionTlbImp not getting everything Pin
Midi_Mick8-Oct-16 2:40
professionalMidi_Mick8-Oct-16 2:40 
QuestionDebug COM DLL from ASP.Net Pin
Member 741142216-Jul-16 18:03
Member 741142216-Jul-16 18:03 
AnswerRe: Debug COM DLL from ASP.Net Pin
F-ES Sitecore21-Jul-16 1:01
professionalF-ES Sitecore21-Jul-16 1:01 
QuestionCreate a new system Calendar for Windows (unmanaged code) Pin
Member 772518028-Mar-16 15:09
Member 772518028-Mar-16 15:09 
AnswerRe: Create a new system Calendar for Windows (unmanaged code) Pin
Richard MacCutchan28-Mar-16 21:54
mveRichard MacCutchan28-Mar-16 21:54 
GeneralRe: Create a new system Calendar for Windows (unmanaged code) Pin
Member 772518029-Mar-16 1:16
Member 772518029-Mar-16 1:16 
GeneralRe: Create a new system Calendar for Windows (unmanaged code) Pin
Richard MacCutchan29-Mar-16 1:40
mveRichard MacCutchan29-Mar-16 1:40 
GeneralRe: Create a new system Calendar for Windows (unmanaged code) Pin
Member 772518029-Mar-16 10:10
Member 772518029-Mar-16 10:10 
GeneralRe: Create a new system Calendar for Windows (unmanaged code) Pin
Richard MacCutchan30-Mar-16 11:54
mveRichard MacCutchan30-Mar-16 11:54 
GeneralRe: Create a new system Calendar for Windows (unmanaged code) Pin
Getterdonne3-Sep-16 13:13
professionalGetterdonne3-Sep-16 13:13 
QuestionC# Invoking Context menu item programmatically. Pin
Member 1223225328-Mar-16 0:39
Member 1223225328-Mar-16 0:39 
QuestionCreating an IShellLink in .NET Pin
Richard Andrew x6429-Dec-15 15:42
professionalRichard Andrew x6429-Dec-15 15:42 
QuestionTrouble with implement Com Local Server Pin
Tri Cuong26-Sep-15 7:00
Tri Cuong26-Sep-15 7:00 
AnswerRe: Trouble with implement Com Local Server Pin
Richard MacCutchan26-Sep-15 20:47
mveRichard MacCutchan26-Sep-15 20:47 
GeneralRe: Trouble with implement Com Local Server Pin
Tri Cuong3-Oct-15 7:29
Tri Cuong3-Oct-15 7:29 
GeneralRe: Trouble with implement Com Local Server Pin
Richard MacCutchan4-Oct-15 2:41
mveRichard MacCutchan4-Oct-15 2:41 
QuestionWhy is the resolution in SampleGrabber different from the resolution in IAMStreamConfig? Pin
garry.fang24-Jun-15 12:44
garry.fang24-Jun-15 12:44 
QuestionC#: Fixed Function ID in COM DLL Pin
DoxMan20-Apr-15 23:52
DoxMan20-Apr-15 23:52 
AnswerRe: C#: Fixed Function ID in COM DLL Pin
Richard Deeming21-Apr-15 2:37
mveRichard Deeming21-Apr-15 2:37 
AnswerRe: C#: Fixed Function ID in COM DLL Pin
F-ES Sitecore29-Apr-15 4:09
professionalF-ES Sitecore29-Apr-15 4:09 
QuestionIoleUndoManager with Excel application Pin
jaafar tribak6-Apr-15 5:28
jaafar tribak6-Apr-15 5:28 
QuestionEXCEL - Hooking Excel VTABLE Pin
jaafar tribak3-Apr-15 17:53
jaafar tribak3-Apr-15 17:53 
The following code is supposed to redirect the call to the Excel Calculate Method to my own function (MeMsg)

After running the HookCOMFunction routine , the Test Macro successfully executes the MeMsg replacement function as expected .. So far so good

However, when executing an excel calculation via the User Interface (not via code) such as by pressing the F9 key , the MeMsg replacement function doesn't get called ... I thought that replacing the 'Calculate' VTable offset address with the address of my replacement function would also work everytime excel is calculated via the User Interface

Any thoughts anyone ? My goal is to hook the excel Calculate Method via code as well as via the UI

Regards.

Code :

Option Explicit

Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long _
)

Private Declare Function VirtualProtect Lib "kernel32.dll" ( _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flNewProtect As Long, _
lpflOldProtect As Long _
) As Long

Private Const PAGE_EXECUTE_READWRITE As Long = &H40&

Sub HookCOMFunction()
Dim pVTable As Long
Const lFuncOffset As Long = 84

CopyMemory pVTable, ByVal ObjPtr(Application), 4
VirtualProtect pVTable + lFuncOffset, 4&, PAGE_EXECUTE_READWRITE, 0&
CopyMemory ByVal pVTable + lFuncOffset, AddressOf MeMsg, 4
End Sub

Private Function MeMsg(ByVal voObjPtr As Long, ByVal Param As Long) As Long
MsgBox "Excel 'Calculate Method Hooked !!"
End Function

Sub Test()
Application.Calculate
End Sub

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.