Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Setting up your project to override CreateInstance()

  1. Back up the platform header files that are modified during this process.

    For the platform with which your project is built, locate and back up the following files, which will be modified for this override solution:

    • For Brew MP 1.0.2, copy AEEShell.h to a new name, such as AEEShell_saved.h. For Brew MP 1.0.3 and later, make a copy of AEEIShell.h.
    • Copy AEEIEnv.h to a new name, such as AEEIEnv_saved.h.
  2. To detect leaks from interfaces instantiated from ISHELL_CreateInstance(), make the following override changes to AEEShell.h (or AEEIShell.h) to override IShell_CreateInstance().
    • Locate the beginning of the documentation block in this file and add the following:
      #ifdef ISHELL_OVERRIDE
      #include "OverrideIShellCreateInstance.h"
      #endif
      
    • For Brew MP 1.0.2, locate the following declaration of ISHELL_CreateInstance() in AEEShell.h:
      #define ISHELL_CreateInstance(p,id,ppo)
                  GET_PVTBL(p,IShell)->CreateInstance(p,id,ppo)
      and replace it with the following:
      #ifdef ISHELL_OVERRIDE
      #define BYPASS_ISHELL_CreateInstance(p,id,ppo)
                  GET_PVTBL(p,IShell)->CreateInstance(p,id,ppo)
      #else
      #define ISHELL_CreateInstance(p,id,ppo)
                  GET_PVTBL(p,IShell)->CreateInstance(p,id,ppo)
      #endif
      
    • For Brew MP 1.0.3 and later, locate the following declaration of IShell_CreateInstance() in AEEIShell.h:
      static __inline int IShell_CreateInstance(IShell *pif, AEECLSID cls,
               void **ppobj)
      {
         return AEEGETPVTBL(pif,IShell)->CreateInstance(pif, cls, ppobj);
      }
      
      and replace it with the following:
      #ifdef ISHELL_OVERRIDE
      static __inline int BYPASS_ISHELL_CreateInstance(IShell *pif, AEECLSID cls,
            void **ppobj)
      #else
      static __inline int IShell_CreateInstance(IShell *pif, AEECLSID cls,
            void **ppobj)
      #endif
      {
         return AEEGETPVTBL(pif,IShell)->CreateInstance(pif, cls, ppobj);
      }
      
  3. To detect leaks from interfaces instantiated from IEnv_CreateInstance(), make the following override changes to AEEIEnv.h to override IEnv_CreateInstance():
    • Locate the beginning of the documentation block and add the following:
      #ifdef IENV_OVERRIDE
      #include "OverrideIEnvCreateInstance.h"
      #endif
      
      
    • Locate the following declaration of IEnv_CreateInstance():
      static __inline int IEnv_CreateInstance(IEnv* pif, AEECLSID cls, void** ppo)
      {
         return AEEGETPVTBL(pif,IEnv)->CreateInstance(pif, cls, ppo);
      }
      
      and replace it with the following:
      #ifdef IENV_OVERRIDE
      static __inline int BYPASS_IEnv_CreateInstance(IEnv* pif, AEECLSID cls,
                  void** ppo)
      #else
      static __inline int IEnv_CreateInstance(IEnv* pif, AEECLSID cls, void** ppo)
      #endif
      {
         return AEEGETPVTBL(pif,IEnv)->CreateInstance(pif, cls, ppo);
      }
      
  4. Copy the provided OverrideCreateInstance.c, OverrideIShellCreateInstance.h, and OverrideIEnvCreateInstance.h files to your project directory.
  5. Add the provided OverrideCreateInstance.c file to your project.
  6. Add the following function call to the application's _InitAppData() (for MOD) or _CtorZ() (for MOD1) function before any calls to ISHELL_CreateInstance are made:
    #ifdef ISHELL_OVERRIDE
       initOverrideCreateInstance(pMe->m_pIShell);
    #endif
    
  7. Add the following function call to the application's _FreeAppData() (for MOD) or _Dtor (for MOD1) function after all the calls to _Release() are made:
    #ifdef ISHELL_OVERRIDE
    	freeOverrideCreateInstance();
    #endif
    
  8. Define one or more of the following in the preprocessor definitions for your project:
    • ISHELL_OVERRIDE: To enable the override for ISHELL_CreateInstance().
    • IENV_OVERRIDE: To enable the override for IEnv_CreateInstance().
    • OVERRIDE_MOD1: To enable any override for MOD1 applications. Do not define this for MOD applications.