diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:23:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:23:15 +0000 |
commit | 62a5715c0af49b62b331c2538025a8ab5ce6c6e5 (patch) | |
tree | d4ddd30e61ba20eca4a3ba0f63f2e33c8573dfa0 /src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp | |
parent | Releasing progress-linux version 7.0.18-dfsg-2~progress7.99u1. (diff) | |
download | virtualbox-62a5715c0af49b62b331c2538025a8ab5ce6c6e5.tar.xz virtualbox-62a5715c0af49b62b331c2538025a8ab5ce6c6e5.zip |
Merging upstream version 7.0.20-dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp')
-rw-r--r-- | src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp b/src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp index 598339db..0fdcafbf 100644 --- a/src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp +++ b/src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp @@ -147,18 +147,33 @@ void rtVccWinInitBssOnNt3(void *pvImageBase) memset(pbToZero, 0, cbToZero); else { +# if 1 /* This dynamic stupidity is because of stupid AV heuristics. */ + static decltype(NtProtectVirtualMemory) *s_pfnNtProtectVirtualMemory = NULL; + if (!s_pfnNtProtectVirtualMemory) + s_pfnNtProtectVirtualMemory + = (decltype(NtProtectVirtualMemory) *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), + "NtProtectVirtualMemory"); + if (!s_pfnNtProtectVirtualMemory) + { + RT_BREAKPOINT(); + continue; + } +# else +# define s_pfnNtProtectVirtualMemory NtProtectVirtualMemory +# endif + /* The section is not writable, so temporarily make it writable. */ PVOID pvAligned = pbToZero - ((uintptr_t)pbToZero & PAGE_OFFSET_MASK); ULONG cbAligned = RT_ALIGN_32(cbToZero + ((uintptr_t)pbToZero & PAGE_OFFSET_MASK), PAGE_SIZE); ULONG fNewProt = paSHdrs[i].Characteristics & IMAGE_SCN_MEM_EXECUTE ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; ULONG fOldProt = fNewProt; - NTSTATUS rcNt = NtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fNewProt, &fOldProt); + NTSTATUS rcNt = s_pfnNtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fNewProt, &fOldProt); if (NT_SUCCESS(rcNt)) { memset(pbToZero, 0, cbToZero); - rcNt = NtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fOldProt, &fNewProt); + rcNt = s_pfnNtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fOldProt, &fNewProt); } else RT_BREAKPOINT(); |