Skip to content

Commit

Permalink
Do not allow copy/paste at all inside NVDA's UI while in secure mode …
Browse files Browse the repository at this point in the history
…(e.g. when NVDA is running on the secure desktop -- lock screen -- windows logon). To do this, Only in the NVDA process itself, and only in secure mode, nvdaHelperRemote hooks the OpenClipboard Windows API function and forces it to return false, and does not call the original OpenClipboard. This simply denies access to the clipboard for NVDA's process. Fixes #1421.
  • Loading branch information
michaelDCurran committed Mar 25, 2011
1 parent bd19dcd commit 2fb1ce7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion nvdaHelper/remote/injection.cpp
Expand Up @@ -39,6 +39,7 @@ HWINEVENTHOOK inprocWinEventHookID=0;
set<HHOOK> inprocCurrentWindowsHooks;
long tlsIndex_inThreadInjectionID=0;
bool isProcessExiting=false;
bool isSecureModeNVDAProcess=false;

//Code executed in-process

Expand Down Expand Up @@ -72,6 +73,14 @@ void killRunningWindowsHooks() {
}
}

//A replacement OpenClipboard function to disable the use of the clipboard in a secure mode NVDA process
//Simply returns false without calling the original OpenClipboard
typedef BOOL(WINAPI *OpenClipboard_funcType)(HWND);
OpenClipboard_funcType real_OpenClipboard=NULL;
BOOL WINAPI fake_OpenClipboard(HWND hwndOwner) {
return false;
}

//A thread function that runs while NVDA is injected in a process.
//Note that a mutex is used to make sure that there is never more than one copy of this thread in a given process at any given time.
//I.e. Another copy of NVDA is started while the first is still running.
Expand Down Expand Up @@ -113,6 +122,8 @@ DWORD WINAPI inprocMgrThreadFunc(LPVOID data) {
}
//Initialize API hooking
apiHook_initialize();
//Fore secure mode NVDA process, hook OpenClipboard to disable usage of the clipboard
if(isSecureModeNVDAProcess) real_OpenClipboard=apiHook_hookFunction_safe("USER32.dll",OpenClipboard,fake_OpenClipboard);
//Initialize in-process subsystems
inProcess_initialize();
//Enable all registered API hooks
Expand Down Expand Up @@ -253,7 +264,12 @@ DWORD outprocMgrThreadID=0;
BOOL outprocInitialized=FALSE;
HANDLE injectionDoneEvent=NULL;

BOOL injection_initialize() {
/**
* Initializes the out-of-process code for NVDAHelper
* @param secureMode 1 specifies that NVDA is running in seucre mode, 0 says not.
*/
BOOL injection_initialize(int secureMode) {
if(secureMode) isSecureModeNVDAProcess=true;
if(outprocInitialized) {
MessageBox(NULL,L"Already initialized",L"nvdaHelperRemote (injection_initialize)",0);
return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion source/NVDAHelper.py
Expand Up @@ -200,7 +200,7 @@ def initialize():
log.critical("Error loading nvdaHelperRemote.dll: %s" % WinError())
return
_remoteLib=CDLL("nvdaHelperRemote",handle=h)
if _remoteLib.injection_initialize() == 0:
if _remoteLib.injection_initialize(globalVars.appArgs.secure) == 0:
raise RuntimeError("Error initializing NVDAHelperRemote")
if os.environ.get('PROCESSOR_ARCHITEW6432')=='AMD64':
_remoteLoader64=RemoteLoader64()
Expand Down

0 comments on commit 2fb1ce7

Please sign in to comment.