#include <msi.h>
#include <winsvc.h>
#include <objbase.h>
-#include <stdio.h>
#include "wine/debug.h"
-#include "wine/heap.h"
+#include "msiexec_internal.h"
#include "initguid.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
typedef HRESULT (WINAPI *DLLUNREGISTERSERVER)(void);
DWORD DoService(void);
+static BOOL silent;
struct string_list
{
WCHAR str[1];
};
+void report_error(const char* msg, ...)
+{
+ char buffer[2048];
+ va_list va_args;
+
+ va_start(va_args, msg);
+ vsnprintf(buffer, sizeof(buffer), msg, va_args);
+ va_end(va_args);
+
+ if (silent)
+ MESSAGE("%s", buffer);
+ else
+ MsiMessageBoxA(NULL, buffer, "MsiExec", 0, GetUserDefaultLangID(), 0);
+}
+
static void ShowUsage(int ExitCode)
{
WCHAR msiexec_version[40];
No typo: The LPWSTR parameter must be a LPWSTR * for this mode */
len = LoadStringW(hmsi, 10, (LPWSTR) &msi_res, 0);
- msi_res = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
- msiexec_help = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) + sizeof(msiexec_version));
+ msi_res = malloc((len + 1) * sizeof(WCHAR));
+ msiexec_help = malloc((len + 1) * sizeof(WCHAR) + sizeof(msiexec_version));
if (msi_res && msiexec_help) {
*msi_res = 0;
LoadStringW(hmsi, 10, msi_res, len + 1);
swprintf(msiexec_help, len + 1 + ARRAY_SIZE(msiexec_version), msi_res, msiexec_version);
MsiMessageBoxW(0, msiexec_help, NULL, 0, GetUserDefaultLangID(), 0);
}
- HeapFree(GetProcessHeap(), 0, msi_res);
- HeapFree(GetProcessHeap(), 0, msiexec_help);
+ free(msi_res);
+ free(msiexec_help);
ExitProcess(ExitCode);
}
{
struct string_list *entry;
- entry = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(struct string_list, str[lstrlenW(str) + 1]));
+ entry = malloc(FIELD_OFFSET(struct string_list, str[wcslen(str) + 1]));
if(!entry)
{
WINE_ERR("Out of memory!\n");
for(list = property_list; list; list = list->next)
len += lstrlenW(list->str) + 3;
- ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+ ret = malloc(len * sizeof(WCHAR));
/* add a space before each string, and quote the value */
p = ret;
for(list = transform_list; list; list = list->next)
len += lstrlenW(list->str) + 1;
- ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+ ret = malloc(len * sizeof(WCHAR));
/* add all the transforms with a semicolon between each one */
p = ret;
return FALSE;
if( lstrlenW(str1) != (len-1) )
return FALSE;
- strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
+ strW = malloc(sizeof(WCHAR) * len);
MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len, strW, len);
- HeapFree(GetProcessHeap(), 0, strW);
+ free(strW);
return (ret == CSTR_EQUAL);
}
return FALSE;
if( lstrlenW(str1) < (len-1) )
return FALSE;
- strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
+ strW = malloc(sizeof(WCHAR) * len);
MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len-1, strW, len-1);
- HeapFree(GetProcessHeap(), 0, strW);
+ free(strW);
return (ret == CSTR_EQUAL);
}
*DllHandle = LoadLibraryExW(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if(!*DllHandle)
{
- fprintf(stderr, "Unable to load dll %s\n", wine_dbgstr_w(DllName));
+ report_error("Unable to load dll %s\n", wine_dbgstr_w(DllName));
ExitProcess(1);
}
proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
if(!proc)
{
- fprintf(stderr, "Dll %s does not implement function %s\n",
- wine_dbgstr_w(DllName), ProcName);
+ report_error("Dll %s does not implement function %s\n",
+ wine_dbgstr_w(DllName), ProcName);
FreeLibrary(*DllHandle);
ExitProcess(1);
}
hr = pfDllRegisterServer();
if(FAILED(hr))
{
- fprintf(stderr, "Failed to register dll %s\n", wine_dbgstr_w(DllName));
+ report_error("Failed to register dll %s\n", wine_dbgstr_w(DllName));
return 1;
}
- printf("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
+ MESSAGE("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
if(DllHandle)
FreeLibrary(DllHandle);
return 0;
hr = pfDllUnregisterServer();
if(FAILED(hr))
{
- fprintf(stderr, "Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
+ report_error("Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
return 1;
}
- printf("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
+ MESSAGE("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
if(DllHandle)
FreeLibrary(DllHandle);
return 0;
if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CREATE_SERVICE)))
{
- fprintf(stderr, "Failed to open the service control manager.\n");
+ report_error("Failed to open the service control manager.\n");
return 1;
}
len = GetSystemDirectoryW(path, MAX_PATH);
}
else if (GetLastError() != ERROR_SERVICE_EXISTS)
{
- fprintf(stderr, "Failed to create MSI service\n");
+ report_error("Failed to create MSI service\n");
ret = 1;
}
CloseServiceHandle(scm);
if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CONNECT)))
{
- fprintf(stderr, "Failed to open service control manager\n");
+ report_error("Failed to open service control manager\n");
return 1;
}
if ((service = OpenServiceW(scm, L"MSIServer", DELETE)))
{
if (!DeleteService(service))
{
- fprintf(stderr, "Failed to delete MSI service\n");
+ report_error("Failed to delete MSI service\n");
ret = 1;
}
CloseServiceHandle(service);
}
else if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
{
- fprintf(stderr, "Failed to open MSI service\n");
+ report_error("Failed to open MSI service\n");
ret = 1;
}
CloseServiceHandle(scm);
static DWORD CALLBACK custom_action_thread(void *arg)
{
GUID guid = *(GUID *)arg;
- heap_free(arg);
+ free(arg);
return __wine_msi_call_dll_function(client_pid, &guid);
}
return 0;
}
- thread_guid = heap_alloc(sizeof(GUID));
+ thread_guid = malloc(sizeof(GUID));
memcpy(thread_guid, &guid, sizeof(GUID));
thread = CreateThread(NULL, 0, custom_action_thread, thread_guid, 0, NULL);
*pargv = NULL;
count = chomp( cmdline, NULL );
- if (!(p = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(cmdline) + count + 1) * sizeof(WCHAR) )))
+ if (!(p = malloc( (wcslen(cmdline) + count + 1) * sizeof(WCHAR) )))
return;
count = chomp( cmdline, p );
- if (!(argv = HeapAlloc( GetProcessHeap(), 0, (count + 1) * sizeof(WCHAR *) )))
+ if (!(argv = malloc( (count + 1) * sizeof(WCHAR *) )))
{
- HeapFree( GetProcessHeap(), 0, p );
+ free( p );
return;
}
for (i = 0; i < count; i++)
if(r == ERROR_SUCCESS && type == REG_SZ)
{
int len = lstrlenW( *pargv[0] );
- if (!(buf = HeapAlloc( GetProcessHeap(), 0, sz + (len + 1) * sizeof(WCHAR) )))
+ if (!(buf = malloc( (len + 1) * sizeof(WCHAR) )))
{
RegCloseKey( hkey );
return FALSE;
process_args(buf, pargc, pargv);
ret = TRUE;
}
- HeapFree(GetProcessHeap(), 0, buf);
+ free(buf);
}
RegCloseKey(hkey);
return ret;
unsigned int p;
WCHAR *path;
- if (!(path = heap_alloc(lstrlenW(package_name) * sizeof(WCHAR) + sizeof(ext))))
+ if (!(path = malloc(wcslen(package_name) * sizeof(WCHAR) + sizeof(ext))))
{
WINE_ERR("No memory.\n");
return NULL;
--p;
if (path[p] == '.')
{
- heap_free(path);
+ free(path);
return NULL;
}
lstrcatW(path, ext);
RepairMode |= REINSTALLMODE_PACKAGE;
break;
default:
- fprintf(stderr, "Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
+ report_error("Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
break;
}
}
AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
break;
default:
- fprintf(stderr, "Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
+ report_error("Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
break;
}
}
LogFileName = argvW[i];
if(MsiEnableLogW(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
{
- fprintf(stderr, "Logging in %s (0x%08x, %u) failed\n",
- wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
+ report_error("Logging in %s (0x%08lx, %lu) failed\n",
+ wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
ExitProcess(1);
}
}
if(lstrlenW(argvW[i]) == 2 || msi_strequal(argvW[i]+2, "n") ||
msi_strequal(argvW[i] + 2, "uiet"))
{
+ silent = TRUE;
InstallUILevel = INSTALLUILEVEL_NONE;
}
else if(msi_strequal(argvW[i]+2, "r"))
}
else
{
- fprintf(stderr, "Unknown option \"%s\" for UI level\n",
- wine_dbgstr_w(argvW[i]+2));
+ report_error("Unknown option \"%s\" for UI level\n",
+ wine_dbgstr_w(argvW[i]+2));
}
}
else if(msi_option_equal(argvW[i], "passive"))
&& (path = get_path_with_extension(PackageName)))
{
ReturnCode = MsiInstallProductW(path, Properties);
- heap_free(path);
+ free(path);
}
}
}
&& (path = get_path_with_extension(PackageName)))
{
ReturnCode = MsiReinstallProductW(path, RepairMode);
- heap_free(path);
+ free(path);
}
}
}
--- /dev/null
+/*
+ * msiexec.exe internal definitions
+ *
+ * Copyright 2023 Eric Pouech for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifdef __WINE_CRT_PRINTF_ATTR
+extern void report_error(const char* msg, ...) __WINE_CRT_PRINTF_ATTR(1, 2);
+#else
+extern void report_error(const char* msg, ...);
+#endif
#define WIN32_LEAN_AND_MEAN
-#include <stdio.h>
#include <windows.h>
#include <winsvc.h>
#include "wine/debug.h"
+#include "msiexec_internal.h"
WINE_DEFAULT_DEBUG_CHANNEL(msiexec);
if (!SetServiceStatus(hstatus, &status))
{
- fprintf(stderr, "Failed to set service status\n");
+ report_error("Failed to set service status\n");
KillService();
return FALSE;
}
static void WINAPI ServiceCtrlHandler(DWORD code)
{
- WINE_TRACE("%u\n", code);
+ WINE_TRACE("%ld\n", code);
switch (code)
{
KillService();
break;
default:
- fprintf(stderr, "Unhandled service control code: %u\n", code);
+ report_error("Unhandled service control code: %ld\n", code);
UpdateSCMStatus(SERVICE_RUNNING, NO_ERROR, 0);
break;
}
thread = CreateThread(0, 0, ServiceExecutionThread, 0, 0, &id);
if (!thread)
{
- fprintf(stderr, "Failed to create thread\n");
+ report_error("Failed to create thread\n");
return FALSE;
}
hstatus = RegisterServiceCtrlHandlerA("MSIServer", ServiceCtrlHandler);
if (!hstatus)
{
- fprintf(stderr, "Failed to register service ctrl handler\n");
+ report_error("Failed to register service ctrl handler\n");
return;
}
kill_event = CreateEventW(0, TRUE, FALSE, 0);
if (!kill_event)
{
- fprintf(stderr, "Failed to create event\n");
+ report_error("Failed to create event\n");
KillService();
UpdateSCMStatus(SERVICE_STOPPED, NO_ERROR, 0);
return;
if (!StartServiceCtrlDispatcherA(service))
{
- fprintf(stderr, "Failed to start MSIServer service\n");
+ report_error("Failed to start MSIServer service\n");
return 1;
}
return rc;
}
-static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
- INT rc)
+static void ui_actioninfo(MSIPACKAGE *package, const WCHAR *action, BOOL start, INT rc)
{
MSIRECORD *row;
WCHAR *template;
row = MSI_CreateRecord(2);
if (!row)
{
- msi_free(template);
+ free(template);
return;
}
MSI_RecordSetStringW(row, 0, template);
MSI_RecordSetInteger(row, 2, start ? package->LastActionResult : rc);
MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
msiobj_release(&row->hdr);
- msi_free(template);
+ free(template);
if (!start) package->LastActionResult = rc;
}
while (ptr[len - 1] == ' ') len--;
- prop = msi_alloc( (len + 1) * sizeof(WCHAR) );
+ prop = malloc( (len + 1) * sizeof(WCHAR) );
memcpy( prop, ptr, len * sizeof(WCHAR) );
prop[len] = 0;
if (!preserve_case) wcsupr( prop );
while (*ptr2 == ' ') ptr2++;
num_quotes = 0;
- val = msi_alloc( (lstrlenW( ptr2 ) + 1) * sizeof(WCHAR) );
+ val = malloc( (wcslen( ptr2 ) + 1) * sizeof(WCHAR) );
len = parse_prop( ptr2, val, &num_quotes );
if (num_quotes % 2)
{
WARN("unbalanced quotes\n");
- msi_free( val );
- msi_free( prop );
+ free( val );
+ free( prop );
return ERROR_INVALID_COMMAND_LINE;
}
remove_quotes( val );
if (r == ERROR_SUCCESS && !wcscmp( prop, L"SourceDir" ))
msi_reset_source_folders( package );
- msi_free( val );
- msi_free( prop );
+ free( val );
+ free( prop );
ptr = ptr2 + len;
}
}
/* allocate space for an array of substring pointers and the substrings */
- ret = msi_alloc( (count+1) * sizeof (LPWSTR) +
- (lstrlenW(str)+1) * sizeof(WCHAR) );
+ ret = malloc( (count + 1) * sizeof(WCHAR *) + (wcslen(str) + 1) * sizeof(WCHAR) );
if (!ret)
return ret;
if (!(p = wcsrchr( db, '\\' )) && !(p = wcsrchr( db, '/' )))
{
- msi_free(db);
+ free(db);
return ERROR_SUCCESS;
}
len = p - db + 2;
- source = msi_alloc( len * sizeof(WCHAR) );
+ source = malloc( len * sizeof(WCHAR) );
lstrcpynW( source, db, len );
- msi_free( db );
+ free( db );
check = msi_dup_property( package->db, L"SourceDir" );
if (!check || replace)
if (r == ERROR_SUCCESS)
msi_reset_source_folders( package );
}
- msi_free( check );
+ free( check );
check = msi_dup_property( package->db, L"SOURCEDIR" );
if (!check || replace)
msi_set_property( package->db, L"SOURCEDIR", source, -1 );
- msi_free( check );
- msi_free( source );
+ free( check );
+ free( source );
return ERROR_SUCCESS;
}
MSIPACKAGE *package = param;
MSICOMPONENT *comp;
- comp = msi_alloc_zero( sizeof(MSICOMPONENT) );
+ comp = calloc( 1, sizeof(MSICOMPONENT) );
if (!comp)
return ERROR_FUNCTION_FAILED;
return r;
}
-typedef struct {
- MSIPACKAGE *package;
- MSIFEATURE *feature;
-} _ilfs;
-
static UINT add_feature_component( MSIFEATURE *feature, MSICOMPONENT *comp )
{
ComponentList *cl;
- cl = msi_alloc( sizeof (*cl) );
+ cl = malloc( sizeof(*cl) );
if ( !cl )
return ERROR_NOT_ENOUGH_MEMORY;
cl->component = comp;
{
FeatureList *fl;
- fl = msi_alloc( sizeof(*fl) );
+ fl = malloc( sizeof(*fl) );
if ( !fl )
return ERROR_NOT_ENOUGH_MEMORY;
fl->feature = child;
return ERROR_SUCCESS;
}
+struct package_feature
+{
+ MSIPACKAGE *package;
+ MSIFEATURE *feature;
+};
+
static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
{
- _ilfs* ilfs = param;
+ struct package_feature *package_feature = param;
LPCWSTR component;
MSICOMPONENT *comp;
component = MSI_RecordGetString(row,1);
/* check to see if the component is already loaded */
- comp = msi_get_loaded_component( ilfs->package, component );
+ comp = msi_get_loaded_component( package_feature->package, component );
if (!comp)
{
WARN("ignoring unknown component %s\n", debugstr_w(component));
return ERROR_SUCCESS;
}
- add_feature_component( ilfs->feature, comp );
+ add_feature_component( package_feature->feature, comp );
comp->Enabled = TRUE;
return ERROR_SUCCESS;
MSIPACKAGE *package = param;
MSIFEATURE *feature;
MSIQUERY *view;
- _ilfs ilfs;
+ struct package_feature package_feature;
UINT rc;
/* fill in the data */
- feature = msi_alloc_zero( sizeof (MSIFEATURE) );
+ feature = calloc( 1, sizeof(MSIFEATURE) );
if (!feature)
return ERROR_NOT_ENOUGH_MEMORY;
if (rc != ERROR_SUCCESS)
return ERROR_SUCCESS;
- ilfs.package = package;
- ilfs.feature = feature;
+ package_feature.package = package;
+ package_feature.feature = feature;
- rc = MSI_IterateRecords(view, NULL, iterate_load_featurecomponents , &ilfs);
+ rc = MSI_IterateRecords(view, NULL, iterate_load_featurecomponents, &package_feature);
msiobj_release(&view->hdr);
return rc;
}
/* fill in the data */
- file = msi_alloc_zero( sizeof (MSIFILE) );
+ file = calloc( 1, sizeof(MSIFILE) );
if (!file)
return ERROR_NOT_ENOUGH_MEMORY;
if (!file->Component)
{
WARN("Component not found: %s\n", debugstr_w(component));
- msi_free(file->File);
- msi_free(file);
+ free(file->File);
+ free(file);
return ERROR_SUCCESS;
}
msi_reduce_to_long_filename( file->FileName );
file->ShortName = msi_dup_record_field( row, 3 );
- file->LongName = strdupW( folder_split_path(file->ShortName, '|'));
+ file->LongName = wcsdup( folder_split_path(file->ShortName, '|') );
file->FileSize = MSI_RecordGetInteger( row, 4 );
file->Version = msi_dup_record_field( row, 5 );
MSIFILEPATCH *patch;
const WCHAR *file_key;
- patch = msi_alloc_zero( sizeof (MSIFILEPATCH) );
+ patch = calloc( 1, sizeof(MSIFILEPATCH) );
if (!patch)
return ERROR_NOT_ENOUGH_MEMORY;
if (!patch->File)
{
ERR("Failed to find target for patch in File table\n");
- msi_free(patch);
+ free(patch);
return ERROR_FUNCTION_FAILED;
}
LPWSTR p, tgt_short, tgt_long, src_short, src_long;
MSIFOLDER *folder;
- if (!(folder = msi_alloc_zero( sizeof(*folder) ))) return ERROR_NOT_ENOUGH_MEMORY;
+ if (!(folder = calloc( 1, sizeof(*folder) ))) return ERROR_NOT_ENOUGH_MEMORY;
list_init( &folder->children );
folder->Directory = msi_dup_record_field( row, 1 );
folder->Parent = msi_dup_record_field( row, 2 );
src_long = src_short;
/* FIXME: use the target short path too */
- folder->TargetDefault = strdupW(tgt_long);
- folder->SourceShortPath = strdupW(src_short);
- folder->SourceLongPath = strdupW(src_long);
- msi_free(p);
+ folder->TargetDefault = wcsdup(tgt_long);
+ folder->SourceShortPath = wcsdup(src_short);
+ folder->SourceLongPath = wcsdup(src_long);
+ free(p);
TRACE("TargetDefault = %s\n",debugstr_w( folder->TargetDefault ));
TRACE("SourceLong = %s\n", debugstr_w( folder->SourceLongPath ));
{
FolderList *fl;
- if (!(fl = msi_alloc( sizeof(*fl) ))) return ERROR_NOT_ENOUGH_MEMORY;
+ if (!(fl = malloc( sizeof(*fl) ))) return ERROR_NOT_ENOUGH_MEMORY;
fl->folder = child;
list_add_tail( &parent->children, &fl->entry );
return ERROR_SUCCESS;
}
}
}
- msi_free(override);
+ free(override);
return TRUE;
}
{
GetTempPathW( MAX_PATH, tmp );
}
- if (!(db->tempfolder = strdupW( tmp ))) return NULL;
+ if (!(db->tempfolder = wcsdup( tmp ))) return NULL;
}
- if ((ret = msi_alloc( (lstrlenW( db->tempfolder ) + 20) * sizeof(WCHAR) )))
+ if ((ret = malloc( (wcslen( db->tempfolder ) + 20) * sizeof(WCHAR) )))
{
for (;;)
{
if (!GetTempFileNameW( db->tempfolder, L"msi", ++id, ret ))
{
- msi_free( ret );
+ free( ret );
return NULL;
}
if (CreateDirectoryW( ret, NULL )) break;
}
va_end( va );
- dir = msi_alloc( sz * sizeof(WCHAR) );
+ dir = malloc( sz * sizeof(WCHAR) );
dir[0] = 0;
va_start( va, count );
static void set_target_path( MSIPACKAGE *package, MSIFILE *file )
{
- msi_free( file->TargetPath );
+ free( file->TargetPath );
if (msi_is_global_assembly( file->Component ))
{
MSIASSEMBLY *assembly = file->Component->assembly;
set_target_path( package, file );
- if ((comp->assembly && !comp->assembly->installed) ||
- msi_get_file_attributes( package, file->TargetPath ) == INVALID_FILE_ATTRIBUTES)
+ if (msi_get_file_attributes( package, file->TargetPath ) == INVALID_FILE_ATTRIBUTES)
{
- comp->Cost += file->FileSize;
+ comp->cost += cost_from_size( file->FileSize );
continue;
}
file_size = msi_get_disk_file_size( package, file->TargetPath );
{
if (msi_compare_file_versions( file_version, file->Version ) < 0)
{
- comp->Cost += file->FileSize - file_size;
+ comp->cost += cost_from_size( file->FileSize - file_size );
}
- msi_free( file_version );
+ free( file_version );
continue;
}
else if ((font_version = msi_get_font_file_version( package, file->TargetPath )))
{
if (msi_compare_font_versions( font_version, file->Version ) < 0)
{
- comp->Cost += file->FileSize - file_size;
+ comp->cost += cost_from_size( file->FileSize - file_size );
}
- msi_free( font_version );
+ free( font_version );
continue;
}
}
if (file_size != file->FileSize)
{
- comp->Cost += file->FileSize - file_size;
+ comp->cost += cost_from_size( file->FileSize - file_size );
}
}
WCHAR *q, *ret;
int n, len = lstrlenW( in ) + 2;
- if (!(q = ret = msi_alloc( len * sizeof(WCHAR) ))) return NULL;
+ if (!(q = ret = malloc( len * sizeof(WCHAR) ))) return NULL;
len = 0;
while (1)
if (MSIREG_OpenInstallProps( package->ProductCode, package->Context, NULL, &hkey, FALSE )) return NULL;
if ((path = msi_reg_get_val_str( hkey, L"InstallLocation" )) && !path[0])
{
- msi_free( path );
+ free( path );
path = NULL;
}
RegCloseKey( hkey );
normalized_path = msi_normalize_path( path );
msi_set_property( package->db, folder->Directory, normalized_path, -1 );
- msi_free( path );
+ free( path );
- msi_free( folder->ResolvedTarget );
+ free( folder->ResolvedTarget );
folder->ResolvedTarget = normalized_path;
LIST_FOR_EACH_ENTRY( fl, &folder->children, FolderList, entry )
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
{
- if (comp->Action == INSTALLSTATE_LOCAL) ret += comp->Cost;
+ if (comp->Action == INSTALLSTATE_LOCAL) ret += comp->cost;
}
return ret;
}
/* set default run level if not set */
level = msi_dup_property( package->db, L"INSTALLLEVEL" );
if (!level) msi_set_property( package->db, L"INSTALLLEVEL", L"1", -1 );
- msi_free(level);
+ free(level);
if ((rc = MSI_SetFeatureStates( package ))) return rc;
}
required = get_volume_space_required( package );
#ifdef __REACTOS__
- swprintf( buf, ARRAY_SIZE(buf), L"%I64u", required / 512 );
+ swprintf( buf, ARRAY_SIZE(buf), L"%I64u", required );
#else
- swprintf( buf, ARRAY_SIZE(buf), L"%lu", required / 512 );
+ swprintf( buf, ARRAY_SIZE(buf), L"%lu", required );
#endif
msi_set_property( package->db, L"PrimaryVolumeSpaceRequired", buf, -1 );
#ifdef __REACTOS__
- swprintf( buf, ARRAY_SIZE(buf), L"%I64u", (free.QuadPart - required) / 512 );
+ swprintf( buf, ARRAY_SIZE(buf), L"%I64u", (free.QuadPart / 512) - required );
#else
- swprintf( buf, ARRAY_SIZE(buf), L"%lu", (free.QuadPart - required) / 512 );
+ swprintf( buf, ARRAY_SIZE(buf), L"%lu", (free.QuadPart / 512) - required );
#endif
msi_set_property( package->db, L"PrimaryVolumeSpaceRemaining", buf, -1 );
msi_set_property( package->db, L"PrimaryVolumePath", primary_folder, 2 );
}
- msi_free( primary_folder );
+ free( primary_folder );
}
- msi_free( primary_key );
+ free( primary_key );
}
/* FIXME: check volume disk space */
{
*size = sizeof(WCHAR);
*type = REG_SZ;
- if ((data = msi_alloc( *size ))) *(WCHAR *)data = 0;
+ if ((data = malloc( *size ))) *(WCHAR *)data = 0;
return data;
}
if (value[0]=='#' && value[1]!='#' && value[1]!='%')
else
*size = lstrlenW(ptr)/2;
- data = msi_alloc(*size);
+ data = malloc(*size);
byte[0] = '0';
byte[1] = 'x';
data[count] = (BYTE)strtol(byte,NULL,0);
count ++;
}
- msi_free(deformated);
+ free(deformated);
TRACE( "data %lu bytes(%u)\n", *size, count );
}
*type=REG_DWORD;
*size = sizeof(DWORD);
- data = msi_alloc(*size);
+ data = malloc(*size);
p = deformated;
if (*p == '-')
p++;
*(DWORD *)data = d;
TRACE( "DWORD %lu\n", *(DWORD *)data);
- msi_free(deformated);
+ free(deformated);
}
}
else
access |= get_registry_view( comp );
- if (!(subkey = strdupW( path ))) return NULL;
+ if (!(subkey = wcsdup( path ))) return NULL;
p = subkey;
if ((q = wcschr( p, '\\' ))) *q = 0;
if (create)
if (res)
{
TRACE( "failed to open key %s (%ld)\n", debugstr_w(subkey), res );
- msi_free( subkey );
+ free( subkey );
return NULL;
}
if (q && q[1])
RegCloseKey( hkey );
}
else ret = hkey;
- msi_free( subkey );
+ free( subkey );
return ret;
}
p += lstrlenW( p ) + 1;
(*count)++;
}
- if (!(ret = msi_alloc( *count * sizeof(WCHAR *) ))) return NULL;
+ if (!(ret = malloc( *count * sizeof(WCHAR *) ))) return NULL;
p = str;
while ((p - str) < len)
{
- if (!(ret[i] = strdupW( p )))
+ if (!(ret[i] = wcsdup( p )))
{
- for (; i >= 0; i--) msi_free( ret[i] );
- msi_free( ret );
+ for (; i >= 0; i--) free( ret[i] );
+ free( ret );
return NULL;
}
p += lstrlenW( p ) + 1;
for (i = 0; i < left_count; i++) *size += (lstrlenW( left[i] ) + 1) * sizeof(WCHAR);
for (i = 0; i < right_count; i++) *size += (lstrlenW( right[i] ) + 1) * sizeof(WCHAR);
- if (!(ret = p = msi_alloc( *size ))) return NULL;
+ if (!(ret = p = malloc( *size ))) return NULL;
for (i = 0; i < left_count; i++)
{
{
if (old[j] && !wcscmp( new[i], old[j] ))
{
- msi_free( old[j] );
+ free( old[j] );
for (k = j; k < old_count - 1; k++) { old[k] = old[k + 1]; }
old[k] = NULL;
ret--;
old = split_multi_string_values( old_ptr, old_len, &old_count );
}
ret = (BYTE *)join_multi_string_values( op, old, old_count, new, new_count, size );
- for (i = 0; i < old_count; i++) msi_free( old[i] );
- for (i = 0; i < new_count; i++) msi_free( new[i] );
- msi_free( old );
- msi_free( new );
+ for (i = 0; i < old_count; i++) free( old[i] );
+ for (i = 0; i < new_count; i++) free( new[i] );
+ free( old );
+ free( new );
return ret;
}
{
BYTE *ret;
if (RegQueryValueExW( hkey, name, NULL, NULL, NULL, size )) return NULL;
- if (!(ret = msi_alloc( *size ))) return NULL;
+ if (!(ret = malloc( *size ))) return NULL;
RegQueryValueExW( hkey, name, NULL, type, ret, size );
return ret;
}
return ERROR_SUCCESS;
deformat_string(package, key , &deformated);
- uikey = msi_alloc( (lstrlenW(deformated) + lstrlenW(szRoot) + 1) * sizeof(WCHAR) );
+ uikey = malloc( (wcslen(deformated) + wcslen(szRoot) + 1) * sizeof(WCHAR) );
lstrcpyW(uikey,szRoot);
lstrcatW(uikey,deformated);
if (!(hkey = open_key( comp, root_key, deformated, TRUE, KEY_QUERY_VALUE | KEY_SET_VALUE )))
{
ERR("Could not create key %s\n", debugstr_w(deformated));
- msi_free(uikey);
- msi_free(deformated);
+ free(uikey);
+ free(deformated);
return ERROR_FUNCTION_FAILED;
}
- msi_free( deformated );
+ free( deformated );
str = msi_record_get_string( row, 5, NULL );
len = deformat_string( package, str, &deformated );
new_value = parse_value( package, deformated, len, &type, &new_size );
- msi_free( deformated );
+ free( deformated );
deformat_string(package, name, &deformated);
if (!is_special_entry( name ))
BYTE *new;
if (old_value && old_type != REG_MULTI_SZ)
{
- msi_free( old_value );
+ free( old_value );
old_value = NULL;
old_size = 0;
}
new = build_multi_string_value( old_value, old_size, new_value, new_size, &new_size );
- msi_free( new_value );
+ free( new_value );
new_value = new;
}
if (!check_first)
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free(new_value);
- msi_free(old_value);
- msi_free(deformated);
- msi_free(uikey);
+ free(new_value);
+ free(old_value);
+ free(deformated);
+ free(uikey);
return ERROR_SUCCESS;
}
WCHAR *subkey, *p;
HKEY hkey;
- if (!(subkey = strdupW( path ))) return;
+ if (!(subkey = wcsdup( path ))) return;
do
{
if ((p = wcsrchr( subkey, '\\' )))
break;
}
} while (p);
- msi_free( subkey );
+ free( subkey );
}
static void delete_value( const MSICOMPONENT *comp, HKEY root, const WCHAR *path, const WCHAR *value )
deformat_string( package, key_str, &deformated_key );
size = lstrlenW( deformated_key ) + lstrlenW( root_key_str ) + 1;
- ui_key_str = msi_alloc( size * sizeof(WCHAR) );
+ ui_key_str = malloc( size * sizeof(WCHAR) );
lstrcpyW( ui_key_str, root_key_str );
lstrcatW( ui_key_str, deformated_key );
if (delete_key) delete_tree( comp, hkey_root, deformated_key );
else delete_value( comp, hkey_root, deformated_key, deformated_name );
- msi_free( deformated_key );
+ free( deformated_key );
uirow = MSI_CreateRecord( 2 );
MSI_RecordSetStringW( uirow, 1, ui_key_str );
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free( ui_key_str );
- msi_free( deformated_name );
+ free( ui_key_str );
+ free( deformated_name );
return ERROR_SUCCESS;
}
deformat_string( package, key_str, &deformated_key );
size = lstrlenW( deformated_key ) + lstrlenW( root_key_str ) + 1;
- ui_key_str = msi_alloc( size * sizeof(WCHAR) );
+ ui_key_str = malloc( size * sizeof(WCHAR) );
lstrcpyW( ui_key_str, root_key_str );
lstrcatW( ui_key_str, deformated_key );
if (delete_key) delete_tree( comp, hkey_root, deformated_key );
else delete_value( comp, hkey_root, deformated_key, deformated_name );
- msi_free( deformated_key );
+ free( deformated_key );
uirow = MSI_CreateRecord( 2 );
MSI_RecordSetStringW( uirow, 1, ui_key_str );
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free( ui_key_str );
- msi_free( deformated_name );
+ free( ui_key_str );
+ free( deformated_name );
return ERROR_SUCCESS;
}
message = MSI_RecordGetString(row, 2);
deformat_string(package, message, &deformated);
MessageBoxW(NULL, deformated, L"Install Failed", MB_OK);
- msi_free(deformated);
+ free(deformated);
}
return ERROR_INSTALL_FAILURE;
{
if (!cmp->KeyPath)
- return strdupW( msi_get_target_folder( package, cmp->Directory ) );
+ return wcsdup( msi_get_target_folder( package, cmp->Directory ) );
if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
{
if (deformated_name)
len+=lstrlenW(deformated_name);
- buffer = msi_alloc( len *sizeof(WCHAR));
+ buffer = malloc(len * sizeof(WCHAR));
if (deformated_name)
swprintf(buffer, len, L"%02d:\\%s\\%s", root, deformated, deformated_name);
else
swprintf(buffer, len, L"%02d:\\%s\\", root, deformated);
- msi_free(deformated);
- msi_free(deformated_name);
+ free(deformated);
+ free(deformated_name);
msiobj_release(&row->hdr);
return buffer;
MSIFILE *file = msi_get_loaded_file( package, cmp->KeyPath );
if (file)
- return strdupW( file->TargetPath );
+ return wcsdup( file->TargetPath );
}
return NULL;
}
if (comp->assembly)
{
DWORD len = lstrlenW( L"<\\" ) + lstrlenW( comp->assembly->display_name );
- WCHAR *keypath = msi_alloc( (len + 1) * sizeof(WCHAR) );
+ WCHAR *keypath = malloc( (len + 1) * sizeof(WCHAR) );
if (keypath)
{
continue;
squash_guid( comp->ComponentId, squashed_cc );
- msi_free( comp->FullKeypath );
+ free( comp->FullKeypath );
comp->FullKeypath = build_full_keypath( package, comp );
refcount_component( package, comp );
sourcepath = msi_resolve_file_source(package, file);
ptr = sourcepath + lstrlenW(base);
lstrcpyW(ptr2, ptr);
- msi_free(sourcepath);
+ free(sourcepath);
msi_reg_set_val_str( hkey, squashed_pc, source );
}
return ERROR_SUCCESS;
}
-typedef struct {
+struct typelib
+{
CLSID clsid;
LPWSTR source;
-
LPWSTR path;
ITypeLib *ptLib;
-} typelib_struct;
+};
static BOOL CALLBACK Typelib_EnumResNameProc( HMODULE hModule, LPCWSTR lpszType,
LPWSTR lpszName, LONG_PTR lParam)
{
TLIBATTR *attr;
- typelib_struct *tl_struct = (typelib_struct*) lParam;
+ struct typelib *tl_struct = (struct typelib *)lParam;
int sz;
HRESULT res;
sz = lstrlenW(tl_struct->source)+4;
if ((INT_PTR)lpszName == 1)
- tl_struct->path = strdupW(tl_struct->source);
+ tl_struct->path = wcsdup(tl_struct->source);
else
{
- tl_struct->path = msi_alloc(sz * sizeof(WCHAR));
+ tl_struct->path = malloc(sz * sizeof(WCHAR));
#ifdef __REACTOS__
swprintf(tl_struct->path, sz, L"%s\\%d", tl_struct->source, (WORD)(INT_PTR)lpszName);
#else
res = LoadTypeLib(tl_struct->path,&tl_struct->ptLib);
if (FAILED(res))
{
- msi_free(tl_struct->path);
+ free(tl_struct->path);
tl_struct->path = NULL;
return TRUE;
return FALSE;
}
- msi_free(tl_struct->path);
+ free(tl_struct->path);
tl_struct->path = NULL;
ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
return TRUE;
}
-static HMODULE msi_load_library( MSIPACKAGE *package, const WCHAR *filename, DWORD flags )
+static HMODULE load_library( MSIPACKAGE *package, const WCHAR *filename, DWORD flags )
{
HMODULE module;
msi_disable_fs_redirection( package );
return module;
}
-static HRESULT msi_load_typelib( MSIPACKAGE *package, const WCHAR *filename, REGKIND kind, ITypeLib **lib )
+static HRESULT load_typelib( MSIPACKAGE *package, const WCHAR *filename, REGKIND kind, ITypeLib **lib )
{
HRESULT hr;
msi_disable_fs_redirection( package );
LPCWSTR component;
MSICOMPONENT *comp;
MSIFILE *file;
- typelib_struct tl_struct;
+ struct typelib tl_struct;
ITypeLib *tlib;
HMODULE module;
HRESULT hr;
}
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
- module = msi_load_library( package, file->TargetPath, LOAD_LIBRARY_AS_DATAFILE );
+ module = load_library( package, file->TargetPath, LOAD_LIBRARY_AS_DATAFILE );
if (module)
{
LPCWSTR guid;
guid = MSI_RecordGetString(row,1);
CLSIDFromString( guid, &tl_struct.clsid);
- tl_struct.source = strdupW( file->TargetPath );
+ tl_struct.source = wcsdup( file->TargetPath );
tl_struct.path = NULL;
EnumResourceNamesW(module, L"TYPELIB", Typelib_EnumResNameProc,
TRACE("Registered %s\n", debugstr_w(tl_struct.path));
ITypeLib_Release(tl_struct.ptLib);
- msi_free(tl_struct.path);
+ free(tl_struct.path);
}
else ERR("Failed to load type library %s\n", debugstr_w(tl_struct.source));
FreeLibrary(module);
- msi_free(tl_struct.source);
+ free(tl_struct.source);
}
else
{
- hr = msi_load_typelib( package, file->TargetPath, REGKIND_REGISTER, &tlib );
+ hr = load_typelib( package, file->TargetPath, REGKIND_REGISTER, &tlib );
if (FAILED(hr))
{
ERR( "failed to load type library: %#lx\n", hr );
static WCHAR *get_link_file( MSIPACKAGE *package, MSIRECORD *row )
{
LPCWSTR directory, extension, link_folder;
- LPWSTR link_file, filename;
+ WCHAR *link_file = NULL, *filename, *new_filename;
directory = MSI_RecordGetString( row, 2 );
link_folder = msi_get_target_folder( package, directory );
msi_create_full_path( package, link_folder );
filename = msi_dup_record_field( row, 3 );
+ if (!filename) return NULL;
msi_reduce_to_long_filename( filename );
extension = wcsrchr( filename, '.' );
if (!extension || wcsicmp( extension, L".lnk" ))
{
int len = lstrlenW( filename );
- filename = msi_realloc( filename, len * sizeof(WCHAR) + sizeof(L".lnk") );
+ new_filename = realloc( filename, len * sizeof(WCHAR) + sizeof(L".lnk") );
+ if (!new_filename) goto done;
+ filename = new_filename;
memcpy( filename + len, L".lnk", sizeof(L".lnk") );
}
link_file = msi_build_directory_name( 2, link_folder, filename );
- msi_free( filename );
+done:
+ free( filename );
return link_file;
}
{
WCHAR *appdata = msi_dup_property( package->db, L"AppDataFolder" );
folder = msi_build_directory_name( 2, appdata, L"Microsoft\\" );
- msi_free( appdata );
+ free( appdata );
}
dest = msi_build_directory_name( 3, folder, L"Installer\\", package->ProductCode );
msi_create_full_path( package, dest );
path = msi_build_directory_name( 2, dest, icon_name );
- msi_free( folder );
- msi_free( dest );
+ free( folder );
+ free( dest );
return path;
}
deformat_string( package, target, &path );
TRACE("target path is %s\n", debugstr_w(path));
IShellLinkW_SetPath( sl, path );
- msi_free( path );
+ free( path );
}
else
{
FIXME("poorly handled shortcut format, advertised shortcut\n");
path = resolve_keypath( package, comp );
IShellLinkW_SetPath( sl, path );
- msi_free( path );
+ free( path );
}
if (!MSI_RecordIsNull(row,6))
LPCWSTR arguments = MSI_RecordGetString(row, 6);
deformat_string(package, arguments, &deformated);
IShellLinkW_SetArguments(sl,deformated);
- msi_free(deformated);
+ free(deformated);
}
if (!MSI_RecordIsNull(row,7))
index = 0;
IShellLinkW_SetIconLocation(sl, path, index);
- msi_free(path);
+ free(path);
}
if (!MSI_RecordIsNull(row,11))
IPersistFile_Save(pf, link_file, FALSE);
msi_revert_fs_redirection( package );
- msi_free(link_file);
+ free(link_file);
err:
if (pf)
link_file = get_link_file( package, row );
TRACE("Removing shortcut file %s\n", debugstr_w( link_file ));
if (!msi_delete_file( package, link_file )) WARN( "failed to remove shortcut file %lu\n", GetLastError() );
- msi_free( link_file );
+ free( link_file );
return ERROR_SUCCESS;
}
if (handle == INVALID_HANDLE_VALUE)
{
ERR("Unable to create file %s\n", debugstr_w(icon_path));
- msi_free( icon_path );
+ free( icon_path );
return ERROR_SUCCESS;
}
WriteFile( handle, buffer, sz, &count, NULL );
} while (sz == 1024);
- msi_free( icon_path );
+ free( icon_path );
CloseHandle( handle );
return ERROR_SUCCESS;
}
-static UINT msi_publish_icons(MSIPACKAGE *package)
+static UINT publish_icons(MSIPACKAGE *package)
{
MSIQUERY *view;
UINT r;
return ERROR_SUCCESS;
}
-static UINT msi_publish_sourcelist(MSIPACKAGE *package, HKEY hkey)
+static UINT publish_sourcelist(MSIPACKAGE *package, HKEY hkey)
{
UINT r;
HKEY source;
return ERROR_SUCCESS;
}
-static UINT msi_publish_product_properties(MSIPACKAGE *package, HKEY hkey)
+static UINT publish_product_properties(MSIPACKAGE *package, HKEY hkey)
{
WCHAR *buffer, *ptr, *guids, packcode[SQUASHED_GUID_SIZE];
DWORD langid;
buffer = msi_dup_property(package->db, INSTALLPROPERTY_PRODUCTNAMEW);
msi_reg_set_val_str(hkey, INSTALLPROPERTY_PRODUCTNAMEW, buffer);
- msi_free(buffer);
+ free(buffer);
langid = msi_get_property_int(package->db, L"ProductLanguage", 0);
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_LANGUAGEW, langid);
{
LPWSTR path = msi_build_icon_path(package, buffer);
msi_reg_set_val_str(hkey, INSTALLPROPERTY_PRODUCTICONW, path);
- msi_free(path);
- msi_free(buffer);
+ free(path);
+ free(buffer);
}
buffer = msi_dup_property(package->db, L"ProductVersion");
{
DWORD verdword = msi_version_str_to_dword(buffer);
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONW, verdword);
- msi_free(buffer);
+ free(buffer);
}
msi_reg_set_val_dword(hkey, L"Assignment", 0);
if (!(guids = msi_get_package_code(package->db))) return ERROR_OUTOFMEMORY;
if ((ptr = wcschr(guids, ';'))) *ptr = 0;
squash_guid(guids, packcode);
- msi_free( guids);
+ free(guids);
msi_reg_set_val_str(hkey, INSTALLPROPERTY_PACKAGECODEW, packcode);
return ERROR_SUCCESS;
}
-static UINT msi_publish_upgrade_code(MSIPACKAGE *package)
+static UINT publish_upgrade_code(MSIPACKAGE *package)
{
UINT r;
HKEY hkey;
if (r != ERROR_SUCCESS)
{
WARN("failed to open upgrade code key\n");
- msi_free(upgrade);
+ free(upgrade);
return ERROR_SUCCESS;
}
squash_guid(package->ProductCode, squashed_pc);
msi_reg_set_val_str(hkey, squashed_pc, NULL);
RegCloseKey(hkey);
- msi_free(upgrade);
+ free(upgrade);
return ERROR_SUCCESS;
}
-static BOOL msi_check_publish(MSIPACKAGE *package)
+static BOOL check_publish(MSIPACKAGE *package)
{
MSIFEATURE *feature;
return FALSE;
}
-static BOOL msi_check_unpublish(MSIPACKAGE *package)
+static BOOL check_unpublish(MSIPACKAGE *package)
{
MSIFEATURE *feature;
return TRUE;
}
-static UINT msi_publish_patches( MSIPACKAGE *package )
+static UINT publish_patches( MSIPACKAGE *package )
{
WCHAR patch_squashed[GUID_SIZE];
HKEY patches_key = NULL, product_patches_key = NULL, product_key;
len += lstrlenW( patch_squashed ) + 1;
}
- p = all_patches = msi_alloc( (len + 1) * sizeof(WCHAR) );
+ p = all_patches = malloc( (len + 1) * sizeof(WCHAR) );
if (!all_patches)
goto done;
RegCloseKey( product_patches_key );
RegCloseKey( patches_key );
RegCloseKey( product_key );
- msi_free( all_patches );
+ free( all_patches );
return r;
}
if (!list_empty(&package->patches))
{
- rc = msi_publish_patches(package);
+ rc = publish_patches(package);
if (rc != ERROR_SUCCESS)
goto end;
}
WCHAR packed[SQUASHED_GUID_SIZE];
squash_guid(guid, packed);
- msi_free(guid);
+ free(guid);
if (!wcscmp(packed, package_code))
{
TRACE("re-publishing product - new package\n");
republish = TRUE;
}
}
- msi_free(package_code);
+ free(package_code);
}
}
/* FIXME: also need to publish if the product is in advertise mode */
- if (!republish && !msi_check_publish(package))
+ if (!republish && !check_publish(package))
{
if (hukey)
RegCloseKey(hukey);
if (rc != ERROR_SUCCESS)
goto end;
- rc = msi_publish_upgrade_code(package);
+ rc = publish_upgrade_code(package);
if (rc != ERROR_SUCCESS)
goto end;
- rc = msi_publish_product_properties(package, hukey);
+ rc = publish_product_properties(package, hukey);
if (rc != ERROR_SUCCESS)
goto end;
- rc = msi_publish_sourcelist(package, hukey);
+ rc = publish_sourcelist(package, hukey);
if (rc != ERROR_SUCCESS)
goto end;
- rc = msi_publish_icons(package);
+ rc = publish_icons(package);
end:
uirow = MSI_CreateRecord( 1 );
dirprop = MSI_RecordGetString( row, 3 );
if (dirprop)
{
- folder = strdupW( msi_get_target_folder( package, dirprop ) );
+ folder = wcsdup( msi_get_target_folder( package, dirprop ) );
if (!folder) folder = msi_dup_property( package->db, dirprop );
}
else
if (!folder)
{
ERR("Unable to resolve folder %s\n", debugstr_w(dirprop));
- msi_free( filename );
+ free( filename );
return NULL;
}
ret = msi_build_directory_name( 2, folder, ptr );
- msi_free( filename );
- msi_free( folder );
+ free( filename );
+ free( folder );
return ret;
}
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free(fullname);
- msi_free(deformated_key);
- msi_free(deformated_value);
- msi_free(deformated_section);
+ free(fullname);
+ free(deformated_key);
+ free(deformated_value);
+ free(deformated_section);
return ERROR_SUCCESS;
}
{
WARN( "unable to remove key %lu\n", GetLastError() );
}
- msi_free( filename );
+ free( filename );
}
else
FIXME("Unsupported action %d\n", action);
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free( deformated_key );
- msi_free( deformated_value );
- msi_free( deformated_section );
+ free( deformated_key );
+ free( deformated_value );
+ free( deformated_section );
return ERROR_SUCCESS;
}
{
WARN( "unable to remove key %lu\n", GetLastError() );
}
- msi_free( filename );
+ free( filename );
}
else
FIXME("Unsupported action %d\n", action);
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free( deformated_key );
- msi_free( deformated_value );
- msi_free( deformated_section );
+ free( deformated_key );
+ free( deformated_value );
+ free( deformated_section );
return ERROR_SUCCESS;
}
static void register_dll( const WCHAR *dll, BOOL unregister )
{
-#ifdef __REACTOS__
static const WCHAR regW[] = L"regsvr32.exe /s \"%s\"";
static const WCHAR unregW[] = L"regsvr32.exe /s /u \"%s\"";
-#else /* __REACTOS__ */
- static const WCHAR regW[] = L"regsvr32.exe \"%s\"";
- static const WCHAR unregW[] = L"regsvr32.exe /u \"%s\"";
-#endif /* __REACTOS__ */
PROCESS_INFORMATION pi;
STARTUPINFOW si;
WCHAR *cmd;
- if (!(cmd = msi_alloc( lstrlenW(dll) * sizeof(WCHAR) + sizeof(unregW) ))) return;
+ if (!(cmd = malloc( wcslen(dll) * sizeof(WCHAR) + sizeof(unregW) ))) return;
if (unregister) swprintf( cmd, lstrlenW(dll) + ARRAY_SIZE(unregW), unregW, dll );
else swprintf( cmd, lstrlenW(dll) + ARRAY_SIZE(unregW), regW, dll );
msi_dialog_check_messages( pi.hProcess );
CloseHandle( pi.hProcess );
}
- msi_free( cmd );
+ free( cmd );
}
static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
if (package->script == SCRIPT_NONE)
return msi_schedule_action(package, SCRIPT_INSTALL, L"PublishFeatures");
- if (!msi_check_publish(package))
+ if (!check_publish(package))
return ERROR_SUCCESS;
rc = MSIREG_OpenFeaturesKey(package->ProductCode, NULL, package->Context,
if (feature->Feature_Parent)
size += lstrlenW( feature->Feature_Parent )+2;
- data = msi_alloc(size * sizeof(WCHAR));
+ data = malloc(size * sizeof(WCHAR));
data[0] = 0;
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
}
msi_reg_set_val_str( userdata, feature->Feature, data );
- msi_free(data);
+ free(data);
size = 0;
if (feature->Feature_Parent)
else
{
size += 2*sizeof(WCHAR);
- data = msi_alloc(size);
+ data = malloc(size);
data[0] = 0x6;
data[1] = 0;
if (feature->Feature_Parent)
lstrcpyW( &data[1], feature->Feature_Parent );
RegSetValueExW(hkey,feature->Feature,0,REG_SZ,
(LPBYTE)data,size);
- msi_free(data);
+ free(data);
}
/* the UI chunk */
return rc;
}
-static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
+static UINT unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
{
UINT r;
HKEY hkey;
if (package->script == SCRIPT_NONE)
return msi_schedule_action(package, SCRIPT_INSTALL, L"UnpublishFeatures");
- if (!msi_check_unpublish(package))
+ if (!check_unpublish(package))
return ERROR_SUCCESS;
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
{
- msi_unpublish_feature(package, feature);
+ unpublish_feature(package, feature);
}
return ERROR_SUCCESS;
}
-static UINT msi_publish_install_properties(MSIPACKAGE *package, HKEY hkey)
+static UINT publish_install_properties(MSIPACKAGE *package, HKEY hkey)
{
static const WCHAR *propval[] =
{
key = *p++;
val = msi_dup_property(package->db, prop);
msi_reg_set_val_str(hkey, key, val);
- msi_free(val);
+ free(val);
}
msi_reg_set_val_dword(hkey, L"WindowsInstaller", 1);
size = deformat_string(package, fmt, &buffer) * sizeof(WCHAR);
RegSetValueExW(hkey, L"ModifyPath", 0, REG_EXPAND_SZ, (LPBYTE)buffer, size);
RegSetValueExW(hkey, L"UninstallString", 0, REG_EXPAND_SZ, (LPBYTE)buffer, size);
- msi_free(buffer);
+ free(buffer);
}
/* FIXME: Write real Estimated Size when we have it */
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONW, verdword);
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword >> 24);
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONMINORW, (verdword >> 16) & 0xFF);
- msi_free(buffer);
+ free(buffer);
}
return ERROR_SUCCESS;
return msi_schedule_action(package, SCRIPT_INSTALL, L"RegisterProduct");
/* FIXME: also need to publish if the product is in advertise mode */
- if (!msi_get_property_int( package->db, L"ProductToBeRegistered", 0 )
- && !msi_check_publish(package))
+ if (!msi_get_property_int( package->db, L"ProductToBeRegistered", 0 ) && !check_publish(package))
return ERROR_SUCCESS;
rc = MSIREG_OpenUninstallKey(package->ProductCode, package->platform, &hkey, TRUE);
if (rc != ERROR_SUCCESS)
goto done;
- rc = msi_publish_install_properties(package, hkey);
+ rc = publish_install_properties(package, hkey);
if (rc != ERROR_SUCCESS)
goto done;
- rc = msi_publish_install_properties(package, props);
+ rc = publish_install_properties(package, props);
if (rc != ERROR_SUCCESS)
goto done;
msi_reg_set_val_str( upgrade_key, squashed_pc, NULL );
RegCloseKey( upgrade_key );
}
- msi_free( upgrade_code );
+ free( upgrade_code );
}
msi_reg_set_val_str( props, INSTALLPROPERTY_LOCALPACKAGEW, package->localfile );
package->delete_on_close = FALSE;
*p = 0;
msi_remove_directory( package, icon_path );
}
- msi_free( icon_path );
+ free( icon_path );
}
return ERROR_SUCCESS;
}
-static UINT msi_unpublish_icons( MSIPACKAGE *package )
+static UINT unpublish_icons( MSIPACKAGE *package )
{
MSIQUERY *view;
UINT r;
if (!res && !count) MSIREG_DeleteClassesUpgradeCodesKey( code );
}
- msi_free( code );
+ free( code );
}
static UINT ACTION_UnpublishProduct(MSIPACKAGE *package)
TRACE("removing local package %s\n", debugstr_w(package->localfile));
package->delete_on_close = TRUE;
- msi_unpublish_icons( package );
+ unpublish_icons( package );
return ERROR_SUCCESS;
}
static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
{
UINT rc;
+ MSIFILE *file;
+ MSIFILEPATCH *patch;
/* first do the same as an InstallExecute */
rc = execute_script(package, SCRIPT_INSTALL);
if (rc != ERROR_SUCCESS)
return rc;
+ /* install global assemblies */
+ LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
+ {
+ MSICOMPONENT *comp = file->Component;
+
+ if (!msi_is_global_assembly( comp ) || (file->state != msifs_missing && file->state != msifs_overwrite))
+ continue;
+
+ rc = msi_install_assembly( package, comp );
+ if (rc != ERROR_SUCCESS)
+ {
+ ERR("Failed to install assembly\n");
+ return ERROR_INSTALL_FAILURE;
+ }
+ file->state = msifs_installed;
+ }
+
+ /* patch global assemblies */
+ LIST_FOR_EACH_ENTRY( patch, &package->filepatches, MSIFILEPATCH, entry )
+ {
+ MSICOMPONENT *comp = patch->File->Component;
+
+ if (!msi_is_global_assembly( comp ) || !patch->path) continue;
+
+ rc = msi_patch_assembly( package, comp->assembly, patch );
+ if (rc && !(patch->Attributes & msidbPatchAttributesNonVital))
+ {
+ ERR("Failed to apply patch to file: %s\n", debugstr_w(patch->File->File));
+ return rc;
+ }
+
+ if ((rc = msi_install_assembly( package, comp )))
+ {
+ ERR("Failed to install patched assembly\n");
+ return rc;
+ }
+ }
+
/* then handle commit actions */
rc = execute_script(package, SCRIPT_COMMIT);
if (rc != ERROR_SUCCESS)
INSTALLPROPERTY_DISKPROMPTW,NULL,&size);
if (rc == ERROR_MORE_DATA)
{
- prompt = msi_alloc(size * sizeof(WCHAR));
+ prompt = malloc(size * sizeof(WCHAR));
MsiSourceListGetInfoW(package->ProductCode, NULL,
package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_DISKPROMPTW,prompt,&size);
}
else
- prompt = strdupW(package->db->path);
+ prompt = wcsdup(package->db->path);
record = MSI_CreateRecord(2);
MSI_RecordSetInteger(record, 1, MSIERR_INSERTDISK);
MSI_RecordSetStringW(record, 2, prompt);
- msi_free(prompt);
+ free(prompt);
while(attrib == INVALID_FILE_ATTRIBUTES)
{
MSI_RecordSetStringW(record, 0, NULL);
rc = MSI_ProcessMessage(package, INSTALLMESSAGE_ERROR, record);
if (rc == IDCANCEL)
+ {
+ msiobj_release(&record->hdr);
return ERROR_INSTALL_USEREXIT;
+ }
attrib = GetFileAttributesW(package->db->path);
}
+ msiobj_release(&record->hdr);
rc = ERROR_SUCCESS;
}
else
if (package->script == SCRIPT_NONE)
return msi_schedule_action(package, SCRIPT_INSTALL, L"RegisterUser");
- if (msi_check_unpublish(package))
+ if (check_unpublish(package))
{
MSIREG_DeleteUserDataProductKey(package->ProductCode, package->Context);
goto end;
{
buffer = msi_dup_property( package->db, szPropKeys[i] );
msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
- msi_free( buffer );
+ free( buffer );
}
end:
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free(productid);
+ free(productid);
RegCloseKey(hkey);
return rc;
}
}
info_template = msi_get_error_message(package->db, MSIERR_INFO_LOGGINGSTART);
MSI_RecordSetStringW(uirow_info, 0, info_template);
- msi_free(info_template);
+ free(info_template);
MSI_ProcessMessage(package, INSTALLMESSAGE_INFO|MB_ICONHAND, uirow_info);
msiobj_release(&uirow_info->hdr);
}
msiobj_release(&uirow->hdr);
end:
- msi_free(productname);
- msi_free(action);
+ free(productname);
+ free(action);
return rc;
}
debugstr_w(component_85));
sz = 20 + lstrlenW( feature ) + 20 + 3;
- ret = msi_alloc_zero( sz * sizeof(WCHAR) );
+ ret = calloc( 1, sz * sizeof(WCHAR) );
if (ret) swprintf( ret, sz, L"%s%s%c%s", productid_85, feature, component ? '>' : '<', component_85 );
return ret;
}
text = MSI_RecordGetString( rec, 4 );
if (text)
{
- p = msi_alloc( (lstrlenW( advertise ) + lstrlenW( text ) + 1) * sizeof(WCHAR) );
+ p = malloc( (wcslen( advertise ) + wcslen( text ) + 1) * sizeof(WCHAR) );
lstrcpyW( p, advertise );
lstrcatW( p, text );
- msi_free( advertise );
+ free( advertise );
advertise = p;
}
existing = msi_reg_get_val_str( hkey, qualifier );
if (wcscmp( advertise, p )) sz += len;
}
}
- if (!(output = msi_alloc( (sz + 1) * sizeof(WCHAR) )))
+ if (!(output = malloc( (sz + 1) * sizeof(WCHAR) )))
{
rc = ERROR_OUTOFMEMORY;
goto end;
end:
RegCloseKey(hkey);
- msi_free( output );
- msi_free( advertise );
- msi_free( existing );
+ free( output );
+ free( advertise );
+ free( existing );
/* the UI chunk */
uirow = MSI_CreateRecord( 2 );
else
{
int len = lstrlenW(file->TargetPath) + lstrlenW(args) + 2;
- if (!(image_path = msi_alloc(len * sizeof(WCHAR))))
+ if (!(image_path = malloc(len * sizeof(WCHAR))))
{
ret = ERROR_OUTOFMEMORY;
goto done;
WARN( "failed to set service description %lu\n", GetLastError() );
}
- if (image_path != file->TargetPath) msi_free(image_path);
+ if (image_path != file->TargetPath) free(image_path);
done:
if (service) CloseServiceHandle(service);
if (hscm) CloseServiceHandle(hscm);
- msi_free(name);
- msi_free(disp);
- msi_free(sd.lpDescription);
- msi_free(load_order);
- msi_free(serv_name);
- msi_free(pass);
- msi_free(depends);
- msi_free(args);
+ free(name);
+ free(disp);
+ free(sd.lpDescription);
+ free(load_order);
+ free(serv_name);
+ free(pass);
+ free(depends);
+ free(args);
return ret;
}
}
/* converts arg1[~]arg2[~]arg3 to a list of ptrs to the strings */
-static LPCWSTR *msi_service_args_to_vector(LPWSTR args, DWORD *numargs)
+static const WCHAR **service_args_to_vector(WCHAR *args, DWORD *numargs)
{
LPCWSTR *vector, *temp_vector;
LPWSTR p, q;
if (!args)
return NULL;
- vector = msi_alloc(sizeof(LPWSTR));
+ vector = malloc(sizeof(WCHAR *));
if (!vector)
return NULL;
{
*q = '\0';
- temp_vector = msi_realloc(vector, (*numargs + 1) * sizeof(LPWSTR));
+ temp_vector = realloc(vector, (*numargs + 1) * sizeof(WCHAR *));
if (!temp_vector)
{
- msi_free(vector);
+ free(vector);
return NULL;
}
vector = temp_vector;
!(comp->Action == INSTALLSTATE_ABSENT && (event & msidbServiceControlEventUninstallStart)))
{
TRACE("not starting %s\n", debugstr_w(name));
- msi_free( name );
+ free(name);
return ERROR_SUCCESS;
}
if (!GetServiceDisplayNameW( scm, name, NULL, &len ) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
- if ((display_name = msi_alloc( ++len * sizeof(WCHAR ))))
+ if ((display_name = malloc(++len * sizeof(WCHAR))))
GetServiceDisplayNameW( scm, name, display_name, &len );
}
goto done;
}
- vector = msi_service_args_to_vector(args, &numargs);
+ vector = service_args_to_vector(args, &numargs);
if (!StartServiceW(service, numargs, vector) &&
GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)
if (service) CloseServiceHandle(service);
if (scm) CloseServiceHandle(scm);
- msi_free(name);
- msi_free(args);
- msi_free(vector);
- msi_free(display_name);
+ free(name);
+ free(args);
+ free(vector);
+ free(display_name);
return r;
}
if (GetLastError() != ERROR_MORE_DATA)
return FALSE;
- dependencies = msi_alloc(needed);
+ dependencies = malloc(needed);
if (!dependencies)
return FALSE;
ret = TRUE;
done:
- msi_free(dependencies);
+ free(dependencies);
return ret;
}
!(comp->Action == INSTALLSTATE_ABSENT && (event & msidbServiceControlEventUninstallStop)))
{
TRACE("not stopping %s\n", debugstr_w(name));
- msi_free( name );
+ free( name );
return ERROR_SUCCESS;
}
if (!GetServiceDisplayNameW( scm, name, NULL, &len ) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
- if ((display_name = msi_alloc( ++len * sizeof(WCHAR ))))
+ if ((display_name = malloc( ++len * sizeof(WCHAR ))))
GetServiceDisplayNameW( scm, name, display_name, &len );
}
CloseServiceHandle( scm );
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free( name );
- msi_free( display_name );
+ free( name );
+ free( display_name );
return ERROR_SUCCESS;
}
!(comp->Action == INSTALLSTATE_ABSENT && (event & msidbServiceControlEventUninstallDelete)))
{
TRACE("service %s not scheduled for removal\n", debugstr_w(name));
- msi_free( name );
+ free( name );
return ERROR_SUCCESS;
}
stop_service( name );
if (!GetServiceDisplayNameW( scm, name, NULL, &len ) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
- if ((display_name = msi_alloc( ++len * sizeof(WCHAR ))))
+ if ((display_name = malloc( ++len * sizeof(WCHAR ))))
GetServiceDisplayNameW( scm, name, display_name, &len );
}
if (service) CloseServiceHandle( service );
if (scm) CloseServiceHandle( scm );
- msi_free( name );
- msi_free( display_name );
+ free( name );
+ free( display_name );
return ERROR_SUCCESS;
}
len += lstrlenW(L"Setup=%s") + lstrlenW(setup_file->FileName);
len += lstrlenW(L"FileUsage=1") + 2; /* \0\0 */
- driver = msi_alloc(len * sizeof(WCHAR));
+ driver = malloc(len * sizeof(WCHAR));
if (!driver)
return ERROR_OUTOFMEMORY;
const WCHAR *dir = msi_get_target_folder( package, driver_file->Component->Directory );
driver_file->TargetPath = msi_build_directory_name( 2, dir, driver_file->FileName );
}
- driver_path = strdupW(driver_file->TargetPath);
+ driver_path = wcsdup(driver_file->TargetPath);
ptr = wcsrchr(driver_path, '\\');
if (ptr) *ptr = '\0';
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free(driver);
- msi_free(driver_path);
+ free(driver);
+ free(driver_path);
return r;
}
if (setup_file)
len += lstrlenW(L"Setup=%s") + lstrlenW(setup_file->FileName);
- translator = msi_alloc(len * sizeof(WCHAR));
+ translator = malloc(len * sizeof(WCHAR));
if (!translator)
return ERROR_OUTOFMEMORY;
}
*ptr = '\0';
- translator_path = strdupW(translator_file->TargetPath);
+ translator_path = wcsdup(translator_file->TargetPath);
ptr = wcsrchr(translator_path, '\\');
if (ptr) *ptr = '\0';
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free(translator);
- msi_free(translator_path);
+ free(translator);
+ free(translator_path);
return r;
}
else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_ADD_DSN;
len = lstrlenW(L"DSN=%s") + lstrlenW(desc) + 2; /* \0\0 */
- attrs = msi_alloc(len * sizeof(WCHAR));
+ attrs = malloc(len * sizeof(WCHAR));
if (!attrs)
return ERROR_OUTOFMEMORY;
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
- msi_free(attrs);
+ free(attrs);
return r;
}
else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_REMOVE_DSN;
len = lstrlenW( L"DSN=%s" ) + lstrlenW( desc ) + 2; /* \0\0 */
- attrs = msi_alloc( len * sizeof(WCHAR) );
+ attrs = malloc( len * sizeof(WCHAR) );
if (!attrs)
return ERROR_OUTOFMEMORY;
{
WARN("Failed to remove ODBC data source\n");
}
- msi_free( attrs );
+ free( attrs );
uirow = MSI_CreateRecord( 3 );
MSI_RecordSetStringW( uirow, 1, desc );
goto done;
}
size = (lstrlenW(value) + 1) * sizeof(WCHAR);
- newval = strdupW(value);
+ newval = wcsdup(value);
if (!newval)
{
res = ERROR_OUTOFMEMORY;
goto done;
}
- if (!(p = q = data = msi_alloc( size )))
+ if (!(p = q = data = malloc( size )))
{
- msi_free(deformatted);
+ free(deformatted);
RegCloseKey(env);
return ERROR_OUTOFMEMORY;
}
}
size = (len_value + 1 + lstrlenW( data ) + 1) * sizeof(WCHAR);
- if (!(p = newval = msi_alloc( size )))
+ if (!(p = newval = malloc( size )))
{
res = ERROR_OUTOFMEMORY;
goto done;
msiobj_release( &uirow->hdr );
if (env) RegCloseKey(env);
- msi_free(deformatted);
- msi_free(data);
- msi_free(newval);
+ free(deformatted);
+ free(data);
+ free(newval);
return res;
}
if (res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ))
goto done;
- if (!(new_value = msi_alloc( size ))) goto done;
+ if (!(new_value = malloc( size ))) goto done;
res = RegQueryValueExW( env, name, NULL, &type, (BYTE *)new_value, &size );
if (res != ERROR_SUCCESS)
msiobj_release( &uirow->hdr );
if (env) RegCloseKey( env );
- msi_free( deformatted );
- msi_free( new_value );
+ free( deformatted );
+ free( new_value );
return r;
}
id = msi_dup_property( package->db, L"ProductID" );
if (id)
{
- msi_free( id );
+ free( id );
return ERROR_SUCCESS;
}
template = msi_dup_property( package->db, L"PIDTemplate" );
r = msi_set_property( package->db, L"ProductID", key, -1 );
#endif
}
- msi_free( template );
- msi_free( key );
+ free( template );
+ free( key );
return r;
}
else
len += ARRAY_SIZE( L"ALL" );
- if (!(cmd = msi_alloc( len * sizeof(WCHAR) )))
+ if (!(cmd = malloc( len * sizeof(WCHAR) )))
{
- msi_free( product );
- msi_free( features );
+ free( product );
+ free( features );
return ERROR_OUTOFMEMORY;
}
swprintf( cmd, len, L"msiexec /qn /i %s REMOVE=%s", product, features ? features : L"ALL" );
- msi_free( product );
- msi_free( features );
+ free( product );
+ free( features );
memset( &si, 0, sizeof(STARTUPINFOW) );
ret = CreateProcessW( NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &info );
- msi_free( cmd );
+ free( cmd );
if (!ret) return GetLastError();
CloseHandle( info.hThread );
return ERROR_SUCCESS;
}
-static BOOL msi_bind_image( MSIPACKAGE *package, const char *filename, const char *path )
+static void bind_image( MSIPACKAGE *package, const char *filename, const char *path )
{
- BOOL ret;
msi_disable_fs_redirection( package );
- ret = BindImage( filename, path, NULL );
+ if (!BindImage( filename, path, NULL )) WARN( "failed to bind image %lu\n", GetLastError() );
msi_revert_fs_redirection( package );
- return ret;
-}
-
-static void bind_image( MSIPACKAGE *package, const char *filename, const char *path )
-{
- if (!msi_bind_image( package, filename, path ))
- {
- WARN( "failed to bind image %lu\n", GetLastError() );
- }
}
static UINT ITERATE_BindImage( MSIRECORD *rec, LPVOID param )
if ((pathA = strdupWtoA( pathW )))
{
bind_image( package, filenameA, pathA );
- msi_free( pathA );
+ free( pathA );
}
- msi_free( pathW );
+ free( pathW );
}
}
- msi_free( path_list );
- msi_free( filenameA );
+ free( path_list );
+ free( filenameA );
return ERROR_SUCCESS;
}
return ERROR_SUCCESS;
}
-static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, LPCSTR action, LPCWSTR table )
+static UINT unimplemented_action_stub( MSIPACKAGE *package, LPCSTR action, LPCWSTR table )
{
MSIQUERY *view;
DWORD count = 0;
static UINT ACTION_IsolateComponents( MSIPACKAGE *package )
{
- return msi_unimplemented_action_stub( package, "IsolateComponents", L"IsolateComponent" );
+ return unimplemented_action_stub( package, "IsolateComponents", L"IsolateComponent" );
}
static UINT ACTION_RMCCPSearch( MSIPACKAGE *package )
{
- return msi_unimplemented_action_stub( package, "RMCCPSearch", L"CCPSearch" );
+ return unimplemented_action_stub( package, "RMCCPSearch", L"CCPSearch" );
}
static UINT ACTION_RegisterComPlus( MSIPACKAGE *package )
{
- return msi_unimplemented_action_stub( package, "RegisterComPlus", L"Complus" );
+ return unimplemented_action_stub( package, "RegisterComPlus", L"Complus" );
}
static UINT ACTION_UnregisterComPlus( MSIPACKAGE *package )
{
- return msi_unimplemented_action_stub( package, "UnregisterComPlus", L"Complus" );
+ return unimplemented_action_stub( package, "UnregisterComPlus", L"Complus" );
}
static UINT ACTION_InstallSFPCatalogFile( MSIPACKAGE *package )
{
- return msi_unimplemented_action_stub( package, "InstallSFPCatalogFile", L"SFPCatalog" );
+ return unimplemented_action_stub( package, "InstallSFPCatalogFile", L"SFPCatalog" );
}
static const struct
LPWSTR p, dir;
LPCWSTR file;
- dir = strdupW(szPackagePath);
+ dir = wcsdup(szPackagePath);
p = wcsrchr(dir, '\\');
if (p)
{
}
else
{
- msi_free(dir);
- dir = msi_alloc(MAX_PATH * sizeof(WCHAR));
+ free(dir);
+ dir = malloc(MAX_PATH * sizeof(WCHAR));
GetCurrentDirectoryW(MAX_PATH, dir);
lstrcatW(dir, L"\\");
file = szPackagePath;
}
- msi_free( package->PackagePath );
- package->PackagePath = msi_alloc((lstrlenW(dir) + lstrlenW(file) + 1) * sizeof(WCHAR));
+ free(package->PackagePath);
+ package->PackagePath = malloc((wcslen(dir) + wcslen(file) + 1) * sizeof(WCHAR));
if (!package->PackagePath)
{
- msi_free(dir);
+ free(dir);
return ERROR_OUTOFMEMORY;
}
lstrcpyW(package->PackagePath, dir);
lstrcatW(package->PackagePath, file);
- msi_free(dir);
+ free(dir);
msi_set_sourcedir_props(package, FALSE);
}
if (wcsicmp( productcode, package->ProductCode ))
{
TRACE( "product code changed %s -> %s\n", debugstr_w(package->ProductCode), debugstr_w(productcode) );
- msi_free( package->ProductCode );
+ free( package->ProductCode );
package->ProductCode = productcode;
}
- else msi_free( productcode );
+ else free( productcode );
if (msi_get_property_int( package->db, L"DISABLEROLLBACK", 0 ))
{
WARN("installation failed, running rollback script\n");
execute_script( package, SCRIPT_ROLLBACK );
}
- msi_free( reinstall );
- msi_free( action );
+ free( reinstall );
+ free( action );
if (rc == ERROR_SUCCESS && package->need_reboot_at_end)
return ERROR_SUCCESS_REBOOT_REQUIRED;
WINE_DEFAULT_DEBUG_CHANNEL(msidb);
-typedef struct tagMSIALTERVIEW
+struct alter_view
{
MSIVIEW view;
MSIDATABASE *db;
MSIVIEW *table;
column_info *colinfo;
INT hold;
-} MSIALTERVIEW;
+};
static UINT ALTER_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p %d %d %p\n", av, row, col, val );
static UINT ALTER_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p %d %d %p\n", av, row, col, stm );
static UINT ALTER_execute( struct tagMSIVIEW *view, MSIRECORD *record )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
UINT ref;
TRACE("%p %p\n", av, record);
static UINT ALTER_close( struct tagMSIVIEW *view )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p\n", av );
static UINT ALTER_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p %p %p\n", av, rows, cols );
static UINT ALTER_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p %d %p %p %p %p\n", av, n, name, type, temporary, table_name );
static UINT ALTER_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
MSIRECORD *rec, UINT row )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p %d %p\n", av, eModifyMode, rec );
static UINT ALTER_delete( struct tagMSIVIEW *view )
{
- MSIALTERVIEW *av = (MSIALTERVIEW*)view;
+ struct alter_view *av = (struct alter_view *)view;
TRACE("%p\n", av );
if (av->table)
av->table->ops->delete( av->table );
- msi_free( av );
+ free( av );
return ERROR_SUCCESS;
}
UINT ALTER_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_info *colinfo, int hold )
{
- MSIALTERVIEW *av;
+ struct alter_view *av;
UINT r;
TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
- av = msi_alloc_zero( sizeof *av );
+ av = calloc( 1, sizeof *av );
if( !av )
return ERROR_FUNCTION_FAILED;
r = TABLE_CreateView( db, name, &av->table );
if (r != ERROR_SUCCESS)
{
- msi_free( av );
+ free( av );
return r;
}
WINE_DEFAULT_DEBUG_CHANNEL(msi);
-typedef struct tagMSISIGNATURE
+struct signature
{
LPCWSTR Name; /* NOT owned by this structure */
LPWSTR File;
FILETIME MinTime;
FILETIME MaxTime;
LPWSTR Languages;
-}MSISIGNATURE;
+};
void msi_parse_version_string(LPCWSTR verStr, PDWORD ms, PDWORD ls)
{
* Returns ERROR_SUCCESS upon success (where not finding the record counts as
* success), something else on error.
*/
-static UINT get_signature( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHAR *name )
+static UINT get_signature( MSIPACKAGE *package, struct signature *sig, const WCHAR *name )
{
WCHAR *minVersion, *maxVersion, *p;
MSIRECORD *row;
if (minVersion)
{
msi_parse_version_string( minVersion, &sig->MinVersionMS, &sig->MinVersionLS );
- msi_free( minVersion );
+ free( minVersion );
}
maxVersion = msi_dup_record_field(row,4);
if (maxVersion)
{
msi_parse_version_string( maxVersion, &sig->MaxVersionMS, &sig->MaxVersionLS );
- msi_free( maxVersion );
+ free( maxVersion );
}
sig->MinSize = MSI_RecordGetInteger(row,5);
if (sig->MinSize == MSI_NULL_INTEGER)
}
/* Frees any memory allocated in sig */
-static void free_signature( MSISIGNATURE *sig )
+static void free_signature( struct signature *sig )
{
- msi_free(sig->File);
- msi_free(sig->Languages);
+ free(sig->File);
+ free(sig->Languages);
}
-static WCHAR *search_file( MSIPACKAGE *package, WCHAR *path, MSISIGNATURE *sig )
+static WCHAR *search_file( MSIPACKAGE *package, WCHAR *path, struct signature *sig )
{
VS_FIXEDFILEINFO *info;
DWORD attr;
attr = msi_get_file_attributes( package, path );
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
- return strdupW(path);
+ return wcsdup(path);
return NULL;
}
size = msi_get_file_version_info( package, path, 0, NULL );
if (!size)
- return strdupW(path);
+ return wcsdup(path);
- buffer = msi_alloc(size);
+ buffer = malloc(size);
if (!buffer)
return NULL;
goto done;
}
- val = strdupW(path);
+ val = wcsdup(path);
done:
- msi_free(buffer);
+ free(buffer);
return val;
}
-static UINT search_components( MSIPACKAGE *package, WCHAR **appValue, MSISIGNATURE *sig )
+static UINT search_components( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
MSIRECORD *row, *rec;
LPCWSTR signature, guid;
else
PathAddBackslashW(path);
- *appValue = strdupW(path);
+ *appValue = wcsdup(path);
}
else if (sigpresent)
{
attr = msi_get_file_attributes( package, path );
if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY))
- *appValue = strdupW(path);
+ *appValue = wcsdup(path);
}
done:
if (*(LPCWSTR)value == '#')
{
/* escape leading pound with another */
- *appValue = msi_alloc(sz + sizeof(WCHAR));
+ *appValue = malloc(sz + sizeof(WCHAR));
(*appValue)[0] = '#';
lstrcpyW(*appValue + 1, (LPCWSTR)value);
}
else
{
- *appValue = msi_alloc(sz);
+ *appValue = malloc(sz);
lstrcpyW(*appValue, (LPCWSTR)value);
}
break;
/* 7 chars for digits, 1 for NULL, 1 for #, and 1 for sign
* char if needed
*/
- *appValue = msi_alloc(10 * sizeof(WCHAR));
+ *appValue = malloc(10 * sizeof(WCHAR));
swprintf(*appValue, 10, L"#%d", *(const DWORD *)value);
break;
case REG_EXPAND_SZ:
sz = ExpandEnvironmentStringsW((LPCWSTR)value, NULL, 0);
- *appValue = msi_alloc(sz * sizeof(WCHAR));
+ *appValue = malloc(sz * sizeof(WCHAR));
ExpandEnvironmentStringsW((LPCWSTR)value, *appValue, sz);
break;
case REG_BINARY:
/* #x<nibbles>\0 */
- *appValue = msi_alloc((sz * 2 + 3) * sizeof(WCHAR));
+ *appValue = malloc((sz * 2 + 3) * sizeof(WCHAR));
lstrcpyW(*appValue, L"#x");
ptr = *appValue + lstrlenW(L"#x");
for (i = 0; i < sz; i++, ptr += 2)
}
}
-static UINT search_directory( MSIPACKAGE *, MSISIGNATURE *, const WCHAR *, int, WCHAR ** );
+static UINT search_directory( MSIPACKAGE *, struct signature *, const WCHAR *, int, WCHAR ** );
-static UINT search_reg( MSIPACKAGE *package, WCHAR **appValue, MSISIGNATURE *sig )
+static UINT search_reg( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
const WCHAR *keyPath, *valueName;
WCHAR *deformatted = NULL, *ptr = NULL, *end;
goto end;
}
- msi_free(deformatted);
+ free(deformatted);
deformat_string(package, valueName, &deformatted);
rc = RegQueryValueExW(key, deformatted, NULL, NULL, NULL, &sz);
/* FIXME: sanity-check sz before allocating (is there an upper-limit
* on the value of a property?)
*/
- value = msi_alloc( sz );
+ value = malloc(sz);
rc = RegQueryValueExW(key, deformatted, NULL, ®Type, value, &sz);
if (rc)
{
sz = ExpandEnvironmentStringsW((LPCWSTR)value, NULL, 0);
if (sz)
{
- LPWSTR buf = msi_alloc(sz * sizeof(WCHAR));
+ WCHAR *buf = malloc(sz * sizeof(WCHAR));
ExpandEnvironmentStringsW((LPCWSTR)value, buf, sz);
- msi_free(value);
+ free(value);
value = (LPBYTE)buf;
}
}
type, debugstr_w(keyPath), debugstr_w(valueName));
}
end:
- msi_free( value );
+ free( value );
RegCloseKey( key );
- msi_free( deformatted );
+ free( deformatted );
msiobj_release(&row->hdr);
return ERROR_SUCCESS;
int i = 1;
if (field == 0)
- return strdupW(buf);
+ return wcsdup(buf);
beg = buf;
while ((end = wcschr(beg, ',')) && i < field)
end = beg + lstrlenW(beg);
*end = '\0';
- return strdupW(beg);
+ return wcsdup(beg);
}
-static UINT search_ini( MSIPACKAGE *package, WCHAR **appValue, MSISIGNATURE *sig )
+static UINT search_ini( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
MSIRECORD *row;
LPWSTR fileName, section, key;
}
}
- msi_free(fileName);
- msi_free(section);
- msi_free(key);
+ free(fileName);
+ free(section);
+ free(key);
msiobj_release(&row->hdr);
deformat_string(package, ptr, &deformatted);
if (!deformatted || lstrlenW(deformatted) > len - 1)
{
- msi_free(deformatted);
+ free(deformatted);
return;
}
lstrcpyW(dst, deformatted);
dst[lstrlenW(deformatted)] = '\0';
- msi_free(deformatted);
+ free(deformatted);
}
static LANGID *parse_languages( const WCHAR *languages, DWORD *num_ids )
{
UINT i, count = 1;
- WCHAR *str = strdupW( languages ), *p, *q;
+ WCHAR *str = wcsdup( languages ), *p, *q;
LANGID *ret;
if (!str) return NULL;
for (p = q = str; (q = wcschr( q, ',' )); q++) count++;
- if (!(ret = msi_alloc( count * sizeof(LANGID) )))
+ if (!(ret = malloc( count * sizeof(LANGID) )))
{
- msi_free( str );
+ free( str );
return NULL;
}
i = 0;
p = q + 1;
i++;
}
- msi_free( str );
+ free( str );
*num_ids = count;
return ret;
}
}
done:
- msi_free( ids );
+ free( ids );
return found;
}
* Return ERROR_SUCCESS in case of success (whether or not the file matches),
* something else if an install-halting error occurs.
*/
-static UINT file_version_matches( MSIPACKAGE *package, const MSISIGNATURE *sig, const WCHAR *filePath,
+static UINT file_version_matches( MSIPACKAGE *package, const struct signature *sig, const WCHAR *filePath,
BOOL *matches )
{
UINT len;
*matches = FALSE;
if (!size) return ERROR_SUCCESS;
- if (!(version = msi_alloc( size ))) return ERROR_OUTOFMEMORY;
+ if (!(version = malloc( size ))) return ERROR_OUTOFMEMORY;
if (msi_get_file_version_info( package, filePath, size, version ))
VerQueryValueW( version, L"\\", (void **)&info, &len );
}
else *matches = TRUE;
}
- msi_free( version );
+ free( version );
return ERROR_SUCCESS;
}
* Return ERROR_SUCCESS in case of success (whether or not the file matches),
* something else if an install-halting error occurs.
*/
-static UINT file_matches_sig( MSIPACKAGE *package, const MSISIGNATURE *sig, const WIN32_FIND_DATAW *findData,
+static UINT file_matches_sig( MSIPACKAGE *package, const struct signature *sig, const WIN32_FIND_DATAW *findData,
const WCHAR *fullFilePath, BOOL *matches )
{
UINT rc = ERROR_SUCCESS;
* Returns ERROR_SUCCESS on success (which may include non-critical errors),
* something else on failures which should halt the install.
*/
-static UINT recurse_search_directory( MSIPACKAGE *package, WCHAR **appValue, MSISIGNATURE *sig, const WCHAR *dir,
+static UINT recurse_search_directory( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig, const WCHAR *dir,
int depth )
{
HANDLE hFind;
* isn't backslash-terminated.
*/
len = dirLen + max(fileLen, lstrlenW(L"*.*")) + 2;
- buf = msi_alloc(len * sizeof(WCHAR));
+ buf = malloc(len * sizeof(WCHAR));
if (!buf)
return ERROR_OUTOFMEMORY;
}
if (*appValue != buf)
- msi_free(buf);
+ free(buf);
return rc;
}
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
{
TRACE("directory exists, returning %s\n", debugstr_w(dir));
- *appValue = strdupW(dir);
+ *appValue = wcsdup(dir);
}
return ERROR_SUCCESS;
return ret;
}
-static UINT search_directory( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHAR *path, int depth, WCHAR **appValue )
+static UINT search_directory( MSIPACKAGE *package, struct signature *sig, const WCHAR *path, int depth, WCHAR **appValue )
{
UINT rc;
DWORD attr;
- LPWSTR val = NULL;
+ WCHAR *val = NULL, *new_val;
TRACE("%p, %p, %s, %d, %p\n", package, sig, debugstr_w(path), depth, appValue);
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) &&
val && val[lstrlenW(val) - 1] != '\\')
{
- val = msi_realloc(val, (lstrlenW(val) + 2) * sizeof(WCHAR));
- if (!val)
+ new_val = realloc(val, (wcslen(val) + 2) * sizeof(WCHAR));
+ if (!new_val)
+ {
+ free(val);
+ val = NULL;
rc = ERROR_OUTOFMEMORY;
+ }
else
+ {
+ val = new_val;
PathAddBackslashW(val);
+ }
}
*appValue = val;
return rc;
}
-static UINT search_sig_name( MSIPACKAGE *, const WCHAR *, MSISIGNATURE *, WCHAR ** );
+static UINT search_sig_name( MSIPACKAGE *, const WCHAR *, struct signature *, WCHAR ** );
-static UINT search_dr( MSIPACKAGE *package, WCHAR **appValue, MSISIGNATURE *sig )
+static UINT search_dr( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
LPWSTR parent = NULL;
LPCWSTR parentName;
parentName = MSI_RecordGetString(row, 2);
if (parentName)
{
- MSISIGNATURE parentSig;
+ struct signature parentSig;
search_sig_name( package, parentName, &parentSig, &parent );
free_signature( &parentSig );
rc = search_directory( package, sig, path, depth, appValue );
- msi_free(parent);
+ free(parent);
msiobj_release(&row->hdr);
TRACE("returning %d\n", rc);
return rc;
}
-static UINT search_sig_name( MSIPACKAGE *package, const WCHAR *sigName, MSISIGNATURE *sig, WCHAR **appValue )
+static UINT search_sig_name( MSIPACKAGE *package, const WCHAR *sigName, struct signature *sig, WCHAR **appValue )
{
UINT rc;
MSIPACKAGE *package = param;
LPCWSTR propName, sigName;
LPWSTR value = NULL;
- MSISIGNATURE sig;
+ struct signature sig;
MSIRECORD *uirow;
UINT r;
if (r == ERROR_SUCCESS && !wcscmp( propName, L"SourceDir" ))
msi_reset_source_folders( package );
- msi_free(value);
+ free(value);
}
free_signature( &sig );
MSIPACKAGE *package = param;
LPCWSTR signature;
LPWSTR value = NULL;
- MSISIGNATURE sig;
+ struct signature sig;
UINT r = ERROR_SUCCESS;
signature = MSI_RecordGetString(row, 1);
{
TRACE("Found signature %s\n", debugstr_w(signature));
msi_set_property( package->db, L"CCP_Success", L"1", -1 );
- msi_free(value);
+ free(value);
r = ERROR_NO_MORE_ITEMS;
}
WINE_DEFAULT_DEBUG_CHANNEL(msi);
-static BOOL load_fusion_dlls( MSIPACKAGE *package )
+static void load_fusion_dlls( MSIPACKAGE *package )
{
HRESULT (WINAPI *pLoadLibraryShim)( const WCHAR *, const WCHAR *, void *, HMODULE * );
WCHAR path[MAX_PATH];
DWORD len = GetSystemDirectoryW( path, MAX_PATH );
lstrcpyW( path + len, L"\\mscoree.dll" );
- if (package->hmscoree || !(package->hmscoree = LoadLibraryW( path ))) return TRUE;
+ if (!package->hmscoree && !(package->hmscoree = LoadLibraryW( path ))) return;
if (!(pLoadLibraryShim = (void *)GetProcAddress( package->hmscoree, "LoadLibraryShim" )))
{
FreeLibrary( package->hmscoree );
package->hmscoree = NULL;
- return TRUE;
+ return;
}
- pLoadLibraryShim( L"fusion.dll", L"v1.0.3705", NULL, &package->hfusion10 );
- pLoadLibraryShim( L"fusion.dll", L"v1.1.4322", NULL, &package->hfusion11 );
- pLoadLibraryShim( L"fusion.dll", L"v2.0.50727", NULL, &package->hfusion20 );
- pLoadLibraryShim( L"fusion.dll", L"v4.0.30319", NULL, &package->hfusion40 );
-
- return TRUE;
+ if (!package->hfusion10) pLoadLibraryShim( L"fusion.dll", L"v1.0.3705", NULL, &package->hfusion10 );
+ if (!package->hfusion11) pLoadLibraryShim( L"fusion.dll", L"v1.1.4322", NULL, &package->hfusion11 );
+ if (!package->hfusion20) pLoadLibraryShim( L"fusion.dll", L"v2.0.50727", NULL, &package->hfusion20 );
+ if (!package->hfusion40) pLoadLibraryShim( L"fusion.dll", L"v4.0.30319", NULL, &package->hfusion40 );
}
-BOOL msi_init_assembly_caches( MSIPACKAGE *package )
+static BOOL init_assembly_caches( MSIPACKAGE *package )
{
HRESULT (WINAPI *pCreateAssemblyCache)( IAssemblyCache **, DWORD );
- if (package->cache_sxs) return TRUE;
- if (CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE;
+ if (!package->cache_sxs && CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE;
- if (!load_fusion_dlls( package )) return FALSE;
+ load_fusion_dlls( package );
package->pGetFileVersion = (void *)GetProcAddress( package->hmscoree, "GetFileVersion" ); /* missing from v1.0.3705 */
- if (package->hfusion10)
+ if (package->hfusion10 && !package->cache_net[CLR_VERSION_V10])
{
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion10, "CreateAssemblyCache" );
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V10], 0 );
}
- if (package->hfusion11)
+ if (package->hfusion11 && !package->cache_net[CLR_VERSION_V11])
{
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion11, "CreateAssemblyCache" );
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V11], 0 );
}
- if (package->hfusion20)
+ if (package->hfusion20 && !package->cache_net[CLR_VERSION_V20])
{
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion20, "CreateAssemblyCache" );
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V20], 0 );
}
- if (package->hfusion40)
+ if (package->hfusion40 && !package->cache_net[CLR_VERSION_V40])
{
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyCache" );
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V40], 0 );
const WCHAR *value = MSI_RecordGetString( rec, 3 );
int len = lstrlenW( L"%s=\"%s\"" ) + lstrlenW( attr ) + lstrlenW( value );
- if (!(name->attrs[name->index] = msi_alloc( len * sizeof(WCHAR) )))
+ if (!(name->attrs[name->index] = malloc( len * sizeof(WCHAR) )))
return ERROR_OUTOFMEMORY;
if (!wcsicmp( attr, L"name" )) lstrcpyW( name->attrs[name->index++], value );
MSI_IterateRecords( view, &name.count, NULL, NULL );
if (!name.count) goto done;
- name.attrs = msi_alloc( name.count * sizeof(WCHAR *) );
+ name.attrs = malloc( name.count * sizeof(WCHAR *) );
if (!name.attrs) goto done;
MSI_IterateRecords( view, NULL, get_assembly_name_attribute, &name );
len = 0;
for (i = 0; i < name.count; i++) len += lstrlenW( name.attrs[i] ) + 1;
- display_name = msi_alloc( (len + 1) * sizeof(WCHAR) );
+ display_name = malloc( (len + 1) * sizeof(WCHAR) );
if (display_name)
{
display_name[0] = 0;
msiobj_release( &view->hdr );
if (name.attrs)
{
- for (i = 0; i < name.count; i++) msi_free( name.attrs[i] );
- msi_free( name.attrs );
+ for (i = 0; i < name.count; i++) free( name.attrs[i] );
+ free( name.attrs );
}
return display_name;
}
-static BOOL is_assembly_installed( IAssemblyCache *cache, const WCHAR *display_name )
-{
- HRESULT hr;
- ASSEMBLY_INFO info;
-
- if (!cache) return FALSE;
-
- memset( &info, 0, sizeof(info) );
- info.cbAssemblyInfo = sizeof(info);
- hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, display_name, &info );
- if (hr == S_OK /* sxs version */ || hr == E_NOT_SUFFICIENT_BUFFER)
- {
- return (info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED);
- }
- TRACE( "QueryAssemblyInfo returned %#lx\n", hr );
- return FALSE;
-}
-
WCHAR *msi_get_assembly_path( MSIPACKAGE *package, const WCHAR *displayname )
{
HRESULT hr;
ASSEMBLY_INFO info;
- IAssemblyCache *cache = package->cache_net[CLR_VERSION_V40];
+ IAssemblyCache *cache;
- if (!cache) return NULL;
+ if (!init_assembly_caches( package ) || !(cache = package->cache_net[CLR_VERSION_V40])) return NULL;
memset( &info, 0, sizeof(info) );
info.cbAssemblyInfo = sizeof(info);
hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
if (hr != E_NOT_SUFFICIENT_BUFFER) return NULL;
- if (!(info.pszCurrentAssemblyPathBuf = msi_alloc( info.cchBuf * sizeof(WCHAR) ))) return NULL;
+ if (!(info.pszCurrentAssemblyPathBuf = malloc( info.cchBuf * sizeof(WCHAR) ))) return NULL;
hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
if (FAILED( hr ))
{
- msi_free( info.pszCurrentAssemblyPathBuf );
+ free( info.pszCurrentAssemblyPathBuf );
return NULL;
}
TRACE("returning %s\n", debugstr_w(info.pszCurrentAssemblyPathBuf));
WCHAR *str;
DWORD len = 0;
- if (!package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum) return NULL;
+ if (!init_assembly_caches( package ) || !package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum)
+ return NULL;
hr = package->pCreateAssemblyNameObject( &name, displayname, CANOF_PARSE_DISPLAY_NAME, NULL );
if (FAILED( hr )) return NULL;
hr = IAssemblyName_GetName( name, &len, NULL );
- if (hr != E_NOT_SUFFICIENT_BUFFER || !(str = msi_alloc( len * sizeof(WCHAR) )))
+ if (hr != E_NOT_SUFFICIENT_BUFFER || !(str = malloc( len * sizeof(WCHAR) )))
{
IAssemblyName_Release( name );
return NULL;
IAssemblyName_Release( name );
if (FAILED( hr ))
{
- msi_free( str );
+ free( str );
return NULL;
}
hr = package->pCreateAssemblyNameObject( &name, str, 0, NULL );
- msi_free( str );
+ free( str );
if (FAILED( hr )) return NULL;
hr = package->pCreateAssemblyEnum( &ret, NULL, name, ASM_CACHE_GAC, NULL );
L"v4.0.30319"
};
-static const WCHAR *get_clr_version_str( enum clr_version version )
-{
- if (version >= ARRAY_SIZE( clr_version )) return L"unknown";
- return clr_version[version];
-}
-
-/* assembly caches must be initialized */
MSIASSEMBLY *msi_load_assembly( MSIPACKAGE *package, MSICOMPONENT *comp )
{
MSIRECORD *rec;
MSIASSEMBLY *a;
if (!(rec = get_assembly_record( package, comp->Component ))) return NULL;
- if (!(a = msi_alloc_zero( sizeof(MSIASSEMBLY) )))
+ if (!(a = calloc( 1, sizeof(MSIASSEMBLY) )))
{
msiobj_release( &rec->hdr );
return NULL;
}
- a->feature = strdupW( MSI_RecordGetString( rec, 2 ) );
+ a->feature = wcsdup( MSI_RecordGetString( rec, 2 ) );
TRACE("feature %s\n", debugstr_w(a->feature));
- a->manifest = strdupW( MSI_RecordGetString( rec, 3 ) );
+ a->manifest = wcsdup( MSI_RecordGetString( rec, 3 ) );
TRACE("manifest %s\n", debugstr_w(a->manifest));
- a->application = strdupW( MSI_RecordGetString( rec, 4 ) );
+ a->application = wcsdup( MSI_RecordGetString( rec, 4 ) );
TRACE("application %s\n", debugstr_w(a->application));
a->attributes = MSI_RecordGetInteger( rec, 5 );
{
WARN("can't get display name\n");
msiobj_release( &rec->hdr );
- msi_free( a->feature );
- msi_free( a->manifest );
- msi_free( a->application );
- msi_free( a );
+ free( a->feature );
+ free( a->manifest );
+ free( a->application );
+ free( a );
return NULL;
}
TRACE("display name %s\n", debugstr_w(a->display_name));
- if (a->application)
- {
- /* We can't check the manifest here because the target path may still change.
- So we assume that the assembly is not installed and lean on the InstallFiles
- action to determine which files need to be installed.
- */
- a->installed = FALSE;
- }
- else
- {
- if (a->attributes == msidbAssemblyAttributesWin32)
- a->installed = is_assembly_installed( package->cache_sxs, a->display_name );
- else
- {
- UINT i;
- for (i = 0; i < CLR_VERSION_MAX; i++)
- {
- a->clr_version[i] = is_assembly_installed( package->cache_net[i], a->display_name );
- if (a->clr_version[i])
- {
- TRACE("runtime version %s\n", debugstr_w(get_clr_version_str( i )));
- a->installed = TRUE;
- break;
- }
- }
- }
- }
- TRACE("assembly is %s\n", a->installed ? "installed" : "not installed");
msiobj_release( &rec->hdr );
return a;
}
hr = package->pGetFileVersion( filename, NULL, 0, &len );
if (hr != E_NOT_SUFFICIENT_BUFFER) return CLR_VERSION_V11;
- if ((strW = msi_alloc( len * sizeof(WCHAR) )))
+ if ((strW = malloc( len * sizeof(WCHAR) )))
{
hr = package->pGetFileVersion( filename, strW, len, &len );
if (hr == S_OK)
for (i = 0; i < CLR_VERSION_MAX; i++)
if (!wcscmp( strW, clr_version[i] )) version = i;
}
- msi_free( strW );
+ free( strW );
}
return version;
}
MSIASSEMBLY *assembly = comp->assembly;
MSIFEATURE *feature = NULL;
+ if (!init_assembly_caches( package )) return ERROR_FUNCTION_FAILED;
+
if (comp->assembly->feature)
feature = msi_get_loaded_feature( package, comp->assembly->feature );
return ERROR_FUNCTION_FAILED;
}
if (feature) feature->Action = INSTALLSTATE_LOCAL;
- assembly->installed = TRUE;
return ERROR_SUCCESS;
}
MSIASSEMBLY *assembly = comp->assembly;
MSIFEATURE *feature = NULL;
+ if (!init_assembly_caches( package )) return ERROR_FUNCTION_FAILED;
+
if (comp->assembly->feature)
feature = msi_get_loaded_feature( package, comp->assembly->feature );
}
}
if (feature) feature->Action = INSTALLSTATE_ABSENT;
- assembly->installed = FALSE;
return ERROR_SUCCESS;
}
UINT i;
WCHAR *ret;
- if (!(ret = msi_alloc( (lstrlenW( filename ) + 1) * sizeof(WCHAR) )))
+ if (!(ret = malloc( (wcslen( filename ) + 1) * sizeof(WCHAR) )))
return NULL;
for (i = 0; filename[i]; i++)
if ((res = open_assemblies_key( context, win32, &root )))
{
- msi_free( path );
+ free( path );
return res;
}
res = RegCreateKeyW( root, path, hkey );
RegCloseKey( root );
- msi_free( path );
+ free( path );
return res;
}
if ((res = open_assemblies_key( context, win32, &root )))
{
- msi_free( path );
+ free( path );
return res;
}
res = RegDeleteKeyW( root, path );
RegCloseKey( root );
- msi_free( path );
+ free( path );
return res;
}
#define REG_INDEX_CLASSES_ROOT 0
#define REG_INDEX_DYN_DATA 6
-typedef struct AutomationObject AutomationObject;
+struct automation_object;
-/* function that is called from AutomationObject::Invoke, specific to this type of object */
-typedef HRESULT (*auto_invoke_func)(AutomationObject* This,
- DISPID dispIdMember, REFIID riid, LCID lcid, WORD flags, DISPPARAMS* pDispParams,
- VARIANT* result, EXCEPINFO* ei, UINT* arg_err);
-/* function that is called from AutomationObject::Release when the object is being freed
- to free any private data structures (or NULL) */
-typedef void (*auto_free_func)(AutomationObject* This);
-
-typedef struct {
+struct tid_id
+{
REFIID riid;
- auto_invoke_func fn_invoke;
- auto_free_func fn_free;
-} tid_id_t;
-
+ /* function that is called from AutomationObject::Invoke, specific to this type of object */
+ HRESULT (*fn_invoke)(struct automation_object *, DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *,
+ EXCEPINFO *, UINT *);
+ /* function that is called from AutomationObject::Release when the object is being freed
+ to free any private data structures (or NULL) */
+ void (*fn_free)(struct automation_object *);
+};
-static HRESULT database_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static HRESULT installer_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static HRESULT record_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static HRESULT session_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static HRESULT list_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static void list_free(AutomationObject*);
-static HRESULT summaryinfo_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static HRESULT view_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static HRESULT database_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static HRESULT installer_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static HRESULT record_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static HRESULT session_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static HRESULT list_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static void list_free(struct automation_object*);
+static HRESULT summaryinfo_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+static HRESULT view_invoke(struct automation_object*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
-static tid_id_t tid_ids[] = {
+static struct tid_id tid_ids[] =
+{
{ &DIID_Database, database_invoke },
{ &DIID_Installer, installer_invoke },
{ &DIID_Record, record_invoke },
}
/*
- * AutomationObject - "base" class for all automation objects. For each interface, we implement Invoke function
- * called from AutomationObject::Invoke.
+ * struct automation_object - "base" class for all automation objects. For each interface, we implement Invoke
+ * function called from AutomationObject::Invoke.
*/
-struct AutomationObject {
+struct automation_object
+{
IDispatch IDispatch_iface;
IProvideMultipleClassInfo IProvideMultipleClassInfo_iface;
LONG ref;
MSIHANDLE msiHandle;
};
-typedef struct {
- AutomationObject autoobj;
+struct list_object
+{
+ struct automation_object autoobj;
int count;
VARIANT *data;
-} ListObject;
+};
static HRESULT create_database(MSIHANDLE, IDispatch**);
-static HRESULT create_list_enumerator(ListObject*, void**);
+static HRESULT create_list_enumerator(struct list_object *, void **);
static HRESULT create_summaryinfo(MSIHANDLE, IDispatch**);
static HRESULT create_view(MSIHANDLE, IDispatch**);
-/* ListEnumerator - IEnumVARIANT implementation for MSI automation lists */
-typedef struct {
+/* struct list_enumerator - IEnumVARIANT implementation for MSI automation lists */
+struct list_enumerator
+{
IEnumVARIANT IEnumVARIANT_iface;
LONG ref;
- /* Current position and pointer to AutomationObject that stores actual data */
+ /* Current position and pointer to struct automation_object that stores actual data */
ULONG pos;
- ListObject *list;
-} ListEnumerator;
+ struct list_object *list;
+};
-typedef struct {
- AutomationObject autoobj;
+struct session_object
+{
+ struct automation_object autoobj;
IDispatch *installer;
-} SessionObject;
+};
-static inline AutomationObject *impl_from_IProvideMultipleClassInfo( IProvideMultipleClassInfo *iface )
+static inline struct automation_object *impl_from_IProvideMultipleClassInfo( IProvideMultipleClassInfo *iface )
{
- return CONTAINING_RECORD(iface, AutomationObject, IProvideMultipleClassInfo_iface);
+ return CONTAINING_RECORD(iface, struct automation_object, IProvideMultipleClassInfo_iface);
}
-static inline AutomationObject *impl_from_IDispatch( IDispatch *iface )
+static inline struct automation_object *impl_from_IDispatch( IDispatch *iface )
{
- return CONTAINING_RECORD(iface, AutomationObject, IDispatch_iface);
+ return CONTAINING_RECORD(iface, struct automation_object, IDispatch_iface);
}
/* AutomationObject methods */
static HRESULT WINAPI AutomationObject_QueryInterface(IDispatch* iface, REFIID riid, void** ppvObject)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
static ULONG WINAPI AutomationObject_AddRef(IDispatch* iface)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
TRACE("(%p/%p)\n", iface, This);
static ULONG WINAPI AutomationObject_Release(IDispatch* iface)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This);
{
if (tid_ids[This->tid].fn_free) tid_ids[This->tid].fn_free(This);
MsiCloseHandle(This->msiHandle);
- msi_free(This);
+ free(This);
}
return ref;
IDispatch* iface,
UINT* pctinfo)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
TRACE("(%p/%p)->(%p)\n", iface, This, pctinfo);
*pctinfo = 1;
LCID lcid,
ITypeInfo** ppTInfo)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
HRESULT hr;
TRACE( "(%p/%p)->(%u, %ld, %p)\n", iface, This, iTInfo, lcid, ppTInfo );
LCID lcid,
DISPID* rgDispId)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
ITypeInfo *ti;
HRESULT hr;
EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
- AutomationObject *This = impl_from_IDispatch(iface);
+ struct automation_object *This = impl_from_IDispatch(iface);
HRESULT hr;
unsigned int uArgErr;
VARIANT varResultDummy;
REFIID riid,
VOID** ppvoid)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
return IDispatch_QueryInterface(&This->IDispatch_iface, riid, ppvoid);
}
static ULONG WINAPI ProvideMultipleClassInfo_AddRef(IProvideMultipleClassInfo* iface)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
return IDispatch_AddRef(&This->IDispatch_iface);
}
static ULONG WINAPI ProvideMultipleClassInfo_Release(IProvideMultipleClassInfo* iface)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
return IDispatch_Release(&This->IDispatch_iface);
}
static HRESULT WINAPI ProvideMultipleClassInfo_GetClassInfo(IProvideMultipleClassInfo* iface, ITypeInfo** ppTI)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
HRESULT hr;
TRACE("(%p/%p)->(%p)\n", iface, This, ppTI);
static HRESULT WINAPI ProvideMultipleClassInfo_GetGUID(IProvideMultipleClassInfo* iface, DWORD dwGuidKind, GUID* pGUID)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
TRACE("(%p/%p)->(%lu, %s)\n", iface, This, dwGuidKind, debugstr_guid(pGUID));
if (dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID)
static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo* iface, ULONG* pcti)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
TRACE("(%p/%p)->(%p)\n", iface, This, pcti);
*pcti = 1;
IID* piidPrimary,
IID* piidSource)
{
- AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
+ struct automation_object *This = impl_from_IProvideMultipleClassInfo(iface);
TRACE("(%p/%p)->(%lu, %#lx, %p, %p, %p, %p, %p)\n", iface, This, iti, dwFlags, ti, pdwTIFlags, pcdispidReserved,
piidPrimary, piidSource);
ProvideMultipleClassInfo_GetInfoOfIndex
};
-static void init_automation_object(AutomationObject *This, MSIHANDLE msiHandle, tid_t tid)
+static void init_automation_object(struct automation_object *This, MSIHANDLE msiHandle, tid_t tid)
{
TRACE("%p, %lu, %s\n", This, msiHandle, debugstr_guid(get_riid_from_tid(tid)));
* ListEnumerator methods
*/
-static inline ListEnumerator *impl_from_IEnumVARIANT(IEnumVARIANT* iface)
+static inline struct list_enumerator *impl_from_IEnumVARIANT(IEnumVARIANT* iface)
{
- return CONTAINING_RECORD(iface, ListEnumerator, IEnumVARIANT_iface);
+ return CONTAINING_RECORD(iface, struct list_enumerator, IEnumVARIANT_iface);
}
static HRESULT WINAPI ListEnumerator_QueryInterface(IEnumVARIANT* iface, REFIID riid,
void** ppvObject)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
static ULONG WINAPI ListEnumerator_AddRef(IEnumVARIANT* iface)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
TRACE("(%p/%p)\n", iface, This);
static ULONG WINAPI ListEnumerator_Release(IEnumVARIANT* iface)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This);
if (!ref)
{
if (This->list) IDispatch_Release(&This->list->autoobj.IDispatch_iface);
- msi_free(This);
+ free(This);
}
return ref;
static HRESULT WINAPI ListEnumerator_Next(IEnumVARIANT* iface, ULONG celt, VARIANT* rgVar,
ULONG* fetched)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
ULONG i, local;
TRACE("%p, %lu, %p, %p\n", iface, celt, rgVar, fetched);
static HRESULT WINAPI ListEnumerator_Skip(IEnumVARIANT* iface, ULONG celt)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
TRACE("%p, %lu\n", iface, celt);
static HRESULT WINAPI ListEnumerator_Reset(IEnumVARIANT* iface)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
TRACE("(%p)\n", iface);
static HRESULT WINAPI ListEnumerator_Clone(IEnumVARIANT* iface, IEnumVARIANT **ppEnum)
{
- ListEnumerator *This = impl_from_IEnumVARIANT(iface);
+ struct list_enumerator *This = impl_from_IEnumVARIANT(iface);
HRESULT hr;
TRACE("(%p,%p)\n", iface, ppEnum);
};
/* Create a list enumerator, placing the result in the pointer ppObj. */
-static HRESULT create_list_enumerator(ListObject *list, void **ppObj)
+static HRESULT create_list_enumerator(struct list_object *list, void **ppObj)
{
- ListEnumerator *object;
+ struct list_enumerator *object;
TRACE("(%p, %p)\n", list, ppObj);
- object = msi_alloc(sizeof(ListEnumerator));
+ object = malloc(sizeof(*object));
/* Set all the VTable references */
object->IEnumVARIANT_iface.lpVtbl = &ListEnumerator_Vtbl;
}
static HRESULT summaryinfo_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
break;
case VT_LPSTR:
- if (!(str = msi_alloc(++size * sizeof(WCHAR))))
+ if (!(str = malloc(++size * sizeof(WCHAR))))
ERR("Out of memory\n");
else if ((ret = MsiSummaryInfoGetPropertyW(This->msiHandle, V_I4(&varg0), &type, NULL,
NULL, str, &size)) != ERROR_SUCCESS)
V_VT(pVarResult) = VT_BSTR;
V_BSTR(pVarResult) = SysAllocString(str);
}
- msi_free(str);
+ free(str);
break;
case VT_FILETIME:
}
static HRESULT record_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
V_BSTR(pVarResult) = NULL;
if ((ret = MsiRecordGetStringW(This->msiHandle, V_I4(&varg0), NULL, &dwLen)) == ERROR_SUCCESS)
{
- if (!(szString = msi_alloc((++dwLen)*sizeof(WCHAR))))
+ if (!(szString = malloc((++dwLen) * sizeof(WCHAR))))
ERR("Out of memory\n");
else if ((ret = MsiRecordGetStringW(This->msiHandle, V_I4(&varg0), szString, &dwLen)) == ERROR_SUCCESS)
V_BSTR(pVarResult) = SysAllocString(szString);
- msi_free(szString);
+ free(szString);
}
if (ret != ERROR_SUCCESS)
ERR("MsiRecordGetString returned %d\n", ret);
static HRESULT create_record(MSIHANDLE msiHandle, IDispatch **disp)
{
- AutomationObject *record;
+ struct automation_object *record;
- record = msi_alloc(sizeof(*record));
+ record = malloc(sizeof(*record));
if (!record) return E_OUTOFMEMORY;
init_automation_object(record, msiHandle, Record_tid);
}
static HRESULT list_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
- ListObject *list = CONTAINING_RECORD(This, ListObject, autoobj);
+ struct list_object *list = CONTAINING_RECORD(This, struct list_object, autoobj);
IUnknown *pUnk = NULL;
HRESULT hr;
return S_OK;
}
-static void list_free(AutomationObject *This)
+static void list_free(struct automation_object *This)
{
- ListObject *list = CONTAINING_RECORD(This, ListObject, autoobj);
+ struct list_object *list = CONTAINING_RECORD(This, struct list_object, autoobj);
int i;
for (i = 0; i < list->count; i++)
VariantClear(&list->data[i]);
- msi_free(list->data);
+ free(list->data);
}
static HRESULT get_products_count(const WCHAR *product, int *len)
static HRESULT create_list(const WCHAR *product, IDispatch **dispatch)
{
- ListObject *list;
+ struct list_object *list;
HRESULT hr;
int i;
- list = msi_alloc_zero(sizeof(ListObject));
+ list = calloc(1, sizeof(*list));
if (!list) return E_OUTOFMEMORY;
init_automation_object(&list->autoobj, 0, StringList_tid);
return hr;
}
- list->data = msi_alloc(list->count*sizeof(VARIANT));
+ list->data = malloc(list->count * sizeof(VARIANT));
if (!list->data)
{
IDispatch_Release(*dispatch);
}
static HRESULT view_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
{
hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &varg0, puArgErr);
if (SUCCEEDED(hr) && V_DISPATCH(&varg0) != NULL)
- MsiViewExecute(This->msiHandle, ((AutomationObject *)V_DISPATCH(&varg0))->msiHandle);
+ MsiViewExecute(This->msiHandle, ((struct automation_object *)V_DISPATCH(&varg0))->msiHandle);
else
MsiViewExecute(This->msiHandle, 0);
}
hr = DispGetParam(pDispParams, 1, VT_DISPATCH, &varg1, puArgErr);
if (FAILED(hr)) return hr;
if (!V_DISPATCH(&varg1)) return DISP_E_EXCEPTION;
- if ((ret = MsiViewModify(This->msiHandle, V_I4(&varg0), ((AutomationObject *)V_DISPATCH(&varg1))->msiHandle)) != ERROR_SUCCESS)
+ if ((ret = MsiViewModify(This->msiHandle, V_I4(&varg0),
+ ((struct automation_object *)V_DISPATCH(&varg1))->msiHandle)) != ERROR_SUCCESS)
{
VariantClear(&varg1);
ERR("MsiViewModify returned %d\n", ret);
}
HRESULT database_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
}
static HRESULT session_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
- SessionObject *session = CONTAINING_RECORD(This, SessionObject, autoobj);
+ struct session_object *session = CONTAINING_RECORD(This, struct session_object, autoobj);
WCHAR *szString;
DWORD dwLen = 0;
MSIHANDLE msiHandle;
V_BSTR(pVarResult) = NULL;
if ((ret = MsiGetPropertyW(This->msiHandle, V_BSTR(&varg0), NULL, &dwLen)) == ERROR_SUCCESS)
{
- if (!(szString = msi_alloc((++dwLen)*sizeof(WCHAR))))
+ if (!(szString = malloc((++dwLen) * sizeof(WCHAR))))
ERR("Out of memory\n");
else if ((ret = MsiGetPropertyW(This->msiHandle, V_BSTR(&varg0), szString, &dwLen)) == ERROR_SUCCESS)
V_BSTR(pVarResult) = SysAllocString(szString);
- msi_free(szString);
+ free(szString);
}
if (ret != ERROR_SUCCESS)
ERR("MsiGetProperty returned %d\n", ret);
V_VT(pVarResult) = VT_I4;
V_I4(pVarResult) =
- MsiProcessMessage(This->msiHandle, V_I4(&varg0), ((AutomationObject *)V_DISPATCH(&varg1))->msiHandle);
+ MsiProcessMessage(This->msiHandle, V_I4(&varg0), ((struct automation_object *)V_DISPATCH(&varg1))->msiHandle);
break;
case DISPID_SESSION_SETINSTALLLEVEL:
case REG_EXPAND_SZ:
if (!(dwNewSize = ExpandEnvironmentStringsW(szString, szNewString, dwNewSize)))
ERR("ExpandEnvironmentStrings returned error %lu\n", GetLastError());
- else if (!(szNewString = msi_alloc(dwNewSize * sizeof(WCHAR))))
+ else if (!(szNewString = malloc(dwNewSize * sizeof(WCHAR))))
ERR("Out of memory\n");
else if (!(dwNewSize = ExpandEnvironmentStringsW(szString, szNewString, dwNewSize)))
ERR("ExpandEnvironmentStrings returned error %lu\n", GetLastError());
V_VT(pVarResult) = VT_BSTR;
V_BSTR(pVarResult) = SysAllocStringLen(szNewString, dwNewSize);
}
- msi_free(szNewString);
+ free(szNewString);
break;
case REG_DWORD:
return create_record(hrec, &V_DISPATCH(pVarResult));
}
-static HRESULT InstallerImpl_OpenPackage(AutomationObject* This,
+static HRESULT InstallerImpl_OpenPackage(struct automation_object *This,
WORD wFlags,
DISPPARAMS* pDispParams,
VARIANT* pVarResult,
goto done;
}
- szString = msi_alloc(size);
+ szString = malloc(size);
if (!szString)
{
hr = E_OUTOFMEMORY;
&type, (LPBYTE)szString, &size);
if (ret != ERROR_SUCCESS)
{
- msi_free(szString);
+ free(szString);
hr = DISP_E_BADINDEX;
goto done;
}
variant_from_registry_value(pVarResult, type,
(LPBYTE)szString, size);
- msi_free(szString);
+ free(szString);
break;
/* Try to make it into VT_I4, can use VariantChangeType for this. */
if (ret != ERROR_SUCCESS)
goto done;
- szString = msi_alloc(++size * sizeof(WCHAR));
+ szString = malloc(++size * sizeof(WCHAR));
if (!szString)
{
hr = E_OUTOFMEMORY;
V_BSTR(pVarResult) = SysAllocString(szString);
}
- msi_free(szString);
+ free(szString);
}
done:
goto done;
}
- str = msi_alloc(++size * sizeof(WCHAR));
+ str = malloc(++size * sizeof(WCHAR));
if (!str)
{
hr = E_OUTOFMEMORY;
hr = S_OK;
done:
- msi_free(str);
+ free(str);
VariantClear(&varg0);
VariantClear(&varg1);
return hr;
}
static HRESULT installer_invoke(
- AutomationObject* This,
+ struct automation_object *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
HRESULT create_msiserver(IUnknown *outer, void **ppObj)
{
- AutomationObject *installer;
+ struct automation_object *installer;
TRACE("(%p %p)\n", outer, ppObj);
if (outer)
return CLASS_E_NOAGGREGATION;
- installer = msi_alloc(sizeof(AutomationObject));
+ installer = malloc(sizeof(*installer));
if (!installer) return E_OUTOFMEMORY;
init_automation_object(installer, 0, Installer_tid);
HRESULT create_session(MSIHANDLE msiHandle, IDispatch *installer, IDispatch **disp)
{
- SessionObject *session;
+ struct session_object *session;
- session = msi_alloc(sizeof(SessionObject));
+ session = malloc(sizeof(*session));
if (!session) return E_OUTOFMEMORY;
init_automation_object(&session->autoobj, msiHandle, Session_tid);
static HRESULT create_database(MSIHANDLE msiHandle, IDispatch **dispatch)
{
- AutomationObject *database;
+ struct automation_object *database;
TRACE("%lu %p\n", msiHandle, dispatch);
- database = msi_alloc(sizeof(AutomationObject));
+ database = malloc(sizeof(*database));
if (!database) return E_OUTOFMEMORY;
init_automation_object(database, msiHandle, Database_tid);
static HRESULT create_view(MSIHANDLE msiHandle, IDispatch **dispatch)
{
- AutomationObject *view;
+ struct automation_object *view;
TRACE("%lu %p\n", msiHandle, dispatch);
- view = msi_alloc(sizeof(AutomationObject));
+ view = malloc(sizeof(*view));
if (!view) return E_OUTOFMEMORY;
init_automation_object(view, msiHandle, View_tid);
static HRESULT create_summaryinfo(MSIHANDLE msiHandle, IDispatch **disp)
{
- AutomationObject *info;
+ struct automation_object *info;
- info = msi_alloc(sizeof(*info));
+ info = malloc(sizeof(*info));
if (!info) return E_OUTOFMEMORY;
init_automation_object(info, msiHandle, SummaryInfo_tid);
/* fill in the data */
- appid = msi_alloc_zero( sizeof(MSIAPPID) );
+ appid = calloc( 1, sizeof(MSIAPPID) );
if (!appid)
return NULL;
/* fill in the data */
- progid = msi_alloc_zero( sizeof(MSIPROGID) );
+ progid = calloc( 1, sizeof(MSIPROGID) );
if (!progid)
return NULL;
FilePath = msi_build_icon_path(package, FileName);
- progid->IconPath = msi_alloc( (lstrlenW(FilePath) + 10) * sizeof(WCHAR) );
+ progid->IconPath = malloc( (wcslen(FilePath) + 10) * sizeof(WCHAR) );
swprintf( progid->IconPath, lstrlenW(FilePath) + 10, L"%s,%d", FilePath, icon_index );
- msi_free(FilePath);
+ free(FilePath);
}
else
{
/* fill in the data */
- cls = msi_alloc_zero( sizeof(MSICLASS) );
+ cls = calloc( 1, sizeof(MSICLASS) );
if (!cls)
return NULL;
FilePath = msi_build_icon_path(package, FileName);
- cls->IconPath = msi_alloc( (lstrlenW(FilePath) + 5) * sizeof(WCHAR) );
+ cls->IconPath = malloc( (wcslen(FilePath) + 5) * sizeof(WCHAR) );
swprintf( cls->IconPath, lstrlenW(FilePath) + 5, L"%s,%d", FilePath, icon_index );
- msi_free(FilePath);
+ free(FilePath);
}
else
{
switch(i)
{
case 1:
- cls->DefInprocHandler = strdupW(L"ole2.dll");
+ cls->DefInprocHandler = wcsdup(L"ole2.dll");
break;
case 2:
- cls->DefInprocHandler32 = strdupW(L"ole32.dll");
+ cls->DefInprocHandler32 = wcsdup(L"ole32.dll");
break;
case 3:
- cls->DefInprocHandler = strdupW(L"ole2.dll");
- cls->DefInprocHandler32 = strdupW(L"ole32.dll");
+ cls->DefInprocHandler = wcsdup(L"ole2.dll");
+ cls->DefInprocHandler32 = wcsdup(L"ole32.dll");
break;
}
}
/* fill in the data */
- mt = msi_alloc_zero( sizeof(MSIMIME) );
+ mt = calloc( 1, sizeof(MSIMIME) );
if (!mt)
return mt;
extension = MSI_RecordGetString( row, 2 );
mt->Extension = load_given_extension( package, extension );
- mt->suffix = strdupW( extension );
+ mt->suffix = wcsdup( extension );
mt->clsid = msi_dup_record_field( row, 3 );
mt->Class = load_given_class( package, mt->clsid );
/* fill in the data */
- ext = msi_alloc_zero( sizeof(MSIEXTENSION) );
+ ext = calloc( 1, sizeof(MSIEXTENSION) );
if (!ext)
return NULL;
/* fill in the data */
- verb = msi_alloc_zero( sizeof(MSIVERB) );
+ verb = calloc( 1, sizeof(MSIVERB) );
if (!verb)
return ERROR_OUTOFMEMORY;
if (cls->Argument)
size += lstrlenW(cls->Argument)+1;
- argument = msi_alloc( size * sizeof(WCHAR) );
+ argument = malloc( size * sizeof(WCHAR) );
lstrcpyW( argument, file->TargetPath );
if (cls->Argument)
}
msi_reg_set_val_str( hkey3, NULL, argument );
- msi_free(argument);
+ free(argument);
RegCloseKey(hkey3);
ptr2 = wcschr(ptr,';');
if (ptr2)
*ptr2 = 0;
- keyname = msi_alloc( (lstrlenW(L"FileType\\%s\\%d") + lstrlenW(cls->clsid) + 4) * sizeof(WCHAR));
+ keyname = malloc( sizeof(L"FileType\\%s\\%d") + (wcslen(cls->clsid) + 3) * sizeof(WCHAR) );
swprintf( keyname, lstrlenW(L"FileType\\%s\\%d") + lstrlenW(cls->clsid) + 4,
L"FileType\\%s\\%d", cls->clsid, index );
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, ptr );
- msi_free(keyname);
+ free( keyname );
if (ptr2)
ptr = ptr2+1;
}
if (cls->FileTypeMask)
{
- filetype = msi_alloc( (lstrlenW( L"FileType\\" ) + lstrlenW( cls->clsid ) + 1) * sizeof(WCHAR) );
+ filetype = malloc( sizeof( L"FileType\\" ) + wcslen( cls->clsid ) * sizeof(WCHAR) );
if (filetype)
{
lstrcpyW( filetype, L"FileType\\" );
lstrcatW( filetype, cls->clsid );
res = RegDeleteTreeW( HKEY_CLASSES_ROOT, filetype );
- msi_free( filetype );
+ free( filetype );
if (res != ERROR_SUCCESS)
WARN("failed to delete file type %ld\n", res);
size += lstrlenW(verb->Argument);
size += 4;
- command = msi_alloc(size * sizeof (WCHAR));
+ command = malloc(size * sizeof(WCHAR));
if (verb->Argument)
swprintf(command, size, L"\"%s\" %s", component->FullKeypath, verb->Argument);
else
swprintf(command, size, L"\"%s\"", component->FullKeypath);
msi_reg_set_val_str( key, NULL, command );
- msi_free(command);
+ free(command);
advertise = msi_create_component_advertise_string(package, component,
extension->Feature->Feature);
size += lstrlenW(verb->Argument);
size += 4;
- command = msi_alloc_zero(size * sizeof (WCHAR));
+ command = calloc(size, sizeof(WCHAR));
lstrcpyW(command,advertise);
if (verb->Argument)
msi_reg_set_val_multi_str( key, L"command", command );
RegCloseKey(key);
- msi_free(keyname);
- msi_free(advertise);
- msi_free(command);
+ free(keyname);
+ free(advertise);
+ free(command);
if (verb->Command)
{
keyname = msi_build_directory_name( 3, progid, L"shell", verb->Verb );
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Command );
- msi_free(keyname);
+ free(keyname);
}
if (verb->Sequence != MSI_NULL_INTEGER)
*Sequence = verb->Sequence;
keyname = msi_build_directory_name( 2, progid, L"shell" );
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Verb );
- msi_free(keyname);
+ free(keyname);
}
}
return ERROR_SUCCESS;
ext->action = INSTALLSTATE_LOCAL;
- extension = msi_alloc( (lstrlenW( ext->Extension ) + 2) * sizeof(WCHAR) );
+ extension = malloc( (wcslen( ext->Extension ) + 2) * sizeof(WCHAR) );
if (extension)
{
extension[0] = '.';
lstrcpyW( extension + 1, ext->Extension );
res = RegCreateKeyW( HKEY_CLASSES_ROOT, extension, &hkey );
- msi_free( extension );
+ free( extension );
if (res != ERROR_SUCCESS)
WARN("failed to create extension key %ld\n", res);
}
msi_reg_set_val_str( hkey, NULL, progid );
- newkey = msi_alloc( (lstrlenW(progid) + lstrlenW(L"\\ShellNew") + 1) * sizeof(WCHAR));
+ newkey = malloc( wcslen(progid) * sizeof(WCHAR) + sizeof(L"\\ShellNew") );
lstrcpyW(newkey, progid);
lstrcatW(newkey, L"\\ShellNew");
RegCreateKeyW(hkey, newkey, &hkey2);
RegCloseKey(hkey2);
- msi_free(newkey);
+ free(newkey);
/* do all the verbs */
LIST_FOR_EACH_ENTRY( verb, &ext->verbs, MSIVERB, entry )
ext->action = INSTALLSTATE_ABSENT;
- extension = msi_alloc( (lstrlenW( ext->Extension ) + 2) * sizeof(WCHAR) );
+ extension = malloc( (wcslen( ext->Extension ) + 2) * sizeof(WCHAR) );
if (extension)
{
extension[0] = '.';
lstrcpyW( extension + 1, ext->Extension );
res = RegDeleteTreeW( HKEY_CLASSES_ROOT, extension );
- msi_free( extension );
+ free( extension );
if (res != ERROR_SUCCESS)
WARN("failed to delete extension key %ld\n", res);
}
else
progid = ext->ProgIDText;
- progid_shell = msi_alloc( (lstrlenW( progid ) + lstrlenW( L"\\shell" ) + 1) * sizeof(WCHAR) );
+ progid_shell = malloc( wcslen( progid ) * sizeof(WCHAR) + sizeof( L"\\shell" ) );
if (progid_shell)
{
lstrcpyW( progid_shell, progid );
lstrcatW( progid_shell, L"\\shell" );
res = RegDeleteTreeW( HKEY_CLASSES_ROOT, progid_shell );
- msi_free( progid_shell );
+ free( progid_shell );
if (res != ERROR_SUCCESS)
WARN("failed to delete shell key %ld\n", res);
RegDeleteKeyW( HKEY_CLASSES_ROOT, progid );
TRACE("Registering MIME type %s\n", debugstr_w(mt->ContentType));
- if (mt->Extension) extension = msi_alloc( (lstrlenW( mt->Extension->Extension ) + 2) * sizeof(WCHAR) );
- key = msi_alloc( (lstrlenW( mt->ContentType ) +
- lstrlenW( L"MIME\\Database\\Content Type\\" ) + 1) * sizeof(WCHAR) );
+ if (mt->Extension) extension = malloc( (wcslen( mt->Extension->Extension ) + 2) * sizeof(WCHAR) );
+ key = malloc( sizeof( L"MIME\\Database\\Content Type\\" ) +
+ wcslen( mt->ContentType ) * sizeof(WCHAR) );
if (extension && key)
{
if (mt->clsid)
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, L"CLSID", mt->clsid );
}
- msi_free( extension );
- msi_free( key );
+ free( extension );
+ free( key );
uirow = MSI_CreateRecord( 2 );
MSI_RecordSetStringW( uirow, 1, mt->ContentType );
TRACE("Unregistering MIME type %s\n", debugstr_w(mime->ContentType));
- mime_key = msi_alloc( (lstrlenW( L"MIME\\Database\\Content Type\\" ) +
- lstrlenW( mime->ContentType ) + 1) * sizeof(WCHAR) );
+ mime_key = malloc( sizeof( L"MIME\\Database\\Content Type\\" ) +
+ wcslen( mime->ContentType ) * sizeof(WCHAR) );
if (mime_key)
{
lstrcpyW( mime_key, L"MIME\\Database\\Content Type\\" );
res = RegDeleteKeyW( HKEY_CLASSES_ROOT, mime_key );
if (res != ERROR_SUCCESS)
WARN("failed to delete MIME key %ld\n", res);
- msi_free( mime_key );
+ free( mime_key );
}
uirow = MSI_CreateRecord( 2 );
static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
{
LPWSTR strlower, sublower, r;
- strlower = CharLowerW( strdupW( str ) );
- sublower = CharLowerW( strdupW( sub ) );
+ strlower = CharLowerW( wcsdup( str ) );
+ sublower = CharLowerW( wcsdup( sub ) );
r = wcsstr( strlower, sublower );
if (r)
r = (LPWSTR)str + (r - strlower);
- msi_free( strlower );
- msi_free( sublower );
+ free( strlower );
+ free( sublower );
return r;
}
{
struct list *mem;
- mem = msi_alloc( sizeof (struct list) + sz );
+ mem = malloc( sizeof (struct list) + sz );
if( !mem )
return NULL;
new_ptr = cond_alloc( cond, sz );
if( !new_ptr )
{
- msi_free( ptr );
+ free( ptr );
return NULL;
}
memcpy( new_ptr, ptr, sz );
- msi_free( ptr );
+ free( ptr );
return new_ptr;
}
if( ptr )
{
list_remove( mem );
- msi_free( mem );
+ free( mem );
}
}
return MSICONDITION_ERROR;
r = MsiEvaluateConditionW( hInstall, szwCond );
- msi_free( szwCond );
+ free( szwCond );
return r;
}
/* below is the query interface to a table */
-typedef struct tagMSICREATEVIEW
+struct create_view
{
MSIVIEW view;
MSIDATABASE *db;
BOOL bIsTemp;
BOOL hold;
column_info *col_info;
-} MSICREATEVIEW;
+};
static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
TRACE("%p %d %d %p\n", cv, row, col, val );
static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
BOOL persist = (cv->bIsTemp) ? MSICONDITION_FALSE : MSICONDITION_TRUE;
TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name),
static UINT CREATE_close( struct tagMSIVIEW *view )
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
TRACE("%p\n", cv);
static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
TRACE("%p %p %p\n", cv, rows, cols );
static UINT CREATE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
TRACE("%p %d %p %p %p %p\n", cv, n, name, type, temporary, table_name );
static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
MSIRECORD *rec, UINT row)
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
TRACE("%p %d %p\n", cv, eModifyMode, rec );
static UINT CREATE_delete( struct tagMSIVIEW *view )
{
- MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
+ struct create_view *cv = (struct create_view *)view;
TRACE("%p\n", cv );
msiobj_release( &cv->db->hdr );
- msi_free( cv );
+ free( cv );
return ERROR_SUCCESS;
}
UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table,
column_info *col_info, BOOL hold )
{
- MSICREATEVIEW *cv = NULL;
+ struct create_view *cv = NULL;
UINT r;
column_info *col;
BOOL temp = TRUE;
if( r != ERROR_SUCCESS )
return r;
- cv = msi_alloc_zero( sizeof *cv );
+ cv = calloc( 1, sizeof *cv );
if( !cv )
return ERROR_FUNCTION_FAILED;
if ( !temp && tempprim )
{
- msi_free( cv );
+ free( cv );
return ERROR_FUNCTION_FAILED;
}
#define CUSTOM_ACTION_TYPE_MASK 0x3F
-typedef struct tagMSIRUNNINGACTION
+struct running_action
{
struct list entry;
HANDLE handle;
BOOL process;
LPWSTR name;
-} MSIRUNNINGACTION;
+};
typedef UINT (WINAPI *MsiCustomActionEntryPoint)( MSIHANDLE );
-static CRITICAL_SECTION msi_custom_action_cs;
-static CRITICAL_SECTION_DEBUG msi_custom_action_cs_debug =
+static CRITICAL_SECTION custom_action_cs;
+static CRITICAL_SECTION_DEBUG custom_action_cs_debug =
{
- 0, 0, &msi_custom_action_cs,
- { &msi_custom_action_cs_debug.ProcessLocksList,
- &msi_custom_action_cs_debug.ProcessLocksList },
- 0, 0, { (DWORD_PTR)(__FILE__ ": msi_custom_action_cs") }
+ 0, 0, &custom_action_cs,
+ { &custom_action_cs_debug.ProcessLocksList,
+ &custom_action_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": custom_action_cs") }
};
-static CRITICAL_SECTION msi_custom_action_cs = { &msi_custom_action_cs_debug, -1, 0, 0, 0, 0 };
+static CRITICAL_SECTION custom_action_cs = { &custom_action_cs_debug, -1, 0, 0, 0, 0 };
-static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_actions );
+static struct list pending_custom_actions = LIST_INIT( pending_custom_actions );
void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
{
count = package->script_actions_count[script];
package->script_actions_count[script]++;
- if (count != 0) newbuf = msi_realloc( package->script_actions[script],
- package->script_actions_count[script] * sizeof(WCHAR *) );
- else newbuf = msi_alloc( sizeof(WCHAR *) );
+ if (count != 0) newbuf = realloc( package->script_actions[script],
+ package->script_actions_count[script] * sizeof(WCHAR *) );
+ else newbuf = malloc( sizeof(WCHAR *) );
- newbuf[count] = strdupW( action );
+ newbuf[count] = wcsdup( action );
package->script_actions[script] = newbuf;
return ERROR_SUCCESS;
}
count = package->unique_actions_count;
package->unique_actions_count++;
- if (count != 0) newbuf = msi_realloc( package->unique_actions,
- package->unique_actions_count * sizeof(WCHAR *) );
- else newbuf = msi_alloc( sizeof(WCHAR *) );
+ if (count != 0) newbuf = realloc( package->unique_actions,
+ package->unique_actions_count * sizeof(WCHAR *) );
+ else newbuf = malloc( sizeof(WCHAR *) );
- newbuf[count] = strdupW( action );
+ newbuf[count] = wcsdup( action );
package->unique_actions = newbuf;
return ERROR_SUCCESS;
}
*
* [CustomActionData<=>UserSID<=>ProductCode]Action
*/
-static LPWSTR msi_get_deferred_action(LPCWSTR action, LPCWSTR actiondata,
- LPCWSTR usersid, LPCWSTR prodcode)
+static WCHAR *get_deferred_action(const WCHAR *action, const WCHAR *actiondata, const WCHAR *usersid,
+ const WCHAR *prodcode)
{
LPWSTR deferred;
DWORD len;
if (!actiondata)
- return strdupW(action);
+ return wcsdup(action);
len = lstrlenW(action) + lstrlenW(actiondata) +
lstrlenW(usersid) + lstrlenW(prodcode) +
lstrlenW(L"[%s<=>%s<=>%s]%s") - 7;
- deferred = msi_alloc(len * sizeof(WCHAR));
+ deferred = malloc(len * sizeof(WCHAR));
swprintf(deferred, len, L"[%s<=>%s<=>%s]%s", actiondata, usersid, prodcode, action);
return deferred;
{
GetTempPathW( MAX_PATH, tmp );
}
- if (!(db->tempfolder = strdupW( tmp ))) return NULL;
+ if (!(db->tempfolder = wcsdup( tmp ))) return NULL;
}
- if ((ret = msi_alloc( (lstrlenW( db->tempfolder ) + 20) * sizeof(WCHAR) )))
+ if ((ret = malloc( (wcslen( db->tempfolder ) + 20) * sizeof(WCHAR) )))
{
if (!GetTempFileNameW( db->tempfolder, L"msi", 0, ret ))
{
- msi_free( ret );
+ free( ret );
return NULL;
}
}
if (!(tmpfile = msi_create_temp_file( package->db ))) return NULL;
if (!(row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `Binary` WHERE `Name` = '%s'", source ))) goto error;
- if (!(binary = msi_alloc_zero( sizeof(MSIBINARY) ))) goto error;
+ if (!(binary = calloc( 1, sizeof(MSIBINARY) ))) goto error;
file = CreateFileW( tmpfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if (file == INVALID_HANDLE_VALUE) goto error;
CloseHandle( file );
if (r != ERROR_SUCCESS) goto error;
- binary->source = strdupW( source );
+ binary->source = wcsdup( source );
binary->tmpfile = tmpfile;
list_add_tail( &package->binaries, &binary->entry );
error:
if (row) msiobj_release( &row->hdr );
DeleteFileW( tmpfile );
- msi_free( tmpfile );
- msi_free( binary );
+ free( tmpfile );
+ free( binary );
return NULL;
}
static void file_running_action(MSIPACKAGE* package, HANDLE Handle,
BOOL process, LPCWSTR name)
{
- MSIRUNNINGACTION *action;
+ struct running_action *action;
- action = msi_alloc( sizeof(MSIRUNNINGACTION) );
+ action = malloc( sizeof(*action) );
action->handle = Handle;
action->process = process;
- action->name = strdupW(name);
+ action->name = wcsdup(name);
list_add_tail( &package->RunningActions, &action->entry );
}
return rc;
}
-typedef struct _msi_custom_action_info {
+typedef struct
+{
struct list entry;
MSIPACKAGE *package;
LPWSTR source;
INT type;
GUID guid;
DWORD arch;
-} msi_custom_action_info;
+} custom_action_info;
-static void free_custom_action_data( msi_custom_action_info *info )
+static void free_custom_action_data( custom_action_info *info )
{
- EnterCriticalSection( &msi_custom_action_cs );
+ EnterCriticalSection( &custom_action_cs );
list_remove( &info->entry );
if (info->handle)
CloseHandle( info->handle );
- msi_free( info->action );
- msi_free( info->source );
- msi_free( info->target );
+ free( info->action );
+ free( info->source );
+ free( info->target );
msiobj_release( &info->package->hdr );
- msi_free( info );
+ free( info );
- LeaveCriticalSection( &msi_custom_action_cs );
+ LeaveCriticalSection( &custom_action_cs );
}
-static UINT wait_thread_handle( msi_custom_action_info *info )
+static UINT wait_thread_handle( custom_action_info *info )
{
UINT rc = ERROR_SUCCESS;
return rc;
}
-static msi_custom_action_info *find_action_by_guid( const GUID *guid )
+static custom_action_info *find_action_by_guid( const GUID *guid )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
BOOL found = FALSE;
- EnterCriticalSection( &msi_custom_action_cs );
+ EnterCriticalSection( &custom_action_cs );
- LIST_FOR_EACH_ENTRY( info, &msi_pending_custom_actions, msi_custom_action_info, entry )
+ LIST_FOR_EACH_ENTRY( info, &pending_custom_actions, custom_action_info, entry )
{
if (IsEqualGUID( &info->guid, guid ))
{
}
}
- LeaveCriticalSection( &msi_custom_action_cs );
+ LeaveCriticalSection( &custom_action_cs );
if (!found)
return NULL;
static DWORD WINAPI custom_client_thread(void *arg)
{
- msi_custom_action_info *info = arg;
+ custom_action_info *info = arg;
DWORD64 thread64;
HANDLE process;
HANDLE thread;
pipe = info->package->custom_server_64_pipe;
}
- EnterCriticalSection(&msi_custom_action_cs);
+ EnterCriticalSection(&custom_action_cs);
if (!WriteFile(pipe, &info->guid, sizeof(info->guid), &size, NULL) ||
size != sizeof(info->guid))
{
ERR("failed to write to custom action client pipe: %lu\n", GetLastError());
- LeaveCriticalSection(&msi_custom_action_cs);
+ LeaveCriticalSection(&custom_action_cs);
return GetLastError();
}
if (!ReadFile(pipe, &thread64, sizeof(thread64), &size, NULL) || size != sizeof(thread64))
{
ERR("failed to read from custom action client pipe: %lu\n", GetLastError());
- LeaveCriticalSection(&msi_custom_action_cs);
+ LeaveCriticalSection(&custom_action_cs);
return GetLastError();
}
- LeaveCriticalSection(&msi_custom_action_cs);
+ LeaveCriticalSection(&custom_action_cs);
if (DuplicateHandle(process, (HANDLE)(DWORD_PTR)thread64, GetCurrentProcess(),
&thread, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
}
}
-static msi_custom_action_info *do_msidbCustomActionTypeDll(
+static custom_action_info *do_msidbCustomActionTypeDll(
MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
RPC_STATUS status;
BOOL ret;
- info = msi_alloc( sizeof *info );
+ info = malloc( sizeof *info );
if (!info)
return NULL;
msiobj_addref( &package->hdr );
info->package = package;
info->type = type;
- info->target = strdupW( target );
- info->source = strdupW( source );
- info->action = strdupW( action );
+ info->target = wcsdup( target );
+ info->source = wcsdup( source );
+ info->action = wcsdup( action );
CoCreateGuid( &info->guid );
- EnterCriticalSection( &msi_custom_action_cs );
- list_add_tail( &msi_pending_custom_actions, &info->entry );
- LeaveCriticalSection( &msi_custom_action_cs );
+ EnterCriticalSection( &custom_action_cs );
+ list_add_tail( &pending_custom_actions, &info->entry );
+ LeaveCriticalSection( &custom_action_cs );
if (!package->rpc_server_started)
{
static UINT HANDLE_CustomType1( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
INT type, const WCHAR *action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
MSIBINARY *binary;
if (!(binary = get_temp_binary(package, source)))
int len_arg = 0;
DWORD len_exe;
- if (!(exe = msi_alloc( MAX_PATH * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
+ if (!(exe = malloc( MAX_PATH * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
len_exe = SearchPathW( NULL, app, L".exe", MAX_PATH, exe, NULL );
if (len_exe >= MAX_PATH)
{
- msi_free( exe );
- if (!(exe = msi_alloc( len_exe * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
+ free( exe );
+ if (!(exe = malloc( len_exe * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
len_exe = SearchPathW( NULL, app, L".exe", len_exe, exe, NULL );
}
if (!len_exe)
{
ERR("can't find executable %lu\n", GetLastError());
- msi_free( exe );
+ free( exe );
return INVALID_HANDLE_VALUE;
}
if (arg) len_arg = lstrlenW( arg );
- if (!(cmd = msi_alloc( (len_exe + len_arg + 4) * sizeof(WCHAR) )))
+ if (!(cmd = malloc( (len_exe + len_arg + 4) * sizeof(WCHAR) )))
{
- msi_free( exe );
+ free( exe );
return INVALID_HANDLE_VALUE;
}
p = cmd;
}
memset( &si, 0, sizeof(STARTUPINFOW) );
ret = CreateProcessW( exe, exe ? cmd : arg, NULL, NULL, FALSE, 0, NULL, dir, &si, &info );
- msi_free( cmd );
- msi_free( exe );
+ free( cmd );
+ free( exe );
if (!ret)
{
ERR("unable to execute command %lu\n", GetLastError());
TRACE("exe %s arg %s\n", debugstr_w(binary->tmpfile), debugstr_w(arg));
handle = execute_command( binary->tmpfile, arg, L"C:\\" );
- msi_free( arg );
+ free( arg );
if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
return wait_process_handle( package, type, handle, action );
}
static UINT HANDLE_CustomType17( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
INT type, const WCHAR *action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
MSIFILE *file;
TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
TRACE("exe %s arg %s\n", debugstr_w(file->TargetPath), debugstr_w(arg));
handle = execute_command( file->TargetPath, arg, L"C:\\" );
- msi_free( arg );
+ free( arg );
if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
return wait_process_handle( package, type, handle, action );
}
else if ((package->ui_level & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
MessageBoxW( NULL, deformated, NULL, MB_OK );
- msi_free( deformated );
+ free( deformated );
return ERROR_INSTALL_FAILURE;
}
UINT len = ARRAY_SIZE(L"/qb /i ") - 1;
WCHAR *ret;
- if (!(ret = msi_alloc( (len + len_filename + len_params + 4) * sizeof(WCHAR) ))) return NULL;
+ if (!(ret = malloc( (len + len_filename + len_params + 4) * sizeof(WCHAR) ))) return NULL;
memcpy( ret, L"/qb /i ", sizeof(L"/qb /i ") );
ret[len++] = '"';
memcpy( ret + len, filename, len_filename * sizeof(WCHAR) );
if (!(dir = msi_dup_property( package->db, L"OriginalDatabase" ))) return ERROR_OUTOFMEMORY;
if (!(p = wcsrchr( dir, '\\' )) && !(p = wcsrchr( dir, '/' )))
{
- msi_free( dir );
+ free( dir );
return ERROR_FUNCTION_FAILED;
}
*p = 0;
len_dir = p - dir;
- if (!(filename = msi_alloc( (len_dir + len_source + 2) * sizeof(WCHAR) )))
+ if (!(filename = malloc( (len_dir + len_source + 2) * sizeof(WCHAR) )))
{
- msi_free( dir );
+ free( dir );
return ERROR_OUTOFMEMORY;
}
memcpy( filename, dir, len_dir * sizeof(WCHAR) );
if (!(args = build_msiexec_args( filename, target )))
{
- msi_free( dir );
+ free( dir );
+ free( filename );
return ERROR_OUTOFMEMORY;
}
TRACE("installing %s concurrently\n", debugstr_w(source));
handle = execute_command( L"msiexec", args, dir );
- msi_free( dir );
- msi_free( args );
+ free( dir );
+ free( filename );
+ free( args );
if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
return wait_process_handle( package, type, handle, action );
}
if (r != ERROR_SUCCESS)
goto error;
- if (!(binary = msi_alloc( sizeof(*binary) ))) goto error;
+ if (!(binary = malloc( sizeof(*binary) ))) goto error;
binary->source = NULL;
binary->tmpfile = tmpfile;
list_add_tail( &package->binaries, &binary->entry );
TRACE("installing %s concurrently\n", debugstr_w(source));
handle = execute_command( L"msiexec", args, L"C:\\" );
- msi_free( args );
+ free( args );
if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
return wait_process_handle( package, type, handle, action );
error:
DeleteFileW( tmpfile );
- msi_free( tmpfile );
+ free( tmpfile );
return ERROR_FUNCTION_FAILED;
}
TRACE("exe %s arg %s\n", debugstr_w(exe), debugstr_w(arg));
handle = execute_command( exe, arg, L"C:\\" );
- msi_free( exe );
- msi_free( arg );
+ free( exe );
+ free( arg );
if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
return wait_process_handle( package, type, handle, action );
}
TRACE("cmd %s dir %s\n", debugstr_w(cmd), debugstr_w(workingdir));
handle = execute_command( NULL, cmd, workingdir );
- msi_free( cmd );
+ free( cmd );
if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
return wait_process_handle( package, type, handle, action );
}
static DWORD ACTION_CallScript( const GUID *guid )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
MSIHANDLE hPackage;
UINT r = ERROR_FUNCTION_FAILED;
return rc;
}
-static msi_custom_action_info *do_msidbCustomActionTypeScript(
+static custom_action_info *do_msidbCustomActionTypeScript(
MSIPACKAGE *package, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
- info = msi_alloc( sizeof *info );
+ info = malloc( sizeof *info );
if (!info)
return NULL;
msiobj_addref( &package->hdr );
info->package = package;
info->type = type;
- info->target = strdupW( function );
- info->source = strdupW( script );
- info->action = strdupW( action );
+ info->target = wcsdup( function );
+ info->source = wcsdup( script );
+ info->action = wcsdup( action );
CoCreateGuid( &info->guid );
- EnterCriticalSection( &msi_custom_action_cs );
- list_add_tail( &msi_pending_custom_actions, &info->entry );
- LeaveCriticalSection( &msi_custom_action_cs );
+ EnterCriticalSection( &custom_action_cs );
+ list_add_tail( &pending_custom_actions, &info->entry );
+ LeaveCriticalSection( &custom_action_cs );
info->handle = CreateThread( NULL, 0, ScriptThread, &info->guid, 0, NULL );
if (!info->handle)
static UINT HANDLE_CustomType37_38( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
INT type, const WCHAR *action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
INT type, const WCHAR *action )
{
MSIRECORD *row = NULL;
- msi_custom_action_info *info;
+ custom_action_info *info;
CHAR *buffer = NULL;
WCHAR *bufferw = NULL;
DWORD sz = 0;
r = MSI_RecordReadStream(row, 2, NULL, &sz);
if (r != ERROR_SUCCESS) goto done;
- buffer = msi_alloc( sz + 1 );
+ buffer = malloc( sz + 1 );
if (!buffer)
{
r = ERROR_FUNCTION_FAILED;
r = wait_thread_handle( info );
done:
- msi_free(bufferw);
- msi_free(buffer);
+ free(bufferw);
+ free(buffer);
msiobj_release(&row->hdr);
return r;
}
static UINT HANDLE_CustomType21_22( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
INT type, const WCHAR *action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
MSIFILE *file;
HANDLE hFile;
DWORD sz, szHighWord = 0, read;
CloseHandle(hFile);
return ERROR_FUNCTION_FAILED;
}
- buffer = msi_alloc( sz + 1 );
+ buffer = malloc( sz + 1 );
if (!buffer)
{
CloseHandle(hFile);
r = wait_thread_handle( info );
done:
- msi_free(bufferw);
- msi_free(buffer);
+ free(bufferw);
+ free(buffer);
return r;
}
static UINT HANDLE_CustomType53_54( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
INT type, const WCHAR *action )
{
- msi_custom_action_info *info;
+ custom_action_info *info;
WCHAR *prop;
TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
if (!prop) return ERROR_SUCCESS;
info = do_msidbCustomActionTypeScript( package, type, prop, NULL, action );
- msi_free(prop);
+ free(prop);
return wait_thread_handle( info );
}
WCHAR *actiondata = msi_dup_property( package->db, action );
WCHAR *usersid = msi_dup_property( package->db, L"UserSID" );
WCHAR *prodcode = msi_dup_property( package->db, L"ProductCode" );
- WCHAR *deferred = msi_get_deferred_action( action, actiondata, usersid, prodcode );
+ WCHAR *deferred = get_deferred_action( action, actiondata, usersid, prodcode );
if (!deferred)
{
- msi_free( actiondata );
- msi_free( usersid );
- msi_free( prodcode );
+ free( actiondata );
+ free( usersid );
+ free( prodcode );
return ERROR_OUTOFMEMORY;
}
if (type & msidbCustomActionTypeCommit)
msi_schedule_action( package, SCRIPT_INSTALL, deferred );
}
- msi_free( actiondata );
- msi_free( usersid );
- msi_free( prodcode );
- msi_free( deferred );
+ free( actiondata );
+ free( usersid );
+ free( prodcode );
+ free( deferred );
return ERROR_SUCCESS;
}
else
msi_set_property( package->db, L"CustomActionData", L"", -1 );
- msi_free(actiondata);
+ free(actiondata);
}
}
else if (!check_execution_scheduling_options(package,action,type))
case 7: /* Concurrent install from substorage */
deformat_string( package, target, &deformated );
rc = HANDLE_CustomType7( package, source, target, type, action );
- msi_free( deformated );
+ free( deformated );
break;
case 17:
rc = HANDLE_CustomType17( package, source, target, type, action );
case 23: /* Installs another package in the source tree */
deformat_string( package, target, &deformated );
rc = HANDLE_CustomType23( package, source, deformated, type, action );
- msi_free( deformated );
+ free( deformated );
break;
case 34: /* EXE to be run in specified directory */
rc = HANDLE_CustomType34( package, source, target, type, action );
case 35: /* Directory set with formatted text */
deformat_string( package, target, &deformated );
MSI_SetTargetPathW( package, source, deformated );
- msi_free( deformated );
+ free( deformated );
break;
case 37: /* JScript/VBScript text stored in target column */
case 38:
len = deformat_string( package, target, &deformated );
rc = msi_set_property( package->db, source, deformated, len );
if (rc == ERROR_SUCCESS && !wcscmp( source, L"SourceDir" )) msi_reset_source_folders( package );
- msi_free( deformated );
+ free( deformated );
break;
case 53: /* JScript/VBScript text specified by a property value */
case 54:
struct list *item;
HANDLE *wait_handles;
unsigned int handle_count, i;
- msi_custom_action_info *info, *cursor;
+ custom_action_info *info, *cursor;
while ((item = list_head( &package->RunningActions )))
{
- MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
+ struct running_action *action = LIST_ENTRY( item, struct running_action, entry );
list_remove( &action->entry );
msi_dialog_check_messages( action->handle );
CloseHandle( action->handle );
- msi_free( action->name );
- msi_free( action );
+ free( action->name );
+ free( action );
}
- EnterCriticalSection( &msi_custom_action_cs );
+ EnterCriticalSection( &custom_action_cs );
- handle_count = list_count( &msi_pending_custom_actions );
- wait_handles = msi_alloc( handle_count * sizeof(HANDLE) );
+ handle_count = list_count( &pending_custom_actions );
+ wait_handles = malloc( handle_count * sizeof(HANDLE) );
handle_count = 0;
- LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
+ LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &pending_custom_actions, custom_action_info, entry )
{
if (info->package == package )
{
}
}
- LeaveCriticalSection( &msi_custom_action_cs );
+ LeaveCriticalSection( &custom_action_cs );
for (i = 0; i < handle_count; i++)
{
msi_dialog_check_messages( wait_handles[i] );
CloseHandle( wait_handles[i] );
}
- msi_free( wait_handles );
+ free( wait_handles );
- EnterCriticalSection( &msi_custom_action_cs );
- LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
+ EnterCriticalSection( &custom_action_cs );
+ LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &pending_custom_actions, custom_action_info, entry )
{
if (info->package == package)
free_custom_action_data( info );
}
- LeaveCriticalSection( &msi_custom_action_cs );
+ LeaveCriticalSection( &custom_action_cs );
}
UINT __cdecl s_remote_GetActionInfo(const GUID *guid, WCHAR **name, int *type, WCHAR **dll, char **func, MSIHANDLE *hinst)
{
- msi_custom_action_info *info;
+ custom_action_info *info;
info = find_action_by_guid(guid);
if (!info)
return ERROR_INVALID_DATA;
- *name = strdupW(info->action);
+ *name = wcsdup(info->action);
*type = info->type;
*hinst = alloc_msihandle(&info->package->hdr);
- *dll = strdupW(info->source);
+ *dll = wcsdup(info->source);
*func = strdupWtoA(info->target);
return ERROR_SUCCESS;
MSITRANSFORM *t = LIST_ENTRY( list_head( &db->transforms ), MSITRANSFORM, entry );
list_remove( &t->entry );
IStorage_Release( t->stg );
- msi_free( t );
+ free( t );
}
}
{
if (db->streams[i].stream) IStream_Release( db->streams[i].stream );
}
- msi_free( db->streams );
+ free( db->streams );
}
void append_storage_to_db( MSIDATABASE *db, IStorage *stg )
{
MSITRANSFORM *t;
- t = msi_alloc( sizeof *t );
+ t = malloc( sizeof *t );
t->stg = stg;
IStorage_AddRef( stg );
list_add_head( &db->transforms, &t->entry );
{
MSIDATABASE *db = (MSIDATABASE *) arg;
- msi_free(db->path);
+ free( db->path );
free_streams( db );
free_cached_tables( db );
free_transforms( db );
if (db->deletefile)
{
DeleteFileW( db->deletefile );
- msi_free( db->deletefile );
+ free( db->deletefile );
}
- msi_free( db->tempfolder );
+ free( db->tempfolder );
}
static HRESULT db_initialize( IStorage *stg, const GUID *clsid )
else
lstrcpyW( path, save_path );
- db->path = strdupW( path );
+ db->path = wcsdup( path );
db->media_transform_offset = MSI_INITIAL_MEDIA_TRANSFORM_OFFSET;
db->media_transform_disk_id = MSI_INITIAL_MEDIA_TRANSFORM_DISKID;
db->storage = stg;
db->mode = mode;
if (created)
- db->deletefile = strdupW( szDBPath );
+ db->deletefile = wcsdup( szDBPath );
list_init( &db->tables );
list_init( &db->transforms );
end:
if( !IS_INTMSIDBOPEN(szPersist) )
- msi_free( szwPersist );
- msi_free( szwDBPath );
+ free( szwPersist );
+ free( szwDBPath );
return r;
}
-static LPWSTR msi_read_text_archive(LPCWSTR path, DWORD *len)
+static WCHAR *read_text_archive(const WCHAR *path, DWORD *len)
{
HANDLE file;
LPSTR data = NULL;
return NULL;
size = GetFileSize( file, NULL );
- if (!(data = msi_alloc( size ))) goto done;
+ if (!(data = malloc( size ))) goto done;
if (!ReadFile( file, data, size, &read, NULL ) || read != size) goto done;
while (!data[size - 1]) size--;
*len = MultiByteToWideChar( CP_ACP, 0, data, size, NULL, 0 );
- if ((wdata = msi_alloc( (*len + 1) * sizeof(WCHAR) )))
+ if ((wdata = malloc( (*len + 1) * sizeof(WCHAR) )))
{
MultiByteToWideChar( CP_ACP, 0, data, size, wdata, *len );
wdata[*len] = 0;
done:
CloseHandle( file );
- msi_free( data );
+ free( data );
return wdata;
}
-static void msi_parse_line(LPWSTR *line, LPWSTR **entries, DWORD *num_entries, DWORD *len)
+static UINT parse_line(WCHAR **line, WCHAR ***entries, DWORD *num_entries, DWORD *len)
{
LPWSTR ptr = *line, save;
DWORD i, count = 1, chars_left = *len;
chars_left--;
}
- *entries = msi_alloc(count * sizeof(LPWSTR));
+ /*
+ * make sure this line has the same number of entries as there are columns
+ * which are indicated by the first line.
+ */
+ if (*num_entries && *num_entries != count)
+ return ERROR_FUNCTION_FAILED;
+
+ *entries = malloc(count * sizeof(WCHAR *));
if (!*entries)
- return;
+ return ERROR_OUTOFMEMORY;
/* store pointers into the data */
chars_left = *len;
/* move to the next line if there's more, else EOF */
*line = ptr;
*len = chars_left;
- if (num_entries)
+ if (!*num_entries)
*num_entries = count;
+
+ return ERROR_SUCCESS;
}
-static LPWSTR msi_build_createsql_prelude(LPWSTR table)
+static WCHAR *build_createsql_prelude(const WCHAR *table)
{
LPWSTR prelude;
DWORD size;
size = ARRAY_SIZE(L"CREATE TABLE `%s` ( ") + lstrlenW(table) - 2;
- prelude = msi_alloc(size * sizeof(WCHAR));
+ prelude = malloc(size * sizeof(WCHAR));
if (!prelude)
return NULL;
return prelude;
}
-static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, DWORD num_columns)
+static WCHAR *build_createsql_columns(WCHAR **columns_data, WCHAR **types, DWORD num_columns)
{
LPWSTR columns, p;
LPCWSTR type;
WCHAR expanded[128], *ptr;
WCHAR size[10], comma[2], extra[30];
- columns = msi_alloc_zero(sql_size * sizeof(WCHAR));
+ columns = calloc(sql_size, sizeof(WCHAR));
if (!columns)
return NULL;
else
{
WARN("invalid int width %lu\n", len);
- msi_free(columns);
+ free(columns);
return NULL;
}
break;
break;
default:
ERR("Unknown type: %c\n", types[i][0]);
- msi_free(columns);
+ free(columns);
return NULL;
}
swprintf(expanded, ARRAY_SIZE(expanded), L"`%s` %s%s%s%s ", columns_data[i], type, size, extra, comma);
sql_size += lstrlenW(expanded);
- p = msi_realloc(columns, sql_size * sizeof(WCHAR));
+ p = realloc(columns, sql_size * sizeof(WCHAR));
if (!p)
{
- msi_free(columns);
+ free(columns);
return NULL;
}
columns = p;
return columns;
}
-static LPWSTR msi_build_createsql_postlude(LPWSTR *primary_keys, DWORD num_keys)
+static WCHAR *build_createsql_postlude(WCHAR **primary_keys, DWORD num_keys)
{
LPWSTR postlude, keys, ptr;
DWORD size, i;
for (i = 0, size = 1; i < num_keys; i++)
size += lstrlenW(L"`%s`, ") + lstrlenW(primary_keys[i]) - 2;
- keys = msi_alloc(size * sizeof(WCHAR));
+ keys = malloc(size * sizeof(WCHAR));
if (!keys)
return NULL;
*(ptr - 2) = '\0';
size = lstrlenW(L"PRIMARY KEY %s)") + size - 1;
- postlude = msi_alloc(size * sizeof(WCHAR));
+ postlude = malloc(size * sizeof(WCHAR));
if (!postlude)
goto done;
swprintf(postlude, size, L"PRIMARY KEY %s)", keys);
done:
- msi_free(keys);
+ free(keys);
return postlude;
}
-static UINT msi_add_table_to_db(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types, LPWSTR *labels, DWORD num_labels, DWORD num_columns)
+static UINT add_table_to_db(MSIDATABASE *db, WCHAR **columns, WCHAR **types, WCHAR **labels, DWORD num_labels,
+ DWORD num_columns)
{
UINT r = ERROR_OUTOFMEMORY;
DWORD size;
LPWSTR create_sql = NULL;
LPWSTR prelude, columns_sql, postlude;
- prelude = msi_build_createsql_prelude(labels[0]);
- columns_sql = msi_build_createsql_columns(columns, types, num_columns);
- postlude = msi_build_createsql_postlude(labels + 1, num_labels - 1); /* skip over table name */
+ prelude = build_createsql_prelude(labels[0]);
+ columns_sql = build_createsql_columns(columns, types, num_columns);
+ postlude = build_createsql_postlude(labels + 1, num_labels - 1); /* skip over table name */
if (!prelude || !columns_sql || !postlude)
goto done;
size = lstrlenW(prelude) + lstrlenW(columns_sql) + lstrlenW(postlude) + 1;
- create_sql = msi_alloc(size * sizeof(WCHAR));
+ create_sql = malloc(size * sizeof(WCHAR));
if (!create_sql)
goto done;
msiobj_release(&view->hdr);
done:
- msi_free(prelude);
- msi_free(columns_sql);
- msi_free(postlude);
- msi_free(create_sql);
+ free(prelude);
+ free(columns_sql);
+ free(postlude);
+ free(create_sql);
return r;
}
-static LPWSTR msi_import_stream_filename(LPCWSTR path, LPCWSTR name)
+static WCHAR *import_stream_filename(const WCHAR *path, const WCHAR *name)
{
DWORD len;
LPWSTR fullname, ptr;
len = lstrlenW(path) + lstrlenW(name) + 1;
- fullname = msi_alloc(len*sizeof(WCHAR));
+ fullname = malloc(len * sizeof(WCHAR));
if (!fullname)
return NULL;
ptr = wcsrchr(fullname, '.');
if (!ptr)
{
- msi_free (fullname);
+ free(fullname);
return NULL;
}
*ptr++ = '\\';
if (*data[i])
{
UINT r;
- LPWSTR file = msi_import_stream_filename(path, data[i]);
+ WCHAR *file = import_stream_filename(path, data[i]);
if (!file)
return ERROR_FUNCTION_FAILED;
r = MSI_RecordSetStreamFromFileW(*rec, i + 1, file);
- msi_free (file);
+ free (file);
if (r != ERROR_SUCCESS)
return ERROR_FUNCTION_FAILED;
}
return ERROR_SUCCESS;
}
-static UINT msi_add_records_to_table(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types,
- LPWSTR *labels, LPWSTR **records,
- int num_columns, int num_records,
- LPWSTR path)
+static UINT add_records_to_table(MSIDATABASE *db, WCHAR **columns, WCHAR **types, WCHAR **labels, WCHAR ***records,
+ int num_columns, int num_records, WCHAR *path)
{
UINT r;
int i;
static UINT MSI_DatabaseImport(MSIDATABASE *db, LPCWSTR folder, LPCWSTR file)
{
UINT r;
- DWORD len, i, num_labels, num_types, num_columns, num_records = 0;
+ DWORD len, i, num_labels = 0, num_types = 0, num_columns = 0, num_records = 0;
WCHAR **columns, **types, **labels, *path, *ptr, *data, ***records = NULL, ***temp_records;
TRACE("%p %s %s\n", db, debugstr_w(folder), debugstr_w(file) );
return ERROR_INVALID_PARAMETER;
len = lstrlenW(folder) + lstrlenW(L"\\") + lstrlenW(file) + 1;
- path = msi_alloc( len * sizeof(WCHAR) );
+ path = malloc( len * sizeof(WCHAR) );
if (!path)
return ERROR_OUTOFMEMORY;
lstrcatW( path, L"\\" );
lstrcatW( path, file );
- data = msi_read_text_archive( path, &len );
+ data = read_text_archive( path, &len );
if (!data)
{
- msi_free(path);
+ free(path);
return ERROR_FUNCTION_FAILED;
}
ptr = data;
- msi_parse_line( &ptr, &columns, &num_columns, &len );
- msi_parse_line( &ptr, &types, &num_types, &len );
- msi_parse_line( &ptr, &labels, &num_labels, &len );
+ parse_line( &ptr, &columns, &num_columns, &len );
+ parse_line( &ptr, &types, &num_types, &len );
+ parse_line( &ptr, &labels, &num_labels, &len );
if (num_columns == 1 && !columns[0][0] && num_labels == 1 && !labels[0][0] &&
num_types == 2 && !wcscmp( types[1], L"_ForceCodepage" ))
goto done;
}
- records = msi_alloc(sizeof(WCHAR **));
+ records = malloc(sizeof(WCHAR **));
if (!records)
{
r = ERROR_OUTOFMEMORY;
/* read in the table records */
while (len)
{
- msi_parse_line( &ptr, &records[num_records], NULL, &len );
+ r = parse_line( &ptr, &records[num_records], &num_columns, &len );
+ if (r != ERROR_SUCCESS)
+ goto done;
num_records++;
- temp_records = msi_realloc(records, (num_records + 1) * sizeof(WCHAR **));
+ temp_records = realloc(records, (num_records + 1) * sizeof(WCHAR **));
if (!temp_records)
{
r = ERROR_OUTOFMEMORY;
{
if (!TABLE_Exists(db, labels[0]))
{
- r = msi_add_table_to_db( db, columns, types, labels, num_labels, num_columns );
+ r = add_table_to_db( db, columns, types, labels, num_labels, num_columns );
if (r != ERROR_SUCCESS)
{
r = ERROR_FUNCTION_FAILED;
}
}
- r = msi_add_records_to_table( db, columns, types, labels, records, num_columns, num_records, path );
+ r = add_records_to_table( db, columns, types, labels, records, num_columns, num_records, path );
}
done:
- msi_free(path);
- msi_free(data);
- msi_free(columns);
- msi_free(types);
- msi_free(labels);
+ free(path);
+ free(data);
+ free(columns);
+ free(types);
+ free(labels);
for (i = 0; i < num_records; i++)
- msi_free(records[i]);
+ free(records[i]);
- msi_free(records);
+ free(records);
return r;
}
r = MsiDatabaseImportW( handle, path, file );
end:
- msi_free( path );
- msi_free( file );
+ free( path );
+ free( file );
return r;
}
-static UINT msi_export_field( HANDLE handle, MSIRECORD *row, UINT field )
+static UINT export_field( HANDLE handle, MSIRECORD *row, UINT field )
{
- char *buffer;
+ char *buffer, *ptr;
BOOL ret;
DWORD sz = 0x100;
UINT r;
- buffer = msi_alloc( sz );
+ buffer = malloc( sz );
if (!buffer)
return ERROR_OUTOFMEMORY;
char *tmp;
sz++; /* leave room for NULL terminator */
- tmp = msi_realloc( buffer, sz );
+ tmp = realloc( buffer, sz );
if (!tmp)
{
- msi_free( buffer );
+ free( buffer );
return ERROR_OUTOFMEMORY;
}
buffer = tmp;
r = MSI_RecordGetStringA( row, field, buffer, &sz );
if (r != ERROR_SUCCESS)
{
- msi_free( buffer );
+ free( buffer );
return r;
}
}
else if (r != ERROR_SUCCESS)
{
- msi_free( buffer );
+ free( buffer );
return r;
}
+ ptr = buffer;
+ while( *ptr )
+ {
+ if (*ptr == '\r' && *( ptr + 1 ) == '\n')
+ {
+ *ptr++ = '\x11';
+ *ptr++ = '\x19';
+ continue;
+ }
+
+ if (*ptr == '\n')
+ *ptr = '\x19';
+
+ ptr++;
+ }
+
ret = WriteFile( handle, buffer, sz, &sz, NULL );
- msi_free( buffer );
+ free( buffer );
return ret ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED;
}
-static UINT msi_export_stream( const WCHAR *folder, const WCHAR *table, MSIRECORD *row, UINT field, UINT start )
+static UINT export_stream( const WCHAR *folder, const WCHAR *table, MSIRECORD *row, UINT field, UINT start )
{
WCHAR stream[MAX_STREAM_NAME_LEN + 1], *path;
DWORD sz, read_size, write_size;
return r;
len = sz + lstrlenW( folder ) + lstrlenW( table ) + ARRAY_SIZE( L"%s\\%s" ) + 1;
- if (!(path = msi_alloc( len * sizeof(WCHAR) )))
+ if (!(path = malloc( len * sizeof(WCHAR) )))
return ERROR_OUTOFMEMORY;
len = swprintf( path, len, L"%s\\%s", folder, table );
if (!CreateDirectoryW( path, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS)
{
- msi_free( path );
+ free( path );
return ERROR_FUNCTION_FAILED;
}
lstrcpyW( path + len, stream );
file = CreateFileW( path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
- msi_free( path );
+ free( path );
if (file == INVALID_HANDLE_VALUE)
return ERROR_FUNCTION_FAILED;
const WCHAR *table;
};
-static UINT msi_export_record( struct row_export_info *row_export_info, MSIRECORD *row, UINT start )
+static UINT export_record( struct row_export_info *row_export_info, MSIRECORD *row, UINT start )
{
HANDLE handle = row_export_info->handle;
UINT i, count, r = ERROR_SUCCESS;
count = MSI_RecordGetFieldCount( row );
for (i = start; i <= count; i++)
{
- r = msi_export_field( handle, row, i );
+ r = export_field( handle, row, i );
if (r == ERROR_INVALID_PARAMETER)
{
- r = msi_export_stream( row_export_info->folder, row_export_info->table, row, i, start );
+ r = export_stream( row_export_info->folder, row_export_info->table, row, i, start );
if (r != ERROR_SUCCESS)
return r;
/* exporting a binary stream, repeat the "Name" field */
- r = msi_export_field( handle, row, start );
+ r = export_field( handle, row, start );
if (r != ERROR_SUCCESS)
return r;
}
return r;
}
-static UINT msi_export_row( MSIRECORD *row, void *arg )
+static UINT export_row( MSIRECORD *row, void *arg )
{
- return msi_export_record( arg, row, 1 );
+ return export_record( arg, row, 1 );
}
-static UINT msi_export_forcecodepage( HANDLE handle, UINT codepage )
+static UINT export_forcecodepage( HANDLE handle, UINT codepage )
{
static const char fmt[] = "\r\n\r\n%u\t_ForceCodepage\r\n";
char data[sizeof(fmt) + 10];
return ERROR_SUCCESS;
}
-static UINT msi_export_summaryinformation( MSIDATABASE *db, HANDLE handle )
+static UINT export_summaryinformation( MSIDATABASE *db, HANDLE handle )
{
static const char header[] = "PropertyId\tValue\r\n"
"i2\tl255\r\n"
return ERROR_INVALID_PARAMETER;
len = lstrlenW(folder) + lstrlenW(file) + 2;
- filename = msi_alloc(len * sizeof (WCHAR));
+ filename = malloc(len * sizeof(WCHAR));
if (!filename)
return ERROR_OUTOFMEMORY;
handle = CreateFileW( filename, GENERIC_READ | GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
- msi_free( filename );
+ free( filename );
if (handle == INVALID_HANDLE_VALUE)
return ERROR_FUNCTION_FAILED;
if (!wcscmp( table, L"_ForceCodepage" ))
{
UINT codepage = msi_get_string_table_codepage( db->strings );
- r = msi_export_forcecodepage( handle, codepage );
+ r = export_forcecodepage( handle, codepage );
goto done;
}
if (!wcscmp( table, L"_SummaryInformation" ))
{
- r = msi_export_summaryinformation( db, handle );
+ r = export_summaryinformation( db, handle );
goto done;
}
r = MSI_ViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec);
if (r == ERROR_SUCCESS)
{
- msi_export_record( &row_export_info, rec, 1 );
+ export_record( &row_export_info, rec, 1 );
msiobj_release( &rec->hdr );
}
r = MSI_ViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec);
if (r == ERROR_SUCCESS)
{
- msi_export_record( &row_export_info, rec, 1 );
+ export_record( &row_export_info, rec, 1 );
msiobj_release( &rec->hdr );
}
if (r == ERROR_SUCCESS)
{
MSI_RecordSetStringW( rec, 0, table );
- msi_export_record( &row_export_info, rec, 0 );
+ export_record( &row_export_info, rec, 0 );
msiobj_release( &rec->hdr );
}
/* write out row 4 onwards, the data */
- r = MSI_IterateRecords( view, 0, msi_export_row, &row_export_info );
+ r = MSI_IterateRecords( view, 0, export_row, &row_export_info );
msiobj_release( &view->hdr );
}
r = MsiDatabaseExportW( handle, table, path, file );
end:
- msi_free( table );
- msi_free( path );
- msi_free( file );
+ free( table );
+ free( path );
+ free( file );
return r;
}
table = strdupAtoW(szTableName);
r = MsiDatabaseMergeW(hDatabase, hDatabaseMerge, table);
- msi_free(table);
+ free(table);
return r;
}
-typedef struct _tagMERGETABLE
+struct merge_table
{
struct list entry;
struct list rows;
DWORD numtypes;
LPWSTR *labels;
DWORD numlabels;
-} MERGETABLE;
+};
-typedef struct _tagMERGEROW
+struct merge_row
{
struct list entry;
MSIRECORD *data;
-} MERGEROW;
+};
-typedef struct _tagMERGEDATA
+struct merge_data
{
MSIDATABASE *db;
MSIDATABASE *merge;
- MERGETABLE *curtable;
+ struct merge_table *curtable;
MSIQUERY *curview;
struct list *tabledata;
-} MERGEDATA;
+};
static BOOL merge_type_match(LPCWSTR type1, LPCWSTR type2)
{
{
str = msi_dup_record_field(colnames, ++i);
cmp = wcscmp( key, str );
- msi_free(str);
+ free(str);
} while (cmp);
msiobj_release(&colnames->hdr);
{
/* quote string record fields */
sz += 2;
- val = msi_alloc(sz * sizeof(WCHAR));
+ val = malloc(sz * sizeof(WCHAR));
if (!val)
return NULL;
else
{
/* do not quote integer record fields */
- val = msi_alloc(sz * sizeof(WCHAR));
+ val = malloc(sz * sizeof(WCHAR));
if (!val)
return NULL;
if (r != ERROR_SUCCESS)
{
ERR("failed to get string!\n");
- msi_free(val);
+ free(val);
return NULL;
}
static LPWSTR create_diff_row_query(MSIDATABASE *merge, MSIQUERY *view,
LPWSTR table, MSIRECORD *rec)
{
- LPWSTR query = NULL, clause = NULL, val;
+ WCHAR *query = NULL, *clause = NULL, *new_clause, *val;
LPCWSTR setptr, key;
DWORD size, oldsize;
MSIRECORD *keys;
if (r != ERROR_SUCCESS)
return NULL;
- clause = msi_alloc_zero(sizeof(WCHAR));
- if (!clause)
- goto done;
-
size = 1;
count = MSI_RecordGetFieldCount(keys);
for (i = 1; i <= count; i++)
oldsize = size;
size += lstrlenW(setptr) + lstrlenW(key) + lstrlenW(val) - 4;
- clause = msi_realloc(clause, size * sizeof (WCHAR));
- if (!clause)
+ new_clause = realloc(clause, size * sizeof(WCHAR));
+ if (!new_clause)
{
- msi_free(val);
+ free(val);
goto done;
}
+ clause = new_clause;
swprintf(clause + oldsize - 1, size - (oldsize - 1), setptr, key, val);
- msi_free(val);
+ free(val);
}
size = lstrlenW(L"SELECT * FROM `%s` WHERE %s") + lstrlenW(table) + lstrlenW(clause) + 1;
- query = msi_alloc(size * sizeof(WCHAR));
+ query = malloc(size * sizeof(WCHAR));
if (!query)
goto done;
swprintf(query, size, L"SELECT * FROM `%s` WHERE %s", table, clause);
done:
- msi_free(clause);
+ free(clause);
msiobj_release(&keys->hdr);
return query;
}
static UINT merge_diff_row(MSIRECORD *rec, LPVOID param)
{
- MERGEDATA *data = param;
- MERGETABLE *table = data->curtable;
- MERGEROW *mergerow;
+ struct merge_data *data = param;
+ struct merge_table *table = data->curtable;
+ struct merge_row *mergerow;
MSIQUERY *dbview = NULL;
MSIRECORD *row = NULL;
LPWSTR query = NULL;
r = ERROR_SUCCESS;
}
- mergerow = msi_alloc(sizeof(MERGEROW));
+ mergerow = malloc(sizeof(*mergerow));
if (!mergerow)
{
r = ERROR_OUTOFMEMORY;
if (!mergerow->data)
{
r = ERROR_OUTOFMEMORY;
- msi_free(mergerow);
+ free(mergerow);
goto done;
}
list_add_tail(&table->rows, &mergerow->entry);
done:
- msi_free(query);
+ free(query);
msiobj_release(&row->hdr);
msiobj_release(&dbview->hdr);
return r;
}
-static UINT msi_get_table_labels(MSIDATABASE *db, LPCWSTR table, LPWSTR **labels, DWORD *numlabels)
+static UINT get_table_labels(MSIDATABASE *db, const WCHAR *table, WCHAR ***labels, DWORD *numlabels)
{
UINT r, i, count;
MSIRECORD *prec = NULL;
count = MSI_RecordGetFieldCount(prec);
*numlabels = count + 1;
- *labels = msi_alloc((*numlabels)*sizeof(LPWSTR));
+ *labels = malloc((*numlabels) * sizeof(WCHAR *));
if (!*labels)
{
r = ERROR_OUTOFMEMORY;
goto end;
}
- (*labels)[0] = strdupW(table);
+ (*labels)[0] = wcsdup(table);
for (i=1; i<=count; i++ )
{
- (*labels)[i] = strdupW(MSI_RecordGetString(prec, i));
+ (*labels)[i] = wcsdup(MSI_RecordGetString(prec, i));
}
end:
return r;
}
-static UINT msi_get_query_columns(MSIQUERY *query, LPWSTR **columns, DWORD *numcolumns)
+static UINT get_query_columns(MSIQUERY *query, WCHAR ***columns, DWORD *numcolumns)
{
UINT r, i, count;
MSIRECORD *prec = NULL;
return r;
count = MSI_RecordGetFieldCount(prec);
- *columns = msi_alloc(count*sizeof(LPWSTR));
+ *columns = malloc(count * sizeof(WCHAR *));
if (!*columns)
{
r = ERROR_OUTOFMEMORY;
for (i=1; i<=count; i++ )
{
- (*columns)[i-1] = strdupW(MSI_RecordGetString(prec, i));
+ (*columns)[i-1] = wcsdup(MSI_RecordGetString(prec, i));
}
*numcolumns = count;
return r;
}
-static UINT msi_get_query_types(MSIQUERY *query, LPWSTR **types, DWORD *numtypes)
+static UINT get_query_types(MSIQUERY *query, WCHAR ***types, DWORD *numtypes)
{
UINT r, i, count;
MSIRECORD *prec = NULL;
return r;
count = MSI_RecordGetFieldCount(prec);
- *types = msi_alloc(count*sizeof(LPWSTR));
+ *types = malloc(count * sizeof(WCHAR *));
if (!*types)
{
r = ERROR_OUTOFMEMORY;
*numtypes = count;
for (i=1; i<=count; i++ )
{
- (*types)[i-1] = strdupW(MSI_RecordGetString(prec, i));
+ (*types)[i-1] = wcsdup(MSI_RecordGetString(prec, i));
}
end:
return r;
}
-static void merge_free_rows(MERGETABLE *table)
+static void merge_free_rows(struct merge_table *table)
{
struct list *item, *cursor;
LIST_FOR_EACH_SAFE(item, cursor, &table->rows)
{
- MERGEROW *row = LIST_ENTRY(item, MERGEROW, entry);
+ struct merge_row *row = LIST_ENTRY(item, struct merge_row, entry);
list_remove(&row->entry);
msiobj_release(&row->data->hdr);
- msi_free(row);
+ free(row);
}
}
-static void free_merge_table(MERGETABLE *table)
+static void free_merge_table(struct merge_table *table)
{
UINT i;
if (table->labels != NULL)
{
for (i = 0; i < table->numlabels; i++)
- msi_free(table->labels[i]);
+ free(table->labels[i]);
- msi_free(table->labels);
+ free(table->labels);
}
if (table->columns != NULL)
{
for (i = 0; i < table->numcolumns; i++)
- msi_free(table->columns[i]);
+ free(table->columns[i]);
- msi_free(table->columns);
+ free(table->columns);
}
if (table->types != NULL)
{
for (i = 0; i < table->numtypes; i++)
- msi_free(table->types[i]);
+ free(table->types[i]);
- msi_free(table->types);
+ free(table->types);
}
- msi_free(table->name);
+ free(table->name);
merge_free_rows(table);
- msi_free(table);
+ free(table);
}
-static UINT msi_get_merge_table (MSIDATABASE *db, LPCWSTR name, MERGETABLE **ptable)
+static UINT get_merge_table(MSIDATABASE *db, const WCHAR *name, struct merge_table **ptable)
{
UINT r;
- MERGETABLE *table;
+ struct merge_table *table;
MSIQUERY *mergeview = NULL;
- table = msi_alloc_zero(sizeof(MERGETABLE));
+ table = calloc(1, sizeof(*table));
if (!table)
{
*ptable = NULL;
return ERROR_OUTOFMEMORY;
}
- r = msi_get_table_labels(db, name, &table->labels, &table->numlabels);
+ r = get_table_labels(db, name, &table->labels, &table->numlabels);
if (r != ERROR_SUCCESS)
goto err;
if (r != ERROR_SUCCESS)
goto err;
- r = msi_get_query_columns(mergeview, &table->columns, &table->numcolumns);
+ r = get_query_columns(mergeview, &table->columns, &table->numcolumns);
if (r != ERROR_SUCCESS)
goto err;
- r = msi_get_query_types(mergeview, &table->types, &table->numtypes);
+ r = get_query_types(mergeview, &table->types, &table->numtypes);
if (r != ERROR_SUCCESS)
goto err;
list_init(&table->rows);
- table->name = strdupW(name);
+ table->name = wcsdup(name);
table->numconflicts = 0;
msiobj_release(&mergeview->hdr);
static UINT merge_diff_tables(MSIRECORD *rec, LPVOID param)
{
- MERGEDATA *data = param;
- MERGETABLE *table;
+ struct merge_data *data = param;
+ struct merge_table *table;
MSIQUERY *dbview = NULL;
MSIQUERY *mergeview = NULL;
LPCWSTR name;
goto done;
}
- r = msi_get_merge_table(data->merge, name, &table);
+ r = get_merge_table(data->merge, name, &table);
if (r != ERROR_SUCCESS)
goto done;
struct list *tabledata)
{
MSIQUERY *view;
- MERGEDATA data;
+ struct merge_data data;
UINT r;
r = MSI_DatabaseOpenViewW(merge, L"SELECT * FROM `_Tables`", &view);
return r;
}
-static UINT merge_table(MSIDATABASE *db, MERGETABLE *table)
+static UINT merge_table(MSIDATABASE *db, struct merge_table *table)
{
UINT r;
- MERGEROW *row;
+ struct merge_row *row;
MSIVIEW *tv;
if (!TABLE_Exists(db, table->name))
{
- r = msi_add_table_to_db(db, table->columns, table->types,
- table->labels, table->numlabels, table->numcolumns);
+ r = add_table_to_db(db, table->columns, table->types, table->labels, table->numlabels, table->numcolumns);
if (r != ERROR_SUCCESS)
return ERROR_FUNCTION_FAILED;
}
- LIST_FOR_EACH_ENTRY(row, &table->rows, MERGEROW, entry)
+ LIST_FOR_EACH_ENTRY(row, &table->rows, struct merge_row, entry)
{
r = TABLE_CreateView(db, table->name, &tv);
if (r != ERROR_SUCCESS)
struct list tabledata = LIST_INIT(tabledata);
struct list *item, *cursor;
MSIDATABASE *db, *merge;
- MERGETABLE *table;
+ struct merge_table *table;
BOOL conflicts;
UINT r;
goto done;
conflicts = FALSE;
- LIST_FOR_EACH_ENTRY(table, &tabledata, MERGETABLE, entry)
+ LIST_FOR_EACH_ENTRY(table, &tabledata, struct merge_table, entry)
{
if (table->numconflicts)
{
LIST_FOR_EACH_SAFE(item, cursor, &tabledata)
{
- MERGETABLE *table = LIST_ENTRY(item, MERGETABLE, entry);
+ struct merge_table *table = LIST_ENTRY(item, struct merge_table, entry);
list_remove(&table->entry);
free_merge_table(table);
}
* that's a bug in the way I'm running the query, or a just a bug.
*/
-typedef struct tagMSIDELETEVIEW
+struct delete_view
{
MSIVIEW view;
MSIDATABASE *db;
MSIVIEW *table;
-} MSIDELETEVIEW;
+};
static UINT DELETE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p %d %d %p\n", dv, row, col, val );
static UINT DELETE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p %d %d %p\n", dv, row, col, stm );
static UINT DELETE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
UINT r, i, rows = 0, cols = 0;
TRACE("%p %p\n", dv, record);
static UINT DELETE_close( struct tagMSIVIEW *view )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p\n", dv );
static UINT DELETE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p %p %p\n", dv, rows, cols );
static UINT DELETE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p %d %p %p %p %p\n", dv, n, name, type, temporary, table_name );
static UINT DELETE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
MSIRECORD *rec, UINT row )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p %d %p\n", dv, eModifyMode, rec );
static UINT DELETE_delete( struct tagMSIVIEW *view )
{
- MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
+ struct delete_view *dv = (struct delete_view *)view;
TRACE("%p\n", dv );
if( dv->table )
dv->table->ops->delete( dv->table );
- msi_free( dv );
+ free( dv );
return ERROR_SUCCESS;
}
UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table )
{
- MSIDELETEVIEW *dv = NULL;
+ struct delete_view *dv = NULL;
TRACE("%p\n", dv );
- dv = msi_alloc_zero( sizeof *dv );
+ dv = calloc( 1, sizeof *dv );
if( !dv )
return ERROR_FUNCTION_FAILED;
*/
#define COBJMACROS
-#define NONAMELESSUNION
#include <stdarg.h>
extern HINSTANCE msi_hInstance;
-struct msi_control_tag;
-typedef struct msi_control_tag msi_control;
-typedef UINT (*msi_handler)( msi_dialog *, msi_control *, WPARAM );
-typedef void (*msi_update)( msi_dialog *, msi_control * );
-typedef UINT (*control_event_handler)( msi_dialog *, const WCHAR *, const WCHAR * );
-typedef UINT (*event_handler)( msi_dialog *, const WCHAR * );
-
-struct msi_control_tag
+struct control
{
struct list entry;
HWND hwnd;
- msi_handler handler;
- msi_update update;
+ UINT (*handler)( msi_dialog *, struct control *, WPARAM );
+ void (*update)( msi_dialog *, struct control * );
LPWSTR property;
LPWSTR value;
HBITMAP hBitmap;
WCHAR name[1];
};
-typedef struct msi_font_tag
+struct font
{
struct list entry;
HFONT hfont;
COLORREF color;
WCHAR name[1];
-} msi_font;
+};
struct msi_dialog_tag
{
MSIPACKAGE *package;
msi_dialog *parent;
- control_event_handler event_handler;
+ UINT (*event_handler)( msi_dialog *, const WCHAR *, const WCHAR * );
BOOL finished;
INT scale;
DWORD attributes;
HWND hWndFocus;
LPWSTR control_default;
LPWSTR control_cancel;
- event_handler pending_event;
+ UINT (*pending_event)( msi_dialog *, const WCHAR * );
LPWSTR pending_argument;
INT retval;
WCHAR name[1];
WCHAR *attribute;
};
-typedef UINT (*msi_dialog_control_func)( msi_dialog *dialog, MSIRECORD *rec );
struct control_handler
{
LPCWSTR control_type;
- msi_dialog_control_func func;
+ UINT (*func)( msi_dialog *dialog, MSIRECORD *rec );
};
-typedef struct
+struct radio_button_group_descr
{
- msi_dialog* dialog;
- msi_control *parent;
- LPWSTR propval;
-} radio_button_group_descr;
+ msi_dialog *dialog;
+ struct control *parent;
+ WCHAR *propval;
+};
/* dialog sequencing */
static DWORD uiThreadId;
static HWND hMsiHiddenWindow;
-static LPWSTR msi_get_window_text( HWND hwnd )
+static WCHAR *get_window_text( HWND hwnd )
{
UINT sz, r;
- LPWSTR buf;
+ WCHAR *buf, *new_buf;
sz = 0x20;
- buf = msi_alloc( sz*sizeof(WCHAR) );
+ buf = malloc( sz * sizeof(WCHAR) );
while ( buf )
{
r = GetWindowTextW( hwnd, buf, sz );
if ( r < (sz - 1) )
break;
sz *= 2;
- buf = msi_realloc( buf, sz*sizeof(WCHAR) );
+ new_buf = realloc( buf, sz * sizeof(WCHAR) );
+ if ( !new_buf )
+ free( buf );
+ buf = new_buf;
}
return buf;
}
-static INT msi_dialog_scale_unit( msi_dialog *dialog, INT val )
+static INT dialog_scale_unit( msi_dialog *dialog, INT val )
{
return MulDiv( val, dialog->scale, 12 );
}
-static msi_control *msi_dialog_find_control( msi_dialog *dialog, LPCWSTR name )
+static struct control *dialog_find_control( msi_dialog *dialog, const WCHAR *name )
{
- msi_control *control;
+ struct control *control;
if( !name )
return NULL;
if( !dialog->hwnd )
return NULL;
- LIST_FOR_EACH_ENTRY( control, &dialog->controls,