wincompat: use new protected prefix on Windows

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-03-19 16:33:14 -06:00
parent e98b84ab84
commit be969b7fe1
1 changed files with 3 additions and 2 deletions

View File

@ -115,6 +115,7 @@ err:
static int userspace_get_wireguard_interfaces(struct string_list *list) static int userspace_get_wireguard_interfaces(struct string_list *list)
{ {
static const char prefix[] = "ProtectedPrefix\\Administrators\\WireGuard\\";
WIN32_FIND_DATA find_data; WIN32_FIND_DATA find_data;
HANDLE find_handle; HANDLE find_handle;
int ret = 0; int ret = 0;
@ -123,9 +124,9 @@ static int userspace_get_wireguard_interfaces(struct string_list *list)
if (find_handle == INVALID_HANDLE_VALUE) if (find_handle == INVALID_HANDLE_VALUE)
return -GetLastError(); return -GetLastError();
do { do {
if (strncmp("WireGuard\\", find_data.cFileName, 10)) if (strncmp(prefix, find_data.cFileName, strlen(prefix)))
continue; continue;
ret = string_list_add(list, find_data.cFileName + 10); ret = string_list_add(list, find_data.cFileName + strlen(prefix));
if (ret < 0) if (ret < 0)
goto out; goto out;
} while (FindNextFile(find_handle, &find_data)); } while (FindNextFile(find_handle, &find_data));