msi: Split code to create a random package name into a separate function.
This commit is contained in:
parent
00fdc6cb80
commit
5f83069bd8
|
@ -3487,32 +3487,25 @@ end:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT msi_make_package_local( MSIPACKAGE *package, HKEY hkey )
|
static UINT msi_get_local_package_name( LPWSTR path )
|
||||||
{
|
{
|
||||||
static const WCHAR installerPathFmt[] = {
|
static const WCHAR szInstaller[] = {
|
||||||
'%','s','\\','I','n','s','t','a','l','l','e','r','\\',0};
|
'\\','I','n','s','t','a','l','l','e','r','\\',0};
|
||||||
static const WCHAR fmt[] = {
|
static const WCHAR fmt[] = { '%','x','.','m','s','i',0};
|
||||||
'%','s','\\',
|
DWORD time, len, i;
|
||||||
'I','n','s','t','a','l','l','e','r','\\',
|
HANDLE handle;
|
||||||
'%','x','.','m','s','i',0};
|
|
||||||
static const WCHAR szOriginalDatabase[] =
|
|
||||||
{'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
|
|
||||||
WCHAR windir[MAX_PATH], path[MAX_PATH], packagefile[MAX_PATH];
|
|
||||||
INT num, start;
|
|
||||||
LPWSTR msiFilePath;
|
|
||||||
BOOL r;
|
|
||||||
|
|
||||||
/* copy the package locally */
|
time = GetTickCount();
|
||||||
num = GetTickCount() & 0xffff;
|
GetWindowsDirectoryW( path, MAX_PATH );
|
||||||
if (!num)
|
lstrcatW( path, szInstaller );
|
||||||
num = 1;
|
CreateDirectoryW( path, NULL );
|
||||||
start = num;
|
|
||||||
GetWindowsDirectoryW( windir, MAX_PATH );
|
len = lstrlenW(path);
|
||||||
snprintfW( packagefile, MAX_PATH, fmt, windir, num );
|
for (i=0; i<0x10000; i++)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
HANDLE handle = CreateFileW(packagefile,GENERIC_WRITE, 0, NULL,
|
snprintfW( &path[len], MAX_PATH - len, fmt, (time+i)&0xffff );
|
||||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
|
handle = CreateFileW( path, GENERIC_WRITE, 0, NULL,
|
||||||
|
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
|
@ -3520,13 +3513,23 @@ static UINT msi_make_package_local( MSIPACKAGE *package, HKEY hkey )
|
||||||
}
|
}
|
||||||
if (GetLastError() != ERROR_FILE_EXISTS &&
|
if (GetLastError() != ERROR_FILE_EXISTS &&
|
||||||
GetLastError() != ERROR_SHARING_VIOLATION)
|
GetLastError() != ERROR_SHARING_VIOLATION)
|
||||||
break;
|
return ERROR_FUNCTION_FAILED;
|
||||||
if (!(++num & 0xffff)) num = 1;
|
}
|
||||||
sprintfW(packagefile,fmt,num);
|
|
||||||
} while (num != start);
|
|
||||||
|
|
||||||
snprintfW( path, MAX_PATH, installerPathFmt, windir );
|
return ERROR_SUCCESS;
|
||||||
create_full_pathW(path);
|
}
|
||||||
|
|
||||||
|
static UINT msi_make_package_local( MSIPACKAGE *package, HKEY hkey )
|
||||||
|
{
|
||||||
|
static const WCHAR szOriginalDatabase[] =
|
||||||
|
{'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
|
||||||
|
WCHAR packagefile[MAX_PATH];
|
||||||
|
LPWSTR msiFilePath;
|
||||||
|
UINT r;
|
||||||
|
|
||||||
|
r = msi_get_local_package_name( packagefile );
|
||||||
|
if (r != ERROR_SUCCESS)
|
||||||
|
return r;
|
||||||
|
|
||||||
TRACE("Copying to local package %s\n",debugstr_w(packagefile));
|
TRACE("Copying to local package %s\n",debugstr_w(packagefile));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue