Difference between revisions of "Studio:Delegating ISHELL SendEvent"

From STRIDE Wiki
Jump to: navigation, search
 
m (Text replace - 'Category:Intercept Modules' to 'Category:Studio:Intercept Modules')
 
(12 intermediate revisions by 3 users not shown)
Line 2: Line 2:
  
 
Delegating the user's call to the IShell helper macro ISHELL_SendEvent is a better method. ISHELL_SendEvent is defined in AEEShell.h as follows:<br>
 
Delegating the user's call to the IShell helper macro ISHELL_SendEvent is a better method. ISHELL_SendEvent is defined in AEEShell.h as follows:<br>
<tt>#define ISHELL_SendEvent(p,cls,ec,wp,dw)<br>
+
<Source lang="c">
GET_PVTBL(p,IShell)->SendEvent(p,0,cls,ec,wp,dw)</tt><br>
+
#define ISHELL_SendEvent(p,cls,ec,wp,dw)
 +
GET_PVTBL(p,IShell)->SendEvent(p,0,cls,ec,wp,dw)
 +
</Source>
  
 
This requires a small amount of instrumentation to the calling application, essentially to define the Group ID and include IM.h. You must also complete the following steps:<br>
 
This requires a small amount of instrumentation to the calling application, essentially to define the Group ID and include IM.h. You must also complete the following steps:<br>
 
<ol>
 
<ol>
 
<li>Ensure that the calling application is using the helper macro to call the Send event.</li>
 
<li>Ensure that the calling application is using the helper macro to call the Send event.</li>
<li>Add the following code to the AEEShell.h file instead of the #ifdef _SCL conditional block:</li>
+
<li>Add the following code to the AEEShell.h file inside of the #ifdef _SCL conditional block:</li>
<tt>#undef ISHELL_SendEvent<br>
+
<source lang="c">
int ISHELL_SendEvent(IShell *po, AEECLSID cls, AEEEvent eCode, uint16 wParam, uint32 dwParam);<br>
+
#undef ISHELL_SendEvent
#pragma scl_function(ISHELL_SendEvent)<br>
+
int ISHELL_SendEvent(IShell *po, AEECLSID cls, AEEEvent eCode, uint16 wParam, uint32 dwParam);
#pragma scl_ptr_opaque(ISHELL_SendEvent,po)<br></tt>
+
#pragma scl_function(ISHELL_SendEvent, "REFERENCE", "IMPLICIT", <groupid-name>)
<li>Create a user-mangled dynamic delegate for the function ISHELL_SendEvent.</li>
+
#pragma scl_ptr_opaque(ISHELL_SendEvent,po)
 +
</source>
 +
<li>Generate ''remote interceptor'' (formal ''dynamic delegate'') for the function ISHELL_SendEvent:</li>
 +
<pre>
 +
> s2sinstrument --mode=PIT(ISHELL_SendEvent) ...
 +
</pre>
 
<li>Add the instrumentation to the calling application's code:</li>
 
<li>Add the instrumentation to the calling application's code:</li>
<tt>#ifdef srIMON<br>
+
<source lang="c">
#define <groupid-name><br>
+
#define <groupid-name>
#include <name>IM.h<br>
+
#include <name>IM.h
#endif</tt><br>
+
</source>
  
 
This allows you to dynamically intercept the call for the application under test.
 
This allows you to dynamically intercept the call for the application under test.
 +
 +
[[Category:Studio:Intercept Modules]]

Latest revision as of 09:42, 21 August 2009

When trying to dynamically intercept a call for the application under test, intercepting only the call/method of interest was difficult when delegating the IShell Virtual Table, as it allows all methods to be intercepted for all callers.

Delegating the user's call to the IShell helper macro ISHELL_SendEvent is a better method. ISHELL_SendEvent is defined in AEEShell.h as follows:

#define ISHELL_SendEvent(p,cls,ec,wp,dw)
GET_PVTBL(p,IShell)->SendEvent(p,0,cls,ec,wp,dw)

This requires a small amount of instrumentation to the calling application, essentially to define the Group ID and include IM.h. You must also complete the following steps:

  1. Ensure that the calling application is using the helper macro to call the Send event.
  2. Add the following code to the AEEShell.h file inside of the #ifdef _SCL conditional block:
  3. #undef ISHELL_SendEvent
    int ISHELL_SendEvent(IShell *po, AEECLSID cls, AEEEvent eCode, uint16 wParam, uint32 dwParam);
    #pragma scl_function(ISHELL_SendEvent, "REFERENCE", "IMPLICIT", <groupid-name>)
    #pragma scl_ptr_opaque(ISHELL_SendEvent,po)
    
  4. Generate remote interceptor (formal dynamic delegate) for the function ISHELL_SendEvent:
  5. > s2sinstrument --mode=PIT(ISHELL_SendEvent) ...
    
  6. Add the instrumentation to the calling application's code:
  7. #define <groupid-name>
    #include <name>IM.h
    

    This allows you to dynamically intercept the call for the application under test.