[FUSION] Sync with Wine Staging 3.3. CORE-14434

This commit is contained in:
Amine Khaldi 2018-03-09 13:07:30 +01:00
parent e4bb5d086b
commit b980bb98c2
9 changed files with 177 additions and 110 deletions

View file

@ -9,7 +9,7 @@ list(APPEND COMMON_SOURCE
asmname.c
assembly.c
fusion.c
fusionpriv.h
precomp.h
${CMAKE_CURRENT_BINARY_DIR}/fusion_stubs.c)
add_library(fusion_common STATIC ${COMMON_SOURCE})
@ -22,7 +22,7 @@ add_library(fusion SHARED
set_module_type(fusion win32dll)
target_link_libraries(fusion fusion_common uuid wine)
add_importlibs(fusion advapi32 dbghelp shlwapi user32 msvcrt kernel32 ntdll)
add_pch(fusion_common fusionpriv.h COMMON_SOURCE)
add_pch(fusion_common precomp.h COMMON_SOURCE)
add_cd_file(TARGET fusion DESTINATION reactos/Microsoft.NET/Framework/v1.0.3705 FOR all)
add_cd_file(TARGET fusion DESTINATION reactos/system32 FOR all)

View file

@ -18,7 +18,28 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winver.h"
#include "wincrypt.h"
#include "winreg.h"
#include "shlwapi.h"
#include "dbghelp.h"
#include "ole2.h"
#include "fusion.h"
#include "corerror.h"
#include "fusionpriv.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
typedef struct {
IAssemblyCache IAssemblyCache_iface;
@ -42,9 +63,7 @@ static BOOL create_full_path(LPCWSTR path)
BOOL ret = TRUE;
int len;
new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) * sizeof(WCHAR));
if (!new_path)
return FALSE;
if (!(new_path = heap_alloc((strlenW(path) + 1) * sizeof(WCHAR)))) return FALSE;
strcpyW(new_path, path);
@ -82,7 +101,7 @@ static BOOL create_full_path(LPCWSTR path)
new_path[len] = '\\';
}
HeapFree(GetProcessHeap(), 0, new_path);
heap_free(new_path);
return ret;
}
@ -179,7 +198,7 @@ static ULONG WINAPI IAssemblyCacheImpl_Release(IAssemblyCache *iface)
if (!refCount)
{
CloseHandle( cache->lock );
HeapFree( GetProcessHeap(), 0, cache );
heap_free( cache );
}
return refCount;
}
@ -237,7 +256,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_UninstallAssembly(IAssemblyCache *iface
if (hr != HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER ))
goto done;
if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
if (!(path = heap_alloc( len * sizeof(WCHAR) )))
{
hr = E_OUTOFMEMORY;
goto done;
@ -272,7 +291,7 @@ done:
IAssemblyName_Release( asmname );
if (next) IAssemblyName_Release( next );
if (asmenum) IAssemblyEnum_Release( asmenum );
HeapFree( GetProcessHeap(), 0, path );
heap_free( path );
cache_unlock( cache );
return hr;
}
@ -354,9 +373,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_CreateAssemblyCacheItem(IAssemblyCache
*ppAsmItem = NULL;
item = HeapAlloc(GetProcessHeap(), 0, sizeof(IAssemblyCacheItemImpl));
if (!item)
return E_OUTOFMEMORY;
if (!(item = heap_alloc(sizeof(*item)))) return E_OUTOFMEMORY;
item->IAssemblyCacheItem_iface.lpVtbl = &AssemblyCacheItemVtbl;
item->ref = 1;
@ -379,22 +396,22 @@ static HRESULT copy_file( const WCHAR *src_dir, DWORD src_len, const WCHAR *dst_
DWORD len = strlenW( filename );
HRESULT hr = S_OK;
if (!(src_file = HeapAlloc( GetProcessHeap(), 0, (src_len + len + 1) * sizeof(WCHAR) )))
if (!(src_file = heap_alloc( (src_len + len + 1) * sizeof(WCHAR) )))
return E_OUTOFMEMORY;
memcpy( src_file, src_dir, src_len * sizeof(WCHAR) );
strcpyW( src_file + src_len, filename );
if (!(dst_file = HeapAlloc( GetProcessHeap(), 0, (dst_len + len + 1) * sizeof(WCHAR) )))
if (!(dst_file = heap_alloc( (dst_len + len + 1) * sizeof(WCHAR) )))
{
HeapFree( GetProcessHeap(), 0, src_file );
heap_free( src_file );
return E_OUTOFMEMORY;
}
memcpy( dst_file, dst_dir, dst_len * sizeof(WCHAR) );
strcpyW( dst_file + dst_len, filename );
if (!CopyFileW( src_file, dst_file, FALSE )) hr = HRESULT_FROM_WIN32( GetLastError() );
HeapFree( GetProcessHeap(), 0, src_file );
HeapFree( GetProcessHeap(), 0, dst_file );
heap_free( src_file );
heap_free( dst_file );
return hr;
}
@ -467,7 +484,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
get_assembly_directory(asmdir, MAX_PATH, clr_version, architecture);
dst_len += strlenW(asmdir) + strlenW(name) + strlenW(version) + strlenW(token);
if (!(dst_dir = HeapAlloc(GetProcessHeap(), 0, dst_len * sizeof(WCHAR))))
if (!(dst_dir = heap_alloc(dst_len * sizeof(WCHAR))))
{
hr = E_OUTOFMEMORY;
goto done;
@ -507,13 +524,13 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
}
done:
HeapFree(GetProcessHeap(), 0, name);
HeapFree(GetProcessHeap(), 0, token);
HeapFree(GetProcessHeap(), 0, version);
HeapFree(GetProcessHeap(), 0, asmpath);
HeapFree(GetProcessHeap(), 0, dst_dir);
for (i = 0; i < count; i++) HeapFree(GetProcessHeap(), 0, external_files[i]);
HeapFree(GetProcessHeap(), 0, external_files);
heap_free(name);
heap_free(token);
heap_free(version);
heap_free(asmpath);
heap_free(dst_dir);
for (i = 0; i < count; i++) heap_free(external_files[i]);
heap_free(external_files);
assembly_release(assembly);
cache_unlock( cache );
return hr;
@ -544,16 +561,14 @@ HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved
*ppAsmCache = NULL;
cache = HeapAlloc(GetProcessHeap(), 0, sizeof(IAssemblyCacheImpl));
if (!cache)
return E_OUTOFMEMORY;
if (!(cache = heap_alloc(sizeof(*cache)))) return E_OUTOFMEMORY;
cache->IAssemblyCache_iface.lpVtbl = &AssemblyCacheVtbl;
cache->ref = 1;
cache->lock = CreateMutexW( NULL, FALSE, cache_mutex_nameW );
if (!cache->lock)
{
HeapFree( GetProcessHeap(), 0, cache );
heap_free( cache );
return HRESULT_FROM_WIN32( GetLastError() );
}
*ppAsmCache = &cache->IAssemblyCache_iface;
@ -606,7 +621,7 @@ static ULONG WINAPI IAssemblyCacheItemImpl_Release(IAssemblyCacheItem *iface)
TRACE("(%p)->(ref before = %u)\n", This, refCount + 1);
if (!refCount)
HeapFree(GetProcessHeap(), 0, This);
heap_free(This);
return refCount;
}

View file

@ -18,9 +18,26 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "guiddef.h"
#include "fusion.h"
#include "corerror.h"
#include "fusionpriv.h"
#include <wine/list.h>
#include "wine/debug.h"
#include "wine/unicode.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
typedef struct _tagASMNAME
{
@ -89,10 +106,10 @@ static ULONG WINAPI IAssemblyEnumImpl_Release(IAssemblyEnum *iface)
list_remove(&asmname->entry);
IAssemblyName_Release(asmname->name);
HeapFree(GetProcessHeap(), 0, asmname);
heap_free(asmname);
}
HeapFree(GetProcessHeap(), 0, This);
heap_free(This);
}
return refCount;
@ -338,8 +355,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
}
sprintfW(disp, name_fmt, parent, version, token);
asmname = HeapAlloc(GetProcessHeap(), 0, sizeof(ASMNAME));
if (!asmname)
if (!(asmname = heap_alloc(sizeof(*asmname))))
{
hr = E_OUTOFMEMORY;
break;
@ -349,7 +365,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
CANOF_PARSE_DISPLAY_NAME, NULL);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, asmname);
heap_free(asmname);
break;
}
@ -357,7 +373,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
if (FAILED(hr))
{
IAssemblyName_Release(asmname->name);
HeapFree(GetProcessHeap(), 0, asmname);
heap_free(asmname);
break;
}
@ -460,9 +476,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved,
if (dwFlags == 0 || dwFlags == ASM_CACHE_ROOT)
return E_INVALIDARG;
asmenum = HeapAlloc(GetProcessHeap(), 0, sizeof(IAssemblyEnumImpl));
if (!asmenum)
return E_OUTOFMEMORY;
if (!(asmenum = heap_alloc(sizeof(*asmenum)))) return E_OUTOFMEMORY;
asmenum->IAssemblyEnum_iface.lpVtbl = &AssemblyEnumVtbl;
asmenum->ref = 1;
@ -473,7 +487,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved,
hr = enumerate_gac(asmenum, pName);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, asmenum);
heap_free(asmenum);
return hr;
}
}

View file

@ -18,11 +18,26 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
#define INITGUID
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "guiddef.h"
#include "fusion.h"
#include "corerror.h"
#include "strsafe.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "fusionpriv.h"
#include <assert.h>
#include <winuser.h>
#include <strsafe.h>
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
typedef struct {
IAssemblyName IAssemblyName_iface;
@ -100,12 +115,12 @@ static ULONG WINAPI IAssemblyNameImpl_Release(IAssemblyName *iface)
if (!refCount)
{
HeapFree(GetProcessHeap(), 0, This->path);
HeapFree(GetProcessHeap(), 0, This->displayname);
HeapFree(GetProcessHeap(), 0, This->name);
HeapFree(GetProcessHeap(), 0, This->culture);
HeapFree(GetProcessHeap(), 0, This->procarch);
HeapFree(GetProcessHeap(), 0, This);
heap_free(This->path);
heap_free(This->displayname);
heap_free(This->name);
heap_free(This->culture);
heap_free(This->procarch);
heap_free(This);
}
return refCount;
@ -648,7 +663,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int len )
BOOL quoted = FALSE;
unsigned int i = 0;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
if (*p == '\"')
{
quoted = TRUE;
@ -657,7 +672,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int len )
while (*p && *p != '\"') ret[i++] = *p++;
if ((quoted && *p != '\"') || (!quoted && *p == '\"'))
{
HeapFree( GetProcessHeap(), 0, ret );
heap_free( ret );
return NULL;
}
ret[i] = 0;
@ -754,7 +769,7 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
hr = parse_procarch( name, name->procarch );
}
HeapFree( GetProcessHeap(), 0, value );
heap_free( value );
if (FAILED(hr))
goto done;
@ -763,13 +778,13 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
}
done:
HeapFree(GetProcessHeap(), 0, save);
heap_free(save);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, name->displayname);
HeapFree(GetProcessHeap(), 0, name->name);
HeapFree(GetProcessHeap(), 0, name->culture);
HeapFree(GetProcessHeap(), 0, name->procarch);
heap_free(name->displayname);
heap_free(name->name);
heap_free(name->culture);
heap_free(name->procarch);
}
return hr;
}
@ -794,9 +809,7 @@ HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj,
(!szAssemblyName || !*szAssemblyName))
return E_INVALIDARG;
name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAssemblyNameImpl));
if (!name)
return E_OUTOFMEMORY;
if (!(name = heap_alloc_zero(sizeof(*name)))) return E_OUTOFMEMORY;
name->IAssemblyName_iface.lpVtbl = &AssemblyNameVtbl;
name->ref = 1;
@ -804,7 +817,7 @@ HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj,
hr = parse_display_name(name, szAssemblyName);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, name);
heap_free(name);
return hr;
}

View file

@ -18,11 +18,22 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "fusionpriv.h"
#include <stdarg.h>
#include <stdio.h>
#include <wincrypt.h>
#include <dbghelp.h>
#include <corhdr.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winver.h"
#include "wincrypt.h"
#include "dbghelp.h"
#include "ole2.h"
#include "fusion.h"
#include "corhdr.h"
#include "fusionpriv.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#define TableFromToken(tk) (TypeFromToken(tk) >> 24)
#define TokenFromTable(idx) (idx << 24)
@ -528,9 +539,7 @@ static HRESULT parse_metadata_header(ASSEMBLY *assembly, DWORD *hdrsz)
metadatahdr = (METADATAHDR *)ptr;
assembly->metadatahdr = HeapAlloc(GetProcessHeap(), 0, sizeof(METADATAHDR));
if (!assembly->metadatahdr)
return E_OUTOFMEMORY;
if (!(assembly->metadatahdr = heap_alloc(sizeof(*assembly->metadatahdr)))) return E_OUTOFMEMORY;
size = FIELD_OFFSET(METADATAHDR, Version);
memcpy(assembly->metadatahdr, metadatahdr, size);
@ -635,9 +644,7 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
*out = NULL;
assembly = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ASSEMBLY));
if (!assembly)
return E_OUTOFMEMORY;
if (!(assembly = heap_alloc_zero(sizeof(*assembly)))) return E_OUTOFMEMORY;
assembly->path = strdupW(file);
if (!assembly->path)
@ -688,12 +695,12 @@ HRESULT assembly_release(ASSEMBLY *assembly)
if (!assembly)
return S_OK;
HeapFree(GetProcessHeap(), 0, assembly->metadatahdr);
HeapFree(GetProcessHeap(), 0, assembly->path);
heap_free(assembly->metadatahdr);
heap_free(assembly->path);
UnmapViewOfFile(assembly->data);
CloseHandle(assembly->hmap);
CloseHandle(assembly->hfile);
HeapFree(GetProcessHeap(), 0, assembly);
heap_free(assembly);
return S_OK;
}
@ -706,7 +713,7 @@ static LPWSTR assembly_dup_str(const ASSEMBLY *assembly, DWORD index)
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
if ((cpy = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
if ((cpy = heap_alloc(len * sizeof(WCHAR))))
MultiByteToWideChar(CP_ACP, 0, str, -1, cpy, len);
return cpy;
@ -741,7 +748,7 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name)
HRESULT assembly_get_path(const ASSEMBLY *assembly, LPWSTR *path)
{
LPWSTR cpy = HeapAlloc(GetProcessHeap(), 0, (strlenW(assembly->path) + 1) * sizeof(WCHAR));
WCHAR *cpy = heap_alloc((strlenW(assembly->path) + 1) * sizeof(WCHAR));
*path = cpy;
if (cpy)
strcpyW(cpy, assembly->path);
@ -768,8 +775,7 @@ HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version)
if (!asmtbl)
return E_FAIL;
*version = HeapAlloc(GetProcessHeap(), 0, sizeof(format) + 4 * strlen("65535") * sizeof(WCHAR));
if (!*version)
if (!(*version = heap_alloc(sizeof(format) + 4 * strlen("65535") * sizeof(WCHAR))))
return E_OUTOFMEMORY;
sprintfW(*version, format, asmtbl->MajorVersion, asmtbl->MinorVersion,
@ -841,8 +847,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
if (!CryptGetHashParam(hash, HP_HASHVAL, NULL, &size, 0))
return E_FAIL;
hashdata = HeapAlloc(GetProcessHeap(), 0, size);
if (!hashdata)
if (!(hashdata = heap_alloc(size)))
{
hr = E_OUTOFMEMORY;
goto done;
@ -854,8 +859,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
for (i = size - 1; i >= size - 8; i--)
tokbytes[size - i - 1] = hashdata[i];
tok = HeapAlloc(GetProcessHeap(), 0, (TOKEN_LENGTH + 1) * sizeof(WCHAR));
if (!tok)
if (!(tok = heap_alloc((TOKEN_LENGTH + 1) * sizeof(WCHAR))))
{
hr = E_OUTOFMEMORY;
goto done;
@ -867,7 +871,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
hr = S_OK;
done:
HeapFree(GetProcessHeap(), 0, hashdata);
heap_free(hashdata);
CryptDestroyHash(hash);
CryptReleaseContext(crypt, 0);
@ -902,9 +906,7 @@ HRESULT assembly_get_external_files(ASSEMBLY *assembly, LPWSTR **files, DWORD *c
if (num_rows <= 0)
return S_OK;
ret = HeapAlloc(GetProcessHeap(), 0, num_rows * sizeof(WCHAR *));
if (!ret)
return E_OUTOFMEMORY;
if (!(ret = heap_alloc(num_rows * sizeof(WCHAR *)))) return E_OUTOFMEMORY;
for (i = 0; i < num_rows; i++)
{
@ -917,8 +919,8 @@ HRESULT assembly_get_external_files(ASSEMBLY *assembly, LPWSTR **files, DWORD *c
ret[i] = assembly_dup_str(assembly, idx);
if (!ret[i])
{
for (; i >= 0; i--) HeapFree(GetProcessHeap(), 0, ret[i]);
HeapFree(GetProcessHeap(), 0, ret);
for (; i >= 0; i--) heap_free(ret[i]);
heap_free(ret);
return E_OUTOFMEMORY;
}
ptr += assembly->stringsz; /* skip Name field */

View file

@ -18,7 +18,20 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "fusionpriv.h"
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "fusion.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
/******************************************************************
* InitializeFusion (FUSION.@)

View file

@ -23,25 +23,16 @@
#include <stdarg.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winver.h"
#include "wine/heap.h"
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include <windef.h>
#include <winbase.h>
#include <winver.h>
#ifdef __REACTOS__
#include <objbase.h>
#include <fusion.h>
#include <corerror.h>
#include <wine/unicode.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
#endif
#include <pshpack1.h>
@ -463,8 +454,7 @@ static inline LPWSTR strdupW(LPCWSTR src)
if (!src)
return NULL;
dest = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR));
if (dest)
if ((dest = heap_alloc((lstrlenW(src) + 1) * sizeof(WCHAR))))
lstrcpyW(dest, src);
return dest;

View file

@ -0,0 +1,20 @@
#ifndef _WINE_FUSION_PRECOMP_H_
#define _WINE_FUSION_PRECOMP_H_
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "fusionpriv.h"
#include <corerror.h>
#include <wine/unicode.h>
#include <wine/debug.h>
#endif /* !_WINE_FUSION_PRECOMP_H_ */

View file

@ -67,7 +67,7 @@ reactos/dll/win32/dbghelp # Synced to WineStaging-3.3
reactos/dll/win32/dciman32 # Synced to WineStaging-3.3
reactos/dll/win32/faultrep # Synced to WineStaging-2.9
reactos/dll/win32/fontsub # Synced to WineStaging-2.9
reactos/dll/win32/fusion # Synced to Wine-3.0
reactos/dll/win32/fusion # Synced to WineStaging-3.3
reactos/dll/win32/gdiplus # Synced to Wine-3.0
reactos/dll/win32/hhctrl.ocx # Synced to Wine-3.0
reactos/dll/win32/hlink # Synced to Wine-3.0