aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-10-30 07:09:13 +0100
committerSimon Rozman <simon@rozman.si>2020-10-31 10:41:47 +0100
commit44568f81cbc88690a11f87b3f7f9e67838547cd1 (patch)
tree0d906c235dab60c82ccbf5a44bab9fc7268afe62 /api
parentapi: fix adapter name numbering termination (diff)
downloadwintun-44568f81cbc88690a11f87b3f7f9e67838547cd1.tar.xz
wintun-44568f81cbc88690a11f87b3f7f9e67838547cd1.zip
api: make architecture-dependent wintun.dll selection an explicit select
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'api')
-rw-r--r--api/adapter.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/api/adapter.c b/api/adapter.c
index 790ed53..1aa8a03 100644
--- a/api/adapter.c
+++ b/api/adapter.c
@@ -1363,9 +1363,21 @@ ExecuteRunDll32(
Result = ERROR_BUFFER_OVERFLOW;
goto cleanupDirectory;
}
- if ((Result = ResourceCopyToFile(
- DllPath, NativeMachine == IMAGE_FILE_MACHINE_ARM64 ? L"wintun-arm64.dll" : L"wintun-amd64.dll")) !=
- ERROR_SUCCESS)
+ const WCHAR *WintunDllResourceName;
+ switch (NativeMachine)
+ {
+ case IMAGE_FILE_MACHINE_AMD64:
+ WintunDllResourceName = L"wintun-amd64.dll";
+ break;
+ case IMAGE_FILE_MACHINE_ARM64:
+ WintunDllResourceName = L"wintun-arm64.dll";
+ break;
+ default:
+ LOG(WINTUN_LOG_ERR, L"Failed to copy resource");
+ Result = ERROR_NOT_SUPPORTED;
+ goto cleanupDirectory;
+ }
+ if ((Result = ResourceCopyToFile(DllPath, WintunDllResourceName)) != ERROR_SUCCESS)
{
LOG(WINTUN_LOG_ERR, L"Failed to copy resource");
goto cleanupDelete;