VirtualBox

Changeset 105155 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 5, 2024 2:44:07 AM (8 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163791
Message:

IPRT/nocrt-startup-*win.cpp: Avoid a couple of ntdll function so as to not trigger silly AV heuristics.

Location:
trunk/src/VBox/Runtime/r3/win
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp

    r98103 r105155  
    148148                else
    149149                {
     150# if 1              /* This dynamic stupidity is because of stupid AV heuristics. */
     151                    static decltype(NtProtectVirtualMemory) *s_pfnNtProtectVirtualMemory = NULL;
     152                    if (!s_pfnNtProtectVirtualMemory)
     153                        s_pfnNtProtectVirtualMemory
     154                            = (decltype(NtProtectVirtualMemory) *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"),
     155                                                                                 "NtProtectVirtualMemory");
     156                    if (!s_pfnNtProtectVirtualMemory)
     157                    {
     158                        RT_BREAKPOINT();
     159                        continue;
     160                    }
     161# else
     162#  define s_pfnNtProtectVirtualMemory NtProtectVirtualMemory
     163# endif
     164
    150165                    /* The section is not writable, so temporarily make it writable. */
    151166                    PVOID pvAligned = pbToZero - ((uintptr_t)pbToZero & PAGE_OFFSET_MASK);
     
    154169                                    ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
    155170                    ULONG fOldProt  = fNewProt;
    156                     NTSTATUS rcNt = NtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fNewProt, &fOldProt);
     171                    NTSTATUS rcNt = s_pfnNtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fNewProt, &fOldProt);
    157172                    if (NT_SUCCESS(rcNt))
    158173                    {
    159174                        memset(pbToZero, 0, cbToZero);
    160175
    161                         rcNt = NtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fOldProt, &fNewProt);
     176                        rcNt = s_pfnNtProtectVirtualMemory(NtCurrentProcess(), &pvAligned, &cbAligned, fOldProt, &fNewProt);
    162177                    }
    163178                    else
  • trunk/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp

    r98103 r105155  
    8282     */
    8383    for (;;)
     84#if 1 /* Using NtTerminateProcess triggers heuristics in some annoying AV scanner.  */
     85        TerminateProcess(NtCurrentProcess(), rcExit);
     86#else
    8487        NtTerminateProcess(NtCurrentProcess(), rcExit);
     88#endif
    8589}
    8690
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette