Changeset 2867 in kBuild for trunk/src/kWorker/kWorker.c
- Timestamp:
- Sep 3, 2016 10:08:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kWorker/kWorker.c
r2865 r2867 209 209 210 210 /** 211 * GetModuleHandle cache for system modules frequently queried. 212 */ 213 typedef struct KWGETMODULEHANDLECACHE 214 { 215 const char *pszName; 216 KU8 cchName; 217 KU8 cwcName; 218 const wchar_t *pwszName; 219 HANDLE hmod; 220 } KWGETMODULEHANDLECACHE; 221 typedef KWGETMODULEHANDLECACHE *PKWGETMODULEHANDLECACHE; 222 223 224 /** 211 225 * A cached file. 212 226 */ … … 361 375 /** Copy of the NT TIB of the main thread. */ 362 376 NT_TIB TibMainThread; 377 /** The NT_TIB::ExceptionList value inside the try case. 378 * We restore this prior to the longjmp. */ 379 void *pOutXcptListHead; 363 380 /** The exit code in case of longjmp. */ 364 381 int rcExitCode; … … 446 463 /** Module hash table. */ 447 464 static PKWMODULE g_apModules[127]; 465 466 /** GetModuleHandle cache. */ 467 static KWGETMODULEHANDLECACHE g_aGetModuleHandleCache[] = 468 { 469 #define MOD_CACHE_STRINGS(str) str, sizeof(str) - 1, (sizeof(L##str) / sizeof(wchar_t)) - 1, L##str 470 { MOD_CACHE_STRINGS("KERNEL32.DLL"), NULL }, 471 { MOD_CACHE_STRINGS("mscoree.dll"), NULL }, 472 }; 473 448 474 449 475 /** The file system cache. */ … … 967 993 static void kwLdrModuleDoNativeImportReplacements(PKWMODULE pMod) 968 994 { 969 KSIZE const cbImage = kLdrModSize(pMod->pLdrMod);995 KSIZE const cbImage = (KSIZE)kLdrModSize(pMod->pLdrMod); 970 996 KU8 const * const pbImage = (KU8 const *)pMod->hOurMod; 971 997 IMAGE_DOS_HEADER const *pMzHdr = (IMAGE_DOS_HEADER const *)pbImage; … … 981 1007 if (pMzHdr->e_magic == IMAGE_DOS_SIGNATURE) 982 1008 { 983 kHlpAssertReturnVoid( pMzHdr->e_lfanew <= cbImage - sizeof(*pNtHdrs));1009 kHlpAssertReturnVoid((KU32)pMzHdr->e_lfanew <= cbImage - sizeof(*pNtHdrs)); 984 1010 pNtHdrs = (IMAGE_NT_HEADERS const *)&pbImage[pMzHdr->e_lfanew]; 985 1011 } … … 1115 1141 1116 1142 /** 1143 * Creates a module from a native kLdr module handle. 1144 * 1145 * @returns Module w/ 1 reference on success, NULL on failure. 1146 * @param pLdrMod The native kLdr module. 1147 * @param pszPath The normalized path to the module. 1148 * @param cbPath The module path length with terminator. 1149 * @param uHashPath The module path hash. 1150 * @param fDoReplacements Whether to do import replacements on this 1151 * module. 1152 */ 1153 static PKWMODULE kwLdrModuleCreateForNativekLdrModule(PKLDRMOD pLdrMod, const char *pszPath, KSIZE cbPath, KU32 uHashPath, 1154 KBOOL fDoReplacements) 1155 { 1156 /* 1157 * Create the entry. 1158 */ 1159 PKWMODULE pMod = (PKWMODULE)kHlpAllocZ(sizeof(*pMod) + cbPath + cbPath * 2 * sizeof(wchar_t)); 1160 if (pMod) 1161 { 1162 pMod->pwszPath = (wchar_t *)(pMod + 1); 1163 kwStrToUtf16(pszPath, (wchar_t *)pMod->pwszPath, cbPath * 2); 1164 pMod->pszPath = (char *)kHlpMemCopy((char *)&pMod->pwszPath[cbPath * 2], pszPath, cbPath); 1165 pMod->uHashPath = uHashPath; 1166 pMod->cRefs = 1; 1167 pMod->offFilename = (KU16)(kHlpGetFilename(pszPath) - pszPath); 1168 pMod->fExe = K_FALSE; 1169 pMod->fNative = K_TRUE; 1170 pMod->pLdrMod = pLdrMod; 1171 pMod->hOurMod = (HMODULE)(KUPTR)pLdrMod->aSegments[0].MapAddress; 1172 1173 if (fDoReplacements) 1174 { 1175 DWORD const dwSavedErr = GetLastError(); 1176 kwLdrModuleDoNativeImportReplacements(pMod); 1177 SetLastError(dwSavedErr); 1178 } 1179 1180 KW_LOG(("New module: %p LB %#010x %s (native)\n", 1181 (KUPTR)pMod->pLdrMod->aSegments[0].MapAddress, kLdrModSize(pMod->pLdrMod), pMod->pszPath)); 1182 return kwLdrModuleLink(pMod); 1183 } 1184 return NULL; 1185 } 1186 1187 1188 1189 /** 1117 1190 * Creates a module using the native loader. 1118 1191 * … … 1132 1205 if (rc == 0) 1133 1206 { 1134 /* 1135 * Create the entry. 1136 */ 1137 KSIZE cbPath = kHlpStrLen(pszPath) + 1; 1138 PKWMODULE pMod = (PKWMODULE)kHlpAllocZ(sizeof(*pMod) + cbPath + 1 + cbPath * 2 * sizeof(wchar_t)); 1207 PKWMODULE pMod = kwLdrModuleCreateForNativekLdrModule(pLdrMod, pszPath, kHlpStrLen(pszPath) + 1, 1208 uHashPath, fDoReplacements); 1139 1209 if (pMod) 1140 { 1141 pMod->pszPath = (char *)kHlpMemCopy(pMod + 1, pszPath, cbPath); 1142 pMod->pwszPath = (wchar_t *)(pMod->pszPath + cbPath + (cbPath & 1)); 1143 kwStrToUtf16(pMod->pszPath, (wchar_t *)pMod->pwszPath, cbPath * 2); 1144 pMod->uHashPath = uHashPath; 1145 pMod->cRefs = 1; 1146 pMod->offFilename = (KU16)(kHlpGetFilename(pszPath) - pszPath); 1147 pMod->fExe = K_FALSE; 1148 pMod->fNative = K_TRUE; 1149 pMod->pLdrMod = pLdrMod; 1150 pMod->hOurMod = (HMODULE)(KUPTR)pLdrMod->aSegments[0].MapAddress; 1151 1152 if (fDoReplacements) 1153 { 1154 DWORD const dwSavedErr = GetLastError(); 1155 kwLdrModuleDoNativeImportReplacements(pMod); 1156 SetLastError(dwSavedErr); 1157 } 1158 1159 KW_LOG(("New module: %p LB %#010x %s (native)\n", 1160 (KUPTR)pMod->pLdrMod->aSegments[0].MapAddress, kLdrModSize(pMod->pLdrMod), pMod->pszPath)); 1161 return kwLdrModuleLink(pMod); 1162 } 1163 //kLdrModClose(pLdrMod); 1210 return pMod; 1211 kLdrModClose(pLdrMod); 1164 1212 } 1165 1213 return NULL; … … 1246 1294 || pLdrMod->enmType == KLDRTYPE_SHARED_LIBRARY_FIXED; 1247 1295 pMod->u.Manual.pvLoad = fFixed ? (void *)(KUPTR)pLdrMod->aSegments[0].LinkAddress : NULL; 1248 pMod->u.Manual.cbImage = kLdrModSize(pLdrMod);1296 pMod->u.Manual.cbImage = (KSIZE)kLdrModSize(pLdrMod); 1249 1297 if ( !fFixed 1250 1298 || pLdrMod->enmType != KLDRTYPE_EXECUTABLE_FIXED /* only allow fixed executables */ … … 1929 1977 exception chain stuff installed by the sandboxed executable. */ 1930 1978 *pTib = g_Sandbox.TibMainThread; 1979 pTib->ExceptionList = g_Sandbox.pOutXcptListHead; 1931 1980 1932 1981 longjmp(g_Sandbox.JmpBuf, 1); … … 2039 2088 static VOID WINAPI kwSandbox_Kernel32_GetStartupInfoA(LPSTARTUPINFOA pStartupInfo) 2040 2089 { 2041 __debugbreak(); 2090 KW_LOG(("GetStartupInfoA\n")); 2091 GetStartupInfoA(pStartupInfo); 2092 pStartupInfo->lpReserved = NULL; 2093 pStartupInfo->lpTitle = NULL; 2094 pStartupInfo->lpReserved2 = NULL; 2095 pStartupInfo->cbReserved2 = 0; 2042 2096 } 2043 2097 2044 2098 2045 2099 /** Kernel32 - GetStartupInfoW() */ 2046 static VOID WINAPI kwSandbox_Kernel32_GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo) 2047 { 2048 __debugbreak(); 2100 static VOID WINAPI kwSandbox_Kernel32_GetStartupInfoW(LPSTARTUPINFOW pStartupInfo) 2101 { 2102 KW_LOG(("GetStartupInfoW\n")); 2103 GetStartupInfoW(pStartupInfo); 2104 pStartupInfo->lpReserved = NULL; 2105 pStartupInfo->lpTitle = NULL; 2106 pStartupInfo->lpReserved2 = NULL; 2107 pStartupInfo->cbReserved2 = 0; 2049 2108 } 2050 2109 … … 2306 2365 */ 2307 2366 2308 2309 /** Kernel32 - LoadLibraryExA() */ 2367 /** 2368 * Kernel32 - LoadLibraryExA() worker that loads resource files and such. 2369 */ 2370 static HMODULE WINAPI kwSandbox_Kernel32_LoadLibraryExA_Resource(LPCSTR pszFilename, HANDLE hFile, DWORD fFlags) 2371 { 2372 HMODULE hmod; 2373 PKWDYNLOAD pDynLoad; 2374 KU32 uHashPath; 2375 char szNormPath[4096]; 2376 2377 /* Normalize the path. */ 2378 int rc = kwPathNormalize(pszFilename, szNormPath, sizeof(szNormPath)); 2379 if (rc != 0) 2380 { 2381 __debugbreak(); 2382 return LoadLibraryExA(pszFilename, hFile, fFlags); 2383 } 2384 2385 /* Try look it up. */ 2386 uHashPath = kwStrHash(szNormPath); 2387 for (pDynLoad = g_Sandbox.pTool->u.Sandboxed.pDynLoadHead; pDynLoad != NULL; pDynLoad = pDynLoad->pNext) 2388 if ( pDynLoad->uHashPath == uHashPath 2389 && kHlpStrComp(pDynLoad->pszPath, szNormPath) == 0) 2390 { 2391 if (pDynLoad->pMod == NULL) 2392 return pDynLoad->hmod; 2393 __debugbreak(); 2394 } 2395 2396 /* Then try load it. */ 2397 hmod = LoadLibraryExA(szNormPath, hFile, fFlags); 2398 if (hmod) 2399 { 2400 KSIZE cbNormPath = kHlpStrLen(szNormPath) + 1; 2401 pDynLoad = (PKWDYNLOAD)kHlpAlloc(sizeof(*pDynLoad) + cbNormPath + cbNormPath * 2 * sizeof(wchar_t)); 2402 if (pDynLoad) 2403 { 2404 pDynLoad->pszPath = (char *)kHlpMemCopy(pDynLoad + 1, szNormPath, cbNormPath); 2405 pDynLoad->pwszPath = (wchar_t *)(pDynLoad->pszPath + cbNormPath + (cbNormPath & 1)); 2406 kwStrToUtf16(pDynLoad->pszPath, (wchar_t *)pDynLoad->pwszPath, cbNormPath * 2); 2407 pDynLoad->pszModName = kHlpGetFilename(pDynLoad->pszPath); 2408 pDynLoad->uHashPath = uHashPath; 2409 pDynLoad->pMod = NULL; /* indicates special */ 2410 pDynLoad->hmod = hmod; 2411 2412 pDynLoad->pNext = g_Sandbox.pTool->u.Sandboxed.pDynLoadHead; 2413 g_Sandbox.pTool->u.Sandboxed.pDynLoadHead = pDynLoad; 2414 } 2415 else 2416 __debugbreak(); 2417 } 2418 return hmod; 2419 } 2420 2421 2422 /** 2423 * Kernel32 - LoadLibraryExA() worker that deals with the api-ms-xxx modules. 2424 */ 2425 static HMODULE WINAPI kwSandbox_Kernel32_LoadLibraryExA_VirtualApiModule(LPCSTR pszFilename, HANDLE hFile, DWORD fFlags) 2426 { 2427 HMODULE hmod; 2428 PKWDYNLOAD pDynLoad; 2429 KU32 uHashPath; 2430 char szNormPath[256]; 2431 KSIZE cbFilename = kHlpStrLen(pszFilename) + 1; 2432 2433 /* Lower case it. */ 2434 if (cbFilename <= sizeof(szNormPath)) 2435 { 2436 kHlpMemCopy(szNormPath, pszFilename, cbFilename); 2437 _strlwr(szNormPath); 2438 } 2439 else 2440 { 2441 SetLastError(ERROR_FILENAME_EXCED_RANGE); 2442 return NULL; 2443 } 2444 2445 /* Try look it up. */ 2446 uHashPath = kwStrHash(szNormPath); 2447 for (pDynLoad = g_Sandbox.pTool->u.Sandboxed.pDynLoadHead; pDynLoad != NULL; pDynLoad = pDynLoad->pNext) 2448 if ( pDynLoad->uHashPath == uHashPath 2449 && kHlpStrComp(pDynLoad->pszPath, szNormPath) == 0) 2450 { 2451 if (pDynLoad->pMod != NULL) 2452 return pDynLoad->hmod; 2453 __debugbreak(); 2454 } 2455 2456 /* Then try load it and make a kLdr module for it. */ 2457 hmod = LoadLibraryExA(szNormPath, hFile, fFlags); 2458 if (hmod) 2459 { 2460 PKLDRMOD pLdrMod; 2461 int rc = kLdrModOpenNativeByHandle((KUPTR)hmod, &pLdrMod); 2462 if (rc == 0) 2463 { 2464 PKWMODULE pMod = kwLdrModuleCreateForNativekLdrModule(pLdrMod, szNormPath, cbFilename, uHashPath, 2465 K_FALSE /*fDoReplacements*/); 2466 if (pMod) 2467 { 2468 pDynLoad = (PKWDYNLOAD)kHlpAlloc(sizeof(*pDynLoad) + cbFilename + cbFilename * sizeof(wchar_t)); 2469 if (pDynLoad) 2470 { 2471 pDynLoad->pwszPath = (wchar_t *)(pDynLoad + 1); 2472 kwStrToUtf16(szNormPath, (wchar_t *)pDynLoad->pwszPath, cbFilename); 2473 pDynLoad->pszPath = (char *)kHlpMemCopy((char *)&pDynLoad->pwszPath[cbFilename], szNormPath, cbFilename); 2474 pDynLoad->pszModName = pDynLoad->pszPath; 2475 pDynLoad->uHashPath = uHashPath; 2476 pDynLoad->pMod = pMod; 2477 pDynLoad->hmod = hmod; 2478 2479 pDynLoad->pNext = g_Sandbox.pTool->u.Sandboxed.pDynLoadHead; 2480 g_Sandbox.pTool->u.Sandboxed.pDynLoadHead = pDynLoad; 2481 return hmod; 2482 } 2483 2484 __debugbreak(); 2485 } 2486 else 2487 __debugbreak(); 2488 } 2489 else 2490 __debugbreak(); 2491 } 2492 return hmod; 2493 } 2494 2495 2496 /** Kernel32 - LoadLibraryExA() */ 2310 2497 static HMODULE WINAPI kwSandbox_Kernel32_LoadLibraryExA(LPCSTR pszFilename, HANDLE hFile, DWORD fFlags) 2311 2498 { … … 2328 2515 | LOAD_LIBRARY_AS_IMAGE_RESOURCE) ) 2329 2516 { 2330 HMODULE hmod;2331 char szNormPath[4096];2332 KU32 uHashPath;2333 2334 2517 /* currently, only deal with those that has a path. */ 2335 2518 if (kHlpIsFilenameOnly(pszFilename)) … … 2339 2522 } 2340 2523 2341 /* Normalize the path. */ 2342 rc = kwPathNormalize(pszFilename, szNormPath, sizeof(szNormPath)); 2343 if (rc != 0) 2344 { 2345 __debugbreak(); 2346 return LoadLibraryExA(pszFilename, hFile, fFlags); 2347 } 2348 2349 /* Try look it up. */ 2350 uHashPath = kwStrHash(szNormPath); 2351 for (pDynLoad = g_Sandbox.pTool->u.Sandboxed.pDynLoadHead; pDynLoad != NULL; pDynLoad = pDynLoad->pNext) 2352 if ( pDynLoad->uHashPath == uHashPath 2353 && kHlpStrComp(pDynLoad->pszPath, szNormPath) == 0) 2354 { 2355 if (pDynLoad->pMod == NULL) 2356 return pDynLoad->hmod; 2357 __debugbreak(); 2358 } 2359 2360 /* Then try load it. */ 2361 hmod = LoadLibraryExA(szNormPath, hFile, fFlags); 2362 if (hmod) 2363 { 2364 KSIZE cbNormPath = kHlpStrLen(szNormPath) + 1; 2365 pDynLoad = (PKWDYNLOAD)kHlpAlloc(sizeof(*pDynLoad) + cbNormPath + cbNormPath * 2 * sizeof(wchar_t)); 2366 if (pDynLoad) 2367 { 2368 pDynLoad->pszPath = (char *)kHlpMemCopy(pDynLoad + 1, szNormPath, cbNormPath); 2369 pDynLoad->pwszPath = (wchar_t *)(pDynLoad->pszPath + cbNormPath + (cbNormPath & 1)); 2370 kwStrToUtf16(pDynLoad->pszPath, (wchar_t *)pDynLoad->pwszPath, cbNormPath * 2); 2371 pDynLoad->pszModName = kHlpGetFilename(pDynLoad->pszPath); 2372 pDynLoad->uHashPath = uHashPath; 2373 pDynLoad->pMod = NULL; /* indicates special */ 2374 pDynLoad->hmod = hmod; 2375 2376 pDynLoad->pNext = g_Sandbox.pTool->u.Sandboxed.pDynLoadHead; 2377 g_Sandbox.pTool->u.Sandboxed.pDynLoadHead = pDynLoad; 2378 } 2379 else 2380 __debugbreak(); 2381 } 2382 return hmod; 2524 return kwSandbox_Kernel32_LoadLibraryExA_Resource(pszFilename, hFile, fFlags); 2383 2525 } 2384 2526 … … 2389 2531 if (!kHlpIsFilenameOnly(pszFilename)) 2390 2532 pMod = kwLdrModuleTryLoadDll(pszFilename, KWLOCATION_UNKNOWN, g_Sandbox.pTool->u.Sandboxed.pExe); 2533 /* Special case: api-ms-win-core-synch-l1-2-0 and friends (32-bit yasm, built with VS2015). */ 2534 else if (strnicmp(pszFilename, TUPLE("api-ms-")) == 0) 2535 return kwSandbox_Kernel32_LoadLibraryExA_VirtualApiModule(pszFilename, hFile, fFlags); 2391 2536 else 2392 2537 { … … 2480 2625 static HMODULE WINAPI kwSandbox_Kernel32_GetModuleHandleA(LPCSTR pszModule) 2481 2626 { 2627 KSIZE i; 2628 KSIZE cchModule; 2629 2630 /* 2631 * The executable. 2632 */ 2482 2633 if (pszModule == NULL) 2483 2634 return (HMODULE)g_Sandbox.pTool->u.Sandboxed.pExe->hOurMod; 2635 2636 /* 2637 * Cache of system modules we've seen queried. 2638 */ 2639 cchModule = kHlpStrLen(pszModule); 2640 for (i = 0; i < K_ELEMENTS(g_aGetModuleHandleCache); i++) 2641 if ( g_aGetModuleHandleCache[i].cchName == cchModule 2642 && stricmp(pszModule, g_aGetModuleHandleCache[i].pszName) == 0) 2643 { 2644 if (g_aGetModuleHandleCache[i].hmod != NULL) 2645 return g_aGetModuleHandleCache[i].hmod; 2646 return g_aGetModuleHandleCache[i].hmod = GetModuleHandleA(pszModule); 2647 } 2648 2484 2649 __debugbreak(); 2485 2650 return NULL; … … 2490 2655 static HMODULE WINAPI kwSandbox_Kernel32_GetModuleHandleW(LPCWSTR pwszModule) 2491 2656 { 2657 KSIZE i; 2658 KSIZE cwcModule; 2659 2660 /* 2661 * The executable. 2662 */ 2492 2663 if (pwszModule == NULL) 2493 2664 return (HMODULE)g_Sandbox.pTool->u.Sandboxed.pExe->hOurMod; 2665 2666 /* 2667 * Cache of system modules we've seen queried. 2668 */ 2669 cwcModule = kwUtf16Len(pwszModule); 2670 for (i = 0; i < K_ELEMENTS(g_aGetModuleHandleCache); i++) 2671 if ( g_aGetModuleHandleCache[i].cwcName == cwcModule 2672 && _wcsicmp(pwszModule, g_aGetModuleHandleCache[i].pwszName) == 0) 2673 { 2674 if (g_aGetModuleHandleCache[i].hmod != NULL) 2675 return g_aGetModuleHandleCache[i].hmod; 2676 return g_aGetModuleHandleCache[i].hmod = GetModuleHandleW(pwszModule); 2677 } 2678 2494 2679 __debugbreak(); 2495 2680 return NULL; … … 2531 2716 static FARPROC WINAPI kwSandbox_Kernel32_GetProcAddress(HMODULE hmod, LPCSTR pszProc) 2532 2717 { 2718 KSIZE i; 2719 2533 2720 /* 2534 2721 * Try locate the module. … … 2564 2751 return NULL; 2565 2752 } 2753 2754 /* 2755 * Hmm... could be a cached module-by-name. 2756 */ 2757 for (i = 0; i < K_ELEMENTS(g_aGetModuleHandleCache); i++) 2758 if (g_aGetModuleHandleCache[i].hmod == hmod) 2759 return GetProcAddress(hmod, pszProc); 2566 2760 2567 2761 __debugbreak(); … … 4482 4676 pSandbox->pTool = pTool; 4483 4677 pSandbox->idMainThread = GetCurrentThreadId(); 4484 pSandbox->TibMainThread = *(PNT_TIB)NtCurrentTeb();4485 4678 pSandbox->pgmptr = (char *)pTool->pszPath; 4486 4679 pSandbox->wpgmptr = (wchar_t *)pTool->pwszPath; … … 4585 4778 if (rc == 0) 4586 4779 { 4780 #if K_ARCH == K_ARCH_AMD64 4587 4781 int (*pfnWin64Entrypoint)(void *pvPeb, void *, void *, void *); 4588 *(KUPTR *)&pfnWin64Entrypoint = uAddrMain; 4589 4590 __try 4591 { 4592 if (setjmp(g_Sandbox.JmpBuf) == 0) 4593 { 4594 #if K_ARCH == K_ARCH_AMD64 4595 *(KU64*)(g_Sandbox.JmpBuf) = 0; /** @todo find other way to prevent longjmp from doing unwind! */ 4782 #elif K_ARCH == K_ARCH_X86_32 4783 int (__cdecl *pfnWin32Entrypoint)(void *pvPeb); 4596 4784 #else 4597 4785 # error "Port me!" 4598 4786 #endif 4787 4788 /* Save the NT TIB first (should do that here, not in some other function). */ 4789 PNT_TIB pTib = (PNT_TIB)NtCurrentTeb(); 4790 g_Sandbox.TibMainThread = *pTib; 4791 4792 /* Make the call in a guarded fashion. */ 4793 #if K_ARCH == K_ARCH_AMD64 4794 /* AMD64 */ 4795 *(KUPTR *)&pfnWin64Entrypoint = uAddrMain; 4796 __try 4797 { 4798 pSandbox->pOutXcptListHead = pTib->ExceptionList; 4799 if (setjmp(g_Sandbox.JmpBuf) == 0) 4800 { 4801 *(KU64*)(g_Sandbox.JmpBuf) = 0; /** @todo find other way to prevent longjmp from doing unwind! */ 4599 4802 rcExit = pfnWin64Entrypoint(kwSandboxGetProcessEnvironmentBlock(), NULL, NULL, NULL); 4600 4803 } … … 4602 4805 rcExit = g_Sandbox.rcExitCode; 4603 4806 } 4807 #elif K_ARCH == K_ARCH_X86_32 4808 /* x86 (see _tmainCRTStartup) */ 4809 *(KUPTR *)&pfnWin32Entrypoint = uAddrMain; 4810 __try 4811 { 4812 pSandbox->pOutXcptListHead = pTib->ExceptionList; 4813 if (setjmp(g_Sandbox.JmpBuf) == 0) 4814 { 4815 //*(KU64*)(g_Sandbox.JmpBuf) = 0; /** @todo find other way to prevent longjmp from doing unwind! */ 4816 rcExit = pfnWin32Entrypoint(kwSandboxGetProcessEnvironmentBlock()); 4817 } 4818 else 4819 rcExit = g_Sandbox.rcExitCode; 4820 } 4821 #endif 4604 4822 __except (EXCEPTION_EXECUTE_HANDLER) 4605 4823 { … … 4607 4825 } 4608 4826 4609 /* 4610 * Restore the TIB and later some other stuff. 4611 */ 4612 *(PNT_TIB)NtCurrentTeb() = g_Sandbox.TibMainThread; 4827 /* Now, restore the NT TIB. */ 4828 *pTib = g_Sandbox.TibMainThread; 4613 4829 } 4614 4830 else
Note:
See TracChangeset
for help on using the changeset viewer.