Changeset 2881 in kBuild for trunk/src/kWorker/kWorker.c
- Timestamp:
- Sep 5, 2016 11:50:47 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kWorker/kWorker.c
r2878 r2881 52 52 #include "nt/kFsCache.h" 53 53 #include "quote_argv.h" 54 #include "md5.h" 54 55 55 56 … … 57 58 * Defined Constants And Macros * 58 59 *********************************************************************************************************************************/ 60 /** @def WITH_TEMP_MEMORY_FILES 61 * Enables temporary memory files for cl.exe. */ 62 #define WITH_TEMP_MEMORY_FILES 63 64 /** @def WITH_HASH_MD5_CACHE 65 * Enables caching of MD5 sums for cl.exe. 66 * This prevents wasting time on rehashing common headers each time 67 * they are included. */ 68 #define WITH_HASH_MD5_CACHE 69 70 59 71 /** String constant comma length. */ 60 72 #define TUPLE(a_sz) a_sz, sizeof(a_sz) - 1 … … 69 81 #endif 70 82 71 72 83 /** @def KWFS_LOG 73 84 * FS cache logging. … … 79 90 #endif 80 91 92 /** @def KWCRYPT_LOG 93 * FS cache logging. 94 * @param a Argument list for kwDbgPrintf */ 95 #ifndef NDEBUG 96 # define KWCRYPT_LOG(a) kwDbgPrintf a 97 #else 98 # define KWCRYPT_LOG(a) do { } while (0) 99 #endif 100 81 101 /** Converts a windows handle to a handle table index. 82 102 * @note We currently just mask off the 31th bit, and do no shifting or anything … … 86 106 /** Maximum handle value we can deal with. */ 87 107 #define KW_HANDLE_MAX 0x20000 88 89 /** @def WITH_TEMP_MEMORY_FILES90 * Enables temporary memory files for cl.exe. */91 #define WITH_TEMP_MEMORY_FILES92 108 93 109 /** Max temporary file size (memory backed). */ … … 238 254 /** Cached file handle. */ 239 255 HANDLE hCached; 256 /** Cached file content. */ 257 KU8 *pbCached; 240 258 /** The file size. */ 241 259 KU32 cbCached; 242 /** Cached file content. */ 243 KU8 *pbCached; 260 #ifdef WITH_HASH_MD5_CACHE 261 /** Set if we've got a valid MD5 hash in abMd5Digest. */ 262 KBOOL fValidMd5; 263 /** The MD5 digest if fValidMd5 is set. */ 264 KU8 abMd5Digest[16]; 265 #endif 244 266 245 267 /** Circular self reference. Prevents the object from ever going away and 246 268 * keeps it handy for debugging. */ 247 269 PKFSOBJ pFsObj; 270 /** The file path (for debugging). */ 271 char szPath[1]; 248 272 } KFSWCACHEDFILE; 249 /** Pointe to a cached filed. */273 /** Pointer to a cached filed. */ 250 274 typedef KFSWCACHEDFILE *PKFSWCACHEDFILE; 275 276 277 #ifdef WITH_HASH_MD5_CACHE 278 /** Pointer to a MD5 hash instance. */ 279 typedef struct KWHASHMD5 *PKWHASHMD5; 280 /** 281 * A MD5 hash instance. 282 */ 283 typedef struct KWHASHMD5 284 { 285 /** The magic value. */ 286 KUPTR uMagic; 287 /** Pointer to the next hash handle. */ 288 PKWHASHMD5 pNext; 289 /** The cached file we've associated this handle with. */ 290 PKFSWCACHEDFILE pCachedFile; 291 /** The number of bytes we've hashed. */ 292 KU32 cbHashed; 293 /** Set if this has gone wrong. */ 294 KBOOL fGoneBad; 295 /** Set if we're in fallback mode (file not cached). */ 296 KBOOL fFallbackMode; 297 /** Set if we've already finalized the digest. */ 298 KBOOL fFinal; 299 /** The MD5 fallback context. */ 300 struct MD5Context Md5Ctx; 301 /** The finalized digest. */ 302 KU8 abDigest[16]; 303 304 } KWHASHMD5; 305 /** Magic value for KWHASHMD5::uMagic (Les McCann). */ 306 # define KWHASHMD5_MAGIC KUPTR_C(0x19350923) 307 #endif /* WITH_HASH_MD5_CACHE */ 308 251 309 252 310 … … 472 530 473 531 UNICODE_STRING SavedCommandLine; 532 533 #ifdef WITH_HASH_MD5_CACHE 534 /** The special MD5 hash instance. */ 535 PKWHASHMD5 pHashHead; 536 /** ReadFile sets these while CryptHashData claims and clears them. 537 * 538 * This is part of the heuristics we use for MD5 caching for header files. The 539 * observed pattern is that c1.dll/c1xx.dll first reads a chunk of a source or 540 * header, then passes the same buffer and read byte count to CryptHashData. 541 */ 542 struct 543 { 544 /** The cached file last read from. */ 545 PKFSWCACHEDFILE pCachedFile; 546 /** The file offset of the last cached read. */ 547 KU32 offRead; 548 /** The number of bytes read last. */ 549 KU32 cbRead; 550 /** The buffer pointer of the last read. */ 551 void *pvRead; 552 } LastHashRead; 553 #endif 474 554 } KWSANDBOX; 475 555 … … 4180 4260 */ 4181 4261 PKFSWCACHEDFILE pCachedFile; 4262 KU32 cbPath = pFsObj->cchParent + pFsObj->cchName + 2; 4182 4263 pCachedFile = (PKFSWCACHEDFILE)kFsCacheObjAddUserData(g_pFsCache, pFsObj, KW_DATA_KEY_CACHED_FILE, 4183 sizeof(*pCachedFile) );4264 sizeof(*pCachedFile) + cbPath); 4184 4265 if (pCachedFile) 4185 4266 { … … 4188 4269 pCachedFile->pbCached = pbCache; 4189 4270 pCachedFile->pFsObj = pFsObj; 4271 kFsCacheObjGetFullPathA(pFsObj, pCachedFile->szPath, cbPath, '/'); 4190 4272 kFsCacheObjRetain(pFsObj); 4191 4273 return pCachedFile; … … 4565 4647 else if (cbActually < cbToRead) 4566 4648 ((KU8 *)pvBuffer)[cbActually] = '\0'; // hack hack hack 4649 4650 #ifdef WITH_HASH_MD5_CACHE 4651 if (g_Sandbox.pHashHead) 4652 { 4653 g_Sandbox.LastHashRead.pCachedFile = pCachedFile; 4654 g_Sandbox.LastHashRead.offRead = pHandle->offFile; 4655 g_Sandbox.LastHashRead.cbRead = cbActually; 4656 g_Sandbox.LastHashRead.pvRead = pvBuffer; 4657 } 4658 #endif 4567 4659 4568 4660 kHlpMemCopy(pvBuffer, &pCachedFile->pbCached[pHandle->offFile], cbActually); … … 5422 5514 /* 5423 5515 * 5516 * Header file hashing. 5517 * Header file hashing. 5518 * Header file hashing. 5519 * 5520 * c1.dll / c1XX.dll hashes the input files. The Visual C++ 2010 profiler 5521 * indicated that ~12% of the time was spent doing MD5 caluclation when 5522 * rebuiling openssl. The hashing it done right after reading the source 5523 * via ReadFile, same buffers and sizes. 5524 */ 5525 5526 #ifdef WITH_HASH_MD5_CACHE 5527 5528 /** Advapi32 - CryptCreateHash */ 5529 static BOOL WINAPI kwSandbox_Advapi32_CryptCreateHash(HCRYPTPROV hProv, ALG_ID idAlg, HCRYPTKEY hKey, DWORD dwFlags, 5530 HCRYPTHASH *phHash) 5531 { 5532 BOOL fRc; 5533 5534 /* 5535 * Only do this for cl.exe when it request normal MD5. 5536 */ 5537 if (g_Sandbox.pTool->u.Sandboxed.enmHint == KWTOOLHINT_VISUAL_CPP_CL) 5538 { 5539 if (idAlg == CALG_MD5) 5540 { 5541 if (hKey == 0) 5542 { 5543 if (dwFlags == 0) 5544 { 5545 PKWHASHMD5 pHash = (PKWHASHMD5)kHlpAllocZ(sizeof(*pHash)); 5546 if (pHash) 5547 { 5548 pHash->uMagic = KWHASHMD5_MAGIC; 5549 pHash->cbHashed = 0; 5550 pHash->fGoneBad = K_FALSE; 5551 pHash->fFallbackMode = K_FALSE; 5552 pHash->fFinal = K_FALSE; 5553 5554 /* link it. */ 5555 pHash->pNext = g_Sandbox.pHashHead; 5556 g_Sandbox.pHashHead = pHash; 5557 5558 *phHash = (KUPTR)pHash; 5559 KWCRYPT_LOG(("CryptCreateHash(hProv=%p, idAlg=CALG_MD5, 0, 0, *phHash=%p) -> %d [cached]\n", 5560 hProv, *phHash, TRUE)); 5561 return TRUE; 5562 } 5563 5564 kwErrPrintf("CryptCreateHash: out of memory!\n"); 5565 } 5566 else 5567 kwErrPrintf("CryptCreateHash: dwFlags=%p is not supported with CALG_MD5\n", hKey); 5568 } 5569 else 5570 kwErrPrintf("CryptCreateHash: hKey=%p is not supported with CALG_MD5\n", hKey); 5571 } 5572 else 5573 kwErrPrintf("CryptCreateHash: idAlg=%#x is not supported\n", idAlg); 5574 } 5575 5576 /* 5577 * Fallback. 5578 */ 5579 fRc = CryptCreateHash(hProv, idAlg, hKey, dwFlags, phHash); 5580 KWCRYPT_LOG(("CryptCreateHash(hProv=%p, idAlg=%#x (%d), hKey=%p, dwFlags=%#x, *phHash=%p) -> %d\n", 5581 hProv, idAlg, idAlg, hKey, dwFlags, *phHash, fRc)); 5582 return fRc; 5583 } 5584 5585 5586 /** Advapi32 - CryptHashData */ 5587 static BOOL WINAPI kwSandbox_Advapi32_CryptHashData(HCRYPTHASH hHash, CONST BYTE *pbData, DWORD cbData, DWORD dwFlags) 5588 { 5589 BOOL fRc; 5590 PKWHASHMD5 pHash = g_Sandbox.pHashHead; 5591 while (pHash && (KUPTR)pHash != hHash) 5592 pHash = pHash->pNext; 5593 KWCRYPT_LOG(("CryptHashData(hHash=%p/%p, pbData=%p, cbData=%#x, dwFlags=%#x)\n", 5594 hHash, pHash, pbData, cbData, dwFlags)); 5595 if (pHash) 5596 { 5597 /* 5598 * Validate the state. 5599 */ 5600 if ( pHash->uMagic == KWHASHMD5_MAGIC 5601 && !pHash->fFinal) 5602 { 5603 if (!pHash->fFallbackMode) 5604 { 5605 /* 5606 * Does this match the previous ReadFile call to a cached file? 5607 * If it doesn't, try falling back. 5608 */ 5609 if ( g_Sandbox.LastHashRead.cbRead == cbData 5610 && g_Sandbox.LastHashRead.pvRead == (void *)pbData) 5611 { 5612 PKFSWCACHEDFILE pCachedFile = g_Sandbox.LastHashRead.pCachedFile; 5613 if ( pCachedFile 5614 && kHlpMemComp(pbData, &pCachedFile->pbCached[g_Sandbox.LastHashRead.offRead], K_MIN(cbData, 64)) == 0) 5615 { 5616 5617 if (g_Sandbox.LastHashRead.offRead == pHash->cbHashed) 5618 { 5619 if ( pHash->pCachedFile == NULL 5620 && pHash->cbHashed == 0) 5621 pHash->pCachedFile = pCachedFile; 5622 if (pHash->pCachedFile == pCachedFile) 5623 { 5624 pHash->cbHashed += cbData; 5625 g_Sandbox.LastHashRead.pCachedFile = NULL; 5626 g_Sandbox.LastHashRead.pvRead = NULL; 5627 g_Sandbox.LastHashRead.cbRead = 0; 5628 g_Sandbox.LastHashRead.offRead = 0; 5629 KWCRYPT_LOG(("CryptHashData(hHash=%p/%p/%s, pbData=%p, cbData=%#x, dwFlags=%#x) -> 1 [cached]\n", 5630 hHash, pCachedFile, pCachedFile->szPath, pbData, cbData, dwFlags)); 5631 return TRUE; 5632 } 5633 5634 /* Note! it's possible to fall back here too, if necessary. */ 5635 kwErrPrintf("CryptHashData: Expected pCachedFile=%p, last read was made to %p!!\n", 5636 pHash->pCachedFile, g_Sandbox.LastHashRead.pCachedFile); 5637 } 5638 else 5639 kwErrPrintf("CryptHashData: Expected last read at %#x, instead it was made at %#x\n", 5640 pHash->cbHashed, g_Sandbox.LastHashRead.offRead); 5641 } 5642 else if (!pCachedFile) 5643 kwErrPrintf("CryptHashData: Last pCachedFile is NULL when buffer address and size matches!\n"); 5644 else 5645 kwErrPrintf("CryptHashData: First 64 bytes of the buffer doesn't match the cache.\n"); 5646 } 5647 else if (g_Sandbox.LastHashRead.cbRead != 0 && pHash->cbHashed != 0) 5648 kwErrPrintf("CryptHashData: Expected cbRead=%#x and pbData=%p, got %#x and %p instead\n", 5649 g_Sandbox.LastHashRead.cbRead, g_Sandbox.LastHashRead.pvRead, cbData, pbData); 5650 if (pHash->cbHashed == 0) 5651 pHash->fFallbackMode = K_TRUE; 5652 if (pHash->fFallbackMode) 5653 { 5654 /* Initiate fallback mode (file that we don't normally cache, like .c/.cpp). */ 5655 pHash->fFallbackMode = K_TRUE; 5656 MD5Init(&pHash->Md5Ctx); 5657 MD5Update(&pHash->Md5Ctx, pbData, cbData); 5658 pHash->cbHashed = cbData; 5659 KWCRYPT_LOG(("CryptHashData(hHash=%p/fallback, pbData=%p, cbData=%#x, dwFlags=%#x) -> 1 [fallback!]\n", 5660 hHash, pbData, cbData, dwFlags)); 5661 return TRUE; 5662 } 5663 pHash->fGoneBad = K_TRUE; 5664 SetLastError(ERROR_INVALID_PARAMETER); 5665 fRc = FALSE; 5666 } 5667 else 5668 { 5669 /* fallback. */ 5670 MD5Update(&pHash->Md5Ctx, pbData, cbData); 5671 pHash->cbHashed += cbData; 5672 fRc = TRUE; 5673 KWCRYPT_LOG(("CryptHashData(hHash=%p/fallback, pbData=%p, cbData=%#x, dwFlags=%#x) -> 1 [fallback]\n", 5674 hHash, pbData, cbData, dwFlags)); 5675 } 5676 } 5677 /* 5678 * Bad handle state. 5679 */ 5680 else 5681 { 5682 if (pHash->uMagic != KWHASHMD5_MAGIC) 5683 kwErrPrintf("CryptHashData: Invalid cached hash handle!!\n"); 5684 else 5685 kwErrPrintf("CryptHashData: Hash is already finalized!!\n"); 5686 SetLastError(NTE_BAD_HASH); 5687 fRc = FALSE; 5688 } 5689 } 5690 else 5691 { 5692 5693 fRc = CryptHashData(hHash, pbData, cbData, dwFlags); 5694 KWCRYPT_LOG(("CryptHashData(hHash=%p, pbData=%p, cbData=%#x, dwFlags=%#x) -> %d\n", hHash, pbData, cbData, dwFlags, fRc)); 5695 } 5696 return fRc; 5697 } 5698 5699 5700 /** Advapi32 - CryptGetHashParam */ 5701 static BOOL WINAPI kwSandbox_Advapi32_CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, 5702 BYTE *pbData, DWORD *pcbData, DWORD dwFlags) 5703 { 5704 BOOL fRc; 5705 PKWHASHMD5 pHash = g_Sandbox.pHashHead; 5706 while (pHash && (KUPTR)pHash != hHash) 5707 pHash = pHash->pNext; 5708 if (pHash) 5709 { 5710 if (pHash->uMagic == KWHASHMD5_MAGIC) 5711 { 5712 if (dwFlags == 0) 5713 { 5714 DWORD cbRet; 5715 void *pvRet; 5716 union 5717 { 5718 DWORD dw; 5719 } uBuf; 5720 5721 switch (dwParam) 5722 { 5723 case HP_HASHVAL: 5724 { 5725 /* Check the hash progress. */ 5726 PKFSWCACHEDFILE pCachedFile = pHash->pCachedFile; 5727 if (pCachedFile) 5728 { 5729 if ( pCachedFile->cbCached == pHash->cbHashed 5730 && !pHash->fGoneBad) 5731 { 5732 if (pCachedFile->fValidMd5) 5733 KWCRYPT_LOG(("Already calculated hash for %p/%s! [hit]\n", pCachedFile, pCachedFile->szPath)); 5734 else 5735 { 5736 MD5Init(&pHash->Md5Ctx); 5737 MD5Update(&pHash->Md5Ctx, pCachedFile->pbCached, pCachedFile->cbCached); 5738 MD5Final(pCachedFile->abMd5Digest, &pHash->Md5Ctx); 5739 pCachedFile->fValidMd5 = K_TRUE; 5740 KWCRYPT_LOG(("Calculated hash for %p/%s.\n", pCachedFile, pCachedFile->szPath)); 5741 } 5742 pvRet = pCachedFile->abMd5Digest; 5743 } 5744 else 5745 { 5746 /* This actually happens (iprt/string.h + common/alloc/alloc.cpp), at least 5747 from what I can tell, so just deal with it. */ 5748 KWCRYPT_LOG(("CryptGetHashParam/HP_HASHVAL: Not at end of cached file! cbCached=%#x cbHashed=%#x fGoneBad=%d (%p/%p/%s)\n", 5749 pHash->pCachedFile->cbCached, pHash->cbHashed, pHash->fGoneBad, 5750 pHash, pCachedFile, pCachedFile->szPath)); 5751 pHash->fFallbackMode = K_TRUE; 5752 pHash->pCachedFile = NULL; 5753 MD5Init(&pHash->Md5Ctx); 5754 MD5Update(&pHash->Md5Ctx, pCachedFile->pbCached, pHash->cbHashed); 5755 MD5Final(pHash->abDigest, &pHash->Md5Ctx); 5756 pvRet = pHash->abDigest; 5757 } 5758 pHash->fFinal = K_TRUE; 5759 cbRet = 16; 5760 break; 5761 } 5762 else if (pHash->fFallbackMode) 5763 { 5764 if (!pHash->fFinal) 5765 { 5766 pHash->fFinal = K_TRUE; 5767 MD5Final(pHash->abDigest, &pHash->Md5Ctx); 5768 } 5769 pvRet = pHash->abDigest; 5770 cbRet = 16; 5771 break; 5772 } 5773 else 5774 { 5775 kwErrPrintf("CryptGetHashParam/HP_HASHVAL: pCachedFile is NULL!!\n"); 5776 SetLastError(ERROR_INVALID_SERVER_STATE); 5777 } 5778 return FALSE; 5779 } 5780 5781 case HP_HASHSIZE: 5782 uBuf.dw = 16; 5783 pvRet = &uBuf; 5784 cbRet = sizeof(DWORD); 5785 break; 5786 5787 case HP_ALGID: 5788 uBuf.dw = CALG_MD5; 5789 pvRet = &uBuf; 5790 cbRet = sizeof(DWORD); 5791 break; 5792 5793 default: 5794 kwErrPrintf("CryptGetHashParam: Unknown dwParam=%#x\n", dwParam); 5795 SetLastError(NTE_BAD_TYPE); 5796 return FALSE; 5797 } 5798 5799 /* 5800 * Copy out cbRet from pvRet. 5801 */ 5802 if (pbData) 5803 { 5804 if (*pcbData >= cbRet) 5805 { 5806 *pcbData = cbRet; 5807 kHlpMemCopy(pbData, pvRet, cbRet); 5808 if (cbRet == 4) 5809 KWCRYPT_LOG(("CryptGetHashParam/%#x/%p/%p: TRUE, cbRet=%#x data=%#x [cached]\n", 5810 dwParam, pHash, pHash->pCachedFile, cbRet, (DWORD *)pbData)); 5811 else if (cbRet == 16) 5812 KWCRYPT_LOG(("CryptGetHashParam/%#x/%p/%p: TRUE, cbRet=%#x data=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x [cached]\n", 5813 dwParam, pHash, pHash->pCachedFile, cbRet, 5814 pbData[0], pbData[1], pbData[2], pbData[3], 5815 pbData[4], pbData[5], pbData[6], pbData[7], 5816 pbData[8], pbData[9], pbData[10], pbData[11], 5817 pbData[12], pbData[13], pbData[14], pbData[15])); 5818 else 5819 KWCRYPT_LOG(("CryptGetHashParam/%#x%/p%/%p: TRUE, cbRet=%#x [cached]\n", 5820 dwParam, pHash, pHash->pCachedFile, cbRet)); 5821 return TRUE; 5822 } 5823 5824 kHlpMemCopy(pbData, pvRet, *pcbData); 5825 } 5826 SetLastError(ERROR_MORE_DATA); 5827 *pcbData = cbRet; 5828 KWCRYPT_LOG(("CryptGetHashParam/%#x: ERROR_MORE_DATA\n")); 5829 } 5830 else 5831 { 5832 kwErrPrintf("CryptGetHashParam: dwFlags is not zero: %#x!\n", dwFlags); 5833 SetLastError(NTE_BAD_FLAGS); 5834 } 5835 } 5836 else 5837 { 5838 kwErrPrintf("CryptGetHashParam: Invalid cached hash handle!!\n"); 5839 SetLastError(NTE_BAD_HASH); 5840 } 5841 fRc = FALSE; 5842 } 5843 /* 5844 * Regular handle. 5845 */ 5846 else 5847 { 5848 fRc = CryptGetHashParam(hHash, dwParam, pbData, pcbData, dwFlags); 5849 KWCRYPT_LOG(("CryptGetHashParam(hHash=%p, dwParam=%#x (%d), pbData=%p, *pcbData=%#x, dwFlags=%#x) -> %d\n", 5850 hHash, dwParam, pbData, *pcbData, dwFlags, fRc)); 5851 } 5852 5853 return fRc; 5854 } 5855 5856 5857 /** Advapi32 - CryptDestroyHash */ 5858 static BOOL WINAPI kwSandbox_Advapi32_CryptDestroyHash(HCRYPTHASH hHash) 5859 { 5860 BOOL fRc; 5861 PKWHASHMD5 pPrev = NULL; 5862 PKWHASHMD5 pHash = g_Sandbox.pHashHead; 5863 while (pHash && (KUPTR)pHash != hHash) 5864 { 5865 pPrev = pHash; 5866 pHash = pHash->pNext; 5867 } 5868 if (pHash) 5869 { 5870 if (pHash->uMagic == KWHASHMD5_MAGIC) 5871 { 5872 pHash->uMagic = 0; 5873 if (!pPrev) 5874 g_Sandbox.pHashHead = pHash->pNext; 5875 else 5876 pPrev->pNext = pHash->pNext; 5877 kHlpFree(pHash); 5878 KWCRYPT_LOG(("CryptDestroyHash(hHash=%p) -> 1 [cached]\n", hHash)); 5879 fRc = TRUE; 5880 } 5881 else 5882 { 5883 kwErrPrintf("CryptDestroyHash: Invalid cached hash handle!!\n"); 5884 KWCRYPT_LOG(("CryptDestroyHash(hHash=%p) -> FALSE! [cached]\n", hHash)); 5885 SetLastError(ERROR_INVALID_HANDLE); 5886 fRc = FALSE; 5887 } 5888 } 5889 /* 5890 * Regular handle. 5891 */ 5892 else 5893 { 5894 fRc = CryptDestroyHash(hHash); 5895 KWCRYPT_LOG(("CryptDestroyHash(hHash=%p) -> %d\n", hHash, fRc)); 5896 } 5897 return fRc; 5898 } 5899 5900 #endif /* WITH_HASH_MD5_CACHE */ 5901 5902 5903 /* 5904 * 5424 5905 * Misc function only intercepted while debugging. 5425 5906 * Misc function only intercepted while debugging. … … 5514 5995 { TUPLE("FlsFree"), NULL, (KUPTR)kwSandbox_Kernel32_FlsFree }, 5515 5996 5997 #ifdef WITH_HASH_MD5_CACHE 5998 { TUPLE("CryptCreateHash"), NULL, (KUPTR)kwSandbox_Advapi32_CryptCreateHash }, 5999 { TUPLE("CryptHashData"), NULL, (KUPTR)kwSandbox_Advapi32_CryptHashData }, 6000 { TUPLE("CryptGetHashParam"), NULL, (KUPTR)kwSandbox_Advapi32_CryptGetHashParam }, 6001 { TUPLE("CryptDestroyHash"), NULL, (KUPTR)kwSandbox_Advapi32_CryptDestroyHash }, 6002 #endif 6003 5516 6004 /* 5517 6005 * MS Visual C++ CRTs. … … 5608 6096 { TUPLE("GetFileAttributesW"), NULL, (KUPTR)kwSandbox_Kernel32_GetFileAttributesW }, 5609 6097 { TUPLE("GetShortPathNameW"), NULL, (KUPTR)kwSandbox_Kernel32_GetShortPathNameW }, 6098 6099 #ifdef WITH_HASH_MD5_CACHE 6100 { TUPLE("CryptCreateHash"), NULL, (KUPTR)kwSandbox_Advapi32_CryptCreateHash }, 6101 { TUPLE("CryptHashData"), NULL, (KUPTR)kwSandbox_Advapi32_CryptHashData }, 6102 { TUPLE("CryptGetHashParam"), NULL, (KUPTR)kwSandbox_Advapi32_CryptGetHashParam }, 6103 { TUPLE("CryptDestroyHash"), NULL, (KUPTR)kwSandbox_Advapi32_CryptDestroyHash }, 6104 #endif 5610 6105 5611 6106 /* … … 5969 6464 PKWVIRTALLOC pTracker; 5970 6465 PKWLOCALSTORAGE pLocalStorage; 6466 #ifdef WITH_HASH_MD5_CACHE 6467 PKWHASHMD5 pHash; 6468 #endif 5971 6469 #ifdef WITH_TEMP_MEMORY_FILES 5972 6470 PKWFSTEMPFILE pTempFile; … … 6007 6505 { 6008 6506 PKWLOCALSTORAGE pNext = pLocalStorage->pNext; 6009 KW_LOG(("Freeing lea ded FlsAlloc index %#x\n", pLocalStorage->idx));6507 KW_LOG(("Freeing leaked FlsAlloc index %#x\n", pLocalStorage->idx)); 6010 6508 FlsFree(pLocalStorage->idx); 6011 6509 kHlpFree(pLocalStorage); … … 6019 6517 { 6020 6518 PKWLOCALSTORAGE pNext = pLocalStorage->pNext; 6021 KW_LOG(("Freeing lea ded TlsAlloc index %#x\n", pLocalStorage->idx));6519 KW_LOG(("Freeing leaked TlsAlloc index %#x\n", pLocalStorage->idx)); 6022 6520 TlsFree(pLocalStorage->idx); 6023 6521 kHlpFree(pLocalStorage); … … 6040 6538 pSandbox->papwszEnvVars[0] = NULL; 6041 6539 } 6540 6541 #ifdef WITH_HASH_MD5_CACHE 6542 /* 6543 * Hash handles. 6544 */ 6545 pHash = pSandbox->pHashHead; 6546 pSandbox->pHashHead = NULL; 6547 while (pHash) 6548 { 6549 PKWHASHMD5 pNext = pHash->pNext; 6550 KWCRYPT_LOG(("Freeing leaked hash instance %#p\n", pHash)); 6551 kHlpFree(pNext); 6552 pHash = pNext; 6553 } 6554 #endif 6042 6555 6043 6556 /*
Note:
See TracChangeset
for help on using the changeset viewer.