aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/syntax/syntaxedit.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-07 03:02:12 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-07 03:02:12 +0100
commitb97ec2e9a6a21e677af52b1547c0e19fb5492db3 (patch)
treeb468b78576a8e8a185392bbae3942fd80e11be23 /ui/syntax/syntaxedit.c
parentsyntax: safe dll loading (diff)
downloadwireguard-windows-b97ec2e9a6a21e677af52b1547c0e19fb5492db3.tar.xz
wireguard-windows-b97ec2e9a6a21e677af52b1547c0e19fb5492db3.zip
syntax: lazily load ui library
This way we don't have msftedit.dll loaded into the address space of the process doing real crypto.
Diffstat (limited to 'ui/syntax/syntaxedit.c')
-rw-r--r--ui/syntax/syntaxedit.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ui/syntax/syntaxedit.c b/ui/syntax/syntaxedit.c
index 95356331..6c6de295 100644
--- a/ui/syntax/syntaxedit.c
+++ b/ui/syntax/syntaxedit.c
@@ -279,14 +279,16 @@ static LRESULT CALLBACK child_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
return parent_proc(hWnd, Msg, wParam, lParam);
}
+static long has_loaded = 0;
+
bool register_syntax_edit(void)
{
WNDCLASSEXW class = { .cbSize = sizeof(WNDCLASSEXW) };
WNDPROC pp;
HANDLE lib;
- if (parent_proc)
- return true;
+ if (InterlockedCompareExchange(&has_loaded, 1, 0) != 0)
+ return !!parent_proc;
lib = LoadLibraryExW(L"msftedit.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (!lib)