mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 14:51:00 +00:00
[CRYPTNET]
* Sync with Wine 1.5.26. svn path=/trunk/; revision=58719
This commit is contained in:
parent
d8217043cd
commit
7865d05379
2 changed files with 60 additions and 86 deletions
|
@ -44,22 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(cryptnet);
|
||||||
|
|
||||||
#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
|
#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
||||||
{
|
|
||||||
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
|
||||||
|
|
||||||
switch (fdwReason) {
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
DisableThreadLibraryCalls(hinstDLL);
|
|
||||||
break;
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
/* Do uninitialisation here */
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const WCHAR cryptNet[] = { 'c','r','y','p','t','n','e','t','.',
|
static const WCHAR cryptNet[] = { 'c','r','y','p','t','n','e','t','.',
|
||||||
'd','l','l',0 };
|
'd','l','l',0 };
|
||||||
|
|
||||||
|
@ -521,24 +505,26 @@ static BOOL CRYPT_GetObjectFromCache(LPCWSTR pszURL, PCRYPT_BLOB_ARRAY pObject,
|
||||||
|
|
||||||
TRACE("(%s, %p, %p)\n", debugstr_w(pszURL), pObject, pAuxInfo);
|
TRACE("(%s, %p, %p)\n", debugstr_w(pszURL), pObject, pAuxInfo);
|
||||||
|
|
||||||
ret = GetUrlCacheEntryInfoW(pszURL, NULL, &size);
|
RetrieveUrlCacheEntryFileW(pszURL, NULL, &size, 0);
|
||||||
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pCacheInfo = CryptMemAlloc(size);
|
||||||
|
if (!pCacheInfo)
|
||||||
{
|
{
|
||||||
pCacheInfo = CryptMemAlloc(size);
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
if (pCacheInfo)
|
return FALSE;
|
||||||
ret = TRUE;
|
|
||||||
else
|
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
|
||||||
}
|
}
|
||||||
if (ret && (ret = GetUrlCacheEntryInfoW(pszURL, pCacheInfo, &size)))
|
|
||||||
|
if ((ret = RetrieveUrlCacheEntryFileW(pszURL, pCacheInfo, &size, 0)))
|
||||||
{
|
{
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
|
|
||||||
GetSystemTimeAsFileTime(&ft);
|
GetSystemTimeAsFileTime(&ft);
|
||||||
if (CompareFileTime(&pCacheInfo->ExpireTime, &ft) >= 0)
|
if (CompareFileTime(&pCacheInfo->ExpireTime, &ft) >= 0)
|
||||||
{
|
{
|
||||||
HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName,
|
HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName, GENERIC_READ,
|
||||||
GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
||||||
if (hFile != INVALID_HANDLE_VALUE)
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -565,6 +551,7 @@ static BOOL CRYPT_GetObjectFromCache(LPCWSTR pszURL, PCRYPT_BLOB_ARRAY pObject,
|
||||||
DeleteUrlCacheEntryW(pszURL);
|
DeleteUrlCacheEntryW(pszURL);
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
|
UnlockUrlCacheEntryFileW(pszURL, 0);
|
||||||
}
|
}
|
||||||
CryptMemFree(pCacheInfo);
|
CryptMemFree(pCacheInfo);
|
||||||
TRACE("returning %d\n", ret);
|
TRACE("returning %d\n", ret);
|
||||||
|
@ -733,21 +720,24 @@ static void CRYPT_CacheURL(LPCWSTR pszURL, const CRYPT_BLOB_ARRAY *pObject,
|
||||||
DWORD dwRetrievalFlags, FILETIME expires)
|
DWORD dwRetrievalFlags, FILETIME expires)
|
||||||
{
|
{
|
||||||
WCHAR cacheFileName[MAX_PATH];
|
WCHAR cacheFileName[MAX_PATH];
|
||||||
DWORD size = 0;
|
HANDLE hCacheFile;
|
||||||
BOOL ret, create = FALSE;
|
DWORD size = 0, entryType;
|
||||||
|
FILETIME ft;
|
||||||
|
|
||||||
GetUrlCacheEntryInfoW(pszURL, NULL, &size);
|
GetUrlCacheEntryInfoW(pszURL, NULL, &size);
|
||||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
INTERNET_CACHE_ENTRY_INFOW *info = CryptMemAlloc(size);
|
INTERNET_CACHE_ENTRY_INFOW *info = CryptMemAlloc(size);
|
||||||
|
|
||||||
if (info)
|
if (!info)
|
||||||
{
|
{
|
||||||
FILETIME ft;
|
ERR("out of memory\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ret = GetUrlCacheEntryInfoW(pszURL, info, &size);
|
if (GetUrlCacheEntryInfoW(pszURL, info, &size))
|
||||||
if (ret)
|
{
|
||||||
lstrcpyW(cacheFileName, info->lpszLocalFileName);
|
lstrcpyW(cacheFileName, info->lpszLocalFileName);
|
||||||
/* Check if the existing cache entry is up to date. If it isn't,
|
/* Check if the existing cache entry is up to date. If it isn't,
|
||||||
* remove the existing cache entry, and create a new one with the
|
* remove the existing cache entry, and create a new one with the
|
||||||
* new value.
|
* new value.
|
||||||
|
@ -755,51 +745,38 @@ static void CRYPT_CacheURL(LPCWSTR pszURL, const CRYPT_BLOB_ARRAY *pObject,
|
||||||
GetSystemTimeAsFileTime(&ft);
|
GetSystemTimeAsFileTime(&ft);
|
||||||
if (CompareFileTime(&info->ExpireTime, &ft) < 0)
|
if (CompareFileTime(&info->ExpireTime, &ft) < 0)
|
||||||
{
|
{
|
||||||
create = TRUE;
|
|
||||||
DeleteUrlCacheEntryW(pszURL);
|
DeleteUrlCacheEntryW(pszURL);
|
||||||
}
|
}
|
||||||
CryptMemFree(info);
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = CreateUrlCacheEntryW(pszURL, pObject->rgBlob[0].cbData, NULL,
|
|
||||||
cacheFileName, 0);
|
|
||||||
create = TRUE;
|
|
||||||
}
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
DWORD entryType;
|
|
||||||
FILETIME ft = { 0 };
|
|
||||||
|
|
||||||
if (create)
|
|
||||||
{
|
|
||||||
HANDLE hCacheFile = CreateFileW(cacheFileName, GENERIC_WRITE, 0,
|
|
||||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
|
|
||||||
if (hCacheFile != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
{
|
||||||
DWORD bytesWritten;
|
info->ExpireTime = expires;
|
||||||
|
SetUrlCacheEntryInfoW(pszURL, info, CACHE_ENTRY_EXPTIME_FC);
|
||||||
WriteFile(hCacheFile, pObject->rgBlob[0].pbData,
|
CryptMemFree(info);
|
||||||
pObject->rgBlob[0].cbData, &bytesWritten, NULL);
|
return;
|
||||||
CloseHandle(hCacheFile);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
if (!(dwRetrievalFlags & CRYPT_STICKY_CACHE_RETRIEVAL))
|
|
||||||
entryType = NORMAL_CACHE_ENTRY;
|
|
||||||
else
|
|
||||||
entryType = STICKY_CACHE_ENTRY;
|
|
||||||
CommitUrlCacheEntryW(pszURL, cacheFileName, expires, ft, entryType,
|
|
||||||
NULL, 0, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
CryptMemFree(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!CreateUrlCacheEntryW(pszURL, pObject->rgBlob[0].cbData, NULL, cacheFileName, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
hCacheFile = CreateFileW(cacheFileName, GENERIC_WRITE, 0,
|
||||||
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
if(hCacheFile == INVALID_HANDLE_VALUE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WriteFile(hCacheFile, pObject->rgBlob[0].pbData,
|
||||||
|
pObject->rgBlob[0].cbData, &size, NULL);
|
||||||
|
CloseHandle(hCacheFile);
|
||||||
|
|
||||||
|
if (!(dwRetrievalFlags & CRYPT_STICKY_CACHE_RETRIEVAL))
|
||||||
|
entryType = NORMAL_CACHE_ENTRY;
|
||||||
|
else
|
||||||
|
entryType = STICKY_CACHE_ENTRY;
|
||||||
|
memset(&ft, 0, sizeof(ft));
|
||||||
|
CommitUrlCacheEntryW(pszURL, cacheFileName, expires, ft, entryType,
|
||||||
|
NULL, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CALLBACK CRYPT_InetStatusCallback(HINTERNET hInt,
|
static void CALLBACK CRYPT_InetStatusCallback(HINTERNET hInt,
|
||||||
|
@ -966,18 +943,15 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
|
||||||
else
|
else
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
/* We don't set ret to TRUE in this block to avoid masking
|
if (ret &&
|
||||||
* an error from HttpSendRequestExW.
|
!(ret = HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context)) &&
|
||||||
*/
|
|
||||||
if (!HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context) &&
|
|
||||||
GetLastError() == ERROR_IO_PENDING)
|
GetLastError() == ERROR_IO_PENDING)
|
||||||
{
|
{
|
||||||
if (WaitForSingleObject(context->event,
|
if (WaitForSingleObject(context->event,
|
||||||
context->timeout) == WAIT_TIMEOUT)
|
context->timeout) == WAIT_TIMEOUT)
|
||||||
{
|
|
||||||
SetLastError(ERROR_TIMEOUT);
|
SetLastError(ERROR_TIMEOUT);
|
||||||
ret = FALSE;
|
else
|
||||||
}
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,
|
ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,
|
||||||
|
@ -1056,8 +1030,8 @@ static BOOL WINAPI File_RetrieveEncodedObjectW(LPCWSTR pszURL,
|
||||||
/* Try to create the file directly - Wine handles / in pathnames */
|
/* Try to create the file directly - Wine handles / in pathnames */
|
||||||
lstrcpynW(path, components.lpszUrlPath,
|
lstrcpynW(path, components.lpszUrlPath,
|
||||||
components.dwUrlPathLength + 1);
|
components.dwUrlPathLength + 1);
|
||||||
hFile = CreateFileW(path, GENERIC_READ, 0, NULL, OPEN_EXISTING,
|
hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/* Try again on the current drive */
|
/* Try again on the current drive */
|
||||||
|
@ -1066,8 +1040,8 @@ static BOOL WINAPI File_RetrieveEncodedObjectW(LPCWSTR pszURL,
|
||||||
{
|
{
|
||||||
lstrcpynW(path + 2, components.lpszUrlPath,
|
lstrcpynW(path + 2, components.lpszUrlPath,
|
||||||
components.dwUrlPathLength + 1);
|
components.dwUrlPathLength + 1);
|
||||||
hFile = CreateFileW(path, GENERIC_READ, 0, NULL,
|
hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
}
|
}
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -1077,8 +1051,8 @@ static BOOL WINAPI File_RetrieveEncodedObjectW(LPCWSTR pszURL,
|
||||||
{
|
{
|
||||||
lstrcpynW(path + 2, components.lpszUrlPath,
|
lstrcpynW(path + 2, components.lpszUrlPath,
|
||||||
components.dwUrlPathLength + 1);
|
components.dwUrlPathLength + 1);
|
||||||
hFile = CreateFileW(path, GENERIC_READ, 0, NULL,
|
hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ reactos/dll/win32/credui # Synced to Wine-1.5.4
|
||||||
reactos/dll/win32/crypt32 # Synced to Wine-1.5.26
|
reactos/dll/win32/crypt32 # Synced to Wine-1.5.26
|
||||||
reactos/dll/win32/cryptdlg # Synced to Wine-1.5.4
|
reactos/dll/win32/cryptdlg # Synced to Wine-1.5.4
|
||||||
reactos/dll/win32/cryptdll # Synced to Wine-1.5.4
|
reactos/dll/win32/cryptdll # Synced to Wine-1.5.4
|
||||||
reactos/dll/win32/cryptnet # Synced to Wine-1.3.37
|
reactos/dll/win32/cryptnet # Synced to Wine-1.5.26
|
||||||
reactos/dll/win32/cryptui # Synced to Wine-1.5.4
|
reactos/dll/win32/cryptui # Synced to Wine-1.5.4
|
||||||
reactos/dll/win32/dbghelp # Synced to Wine-1.3.37
|
reactos/dll/win32/dbghelp # Synced to Wine-1.3.37
|
||||||
reactos/dll/win32/dciman32 # Synced to Wine-1.5.19
|
reactos/dll/win32/dciman32 # Synced to Wine-1.5.19
|
||||||
|
|
Loading…
Reference in a new issue