Author: akhaldi
Date: Mon Apr 8 16:22:12 2013
New Revision: 58719
URL:
http://svn.reactos.org/svn/reactos?rev=58719&view=rev
Log:
[CRYPTNET]
* Sync with Wine 1.5.26.
Modified:
trunk/reactos/dll/win32/cryptnet/cryptnet_main.c
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/cryptnet/cryptnet_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cryptnet/cryptne…
==============================================================================
--- trunk/reactos/dll/win32/cryptnet/cryptnet_main.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/cryptnet/cryptnet_main.c [iso-8859-1] Mon Apr 8 16:22:12
2013
@@ -43,22 +43,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(cryptnet);
#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','.',
'd','l','l',0 };
@@ -521,24 +505,26 @@
TRACE("(%s, %p, %p)\n", debugstr_w(pszURL), pObject, pAuxInfo);
- ret = GetUrlCacheEntryInfoW(pszURL, NULL, &size);
- if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
- {
- pCacheInfo = CryptMemAlloc(size);
- if (pCacheInfo)
- ret = TRUE;
- else
- SetLastError(ERROR_OUTOFMEMORY);
- }
- if (ret && (ret = GetUrlCacheEntryInfoW(pszURL, pCacheInfo, &size)))
+ RetrieveUrlCacheEntryFileW(pszURL, NULL, &size, 0);
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ return FALSE;
+
+ pCacheInfo = CryptMemAlloc(size);
+ if (!pCacheInfo)
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+
+ if ((ret = RetrieveUrlCacheEntryFileW(pszURL, pCacheInfo, &size, 0)))
{
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
if (CompareFileTime(&pCacheInfo->ExpireTime, &ft) >= 0)
{
- HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName,
- GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName, GENERIC_READ,
+ FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
@@ -565,6 +551,7 @@
DeleteUrlCacheEntryW(pszURL);
ret = FALSE;
}
+ UnlockUrlCacheEntryFileW(pszURL, 0);
}
CryptMemFree(pCacheInfo);
TRACE("returning %d\n", ret);
@@ -733,21 +720,24 @@
DWORD dwRetrievalFlags, FILETIME expires)
{
WCHAR cacheFileName[MAX_PATH];
- DWORD size = 0;
- BOOL ret, create = FALSE;
+ HANDLE hCacheFile;
+ DWORD size = 0, entryType;
+ FILETIME ft;
GetUrlCacheEntryInfoW(pszURL, NULL, &size);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
INTERNET_CACHE_ENTRY_INFOW *info = CryptMemAlloc(size);
- if (info)
- {
- FILETIME ft;
-
- ret = GetUrlCacheEntryInfoW(pszURL, info, &size);
- if (ret)
- lstrcpyW(cacheFileName, info->lpszLocalFileName);
+ if (!info)
+ {
+ ERR("out of memory\n");
+ return;
+ }
+
+ if (GetUrlCacheEntryInfoW(pszURL, info, &size))
+ {
+ lstrcpyW(cacheFileName, info->lpszLocalFileName);
/* 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
* new value.
@@ -755,51 +745,38 @@
GetSystemTimeAsFileTime(&ft);
if (CompareFileTime(&info->ExpireTime, &ft) < 0)
{
- create = TRUE;
DeleteUrlCacheEntryW(pszURL);
}
- CryptMemFree(info);
- }
- else
- ret = FALSE;
- }
+ else
+ {
+ info->ExpireTime = expires;
+ SetUrlCacheEntryInfoW(pszURL, info, CACHE_ENTRY_EXPTIME_FC);
+ CryptMemFree(info);
+ return;
+ }
+ }
+ 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
- {
- 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;
-
- WriteFile(hCacheFile, pObject->rgBlob[0].pbData,
- pObject->rgBlob[0].cbData, &bytesWritten, NULL);
- 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);
- }
- }
+ 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,
@@ -966,18 +943,15 @@
else
ret = TRUE;
}
- /* We don't set ret to TRUE in this block to avoid masking
- * an error from HttpSendRequestExW.
- */
- if (!HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context) &&
+ if (ret &&
+ !(ret = HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context))
&&
GetLastError() == ERROR_IO_PENDING)
{
if (WaitForSingleObject(context->event,
context->timeout) == WAIT_TIMEOUT)
- {
SetLastError(ERROR_TIMEOUT);
- ret = FALSE;
- }
+ else
+ ret = TRUE;
}
if (ret)
ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,
@@ -1056,8 +1030,8 @@
/* Try to create the file directly - Wine handles / in pathnames */
lstrcpynW(path, components.lpszUrlPath,
components.dwUrlPathLength + 1);
- hFile = CreateFileW(path, GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
/* Try again on the current drive */
@@ -1066,8 +1040,8 @@
{
lstrcpynW(path + 2, components.lpszUrlPath,
components.dwUrlPathLength + 1);
- hFile = CreateFileW(path, GENERIC_READ, 0, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
if (hFile == INVALID_HANDLE_VALUE)
{
@@ -1077,8 +1051,8 @@
{
lstrcpynW(path + 2, components.lpszUrlPath,
components.dwUrlPathLength + 1);
- hFile = CreateFileW(path, GENERIC_READ, 0, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
}
}
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Mon Apr 8 16:22:12 2013
@@ -55,7 +55,7 @@
reactos/dll/win32/crypt32 # Synced to Wine-1.5.26
reactos/dll/win32/cryptdlg # 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/dbghelp # Synced to Wine-1.3.37
reactos/dll/win32/dciman32 # Synced to Wine-1.5.19