Index: /trunk/src/kWorker/kWorker.c
===================================================================
--- /trunk/src/kWorker/kWorker.c	(revision 2891)
+++ /trunk/src/kWorker/kWorker.c	(revision 2892)
@@ -2527,4 +2527,12 @@
 
 
+/** Kernel32 - SetConsoleCtrlHandler(). */
+static BOOL WINAPI kwSandbox_Kernel32_SetConsoleCtrlHandler(PHANDLER_ROUTINE pfnHandler, BOOL fAdd)
+{
+    KW_LOG(("SetConsoleCtrlHandler(%p, %d) - ignoring\n"));
+    return TRUE;
+}
+
+
 /** The CRT internal __getmainargs() API. */
 static int __cdecl kwSandbox_msvcrt___getmainargs(int *pargc, char ***pargv, char ***penvp,
@@ -4180,5 +4188,4 @@
             && pszExt[3] == '\0')
             return K_TRUE;
-
     }
     /* Misc starting with i. */
@@ -4202,4 +4209,16 @@
                     return K_TRUE;
             }
+        }
+    }
+    /* Assembly header: .mac */
+    else if (chFirst == 'm' || chFirst == 'M')
+    {
+        char const  chSecond = pszExt[1];
+        if (chSecond == 'a' || chSecond == 'A')
+        {
+            char const chThird = pszExt[2];
+            if (  (chThird == 'c' || chThird == 'C')
+                && pszExt[3] == '\0')
+                return K_TRUE;
         }
     }
@@ -4465,4 +4484,18 @@
                                 return hFile;
                             }
+                        }
+                        /* These are for nasm and yasm header searching.  Cache will already
+                           have checked the directories for the file, no need to call
+                           CreateFile to do it again. */
+                        else if (enmError == KFSLOOKUPERROR_NOT_FOUND)
+                        {
+                            KWFS_LOG(("CreateFileA(%s) -> INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND\n", pszFilename));
+                            return INVALID_HANDLE_VALUE;
+                        }
+                        else if (   enmError == KFSLOOKUPERROR_PATH_COMP_NOT_FOUND
+                                 || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR)
+                        {
+                            KWFS_LOG(("CreateFileA(%s) -> INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND\n", pszFilename));
+                            return INVALID_HANDLE_VALUE;
                         }
 
@@ -6098,4 +6131,6 @@
     { TUPLE("FlsFree"),                     NULL,       (KUPTR)kwSandbox_Kernel32_FlsFree },
 
+    { TUPLE("SetConsoleCtrlHandler"),       NULL,       (KUPTR)kwSandbox_Kernel32_SetConsoleCtrlHandler },
+
 #ifdef WITH_HASH_MD5_CACHE
     { TUPLE("CryptCreateHash"),             NULL,       (KUPTR)kwSandbox_Advapi32_CryptCreateHash },
@@ -6202,4 +6237,5 @@
     { TUPLE("DeleteFileW"),                 NULL,       (KUPTR)kwSandbox_Kernel32_DeleteFileW },
 #endif
+    { TUPLE("SetConsoleCtrlHandler"),       NULL,       (KUPTR)kwSandbox_Kernel32_SetConsoleCtrlHandler },
 
 #ifdef WITH_HASH_MD5_CACHE
@@ -6211,4 +6247,5 @@
 
     { TUPLE("RtlPcToFileHeader"),           NULL,       (KUPTR)kwSandbox_ntdll_RtlPcToFileHeader },
+
 
     /*
@@ -6229,4 +6266,47 @@
 /** Number of entries in g_aSandboxNativeReplacements. */
 KU32 const                  g_cSandboxNativeReplacements = K_ELEMENTS(g_aSandboxNativeReplacements);
+
+
+/**
+ * Control handler.
+ *
+ * @returns TRUE if handled, FALSE if not.
+ * @param   dwCtrlType          The signal.
+ */
+static BOOL WINAPI kwSandboxCtrlHandler(DWORD dwCtrlType)
+{
+    switch (dwCtrlType)
+    {
+        case CTRL_C_EVENT:
+            fprintf(stderr, "kWorker: Ctrl-C\n");
+            exit(9);
+            break;
+
+        case CTRL_BREAK_EVENT:
+            fprintf(stderr, "kWorker: Ctrl-Break\n");
+            exit(10);
+            break;
+
+        case CTRL_CLOSE_EVENT:
+            fprintf(stderr, "kWorker: console closed\n");
+            exit(11);
+            break;
+
+        case CTRL_LOGOFF_EVENT:
+            fprintf(stderr, "kWorker: logoff event\n");
+            exit(11);
+            break;
+
+        case CTRL_SHUTDOWN_EVENT:
+            fprintf(stderr, "kWorker: shutdown event\n");
+            exit(11);
+            break;
+
+        default:
+            fprintf(stderr, "kwSandboxCtrlHandler: %#x\n", dwCtrlType);
+            break;
+    }
+    return TRUE;
+}
 
 
@@ -7224,4 +7304,10 @@
 
     /*
+     * Register our Control-C and Control-Break handlers.
+     */
+    if (!SetConsoleCtrlHandler(kwSandboxCtrlHandler, TRUE /*fAdd*/))
+        return kwErrPrintfRc(3, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
+
+    /*
      * Create the cache and mark the temporary directory as using the custom revision.
      */
