/How to Fast Fail a single threded application with Windows 10 Parallel Loading? (via WindowsKernel.com)
Windows Kernel Shared Memory (Error Code 433)

How to Fast Fail a single threded application with Windows 10 Parallel Loading? (via WindowsKernel.com)


I cannot reproduce this at the moment, maybe it depends on the day(or night)time.

This situation (three threads in ntdll.dll!TpReleaseWork after exit) not only (sometimes) appears to my program “spawn(7).exe”, but also (sometimes) to other (well-known) applications (I can see it in Process Explorer) which I cannot modify. Might be an odd situation in the “new” Feature “Window 10 parallel library loading support in ntdll.dll”. Maybe I missed an update, maybe whatever.

Anyway, I need to “fail fast” and because I use the Processes for synchronisation (WaitForSingleObject) I now have two helper funtions.

ExitProcessNow to “kill” myself and WaitForProcessOrMainThread to wait for the target process (or its main thread) recently created with a call to CreateProcess.

VOID
__stdcall
ExitProcessNow( UINT uExitCode )
{
  if ( TerminateProcess( GetCurrentProcess(),
                         uExitCode ) )
    ExitThread( uExitCode );
  else
    ExitProcess( uExitCode );
}

VOID
__stdcall
WaitForProcessOrMainThread( PPROCESS_INFORMATION pProcessInformation,
                            BOOL fWaitForThread )
{
  if ( !fWaitForThread )
    WaitForSingleObject( pProcessInformation->hProcess, INFINITE );
  else
  {
    DWORD ExitCode = 0;
    WaitForSingleObject( pProcessInformation->hThread, INFINITE );
    GetExitCodeThread( pProcessInformation->hThread, &ExitCode );
    TerminateProcess( pProcessInformation->hProcess, ExitCode );
  }
  CloseHandle( pProcessInformation->hThread );
  CloseHandle( pProcessInformation->hProcess );
  pProcessInformation->hThread = NULL;
  pProcessInformation->hProcess = NULL;
}

BTW:

Interestingly, Windows 10 contains a default entry for chrome.exe with MaxLoaderThreads set to 1 to disable parallel loading.
Windows 10 Parallel Loading Breakdown

There might be a reason for it. 😉

This is a syndicated post. Read the original post at Source link .