Implement logging.

This commit is contained in:
Aric Stewart 2004-07-09 19:26:30 +00:00 committed by Alexandre Julliard
parent c34b79ce43
commit 7231a439b4
4 changed files with 211 additions and 147 deletions

View File

@ -232,6 +232,22 @@ inline static char *strdupWtoA( const WCHAR *str )
return ret; return ret;
} }
inline static WCHAR *load_dynamic_stringW(MSIHANDLE row, INT index)
{
DWORD sz;
LPWSTR ret;
sz = 0;
MsiRecordGetStringW(row,index,NULL,&sz);
if (sz <= 0)
return NULL;
sz ++;
ret = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR));
MsiRecordGetStringW(row,index,ret,&sz);
return ret;
}
inline static int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component ) inline static int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component )
{ {
INT rc = -1; INT rc = -1;
@ -352,40 +368,43 @@ static void ui_actiondata(MSIHANDLE hPackage, LPCWSTR action, MSIHANDLE record)
UINT rc; UINT rc;
MSIHANDLE view; MSIHANDLE view;
MSIHANDLE row = 0; MSIHANDLE row = 0;
WCHAR *ActionFormat=NULL; static WCHAR *ActionFormat=NULL;
DWORD sz; static WCHAR LastAction[0x100] = {0};
WCHAR Query[1024]; WCHAR Query[1024];
MSIHANDLE db; MSIHANDLE db;
LPWSTR ptr; LPWSTR ptr;
sprintfW(Query,Query_t,action); if (strcmpW(LastAction,action)!=0)
db = MsiGetActiveDatabase(hPackage);
rc = MsiDatabaseOpenViewW(db, Query, &view);
MsiCloseHandle(db);
MsiViewExecute(view, 0);
rc = MsiViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{ {
MsiViewClose(view); sprintfW(Query,Query_t,action);
MsiCloseHandle(view); db = MsiGetActiveDatabase(hPackage);
return; rc = MsiDatabaseOpenViewW(db, Query, &view);
} MsiCloseHandle(db);
MsiViewExecute(view, 0);
rc = MsiViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MsiViewClose(view);
MsiCloseHandle(view);
return;
}
if (MsiRecordIsNull(row,3)) if (MsiRecordIsNull(row,3))
{ {
MsiCloseHandle(row);
MsiViewClose(view);
MsiCloseHandle(view);
return;
}
if (ActionFormat)
HeapFree(GetProcessHeap(),0,ActionFormat);
ActionFormat = load_dynamic_stringW(row,3);
MsiCloseHandle(row); MsiCloseHandle(row);
MsiViewClose(view); MsiViewClose(view);
MsiCloseHandle(view); MsiCloseHandle(view);
return;
} }
sz = 0;
MsiRecordGetStringW(row,3,NULL,&sz);
sz++;
ActionFormat = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
MsiRecordGetStringW(row,3,ActionFormat,&sz);
MsiCloseHandle(row);
MsiViewClose(view);
MsiCloseHandle(view);
message[0]=0; message[0]=0;
ptr = ActionFormat; ptr = ActionFormat;
@ -404,13 +423,12 @@ static void ui_actiondata(MSIHANDLE hPackage, LPCWSTR action, MSIHANDLE record)
strcatW(message,tmp); strcatW(message,tmp);
ptr2++; ptr2++;
field = atoiW(ptr2); field = atoiW(ptr2);
sz = 0; data = load_dynamic_stringW(record,field);
MsiRecordGetStringW(record,field,NULL,&sz); if (data)
sz++; {
data = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR)); strcatW(message,data);
MsiRecordGetStringW(record,field,data,&sz); HeapFree(GetProcessHeap(),0,data);
strcatW(message,data); }
HeapFree(GetProcessHeap(),0,data);
ptr=strchrW(ptr2,']'); ptr=strchrW(ptr2,']');
ptr++; ptr++;
} }
@ -426,7 +444,6 @@ static void ui_actiondata(MSIHANDLE hPackage, LPCWSTR action, MSIHANDLE record)
MsiProcessMessage(hPackage, INSTALLMESSAGE_ACTIONDATA, row); MsiProcessMessage(hPackage, INSTALLMESSAGE_ACTIONDATA, row);
MsiCloseHandle(row); MsiCloseHandle(row);
HeapFree(GetProcessHeap(),0,ActionFormat);
} }
@ -446,7 +463,6 @@ static void ui_actionstart(MSIHANDLE hPackage, LPCWSTR action)
MSIHANDLE view; MSIHANDLE view;
MSIHANDLE row = 0; MSIHANDLE row = 0;
WCHAR *ActionText=NULL; WCHAR *ActionText=NULL;
DWORD sz;
WCHAR Query[1024]; WCHAR Query[1024];
MSIHANDLE db; MSIHANDLE db;
@ -465,11 +481,7 @@ static void ui_actionstart(MSIHANDLE hPackage, LPCWSTR action)
return; return;
} }
sz = 0; ActionText = load_dynamic_stringW(row,2);
MsiRecordGetStringW(row,2,NULL,&sz);
sz++;
ActionText = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
MsiRecordGetStringW(row,2,ActionText,&sz);
MsiCloseHandle(row); MsiCloseHandle(row);
MsiViewClose(view); MsiViewClose(view);
MsiCloseHandle(view); MsiCloseHandle(view);
@ -635,7 +647,7 @@ static UINT ACTION_ProcessExecSequence(MSIHANDLE hPackage, BOOL UIran)
MsiCloseHandle(row); MsiCloseHandle(row);
MsiViewClose(view); MsiViewClose(view);
MsiCloseHandle(view); MsiCloseHandle(view);
sprintf(Query,ExecSeqQuery,0); sprintf(Query,ExecSeqQuery,seq);
} }
else else
sprintf(Query,ExecSeqQuery,0); sprintf(Query,ExecSeqQuery,0);
@ -671,22 +683,22 @@ static UINT ACTION_ProcessExecSequence(MSIHANDLE hPackage, BOOL UIran)
/* check conditions */ /* check conditions */
if (!MsiRecordIsNull(row,2)) if (!MsiRecordIsNull(row,2))
{ {
sz=0x100; LPWSTR cond = NULL;
rc = MsiRecordGetStringW(row,2,buffer,&sz); cond = load_dynamic_stringW(row,2);
if (rc != ERROR_SUCCESS)
{
MsiCloseHandle(row);
break;
}
/* this is a hack to skip errors in the condition code */ if (cond)
if (MsiEvaluateConditionW(hPackage, buffer) ==
MSICONDITION_FALSE)
{ {
MsiCloseHandle(row); /* this is a hack to skip errors in the condition code */
continue; if (MsiEvaluateConditionW(hPackage, cond) ==
MSICONDITION_FALSE)
{
HeapFree(GetProcessHeap(),0,cond);
MsiCloseHandle(row);
continue;
}
else
HeapFree(GetProcessHeap(),0,cond);
} }
} }
sz=0x100; sz=0x100;
@ -760,21 +772,22 @@ static UINT ACTION_ProcessUISequence(MSIHANDLE hPackage)
/* check conditions */ /* check conditions */
if (!MsiRecordIsNull(row,2)) if (!MsiRecordIsNull(row,2))
{ {
sz=0x100; LPWSTR cond = NULL;
rc = MsiRecordGetStringW(row,2,buffer,&sz); cond = load_dynamic_stringW(row,2);
if (rc != ERROR_SUCCESS)
{
MsiCloseHandle(row);
break;
}
if (MsiEvaluateConditionW(hPackage, buffer) == if (cond)
MSICONDITION_FALSE)
{ {
MsiCloseHandle(row); /* this is a hack to skip errors in the condition code */
continue; if (MsiEvaluateConditionW(hPackage, cond) ==
MSICONDITION_FALSE)
{
HeapFree(GetProcessHeap(),0,cond);
MsiCloseHandle(row);
continue;
}
else
HeapFree(GetProcessHeap(),0,cond);
} }
} }
sz=0x100; sz=0x100;
@ -892,9 +905,8 @@ static UINT ACTION_CustomAction(MSIHANDLE hPackage,const WCHAR *action)
,'o','n','`',' ','=',' ','`',0}; ,'o','n','`',' ','=',' ','`',0};
static const WCHAR end[]={'`',0}; static const WCHAR end[]={'`',0};
UINT type; UINT type;
DWORD sz; LPWSTR source;
WCHAR source[0x100]; LPWSTR target;
WCHAR target[0x200];
WCHAR *deformated=NULL; WCHAR *deformated=NULL;
MSIHANDLE db; MSIHANDLE db;
@ -926,10 +938,8 @@ static UINT ACTION_CustomAction(MSIHANDLE hPackage,const WCHAR *action)
type = MsiRecordGetInteger(row,2); type = MsiRecordGetInteger(row,2);
sz=0x100; source = load_dynamic_stringW(row,3);
MsiRecordGetStringW(row,3,source,&sz); target = load_dynamic_stringW(row,4);
sz=0x200;
MsiRecordGetStringW(row,4,target,&sz);
TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type, TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
debugstr_w(source), debugstr_w(target)); debugstr_w(source), debugstr_w(target));
@ -955,6 +965,8 @@ static UINT ACTION_CustomAction(MSIHANDLE hPackage,const WCHAR *action)
debugstr_w(target)); debugstr_w(target));
} }
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
MsiCloseHandle(row); MsiCloseHandle(row);
MsiViewClose(view); MsiViewClose(view);
MsiCloseHandle(view); MsiCloseHandle(view);
@ -1053,6 +1065,46 @@ static UINT store_binary_to_temp(MSIHANDLE hPackage, const LPWSTR source,
typedef UINT CustomEntry(MSIHANDLE); typedef UINT CustomEntry(MSIHANDLE);
typedef struct
{
MSIHANDLE hPackage;
WCHAR target[MAX_PATH];
WCHAR source[MAX_PATH];
} thread_struct;
static DWORD WINAPI DllThread(LPVOID info)
{
HANDLE DLL;
LPSTR proc;
thread_struct *stuff;
CustomEntry *fn;
stuff = (thread_struct*)info;
TRACE("Asyncronous start (%s, %s) \n", debugstr_w(stuff->source),
debugstr_w(stuff->target));
DLL = LoadLibraryW(stuff->source);
if (DLL)
{
proc = strdupWtoA( stuff->target );
fn = (CustomEntry*)GetProcAddress(DLL,proc);
if (fn)
{
TRACE("Calling function\n");
fn(stuff->hPackage);
}
else
ERR("Cannot load functon\n");
HeapFree(GetProcessHeap(),0,proc);
FreeLibrary(DLL);
}
else
ERR("Unable to load library\n");
return 0;
}
static UINT HANDLE_CustomType1(MSIHANDLE hPackage, const LPWSTR source, static UINT HANDLE_CustomType1(MSIHANDLE hPackage, const LPWSTR source,
const LPWSTR target, const INT type) const LPWSTR target, const INT type)
@ -1061,23 +1113,29 @@ static UINT HANDLE_CustomType1(MSIHANDLE hPackage, const LPWSTR source,
CustomEntry *fn; CustomEntry *fn;
HANDLE DLL; HANDLE DLL;
LPSTR proc; LPSTR proc;
static thread_struct info;
store_binary_to_temp(hPackage, source, tmp_file); store_binary_to_temp(hPackage, source, tmp_file);
TRACE("Calling function %s from %s\n",debugstr_w(target), TRACE("Calling function %s from %s\n",debugstr_w(target),
debugstr_w(tmp_file)); debugstr_w(tmp_file));
if (type & 0xc0)
{
FIXME("Asynchronous execution.. UNHANDLED\n");
return ERROR_SUCCESS;
}
if (!strchrW(tmp_file,'.')) if (!strchrW(tmp_file,'.'))
{ {
static const WCHAR dot[]={'.',0}; static const WCHAR dot[]={'.',0};
strcatW(tmp_file,dot); strcatW(tmp_file,dot);
} }
if (type & 0xc0)
{
DWORD ThreadId;
info.hPackage = hPackage;
strcpyW(info.target,target);
strcpyW(info.source,tmp_file);
TRACE("Start Asyncronous execution\n");
CreateThread(NULL,0,DllThread,(LPVOID)&info,0,&ThreadId);
return ERROR_SUCCESS;
}
DLL = LoadLibraryW(tmp_file); DLL = LoadLibraryW(tmp_file);
if (DLL) if (DLL)
@ -1995,7 +2053,6 @@ static UINT ACTION_CostFinalize(MSIHANDLE hPackage)
while (1) while (1)
{ {
WCHAR Feature[0x100]; WCHAR Feature[0x100];
WCHAR Condition[0x100];
MSIHANDLE row = 0; MSIHANDLE row = 0;
DWORD sz; DWORD sz;
int feature_index; int feature_index;
@ -2010,14 +2067,15 @@ static UINT ACTION_CostFinalize(MSIHANDLE hPackage)
sz = 0x100; sz = 0x100;
MsiRecordGetStringW(row,1,Feature,&sz); MsiRecordGetStringW(row,1,Feature,&sz);
sz = 0x100;
MsiRecordGetStringW(row,3,Condition,&sz);
feature_index = get_loaded_feature(package,Feature); feature_index = get_loaded_feature(package,Feature);
if (feature_index < 0) if (feature_index < 0)
ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature)); ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature));
else else
{ {
LPWSTR Condition;
Condition = load_dynamic_stringW(row,3);
if (MsiEvaluateConditionW(hPackage,Condition) == MSICONDITION_TRUE) if (MsiEvaluateConditionW(hPackage,Condition) == MSICONDITION_TRUE)
{ {
int level = MsiRecordGetInteger(row,2); int level = MsiRecordGetInteger(row,2);
@ -2025,6 +2083,7 @@ static UINT ACTION_CostFinalize(MSIHANDLE hPackage)
level); level);
package->features[feature_index].Level = level; package->features[feature_index].Level = level;
} }
HeapFree(GetProcessHeap(),0,Condition);
} }
MsiCloseHandle(row); MsiCloseHandle(row);
@ -2253,7 +2312,7 @@ static UINT ready_media_for_file(MSIHANDLE hPackage, UINT sequence,
} }
else else
{ {
sz = 0x100; sz = MAX_PATH;
if (MsiGetPropertyW(hPackage, cszSourceDir, source, &sz)) if (MsiGetPropertyW(hPackage, cszSourceDir, source, &sz))
{ {
ERR("No Source dir defined \n"); ERR("No Source dir defined \n");
@ -2745,11 +2804,7 @@ static UINT ACTION_WriteRegistryValues(MSIHANDLE hPackage)
continue; continue;
} }
sz = 0; value = load_dynamic_stringW(row,5);
MsiRecordGetStringW(row,5,NULL,&sz);
sz++;
value = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
MsiRecordGetStringW(row,5,value,&sz);
value_data = parse_value(hPackage, value, &type, &size); value_data = parse_value(hPackage, value, &type, &size);
if (value_data) if (value_data)
@ -2793,8 +2848,9 @@ static DWORD deformat_string(MSIHANDLE hPackage, WCHAR* ptr,WCHAR** data)
DWORD size=0; DWORD size=0;
DWORD chunk=0; DWORD chunk=0;
WCHAR key[0x100]; WCHAR key[0x100];
WCHAR value[0x100]; LPWSTR value;
DWORD sz; DWORD sz;
UINT rc;
/* scan for special characters */ /* scan for special characters */
if (!strchrW(ptr,'[') || (strchrW(ptr,'[') && !strchrW(ptr,']'))) if (!strchrW(ptr,'[') || (strchrW(ptr,'[') && !strchrW(ptr,']')))
@ -2830,10 +2886,16 @@ static DWORD deformat_string(MSIHANDLE hPackage, WCHAR* ptr,WCHAR** data)
mark = strchrW(mark,']'); mark = strchrW(mark,']');
mark++; mark++;
TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark)); TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark));
sz = 0x100; sz = 0;
if (MsiGetPropertyW(hPackage, key, value,&sz) == ERROR_SUCCESS) rc = MsiGetPropertyW(hPackage, key, NULL, &sz);
if ((rc == ERROR_SUCCESS) || (rc == ERROR_MORE_DATA))
{ {
LPWSTR newdata; LPWSTR newdata;
sz++;
value = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
MsiGetPropertyW(hPackage, key, value, &sz);
chunk = (strlenW(value)+1) * sizeof(WCHAR); chunk = (strlenW(value)+1) * sizeof(WCHAR);
size+=chunk; size+=chunk;
newdata = HeapReAlloc(GetProcessHeap(),0,*data,size); newdata = HeapReAlloc(GetProcessHeap(),0,*data,size);
@ -2999,7 +3061,6 @@ static UINT ACTION_LaunchConditions(MSIHANDLE hPackage)
{ {
LPWSTR cond = NULL; LPWSTR cond = NULL;
LPWSTR message = NULL; LPWSTR message = NULL;
DWORD sz;
rc = MsiViewFetch(view,&row); rc = MsiViewFetch(view,&row);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
@ -3008,19 +3069,11 @@ static UINT ACTION_LaunchConditions(MSIHANDLE hPackage)
break; break;
} }
sz = 0; cond = load_dynamic_stringW(row,1);
MsiRecordGetStringW(row,1,NULL,&sz);
sz++;
cond = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
MsiRecordGetStringW(row,1,cond,&sz);
if (MsiEvaluateConditionW(hPackage,cond) != MSICONDITION_TRUE) if (MsiEvaluateConditionW(hPackage,cond) != MSICONDITION_TRUE)
{ {
sz = 0; message = load_dynamic_stringW(row,2);
MsiRecordGetStringW(row,2,NULL,&sz);
sz++;
message = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
MsiRecordGetStringW(row,2,message,&sz);
MessageBoxW(NULL,message,title,MB_OK); MessageBoxW(NULL,message,title,MB_OK);
HeapFree(GetProcessHeap(),0,message); HeapFree(GetProcessHeap(),0,message);
rc = ERROR_FUNCTION_FAILED; rc = ERROR_FUNCTION_FAILED;
@ -3282,7 +3335,6 @@ static UINT register_appid(MSIHANDLE hPackage, LPCWSTR clsid, LPCWSTR app )
MSIPACKAGE* package; MSIPACKAGE* package;
HKEY hkey2,hkey3; HKEY hkey2,hkey3;
LPWSTR buffer=0; LPWSTR buffer=0;
DWORD sz;
package = msihandle2msiinfo(hPackage, MSIHANDLETYPE_PACKAGE); package = msihandle2msiinfo(hPackage, MSIHANDLETYPE_PACKAGE);
if (!package) if (!package)
@ -3316,11 +3368,7 @@ static UINT register_appid(MSIHANDLE hPackage, LPCWSTR clsid, LPCWSTR app )
UINT size; UINT size;
static const WCHAR szRemoteServerName[] = static const WCHAR szRemoteServerName[] =
{'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',0}; {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',0};
sz = 0; buffer = load_dynamic_stringW(row,2);
MsiRecordGetStringW(row,2,NULL,&sz);
sz++;
buffer = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR));
MsiRecordGetStringW(row,2,buffer,&sz);
size = deformat_string(hPackage,buffer,&deformated); size = deformat_string(hPackage,buffer,&deformated);
RegSetValueExW(hkey3,szRemoteServerName,0,REG_SZ,(LPVOID)deformated, RegSetValueExW(hkey3,szRemoteServerName,0,REG_SZ,(LPVOID)deformated,
size); size);
@ -3333,12 +3381,8 @@ static UINT register_appid(MSIHANDLE hPackage, LPCWSTR clsid, LPCWSTR app )
static const WCHAR szLocalService[] = static const WCHAR szLocalService[] =
{'L','o','c','a','l','S','e','r','v','i','c','e',0}; {'L','o','c','a','l','S','e','r','v','i','c','e',0};
UINT size; UINT size;
sz = 0; buffer = load_dynamic_stringW(row,3);
MsiRecordGetStringW(row,3,NULL,&sz); size = (strlenW(buffer)+1) * sizeof(WCHAR);
sz++;
size = sz * sizeof(WCHAR);
buffer = HeapAlloc(GetProcessHeap(),0,size);
MsiRecordGetStringW(row,3,buffer,&sz);
RegSetValueExW(hkey3,szLocalService,0,REG_SZ,(LPVOID)buffer,size); RegSetValueExW(hkey3,szLocalService,0,REG_SZ,(LPVOID)buffer,size);
HeapFree(GetProcessHeap(),0,buffer); HeapFree(GetProcessHeap(),0,buffer);
} }
@ -3348,12 +3392,8 @@ static UINT register_appid(MSIHANDLE hPackage, LPCWSTR clsid, LPCWSTR app )
static const WCHAR szService[] = static const WCHAR szService[] =
{'S','e','r','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0}; {'S','e','r','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0};
UINT size; UINT size;
sz = 0; buffer = load_dynamic_stringW(row,4);
MsiRecordGetStringW(row,4,NULL,&sz); size = (strlenW(buffer)+1) * sizeof(WCHAR);
sz++;
size = sz * sizeof(WCHAR);
buffer = HeapAlloc(GetProcessHeap(),0,size);
MsiRecordGetStringW(row,4,buffer,&sz);
RegSetValueExW(hkey3,szService,0,REG_SZ,(LPVOID)buffer,size); RegSetValueExW(hkey3,szService,0,REG_SZ,(LPVOID)buffer,size);
HeapFree(GetProcessHeap(),0,buffer); HeapFree(GetProcessHeap(),0,buffer);
} }
@ -3363,12 +3403,8 @@ static UINT register_appid(MSIHANDLE hPackage, LPCWSTR clsid, LPCWSTR app )
static const WCHAR szDLL[] = static const WCHAR szDLL[] =
{'D','l','l','S','u','r','r','o','g','a','t','e',0}; {'D','l','l','S','u','r','r','o','g','a','t','e',0};
UINT size; UINT size;
sz = 0; buffer = load_dynamic_stringW(row,5);
MsiRecordGetStringW(row,5,NULL,&sz); size = (strlenW(buffer)+1) * sizeof(WCHAR);
sz++;
size = sz * sizeof(WCHAR);
buffer = HeapAlloc(GetProcessHeap(),0,size);
MsiRecordGetStringW(row,5,buffer,&sz);
RegSetValueExW(hkey3,szDLL,0,REG_SZ,(LPVOID)buffer,size); RegSetValueExW(hkey3,szDLL,0,REG_SZ,(LPVOID)buffer,size);
HeapFree(GetProcessHeap(),0,buffer); HeapFree(GetProcessHeap(),0,buffer);
} }
@ -3551,17 +3587,17 @@ static UINT register_progid_base(MSIHANDLE row, LPWSTR clsid)
{ {
static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
HKEY hkey,hkey2; HKEY hkey,hkey2;
WCHAR buffer[0x1000]; WCHAR buffer[0x100];
DWORD sz; DWORD sz;
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,1,buffer,&sz); MsiRecordGetStringW(row,1,buffer,&sz);
RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey); RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey);
if (!MsiRecordIsNull(row,4)) if (!MsiRecordIsNull(row,4))
{ {
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,4,buffer,&sz); MsiRecordGetStringW(row,4,buffer,&sz);
RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) * RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) *
sizeof(WCHAR)); sizeof(WCHAR));
@ -3569,7 +3605,7 @@ static UINT register_progid_base(MSIHANDLE row, LPWSTR clsid)
if (!MsiRecordIsNull(row,3)) if (!MsiRecordIsNull(row,3))
{ {
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,3,buffer,&sz); MsiRecordGetStringW(row,3,buffer,&sz);
RegCreateKeyW(hkey,szCLSID,&hkey2); RegCreateKeyW(hkey,szCLSID,&hkey2);
@ -3654,11 +3690,11 @@ static UINT register_progid(MSIHANDLE hPackage, MSIHANDLE row, LPWSTR clsid)
HKEY hkey,hkey2; HKEY hkey,hkey2;
static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,2,buffer,&sz); MsiRecordGetStringW(row,2,buffer,&sz);
rc = register_parent_progid(hPackage,buffer,clsid); rc = register_parent_progid(hPackage,buffer,clsid);
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,1,buffer,&sz); MsiRecordGetStringW(row,1,buffer,&sz);
RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey); RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey);
/* clasid is same as parent */ /* clasid is same as parent */
@ -3669,7 +3705,7 @@ static UINT register_progid(MSIHANDLE hPackage, MSIHANDLE row, LPWSTR clsid)
RegCloseKey(hkey2); RegCloseKey(hkey2);
if (!MsiRecordIsNull(row,4)) if (!MsiRecordIsNull(row,4))
{ {
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,4,buffer,&sz); MsiRecordGetStringW(row,4,buffer,&sz);
RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer,
(strlenW(buffer)+1) * sizeof(WCHAR)); (strlenW(buffer)+1) * sizeof(WCHAR));
@ -3807,7 +3843,7 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
while (1) while (1)
{ {
WCHAR target_file[MAX_PATH]; WCHAR target_file[MAX_PATH];
WCHAR buffer[0x1000]; WCHAR buffer[0x100];
DWORD sz; DWORD sz;
DWORD index; DWORD index;
static const WCHAR szlnk[]={'.','l','n','k',0}; static const WCHAR szlnk[]={'.','l','n','k',0};
@ -3819,7 +3855,7 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
break; break;
} }
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,4,buffer,&sz); MsiRecordGetStringW(row,4,buffer,&sz);
index = get_loaded_component(package,buffer); index = get_loaded_component(package,buffer);
@ -3858,18 +3894,18 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
continue; continue;
} }
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,2,buffer,&sz); MsiRecordGetStringW(row,2,buffer,&sz);
resolve_folder(hPackage, buffer,target_file,FALSE,FALSE,NULL); resolve_folder(hPackage, buffer,target_file,FALSE,FALSE,NULL);
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,3,buffer,&sz); MsiRecordGetStringW(row,3,buffer,&sz);
reduce_to_longfilename(buffer); reduce_to_longfilename(buffer);
strcatW(target_file,buffer); strcatW(target_file,buffer);
if (!strchrW(target_file,'.')) if (!strchrW(target_file,'.'))
strcatW(target_file,szlnk); strcatW(target_file,szlnk);
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,5,buffer,&sz); MsiRecordGetStringW(row,5,buffer,&sz);
if (strchrW(buffer,'[')) if (strchrW(buffer,'['))
{ {
@ -3890,7 +3926,7 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
if (!MsiRecordIsNull(row,6)) if (!MsiRecordIsNull(row,6))
{ {
LPWSTR deformated; LPWSTR deformated;
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,6,buffer,&sz); MsiRecordGetStringW(row,6,buffer,&sz);
deformat_string(hPackage,buffer,&deformated); deformat_string(hPackage,buffer,&deformated);
IShellLinkW_SetArguments(sl,deformated); IShellLinkW_SetArguments(sl,deformated);
@ -3900,11 +3936,7 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
if (!MsiRecordIsNull(row,7)) if (!MsiRecordIsNull(row,7))
{ {
LPWSTR deformated; LPWSTR deformated;
sz = 0; deformated = load_dynamic_stringW(row,7);
MsiRecordGetStringW(row,7,NULL,&sz);
sz++;
deformated = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
MsiRecordGetStringW(row,7,deformated,&sz);
IShellLinkW_SetDescription(sl,deformated); IShellLinkW_SetDescription(sl,deformated);
HeapFree(GetProcessHeap(),0,deformated); HeapFree(GetProcessHeap(),0,deformated);
} }
@ -3917,7 +3949,7 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
WCHAR Path[MAX_PATH]; WCHAR Path[MAX_PATH];
INT index; INT index;
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,9,buffer,&sz); MsiRecordGetStringW(row,9,buffer,&sz);
build_icon_path(hPackage,buffer,Path); build_icon_path(hPackage,buffer,Path);
@ -3933,7 +3965,7 @@ static UINT ACTION_CreateShortcuts(MSIHANDLE hPackage)
{ {
WCHAR Path[MAX_PATH]; WCHAR Path[MAX_PATH];
sz = 0x1000; sz = 0x100;
MsiRecordGetStringW(row,12,buffer,&sz); MsiRecordGetStringW(row,12,buffer,&sz);
resolve_folder(hPackage, buffer, Path, FALSE, FALSE, NULL); resolve_folder(hPackage, buffer, Path, FALSE, FALSE, NULL);
IShellLinkW_SetWorkingDirectory(sl,Path); IShellLinkW_SetWorkingDirectory(sl,Path);

View File

@ -68,6 +68,7 @@ HWND gUIhwnd;
INSTALLUI_HANDLERA gUIHandler; INSTALLUI_HANDLERA gUIHandler;
DWORD gUIFilter; DWORD gUIFilter;
LPVOID gUIContext; LPVOID gUIContext;
WCHAR gszLogFile[MAX_PATH];
/* /*
* .MSI file format * .MSI file format
@ -669,9 +670,19 @@ end:
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, BOOL fAppend) UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, BOOL fAppend)
{ {
FIXME("%08lx %s %d\n", dwLogMode, debugstr_w(szLogFile), fAppend); HANDLE the_file = INVALID_HANDLE_VALUE;
TRACE("%08lx %s %d\n", dwLogMode, debugstr_w(szLogFile), fAppend);
strcpyW(gszLogFile,szLogFile);
if (!fAppend)
DeleteFileW(szLogFile);
the_file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (the_file != INVALID_HANDLE_VALUE)
CloseHandle(the_file);
else
ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
return ERROR_SUCCESS; return ERROR_SUCCESS;
/* return ERROR_CALL_NOT_IMPLEMENTED; */
} }
INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct) INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
@ -1101,6 +1112,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
gUIHandler = NULL; gUIHandler = NULL;
gUIFilter = 0; gUIFilter = 0;
gUIContext = NULL; gUIContext = NULL;
gszLogFile[0]=0;
/* FIXME: Initialisation */ /* FIXME: Initialisation */
} else if (fdwReason == DLL_PROCESS_DETACH) { } else if (fdwReason == DLL_PROCESS_DETACH) {
/* FIXME: Cleanup */ /* FIXME: Cleanup */

View File

@ -252,5 +252,6 @@ extern HWND gUIhwnd;
extern INSTALLUI_HANDLERA gUIHandler; extern INSTALLUI_HANDLERA gUIHandler;
extern DWORD gUIFilter; extern DWORD gUIFilter;
extern LPVOID gUIContext; extern LPVOID gUIContext;
extern WCHAR gszLogFile[MAX_PATH];
#endif /* __WINE_MSI_PRIVATE__ */ #endif /* __WINE_MSI_PRIVATE__ */

View File

@ -379,7 +379,10 @@ INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType,
DWORD total_size = 0; DWORD total_size = 0;
INT msg_field=1; INT msg_field=1;
INT i; INT i;
INT rc;
TRACE("%x \n",eMessageType); TRACE("%x \n",eMessageType);
rc = 0;
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR) if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR)
log_type |= INSTALLLOGMODE_ERROR; log_type |= INSTALLLOGMODE_ERROR;
@ -431,8 +434,24 @@ INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType,
debugstr_a(message)); debugstr_a(message));
if (gUIHandler && (gUIFilter & log_type)) if (gUIHandler && (gUIFilter & log_type))
gUIHandler(gUIContext,eMessageType,message); rc = gUIHandler(gUIContext,eMessageType,message);
if ((!rc) && (gszLogFile[0]) && !((eMessageType & 0xff000000) ==
INSTALLMESSAGE_PROGRESS))
{
DWORD write;
HANDLE log_file = CreateFileW(gszLogFile,GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (log_file != INVALID_HANDLE_VALUE)
{
SetFilePointer(log_file,0, NULL, FILE_END);
WriteFile(log_file,message,strlen(message),&write,NULL);
WriteFile(log_file,"\n",1,&write,NULL);
CloseHandle(log_file);
}
}
HeapFree(GetProcessHeap(),0,message); HeapFree(GetProcessHeap(),0,message);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }