diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:23:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:23:06 +0000 |
commit | d9533c342dd90bb3404ecfba87ad3703e038bb6d (patch) | |
tree | 01cfef67ccc5acb2f347a1af9b2168be816a0afa /src/VBox/Runtime/r3/win | |
parent | Adding debian version 7.0.18-dfsg-2. (diff) | |
download | virtualbox-d9533c342dd90bb3404ecfba87ad3703e038bb6d.tar.xz virtualbox-d9533c342dd90bb3404ecfba87ad3703e038bb6d.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')
-rw-r--r-- | src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp | 19 | ||||
-rw-r--r-- | src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp | 4 |
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 } |