summaryrefslogtreecommitdiffstats
path: root/src/VBox/Runtime/r3
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:23:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:23:05 +0000
commit7ed673ceebb0b8ae63da19e5fd850d3d03818513 (patch)
tree4fa0de0623ef46887b526b429d45aac385374da2 /src/VBox/Runtime/r3
parentAdding upstream version 7.0.18-dfsg. (diff)
downloadvirtualbox-7ed673ceebb0b8ae63da19e5fd850d3d03818513.tar.xz
virtualbox-7ed673ceebb0b8ae63da19e5fd850d3d03818513.zip
Adding upstream version 7.0.20-dfsg.upstream/7.0.20-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Runtime/r3')
-rw-r--r--src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp19
-rw-r--r--src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp4
2 files changed, 21 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();
diff --git a/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp b/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp
index 543ea05c..110eae30 100644
--- a/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp
+++ b/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp
@@ -81,7 +81,11 @@ static int rtTerminateProcess(int32_t rcExit, bool fDoAtExit)
* Terminate.
*/
for (;;)
+#if 1 /* Using NtTerminateProcess triggers heuristics in some annoying AV scanner. */
+ TerminateProcess(NtCurrentProcess(), rcExit);
+#else
NtTerminateProcess(NtCurrentProcess(), rcExit);
+#endif
}