third_party/virtualbox/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
/**
 * Writes a substring to standard error.
 *
 * @param   pch                 The start of the substring.
 * @param   cch                 The length of the substring.
 */
Writes a substring to standard error.
@param   pch                 The start of the substring.
@param   cch                 The length of the substring.
Writes a substring to standard error . @param pch The start of the substring . @param cch The length of the substring .
static void suplibHardenedPrintStrN(const char *pch, size_t cch)
{
#ifdef RT_OS_WINDOWS
    HANDLE hStdOut = NtCurrentPeb()->ProcessParameters->StandardOutput;
    if (hStdOut != NULL)
    {
        if (g_enmSupR3HardenedMainState >= SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED)
        {
            DWORD cbWritten;
            WriteFile(hStdOut, pch, (DWORD)cch, &cbWritten, NULL);
        }
        else if (NtWriteFile != NULL && ((uintptr_t)hStdOut & 3) == 0)
        {
            IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
            NtWriteFile(hStdOut, NULL , NULL , NULL ,
                        &Ios, (PVOID)pch, (ULONG)cch, NULL , NULL );
        }
    }
#else
    int res = write(2, pch, cch);
    NOREF(res);
#endif
}
static void suplibHardenedPrintStrN ( const char * pch , size_t cch ) { #ifdef RT_OS_WINDOWS HANDLE hStdOut = NtCurrentPeb ( ) -> ProcessParameters -> StandardOutput ; if ( hStdOut != NULL ) { if ( g_enmSupR3HardenedMainState >= SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED ) { DWORD cbWritten ; WriteFile ( hStdOut , pch , ( DWORD ) cch , & cbWritten , NULL ) ; } else if ( NtWriteFile != NULL && ( ( uintptr_t ) hStdOut & 3 ) == 0 ) { IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER ; NtWriteFile ( hStdOut , NULL , NULL , NULL , & Ios , ( PVOID ) pch , ( ULONG ) cch , NULL , NULL ) ; } } #else int res = write ( 2 , pch , cch ) ; NOREF ( res ) ; #endif }
Writes a substring to standard error.
Writes a substring to standard error .
/* Windows 7 and earlier uses fake handles, with the last two bits set ((hStdOut & 3) == 3). */ /*Event*/ /*ApcRoutine*/ /*ApcContext*/ /*ByteOffset*/ /*Key*/