Changeset 2257

Show
Ignore:
Timestamp:
07/16/08 01:55:20 (6 months ago)
Author:
mdcurran
Message:

NVDAHelper: add some debugging messages that go to standard error when things go wrong. However, of course NVDA will only catch messages in its process, in its log file. Made IA2Support_initialize, installIA2Support and uninstallIA2Support return True or False depending on whether they succeeded. They check all ole function calls etc for success/failier. Added IA2Support_terminate() which calls uninstallIA2Support(). IA2Support_terminate() is called from NVDAHelper's terminate function. This means that IAccessible2 support will be properly cleaned up in NVDA's process as NVDAHelper is terminated.

Location:
trunk/source/NVDAHelper
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/NVDAHelper/IA2Support.c

    r2233 r2257  
    2929IUnknown* IA2DllPunk=NULL; 
    3030 
    31 void installIA2Support() { 
     31BOOL installIA2Support() { 
    3232        LPFNGETCLASSOBJECT IA2Dll_DllGetClassObject; 
    3333        int i; 
    34         if(isIA2Installed) return; 
    35         IA2DllHandle=CoLoadLibrary(IA2DllPath,TRUE); 
    36         if(IA2DllHandle==0) return; 
    37         IA2Dll_DllGetClassObject=(LPFNGETCLASSOBJECT)GetProcAddress(IA2DllHandle,"DllGetClassObject"); 
    38         IA2Dll_DllGetClassObject(&IAccessible2ProxyIID,&IID_IUnknown,(LPVOID*)&IA2DllPunk); 
    39         CoRegisterClassObject(&IAccessible2ProxyIID,IA2DllPunk,CLSCTX_LOCAL_SERVER,REGCLS_MULTIPLEUSE,(LPDWORD)&IA2RegCooky); 
     34        int res; 
     35        if(isIA2Installed) return TRUE; 
     36        if((IA2DllHandle=CoLoadLibrary(IA2DllPath,TRUE))==NULL) { 
     37                fprintf(stderr,"Error loading IAccessible2 proxy dll\n"); 
     38                return FALSE; 
     39        } 
     40        if((IA2Dll_DllGetClassObject=(LPFNGETCLASSOBJECT)GetProcAddress(IA2DllHandle,"DllGetClassObject"))==NULL) { 
     41                fprintf(stderr,"Error locating DllGetClassObject function in IAccessible2 proxy dll\n"); 
     42                return FALSE; 
     43        } 
     44        if((res=IA2Dll_DllGetClassObject(&IAccessible2ProxyIID,&IID_IUnknown,(LPVOID*)&IA2DllPunk))!=S_OK) { 
     45                fprintf(stderr,"Error calling DllGetClassObject, code %d\n",res); 
     46                return FALSE; 
     47        } 
     48        if((res=CoRegisterClassObject(&IAccessible2ProxyIID,IA2DllPunk,CLSCTX_LOCAL_SERVER,REGCLS_MULTIPLEUSE,(LPDWORD)&IA2RegCooky))!=S_OK) { 
     49                fprintf(stderr,"Error registering class object, code %d\n",res); 
     50                return FALSE; 
     51        } 
    4052        for(i=0;i<ia2InterfaceCount;i++) { 
    4153                CoGetPSClsid(&(ia2ClsidArray[i][0]),&(ia2ClsidArray[i][1])); 
    42                 CoRegisterPSClsid(&(ia2ClsidArray[i][0]),&IAccessible2ProxyIID); 
     54                if((res=CoRegisterPSClsid(&(ia2ClsidArray[i][0]),&IAccessible2ProxyIID))!=S_OK) { 
     55                        fprintf(stderr,"Error registering PSClsid for interface %d, code %d\n",i,res); 
     56                        return FALSE; 
     57                } 
    4358        } 
    4459        isIA2Installed=TRUE; 
     60        return TRUE; 
    4561} 
    4662 
    47 void uninstallIA2Support() { 
     63BOOL uninstallIA2Support() { 
    4864        int i; 
     65        int res; 
    4966        if(IA2DllHandle!=0) { 
    5067        for(i=0;i<ia2InterfaceCount;i++) { 
    51                         CoRegisterPSClsid(&(ia2ClsidArray[i][0]),&(ia2ClsidArray[i][1])); 
     68                        if((res=CoRegisterPSClsid(&(ia2ClsidArray[i][0]),&(ia2ClsidArray[i][1])))!=S_OK) { 
     69                                fprintf(stderr,"Error reregistering previous PSClsid for interface %d, code %d\n",i,res); 
     70                                return FALSE; 
     71                        } 
    5272                } 
    53                 CoRevokeClassObject(IA2RegCooky); 
     73                if((res=CoRevokeClassObject(IA2RegCooky))!=S_OK) { 
     74                        fprintf(stderr,"Error revoking class object, code %d\n",res); 
     75                        return FALSE; 
     76                } 
    5477                CoFreeUnusedLibrariesEx(0,0); 
    5578                IA2DllHandle=0; 
    5679                isIA2Installed=FALSE; 
    5780        } 
     81        return TRUE; 
    5882} 
    5983 
    60 void IA2Support_initialize() { 
     84BOOL IA2Support_initialize() { 
    6185        int count=0; 
    6286        GetFullPathName(L"lib/IAccessible2Proxy.dll",256,IA2DllPath,NULL); 
     
    7599        ia2ClsidArray[count++][0]=IID_IAccessibleValue; 
    76100        isIA2Initialized=TRUE; 
    77         installIA2Support(); 
     101        if(!installIA2Support()) { 
     102                fprintf(stderr,"Error installing IA2 support\n"); 
     103                return FALSE; 
     104        } 
     105        return TRUE; 
    78106} 
     107 
     108BOOL IA2Support_terminate() { 
     109        if(!uninstallIA2Support()) { 
     110                fprintf(stderr,"Error uninstalling IA2 support\n"); 
     111                return FALSE; 
     112        } 
     113        return TRUE; 
     114} 
  • trunk/source/NVDAHelper/IA2Support.h

    r2193 r2257  
    1212 
    1313//Private functions 
    14 void IA2Support_initialize(); 
    15 void installIA2Support(); 
     14BOOL IA2Support_initialize(); 
     15BOOL installIA2Support(); 
     16BOOL uninstallIA2Support(); 
     17BOOL IA2Support_terminate(); 
    1618 
    1719#endif 
  • trunk/source/NVDAHelper/hookManager.c

    r2214 r2257  
    7171        GetWindowThreadProcessId(GetDesktopWindow(),&desktopProcessID); 
    7272        GetWindowThreadProcessId(GetShellWindow(),&shellProcessID); 
    73         IA2Support_initialize(); 
     73        if(!IA2Support_initialize()) { 
     74                fprintf(stderr,"Error initializing IA2 support\n"); 
     75                return -1; 
     76        } 
    7477        if((getMessageHookID=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)getMessageHook,moduleHandle,0))==0) { 
    7578                fprintf(stderr,"Error registering window message hook\n"); 
     
    105108                return -1; 
    106109        } 
     110        if(!IA2Support_terminate()) { 
     111                fprintf(stderr,"Error terminating IA2 support\n"); 
     112                return -1; 
     113        } 
    107114        isManagerInitialized=FALSE; 
    108115        return 0;