Skip to content

Commit

Permalink
Merge all vbufBackend dlls into nvdaHelperRemote.dll (#8866)
Browse files Browse the repository at this point in the history
* All vbufBackend dlls have been merged into nvdaHelperRemote.dll.

* Address review comments.

* Update what's new.
  • Loading branch information
michaelDCurran authored Oct 30, 2018
1 parent 5fe34c5 commit 24f5123
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 250 deletions.
2 changes: 0 additions & 2 deletions appveyor/mozillaSyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"ISimpleDOM.dll",
"minHook.dll",
"nvdaHelperRemote.dll",
"VBufBackend_adobeFlash.dll",
"VBufBackend_gecko_ia2.dll",
]
DLL_FILES = [f
for dll in DLL_NAMES
Expand Down
6 changes: 0 additions & 6 deletions appx/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ excludedDistFiles=[
'lib/ISimpleDOM.dll',
'lib/minHook.dll',
'lib/NVDAHelperRemote.dll',
'lib/VBufBackend_adobeAcrobat.dll',
'lib/VBufBackend_adobeFlash.dll',
'lib/VBufBackend_gecko_ia2.dll',
'lib/VBufBackend_lotusNotesRichText.dll',
'lib/VBufBackend_mshtml.dll',
'lib/VBufBackend_webKit.dll',
'lib64/',
'uninstall.exe',
]
Expand Down
33 changes: 0 additions & 33 deletions nvdaHelper/archBuild_sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -203,39 +203,6 @@ if TARGET_ARCH=='x86_64':
env.AddPostAction(remoteLoaderProgram,[signExec])
env.Install(libInstallDir,remoteLoaderProgram)

vbufBaseStaticLib=env.SConscript('vbufBase/sconscript')
Export('vbufBaseStaticLib')

adobeAcrobatVBufBackend=env.SConscript('vbufBackends/adobeAcrobat/sconscript')
if signExec:
env.AddPostAction(adobeAcrobatVBufBackend[0],[signExec])
env.Install(libInstallDir,adobeAcrobatVBufBackend)

adobeFlashVBufBackend=env.SConscript('vbufBackends/adobeFlash/sconscript')
if signExec:
env.AddPostAction(adobeFlashVBufBackend[0],[signExec])
env.Install(libInstallDir,adobeFlashVBufBackend)

lotusNotesRichTextVBufBackend=env.SConscript('vbufBackends/lotusNotesRichText/sconscript')
if signExec:
env.AddPostAction(lotusNotesRichTextVBufBackend[0],[signExec])
env.Install(libInstallDir,lotusNotesRichTextVBufBackend)

geckoVBufBackend=env.SConscript('vbufBackends/gecko_ia2/sconscript')
if signExec:
env.AddPostAction(geckoVBufBackend[0],[signExec])
env.Install(libInstallDir,geckoVBufBackend)

mshtmlVBufBackend=env.SConscript('vbufBackends/mshtml/sconscript')
if signExec:
env.AddPostAction(mshtmlVBufBackend[0],[signExec])
env.Install(libInstallDir,mshtmlVBufBackend)

webKitVBufBackend=env.SConscript('vbufBackends/webKit/sconscript')
if signExec:
env.AddPostAction(webKitVBufBackend[0],[signExec])
env.Install(libInstallDir,webKitVBufBackend)

if TARGET_ARCH=='x86':
env.SConscript('espeak/sconscript')
env.SConscript('liblouis/sconscript')
11 changes: 11 additions & 0 deletions nvdaHelper/remote/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ Import([

winIPCUtilsObj=env.Object("./winIPCUtils","../common/winIPCUtils.cpp")

vbufBackendLibs=[
env.SConscript('../vbufBase/sconscript'),
env.SConscript('../vbufBackends/adobeAcrobat/sconscript'),
env.SConscript('../vbufBackends/adobeFlash/sconscript'),
env.SConscript('../vbufBackends/lotusNotesRichText/sconscript'),
env.SConscript('../vbufBackends/gecko_ia2/sconscript'),
env.SConscript('../vbufBackends/mshtml/sconscript'),
env.SConscript('../vbufBackends/webKit/sconscript'),
]

controllerRPCHeader,controllerRPCClientSource=env.MSRPCStubs(
target="./nvdaController",
source=[
Expand Down Expand Up @@ -105,6 +115,7 @@ remoteLib=env.SharedLibrary(
displayModelRPCServerSource,
nvdaInProcUtilsRPCServerSource,
"nvdaHelperRemote.def",
vbufBackendLibs,
],
LIBS=[
"user32",
Expand Down
49 changes: 28 additions & 21 deletions nvdaHelper/remote/vbufRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,42 @@ This license can be found at:
#include "vbufRemote.h"
#include <vbufBase/backend.h>
#include "dllmain.h"
#include <common/log.h>

using namespace std;

map<VBufBackend_t*,HINSTANCE> backendLibHandles;
const map<wstring,VBufBackend_create_proc> VBufBackendFactoryMap {
{L"adobeAcrobat",AdobeAcrobatVBufBackend_t_createInstance},
{L"adobeFlash",AdobeFlashVBufBackend_t_createInstance},
{L"gecko_ia2",GeckoVBufBackend_t_createInstance},
{L"mshtml",MshtmlVBufBackend_t_createInstance},
{L"lotusNotesRichText",lotusNotesRichTextVBufBackend_t_createInstance},
{L"webKit",WebKitVBufBackend_t_createInstance}
};

extern "C" {

VBufRemote_bufferHandle_t VBufRemote_createBuffer(handle_t bindingHandle, int docHandle, int ID, const wchar_t* backendName) {
wchar_t backendPath[MAX_PATH];
wsprintf(backendPath,L"%s\\VBufBackend_%s.dll",dllDirectory,backendName);
HINSTANCE backendLibHandle=LoadLibrary(backendPath);
if(backendLibHandle==NULL) return NULL;
VBufBackend_create_proc createBackend=(VBufBackend_create_proc)GetProcAddress((HMODULE)(backendLibHandle),"VBufBackend_create");
if(createBackend==NULL) {
FreeLibrary(backendLibHandle);
return NULL;
}
if(!backendName) {
LOG_ERROR(L"backendName is NULL");
return nullptr;
}
auto i=VBufBackendFactoryMap.find(backendName);
if(i==VBufBackendFactoryMap.end()) {
LOG_ERROR(L"Unknown backend: "<<backendName);
return nullptr;
}
VBufBackend_create_proc createBackend=i->second;
VBufBackend_t* backend=createBackend(docHandle,ID);
if(backend==NULL) {
FreeLibrary(backendLibHandle);
return NULL;
}
backendLibHandles[backend]=backendLibHandle;
backend->initialize();
// Stop nvdaHelperRemote from being unloaded while a backend exists.
HINSTANCE tempHandle=nullptr;
if(!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,reinterpret_cast<LPCWSTR>(dllHandle),&tempHandle)) {
LOG_ERROR(L"Could not keep nvdaHelperRemote loaded for backend!");
}
return (VBufRemote_bufferHandle_t)backend;
}

Expand All @@ -49,13 +61,9 @@ void VBufRemote_destroyBuffer(VBufRemote_bufferHandle_t* buffer) {
#endif
VBufBackend_t* backend=(VBufBackend_t*)*buffer;
backend->terminate();
map<VBufBackend_t*,HINSTANCE>::iterator i=backendLibHandles.find(backend);
if(i==backendLibHandles.end()) return;
HINSTANCE backendLibHandle=i->second;
backendLibHandles.erase(i);
backend->lock.acquire();
backend->destroy();
FreeLibrary(backendLibHandle);
FreeLibrary(dllHandle);
*buffer=NULL;
}

Expand Down Expand Up @@ -144,13 +152,12 @@ int VBufRemote_getTextLength(VBufRemote_bufferHandle_t buffer) {
int VBufRemote_getTextInRange(VBufRemote_bufferHandle_t buffer, int startOffset, int endOffset, wchar_t** text, boolean useMarkup) {
VBufBackend_t* backend=(VBufBackend_t*)buffer;
backend->lock.acquire();
VBufStorage_textContainer_t* textContainer=backend->getTextInRange(startOffset,endOffset,useMarkup!=false);
wstring textString=backend->getTextInRange(startOffset,endOffset,useMarkup!=false);
backend->lock.release();
if(textContainer==NULL) {
if(textString.empty()) {
return false;
}
*text=SysAllocString(textContainer->getString().c_str());
textContainer->destroy();
*text=SysAllocString(textString.c_str());
return true;
}

Expand Down
8 changes: 1 addition & 7 deletions nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,15 +864,9 @@ AdobeAcrobatVBufBackend_t::~AdobeAcrobatVBufBackend_t() {
LOG_DEBUG(L"AdobeAcrobat backend destructor");
}

extern "C" __declspec(dllexport) VBufBackend_t* VBufBackend_create(int docHandle, int ID) {
VBufBackend_t* AdobeAcrobatVBufBackend_t_createInstance(int docHandle, int ID) {
VBufBackend_t* backend=new AdobeAcrobatVBufBackend_t(docHandle,ID);
LOG_DEBUG(L"Created new backend at "<<backend);
return backend;
}

BOOL WINAPI DllMain(HINSTANCE hModule,DWORD reason,LPVOID lpReserved) {
if(reason==DLL_PROCESS_ATTACH) {
_CrtSetReportHookW2(_CRT_RPTHOOK_INSTALL,(_CRT_REPORT_HOOKW)NVDALogCrtReportHook);
}
return true;
}
20 changes: 4 additions & 16 deletions nvdaHelper/vbufBackends/adobeAcrobat/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,12 @@

Import([
'env',
'vbufBaseStaticLib',
'acrobatAccessRPCStubs',
])

adobeAcrobatBackendLib=env.SharedLibrary(
target="VBufBackend_adobeAcrobat",
source=[
env['projectResFile'],
"adobeAcrobat.cpp",
env.Object('_acrobatAccess_i',acrobatAccessRPCStubs[2]),
],
LIBS=[
vbufBaseStaticLib,
"user32",
"kernel32",
"oleacc",
"oleaut32",
],
)
adobeAcrobatBackendLib=[
env.Object("adobeAcrobat.cpp"),
env.Object('_acrobatAccess_i',acrobatAccessRPCStubs[2]),
]

Return('adobeAcrobatBackendLib')
9 changes: 1 addition & 8 deletions nvdaHelper/vbufBackends/adobeFlash/adobeFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,7 @@ void AdobeFlashVBufBackend_t::render(VBufStorage_buffer_t* buffer, int docHandle
AdobeFlashVBufBackend_t::AdobeFlashVBufBackend_t(int docHandle, int ID): VBufBackend_t(docHandle,ID), accPropServices(NULL) {
}

extern "C" __declspec(dllexport) VBufBackend_t* VBufBackend_create(int docHandle, int ID) {
VBufBackend_t* AdobeFlashVBufBackend_t_createInstance(int docHandle, int ID) {
VBufBackend_t* backend=new AdobeFlashVBufBackend_t(docHandle,ID);
return backend;
}

BOOL WINAPI DllMain(HINSTANCE hModule,DWORD reason,LPVOID lpReserved) {
if(reason==DLL_PROCESS_ATTACH) {
_CrtSetReportHookW2(_CRT_RPTHOOK_INSTALL,(_CRT_REPORT_HOOKW)NVDALogCrtReportHook);
}
return true;
}
17 changes: 1 addition & 16 deletions nvdaHelper/vbufBackends/adobeFlash/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,8 @@

Import([
'env',
'vbufBaseStaticLib',
])

adobeFlashBackendLib=env.SharedLibrary(
target="VBufBackend_adobeFlash",
source=[
env['projectResFile'],
"adobeFlash.cpp",
],
LIBS=[
vbufBaseStaticLib,
"user32",
"kernel32",
"oleacc",
"oleaut32",
"ole32",
],
)
adobeFlashBackendLib=env.Object("adobeFlash.cpp")

Return('adobeFlashBackendLib')
11 changes: 2 additions & 9 deletions nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ HWND findRealMozillaWindow(HWND hwnd) {
return hwnd;
}

IAccessible2* IAccessible2FromIdentifier(int docHandle, int ID) {
static IAccessible2* IAccessible2FromIdentifier(int docHandle, int ID) {
IAccessible* pacc=NULL;
IServiceProvider* pserv=NULL;
IAccessible2* pacc2=NULL;
Expand Down Expand Up @@ -1128,14 +1128,7 @@ GeckoVBufBackend_t::GeckoVBufBackend_t(int docHandle, int ID): VBufBackend_t(doc
GeckoVBufBackend_t::~GeckoVBufBackend_t() {
}

extern "C" __declspec(dllexport) VBufBackend_t* VBufBackend_create(int docHandle, int ID) {
VBufBackend_t* GeckoVBufBackend_t_createInstance(int docHandle, int ID) {
VBufBackend_t* backend=new GeckoVBufBackend_t(docHandle,ID);
return backend;
}

BOOL WINAPI DllMain(HINSTANCE hModule,DWORD reason,LPVOID lpReserved) {
if(reason==DLL_PROCESS_ATTACH) {
_CrtSetReportHookW2(_CRT_RPTHOOK_INSTALL,(_CRT_REPORT_HOOKW)NVDALogCrtReportHook);
}
return true;
}
22 changes: 1 addition & 21 deletions nvdaHelper/vbufBackends/gecko_ia2/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,8 @@

Import([
'env',
'vbufBaseStaticLib',
'ia2RPCStubs',
])

ia2utilsObj=env.Object("./ia2utils","../../common/ia2utils.cpp")

geckoBackendLib=env.SharedLibrary(
target="VBufBackend_gecko_ia2",
source=[
env['projectResFile'],
"gecko_ia2.cpp",
ia2utilsObj,
env.Object('_ia2_i',ia2RPCStubs[3]),
],
LIBS=[
vbufBaseStaticLib,
"user32",
"kernel32",
"oleacc",
"oleaut32",
"ole32",
],
)
geckoBackendLib=env.Object("gecko_ia2.cpp")

Return('geckoBackendLib')
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,7 @@ void lotusNotesRichTextVBufBackend_t::render(VBufStorage_buffer_t* buffer, int d
lotusNotesRichTextVBufBackend_t::lotusNotesRichTextVBufBackend_t(int docHandle, int ID): VBufBackend_t(docHandle,ID) {
}

extern "C" __declspec(dllexport) VBufBackend_t* VBufBackend_create(int docHandle, int ID) {
VBufBackend_t* lotusNotesRichTextVBufBackend_t_createInstance(int docHandle, int ID) {
VBufBackend_t* backend=new lotusNotesRichTextVBufBackend_t(docHandle,ID);
return backend;
}

BOOL WINAPI DllMain(HINSTANCE hModule,DWORD reason,LPVOID lpReserved) {
if(reason==DLL_PROCESS_ATTACH) {
_CrtSetReportHookW2(_CRT_RPTHOOK_INSTALL,(_CRT_REPORT_HOOKW)NVDALogCrtReportHook);
}
return true;
}
16 changes: 1 addition & 15 deletions nvdaHelper/vbufBackends/lotusNotesRichText/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@

Import([
'env',
'vbufBaseStaticLib',
])

lotusNotesRichTextBackendLib=env.SharedLibrary(
target="VBufBackend_lotusNotesRichText",
source=[
env['projectResFile'],
"lotusNotesRichText.cpp",
],
LIBS=[
vbufBaseStaticLib,
"user32",
"kernel32",
"oleacc",
"oleaut32",
],
)
lotusNotesRichTextBackendLib=env.Object("lotusNotesRichText.cpp")

Return('lotusNotesRichTextBackendLib')
Loading

0 comments on commit 24f5123

Please sign in to comment.