diff options
Diffstat (limited to 'src/VBox/Runtime/r3')
-rw-r--r-- | src/VBox/Runtime/r3/ftp-server.cpp | 2 | ||||
-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 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/VBox/Runtime/r3/ftp-server.cpp b/src/VBox/Runtime/r3/ftp-server.cpp index 425aad03..7a6814fc 100644 --- a/src/VBox/Runtime/r3/ftp-server.cpp +++ b/src/VBox/Runtime/r3/ftp-server.cpp @@ -2269,7 +2269,7 @@ static int rtFtpServerCmdArgsParse(const char *pszCmdParms, uint8_t *pcArgs, cha int rc = RTGetOptArgvFromString(ppapszArgs, &cArgs, pszCmdParms, RTGETOPTARGV_CNV_QUOTE_MS_CRT, " " /* Separators */); if (RT_SUCCESS(rc)) { - if (cArgs <= UINT8_MAX) + if ((unsigned int)cArgs <= (unsigned int)UINT8_MAX) { *pcArgs = (uint8_t)cArgs; } 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 } |