Example #1
0
void GetMsiProperty (MSIHANDLE hModule, char* propertyValue, char* propertyName) {
    if(!propertyName)
        return;

    MSIHANDLE hRecord, hView, hDatabase;

    // get hView & hDatabase
    hDatabase = MsiGetActiveDatabase(hModule);
    char pSelectSql[256] = {0};
    sprintf(pSelectSql, "select * from Property where `Property`='%s'", propertyName);

    MsiDatabaseOpenView(hDatabase, pSelectSql, &hView);
    MsiViewExecute(hView, NULL);

    DWORD dwLength = 256;
    if (MsiViewFetch(hView, &hRecord) != ERROR_SUCCESS)
        return;
    MsiRecordGetString(hRecord, 2, propertyValue, &dwLength);

    // close all handles
    MsiCloseHandle(hRecord);
    MsiViewClose(hView);
    MsiCloseHandle(hView);
    MsiCloseHandle(hDatabase);
}
Example #2
0
File: msidb.c Project: CaoMomo/core
/***********************************************************************
 * msidbExportStream
 *
 * Exports a stream to a file with an .idb extension.
 *
 * Examples (note wildcard escape for *nix/bash):
 * msidb -d <pathtomsi>.msi -f <workdir> -x <streamname>
 * msidb -d <pathtomsi>.msi -f <workdir> -x data.cab
 **********************************************************************/
static BOOL msidbExportStream(LPCWSTR dbfile, LPCWSTR wdir, LPCWSTR streamName)
{
    static const char ext[] = {'.', 'i', 'd', 'b', 0};
    UINT r, len;
    MSIHANDLE dbhandle, streamListView, rec;
    char queryBuffer[100];
    FILE *fp = 0;
    char *streamNameA = strdupWtoA(CP_ACP, streamName);
    char *wdirA = strdupWtoA(CP_ACP, wdir);
    char *streamFileA = 0;
    char streamPath[MAX_PATH];
    char *dataBuffer;
    DWORD dataLen = 0;

    r = MsiOpenDatabaseW(dbfile, (LPCWSTR) MSIDBOPEN_READONLY, &dbhandle);
    if (r != ERROR_SUCCESS) return FALSE;

    sprintf(queryBuffer, "SELECT * FROM _Streams WHERE Name = '%s'", streamNameA);
    MsiDatabaseOpenView(dbhandle, queryBuffer, &streamListView);
    MsiViewExecute(streamListView, 0);
    r = MsiViewFetch(streamListView, &rec);
    if (r != ERROR_SUCCESS) return FALSE;

    if (MsiRecordReadStream(rec, 2, 0, &dataLen) != ERROR_SUCCESS)
        return FALSE;
    dataBuffer = malloc(dataLen);
    if (!dataBuffer) return FALSE;
    if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS)
        return FALSE;

    len = strlen(streamNameA) + 5;
    streamFileA = malloc(len);
    if (streamFileA == NULL) return FALSE;

    strcpy(streamFileA, streamNameA);
    strcat(streamFileA, ext);

    strcpy(streamPath, wdirA);
    strcat(streamPath, PATH_DELIMITER);
    strcat(streamPath, streamFileA);

    fp = fopen(streamPath , "wb");
    if (fp != NULL)
    {
        fwrite(dataBuffer, 1, dataLen, fp);
        fclose(fp);
    }

    free(streamFileA);
    MsiCloseHandle(rec);

    MsiViewClose(streamListView);
    MsiCloseHandle(streamListView);
    MsiCloseHandle(dbhandle);
    free(wdirA);
    free(streamNameA);
    return TRUE;
}
Example #3
0
static void test_packagecoltypes(void)
{
    MSIHANDLE hdb, view, rec;
    char path[MAX_PATH];
    LPCSTR query;
    UINT r, count;

    CoInitialize(NULL);

    lstrcpy(path, CURR_DIR);
    lstrcat(path, "\\");
    lstrcat(path, msifile);

    r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    query = "SELECT * FROM `Media`";
    r = MsiDatabaseOpenView( hdb, query, &view );
    todo_wine
    {
        ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
    }

    r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
    count = MsiRecordGetFieldCount( rec );
    todo_wine
    {
        ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
        ok(count == 6, "Expected 6, got %d\n", count);
        ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
        ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
        ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
        ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
        ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
        ok(check_record(rec, 6, "Source"), "wrong column label\n");
    }

    r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
    count = MsiRecordGetFieldCount( rec );
    todo_wine
    {
        ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
        ok(count == 6, "Expected 6, got %d\n", count);
        ok(check_record(rec, 1, "i2"), "wrong column label\n");
        ok(check_record(rec, 2, "i4"), "wrong column label\n");
        ok(check_record(rec, 3, "L64"), "wrong column label\n");
        ok(check_record(rec, 4, "S255"), "wrong column label\n");
        ok(check_record(rec, 5, "S32"), "wrong column label\n");
        ok(check_record(rec, 6, "S72"), "wrong column label\n");
    }

    MsiCloseHandle(hdb);
    DeleteFile(msifile);
}
Example #4
0
File: msidb.c Project: CaoMomo/core
static BOOL msidbExportStorage(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName)
{
    UINT r, len;
    MSIHANDLE dbhandle, view, rec;
    char queryBuffer[100];
    char *storageNameA = strdupWtoA(CP_ACP, storageName);
    char *wdirA = strdupWtoA(CP_ACP, wdir);
    char *storagePath = NULL;
    char *dataBuffer;
    DWORD dataLen = 0;
    FILE *fp = NULL;
    sprintf(queryBuffer, "SELECT * FROM _Storages WHERE Name = '%s'", storageNameA);

    r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle);
    if (r != ERROR_SUCCESS) return FALSE;

    MsiDatabaseOpenView(dbhandle, queryBuffer, &view);
    MsiViewExecute(view, 0);
    r = MsiViewFetch(view, &rec);
    if (r != ERROR_SUCCESS) return FALSE;

    if ((r = MsiRecordReadStream(rec, 2, 0, &dataLen)) != ERROR_SUCCESS)
    {
        return FALSE;
    }

    if ((dataBuffer = malloc(dataLen)) == NULL) return FALSE;
    if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS) return FALSE;

    len = strlen(wdirA) + strlen(storageNameA) + 2;
    storagePath = malloc(len * sizeof(WCHAR));
    if (storagePath == NULL) return FALSE;

    strcpy(storagePath, wdirA);
    strcat(storagePath, "/");
    strcat(storagePath, storageNameA);

    fp = fopen(storagePath , "wb");
    if (fp != NULL)
    {
        fwrite(dataBuffer, 1, dataLen, fp);
        fclose(fp);
    }

    free(storagePath);
    MsiCloseHandle(rec);

    MsiViewClose(view);
    MsiCloseHandle(view);
    MsiCloseHandle(dbhandle);
    free(storageNameA);
    free(wdirA);
    return TRUE;
}
Example #5
0
BOOL 
ViewExecute(MSIHANDLE hDatabase, char *szQuery)
{
	MSIHANDLE hView;
	
	if(MsiDatabaseOpenView(hDatabase, szQuery, &hView)!=ERROR_SUCCESS)
		return FALSE;
	if(MsiViewExecute(hView, 0)!=ERROR_SUCCESS)
		return FALSE;
	if(MsiCloseHandle(hView)!=ERROR_SUCCESS)
		return FALSE;

	return TRUE;
}
Example #6
0
File: msidb.c Project: CaoMomo/core
static BOOL msidbImportStorages(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageNames[])
{
    static const WCHAR delim[] = {'/', 0};
    UINT r, len, i;
    MSIHANDLE dbhandle, view, rec;
    WCHAR *storagePath = 0;
    char *query = "INSERT INTO _Storages (Name, Data) VALUES(?, ?)";

    r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_TRANSACT, &dbhandle);
    if (r != ERROR_SUCCESS) return FALSE;

    r = MsiDatabaseOpenView(dbhandle, query, &view);
    if (r != ERROR_SUCCESS) return FALSE;
    MsiViewExecute(view, 0);
    r = MsiViewFetch(view, &rec);
    if (r != ERROR_SUCCESS) return FALSE;

    for (i = 0; i < MAX_STORAGES && storageNames[i] != 0; ++i)
    {
        len = lstrlenW(wdir) + lstrlenW(storageNames[i]) + 2;
        storagePath = malloc(len * sizeof(WCHAR));
        if (storagePath == NULL) return FALSE;

        lstrcpyW(storagePath, wdir);
        lstrcatW(storagePath, delim);
        lstrcatW(storagePath, storageNames[i]);

        rec = MsiCreateRecord(2);
        MsiRecordSetStringW(rec, 1, storageNames[i]);
        r = MsiRecordSetStreamW(rec, 2, storagePath);
        if (r != ERROR_SUCCESS)
        {
            return FALSE;
        }

        r = MsiViewExecute(view, rec);
        if (r != ERROR_SUCCESS)
        {
            return FALSE;
        }

        MsiCloseHandle(rec);
    }

    MsiViewClose(view);
    MsiCloseHandle(view);
    MsiDatabaseCommit(dbhandle);
    MsiCloseHandle(dbhandle);
    return TRUE;
}
Example #7
0
File: msidb.c Project: CaoMomo/core
static BOOL msidbImportStreams(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR streamNames[])
{
    UINT r, len;
    MSIHANDLE dbhandle, view, rec;
    int i = 0;
    WCHAR *streamPath = 0;
    char *query = "INSERT INTO _Streams (Name, Data) VALUES(?, ?)";

    r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_TRANSACT, &dbhandle);
    if (r != ERROR_SUCCESS) return FALSE;

    r = MsiDatabaseOpenView(dbhandle, query, &view);
    if (r != ERROR_SUCCESS) return FALSE;

    for (i = 0; i < MAX_STREAMS && streamNames[i] != NULL; i++)
    {
        len = lstrlenW(wdir) + lstrlenW(streamNames[i]) + 2;
        streamPath = malloc(len * sizeof(WCHAR));
        if (streamPath == NULL) return FALSE;

        lstrcpyW(streamPath, wdir);
        lstrcatW(streamPath, PATH_DELIMITERW);
        lstrcatW(streamPath, streamNames[i]);

        rec = MsiCreateRecord(2);
        MsiRecordSetStringW(rec, 1, streamNames[i]);
        r = MsiRecordSetStreamW(rec, 2, streamPath);
        if (r != ERROR_SUCCESS)
        {
            return FALSE;
        }

        r = MsiViewExecute(view, rec);
        if (r != ERROR_SUCCESS)
        {
            return FALSE;
        }

        MsiCloseHandle(rec);
    }

    MsiViewClose(view);
    MsiCloseHandle(view);
    MsiDatabaseCommit(dbhandle);
    MsiCloseHandle(dbhandle);
    return TRUE;
}
Example #8
0
/**
 * Extracts the jar file from the MSI database binary field
 *
 * @param hModule Specify the handle for the MSI database
 */
void ExtractBinaryFile (MSIHANDLE hModule, const char* pFieldName, const char* pDstFileName) {
    char cSelectSql[MAX_PATH_SIZE] = {0};
    MSIHANDLE hRecord, hView, hDatabase;

    // get hView & hDatabase
    hDatabase = MsiGetActiveDatabase(hModule);
    sprintf(cSelectSql, "select * from Binary where `Name`='%s'", pFieldName);
    MsiDatabaseOpenView(hDatabase, cSelectSql, &hView);
    MsiViewExecute(hView, NULL);
    char szTemp[256] = {0};
    DWORD dwLength = 256;
    if (MsiViewFetch(hView, &hRecord) != ERROR_SUCCESS)
    {
        return;
    }
    MsiRecordGetString(hRecord, 1, szTemp, &dwLength);
    if (strncmp(szTemp, pFieldName, strlen(pFieldName)))
    {
        return;
    }
    // write into installer.jar
    #define BUFFERSIZE 1024
    char  szBuffer[BUFFERSIZE] = {0};
    DWORD cbBuf = BUFFERSIZE;
    DWORD countWrite = 0;

    FILE* fp = NULL;
    fp = fopen(pDstFileName, "wb+");
    if (NULL == fp) {
        return;
    }

    do {
        if (MsiRecordReadStream(hRecord, 2, szBuffer, &cbBuf) !=ERROR_SUCCESS)
            break; // error 
        countWrite = fwrite(szBuffer, 1, cbBuf, fp);
    } while (countWrite == BUFFERSIZE);

    fclose(fp);

    // close all handles
    MsiCloseHandle(hRecord);
    MsiViewClose(hView);
    MsiCloseHandle(hView);
    MsiCloseHandle(hDatabase);
}
Example #9
0
BOOL 
UpdateComponentIds(MSIHANDLE hDatabase, int idx)
{
    MSIHANDLE hView, hRecord;

    if (!(MsiDatabaseOpenView(hDatabase, 
          "SELECT Component, ComponentId FROM Component", 
          &hView)==ERROR_SUCCESS))
    {
	return FALSE;
    }

    if (!(MsiViewExecute(hView, 0)==ERROR_SUCCESS))
	return FALSE;
    
    while (MsiViewFetch(hView, &hRecord)!=ERROR_NO_MORE_ITEMS)
    {
	char szValueBuf[39];
	DWORD cchValueBuf=sizeof(szValueBuf);
	char *token, *tokens[5];
	int num=0;

	MsiRecordGetString(hRecord, 2, szValueBuf, &cchValueBuf);
	
	token=strtok(szValueBuf, "{-}");
	while (token != NULL )
	{
	    tokens[num]=token;
	    token=strtok(NULL, "{-}");
	    num++;
	}
	sprintf(szValueBuf, "{%s-%s-%s-%04X-%012X}", tokens[0], tokens[1], tokens[2], idx, idx*idx);

	MsiRecordSetString(hRecord, 2, szValueBuf);
	
	if (!(MsiViewModify(hView, MSIMODIFY_UPDATE, hRecord)==ERROR_SUCCESS))
	    return FALSE;

	MsiCloseHandle(hRecord);
    }
    
    if (!(MsiCloseHandle(hView)==ERROR_SUCCESS))
	return FALSE;

    return TRUE;
}
Example #10
0
static UINT find_entry( MSIHANDLE hdb, const char *table, const char *entry )
{
    static char fmt[] = "SELECT * FROM `%s` WHERE `Name` = '%s'";
    char query[0x100];
    UINT r;
    MSIHANDLE hview, hrec;

    sprintf( query, fmt, table, entry );
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );
    MsiCloseHandle( hrec );
    return r;
}
Example #11
0
MSICA_IMP
ReplaceEula(MSIHANDLE hInstall)
{
	// ::DebugBreak();

    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
    
    //
    // EULA File Content is MBCS (RTF) not Unicode
    AutoProcessHeapPtr<LPSTR> lpEula = pReadEulaFromFileA(hInstall);
    if (NULL == (LPSTR) lpEula)
    {
        _RPT0(_CRT_ERROR, "pReadEulaFromFile failed\n");
        return ERROR_INSTALL_FAILURE;
    }
    
    _RPT0(_CRT_WARN, "ReplaceEula\n");
    
	PMSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);

	if (0 == hDatabase)
	{
        _RPT0(_CRT_ERROR, "MsiGetActiveDatabase failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	PMSIHANDLE hView;
	LPCTSTR query = _T("SELECT * FROM `Control` WHERE `Dialog_` = 'LicenseAgreement' AND `Control` = 'Memo'");
	UINT msiret = MsiDatabaseOpenView(hDatabase, query, &hView);

	if (ERROR_SUCCESS != msiret)
	{
        _RPT0(_CRT_ERROR, "MsiDatabaseOpenView failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	msiret = MsiViewExecute(hView, 0);

	if (ERROR_SUCCESS != msiret)
	{
        _RPT0(_CRT_ERROR, "MsiViewExecute failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	PMSIHANDLE hRecord;
	msiret = MsiViewFetch(hView, &hRecord);

	if (ERROR_SUCCESS != msiret)
	{
        _RPT0(_CRT_ERROR, "MsiViewFetch failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	msiret = MsiViewModify(hView, MSIMODIFY_DELETE, hRecord);

	if (ERROR_SUCCESS != msiret)
	{
        _RPT0(_CRT_ERROR, "MsiViewModify failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	UINT nFields = MsiRecordGetFieldCount(hRecord);

	AutoProcessHeapPtr<LPTSTR> buffer;
	DWORD chBuffer = 0;
	msiret = MsiRecordGetString(hRecord, 10, _T(""), &chBuffer);

	if (ERROR_MORE_DATA == msiret)
	{
		++chBuffer;
		buffer = (LPTSTR) ::HeapAlloc(
            GetProcessHeap(), 
            HEAP_ZERO_MEMORY, 
            chBuffer * sizeof(TCHAR));
		msiret = MsiRecordGetString(hRecord, 1, buffer, &chBuffer);
	}
    
	msiret = MsiRecordSetStringA(hRecord, 10, lpEula);
    
	if (ERROR_SUCCESS != msiret)
	{
        _RPT0(_CRT_ERROR, "MsiRecordSetString failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	msiret = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord);
    
	if (ERROR_SUCCESS != msiret)
	{
        _RPT0(_CRT_ERROR, "MsiViewModify failed\n");
		return ERROR_INSTALL_FAILURE;
	}

	//msiret = MsiViewExecute(hView, hRecord);
	//if (ERROR_SUCCESS != msiret)
	//{
	//	return ERROR_INSTALL_FAILURE;
	//}

	_RPT0(_CRT_WARN, "ReplaceEula completed successfully.\n");

	return ERROR_SUCCESS;
}
Example #12
0
i4 
main(i4 argc, char* argv[])
{

    MSIHANDLE hDatabase;
    char view[1024];
    int Branding_Width, DlgLine_Width, DlgLine_X;
    char Branding_Text[64];

    if((argc < 2) || (GetFileAttributes(argv[1])==-1))
    {
	printf ("usage:\nmsiupd <full path to MSI file>\nmsiupd <full path to MSM file> <%II_INSTALLATION%>");
	return 1;
    }
	
    if(strstr(argv[1], "Ingres SDK") != NULL)
    {
	Branding_Width=40;
	DlgLine_X=45;
	DlgLine_Width=329;
	strcpy(Branding_Text, "Ingres SDK");
    }
    else
    {
	Branding_Width=30;
	DlgLine_X=35;
	DlgLine_Width=339;
	strcpy(Branding_Text, "Ingres");
    }

    MsiOpenDatabase(argv[1], MSIDBOPEN_DIRECT, &hDatabase);
    if (!hDatabase)
	return 1;

    if (argc==2 && strstr(argv[1], ".msi"))
    {
	/*
	** Change the brandings on each page from InstallShield to
	** Advantage Ingres.
	*/
	sprintf(view, "UPDATE Control SET Width = '%d' WHERE Control = 'Branding1'", Branding_Width);
	if(!ViewExecute(hDatabase, view))
	    return 1;
	sprintf(view, "UPDATE Control SET Width = '%d' WHERE Control = 'Branding2'", Branding_Width);
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET X = '%d' WHERE Control = 'DlgLine'", DlgLine_X );
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'AdminWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'InstallWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'PatchWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupInitialization' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupResume' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'MaintenanceWelcome'AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET Width = '%d' WHERE Control = 'DlgLine'", DlgLine_Width );
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'AdminWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'InstallWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'PatchWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupInitialization' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupResume' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'MaintenanceWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET Text = '{&MSSWhiteSerif8}%s' WHERE Control = 'Branding1'", Branding_Text);
	if(!ViewExecute(hDatabase, view))
		return 1;

	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'AdminWelcome' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'InstallWelcome' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'PatchWelcome' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInitialization' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupResume' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'MaintenanceWelcome'AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET Text = '{&Tahoma8}%s' WHERE Control = 'Branding2'", Branding_Text);
	if(!ViewExecute(hDatabase, view))
		return 1;

	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'AdminWelcome' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'InstallWelcome' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'PatchWelcome' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInitialization' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupResume' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'MaintenanceWelcome'AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
    }
    else if(argc==3 && strstr(argv[1], ".msm"))
    {
	/* Update Merge Module database with II_INSTALLATION. */
	MSIHANDLE hView, hRecord;
	int idx;
	char szID[3];

	strcpy(szID, _strupr(argv[2]));

	if (strlen(szID)!=2 || !isalpha(szID[0]) || !isalnum(szID[1]))
	{
	    printf ("Invalid installation identifier!");
	    return 1;
	}

	if (!strcmp(szID, "II"))
	{
	    if(MsiDatabaseCommit(hDatabase)!=ERROR_SUCCESS)
		return 1;
	    if(MsiCloseHandle(hDatabase)!=ERROR_SUCCESS)
		return 1;

	    return 0;
	}

	/* Update shortcut folders. */
	if (!MsiDatabaseOpenView
	(hDatabase, "SELECT Directory, DefaultDir FROM Directory", &hView))
	{
	    if (!MsiViewExecute(hView, 0))
	    {
		while (MsiViewFetch(hView, &hRecord)!=ERROR_NO_MORE_ITEMS)
		{
		    char szValue[80];
		    DWORD dwSize=sizeof(szValue);
			
		    MsiRecordGetString(hRecord, 2, szValue, &dwSize);
		    if (strstr(szValue, "Ingres II [ "))
			sprintf(szValue, "Ingres II [ %s ]", szID);
		    else if (strstr(szValue, "Ingres [ "))
			sprintf(szValue, "Ingres [ %s ]", szID);
		    MsiRecordSetString(hRecord, 2, szValue);
		    MsiViewModify(hView, MSIMODIFY_UPDATE, hRecord);
		    MsiCloseHandle(hRecord);
		}
	    }
	    MsiCloseHandle(hView);
	}
	
	/* Update IVM Startup shortcut. */
	if (!MsiDatabaseOpenView(hDatabase, "SELECT Name, Component_ FROM Shortcut", &hView))
	{
	    if(!MsiViewExecute(hView, 0))
	    {
		while (MsiViewFetch(hView, &hRecord)!=ERROR_NO_MORE_ITEMS)
		{
		    char szValue[80], szValue2[80];
		    DWORD dwSize, dwSize2;
			
		    dwSize=sizeof(szValue); 
		    dwSize2=sizeof(szValue2);
		    MsiRecordGetString(hRecord, 1, szValue, &dwSize);
		    MsiRecordGetString(hRecord, 2, szValue2, &dwSize2);
		    if (strstr(szValue, "Ingres Visual Manager [ ") 
		        && strstr(szValue2, "Shortcuts.") 
		        && !strstr(szValue2, "SDKShortcuts."))
			sprintf(szValue, "Ingres Visual Manager [ %s ]", szID);
		    MsiRecordSetString(hRecord, 1, szValue);
		    MsiViewModify(hView, MSIMODIFY_UPDATE, hRecord);
		    MsiCloseHandle(hRecord);
		}
	    }
	    MsiCloseHandle(hView);
	}

	/* Update Component GUIDs. */
	idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - 'A';
	if (idx <= 0)
	    idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - '0';

	UpdateComponentIds(hDatabase, idx);

    }
    else
    {
	printf ("usage:\nmsiupd <full path to MSI file>\nmsiupd <full path to MSM file> <%II_INSTALLATION%>");
	return 1;
    }

    if(MsiDatabaseCommit(hDatabase)!=ERROR_SUCCESS)
	return 1;
    if(MsiCloseHandle(hDatabase)!=ERROR_SUCCESS)
	return 1;
	
    return 0;
}
Example #13
0
File: msidb.c Project: CaoMomo/core
/***********************************************************************
 * msidbExportTables
 *
 * Takes a list of tables or '*' (for all) to export to text archive
 * files in specified folder
 *
 * For each table, a file called <tablename>.idt is exported containing
 * tab separated ASCII.
 *
 * Examples (note wildcard escape for *nix/bash):
 * msidb -d <pathtomsi>.msi -f <workdir> -e \*
 * msidb -d <pathtomsi>.msi -f <workdir> -e File Directory Binary
 **********************************************************************/
static BOOL msidbExportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[])
{
    static const WCHAR ext[] = {'.', 'i', 'd', 't', 0};
    static const WCHAR all[] = {'*', 0};
    UINT r, len;
    MSIHANDLE dbhandle, tableListView, rec;
    LPWSTR tableFile = 0;
    WCHAR tableName[MAX_TABLE_NAME];
    DWORD size = sizeof(tableName) / sizeof(tableName[0]);
    int i = 0;

    r = MsiOpenDatabaseW(dbfile, (LPCWSTR) MSIDBOPEN_READONLY, &dbhandle);

    if (r != ERROR_SUCCESS) return FALSE;

    if (strcmpW(tables[0], all) == 0)
    {
        r = MsiDatabaseOpenView(dbhandle, "SELECT Name FROM _Tables", &tableListView);
        r = MsiViewExecute(tableListView, 0);
        r = MsiViewFetch(tableListView, &rec);

        while (r == ERROR_SUCCESS)
        {
            size = sizeof(tableName) / sizeof(tableName[0]);
            r = MsiRecordGetStringW(rec, 1, tableName, &size);
            if (r == ERROR_SUCCESS)
            {
                len = lstrlenW(tableName) + 5;
                tableFile = malloc(len * sizeof (WCHAR));
                if (tableFile == NULL) return FALSE;

                lstrcpyW(tableFile, tableName);
                lstrcatW(tableFile, ext);

                r = MsiDatabaseExportW(dbhandle, tableName, wdir, tableFile);

                free(tableFile);
                MsiCloseHandle(rec);
            }

            r = MsiViewFetch(tableListView, &rec);
        }

        MsiViewClose(tableListView);
        MsiCloseHandle(tableListView);
    }
    else
    {
        for (i = 0; i < MAX_TABLES && tables[i] != 0; ++i)
        {
            len = lstrlenW(tables[i]) + 5;
            tableFile = malloc(len * sizeof (WCHAR));
            if (tableFile == NULL) return FALSE;

            lstrcpyW(tableFile, tables[i]);
            lstrcatW(tableFile, ext);
            r = MsiDatabaseExportW(dbhandle, tables[i], wdir, tableFile);

            free(tableFile);
        }
    }

    MsiCloseHandle(dbhandle);
    return TRUE;
}
Example #14
0
/*
**  Name:ingres_prepare_remove_dbms_files
**
**  Description:
**	Set up the RemoveFile table in DBMS Merge Module for the 
**	directories and files that were not installed as part of 
**	the initial installation so that they can be removed from  
**	the system during an uninstall.
**
**  Inputs:
**	hInstall	Handle to the installation.
**
**  Outputs:
**	None.
**	Returns:
**	    ERROR_SUCCESS			The function succeeds.
**	    ERROR_INSTALL_FAILURE	The function fails.
**	Exceptions:
**	    None.
**
**  Side Effects:
**	None.
**
**  History:
**	16-Aug-2001 (penga03)
**	    Created.
**	17-Aug-2001 (penga03)
**	    Do not put the INSTALLDIR in the RemoveFile table.
**	14-may-2004 (somsa01)
**	    Make sure we use the 64-bit GUID,
**	    8CCBF50C_6C17_4366_B8FE_FBB31A4092E0, when needed.
**	17-may-2004 (somsa01)
**	    Backed out prior change, as it does NOT properly fix the problem.
*/
UINT __stdcall
ingres_prepare_remove_dbms_files(MSIHANDLE hInstall)
{
	TCHAR tchValue[MAX_PATH+1], ii_system[MAX_PATH+1], szBuf[MAX_PATH+1];
	DWORD dwSize;
	MSIHANDLE hDatabase, hView, hRecord;
	TCHAR ConfigKey[256], Host[64];
	INSTALLSTATE iInstalled, iAction;
	TCHAR inst_id[64] = "INSTALLDIR.870341B5_2D6D_11D5_BDFC_00B0D0AD4485";
	TCHAR bin_id[64] = "Bin.870341B5_2D6D_11D5_BDFC_00B0D0AD4485";
	char sharedDisk[3];

	MsiGetFeatureState(hInstall, "IngresDBMS", &iInstalled, &iAction);
	if(iAction!=INSTALLSTATE_ABSENT)
		return ERROR_SUCCESS;

	dwSize=sizeof(ii_system);
	if(MsiGetTargetPath(hInstall, inst_id, ii_system, &dwSize)!=ERROR_SUCCESS)
		return ERROR_INSTALL_FAILURE;
	if(ii_system[lstrlen(ii_system)-1] == '\\')
		ii_system[lstrlen(ii_system)-1] = '\0';
	SetEnvironmentVariable("II_SYSTEM", ii_system);
	
	MsiSetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", "0");
	if(Local_NMgtIngAt("II_DATABASE", tchValue)==ERROR_SUCCESS)
	{
		strncpy(sharedDisk, tchValue, 2);
		sharedDisk[2]='\0';
		if (GetFileAttributes(sharedDisk) == -1)
		{
			MsiSetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", "1");
			return ERROR_SUCCESS;
		}
	}

	hDatabase=MsiGetActiveDatabase(hInstall);
	if(!hDatabase)
		return ERROR_INSTALL_FAILURE;
	if(MsiDatabaseOpenView(hDatabase, "INSERT INTO `RemoveFile` (`FileKey`, `Component_`, `FileName`, `DirProperty`, `InstallMode`) VALUES (?, ?, ?, ?, ?) TEMPORARY", &hView)!=ERROR_SUCCESS)
		return ERROR_INSTALL_FAILURE;
	hRecord=MsiCreateRecord(5);
	if(!hRecord)
		return ERROR_INSTALL_FAILURE;

	if(Local_NMgtIngAt("II_DATABASE", tchValue)==ERROR_SUCCESS)
	{
		int KeyCount;
		char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];

		wsprintf(szBuf, "%s\\ingres\\data", tchValue);
		Count=-1;
		CreateDirList(szBuf);
		for(KeyCount=0; KeyCount<=Count; KeyCount++)
		{
			wsprintf(szKey, "RemoveDatabaseDir_%d", KeyCount);
			wsprintf(szKey2, "RemoveDatabaseDir_%d_Dir", KeyCount);

			MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
			
			MsiRecordSetString(hRecord, 1, szKey);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "*.*");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;

			MsiRecordSetString(hRecord, 1, szKey2);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;
		}

		Count++;
		wsprintf(szKey, "RemoveDatabaseDir_%d", Count);
		wsprintf(szKey2, "RemoveDatabaseDir_%d_Dir", Count);

		wsprintf(szBuf, "%s\\ingres", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;

		Count++;
		wsprintf(szKey, "RemoveDatabaseDir_%d", Count);
		wsprintf(szKey2, "RemoveDatabaseDir_%d_Dir", Count);
		
		wsprintf(szBuf, "%s", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
	}

	if(Local_NMgtIngAt("II_CHECKPOINT", tchValue)==ERROR_SUCCESS)
	{
		int KeyCount;
		char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];

		wsprintf(szBuf, "%s\\ingres\\ckp", tchValue);
		Count=-1;
		CreateDirList(szBuf);
		for(KeyCount=0; KeyCount<=Count; KeyCount++)
		{
			wsprintf(szKey, "RemovecCheckpointDir_%d", KeyCount);
			wsprintf(szKey2, "RemoveCheckpointDir_%d_Dir", KeyCount);

			MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
			
			MsiRecordSetString(hRecord, 1, szKey);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "*.*");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;

			MsiRecordSetString(hRecord, 1, szKey2);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;
		}

		Count++;
		wsprintf(szKey, "RemovecCheckpointDir_%d", Count);
		wsprintf(szKey2, "RemovecCheckpointDir_%d_Dir", Count);

		wsprintf(szBuf, "%s\\ingres", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;

		Count++;
		wsprintf(szKey, "RemovecCheckpointDir_%d", Count);
		wsprintf(szKey2, "RemovecCheckpointDir_%d_Dir", Count);
		
		wsprintf(szBuf, "%s", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
	}

	if(Local_NMgtIngAt("II_JOURNAL", tchValue)==ERROR_SUCCESS)
	{
		int KeyCount;
		char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];

		wsprintf(szBuf, "%s\\ingres\\jnl", tchValue);
		Count=-1;
		CreateDirList(szBuf);
		for(KeyCount=0; KeyCount<=Count; KeyCount++)
		{
			wsprintf(szKey, "RemoveJournalDir_%d", KeyCount);
			wsprintf(szKey2, "RemoveJournalDir_%d_Dir", KeyCount);

			MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
			
			MsiRecordSetString(hRecord, 1, szKey);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "*.*");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;

			MsiRecordSetString(hRecord, 1, szKey2);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;
		}

		Count++;
		wsprintf(szKey, "RemoveJournalDir_%d", Count);
		wsprintf(szKey2, "RemoveJournalDir_%d_Dir", Count);

		wsprintf(szBuf, "%s\\ingres", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;

		Count++;
		wsprintf(szKey, "RemoveJournalDir_%d", Count);
		wsprintf(szKey2, "RemoveJournalDir_%d_Dir", Count);
		
		wsprintf(szBuf, "%s", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
	}

	if(Local_NMgtIngAt("II_DUMP", tchValue)==ERROR_SUCCESS)
	{
		int KeyCount;
		char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];

		wsprintf(szBuf, "%s\\ingres\\dmp", tchValue);
		Count=-1;
		CreateDirList(szBuf);
		for(KeyCount=0; KeyCount<=Count; KeyCount++)
		{
			wsprintf(szKey, "RemoveDumpDir_%d", KeyCount);
			wsprintf(szKey2, "RemoveDumpDir_%d_Dir", KeyCount);

			MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
			
			MsiRecordSetString(hRecord, 1, szKey);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "*.*");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;

			MsiRecordSetString(hRecord, 1, szKey2);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;
		}

		Count++;
		wsprintf(szKey, "RemoveDumpDir_%d", Count);
		wsprintf(szKey2, "RemoveDumpDir_%d_Dir", Count);

		wsprintf(szBuf, "%s\\ingres", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;

		Count++;
		wsprintf(szKey, "RemoveDumpDir_%d", Count);
		wsprintf(szKey2, "RemoveDumpDir_%d_Dir", Count);
		
		wsprintf(szBuf, "%s", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
	}

	if(Local_NMgtIngAt("II_WORK", tchValue)==ERROR_SUCCESS)
	{
		int KeyCount;
		char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];

		wsprintf(szBuf, "%s\\ingres\\work", tchValue);
		Count=-1;
		CreateDirList(szBuf);
		for(KeyCount=0; KeyCount<=Count; KeyCount++)
		{
			wsprintf(szKey, "RemoveWorkDir_%d", KeyCount);
			wsprintf(szKey2, "RemoveWorkDir_%d_Dir", KeyCount);

			MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
			
			MsiRecordSetString(hRecord, 1, szKey);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "*.*");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;

			MsiRecordSetString(hRecord, 1, szKey2);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;
		}

		Count++;
		wsprintf(szKey, "RemoveWorkDir_%d", Count);
		wsprintf(szKey2, "RemoveWorkDir_%d_Dir", Count);

		wsprintf(szBuf, "%s\\ingres", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;

		Count++;
		wsprintf(szKey, "RemoveWorkDir_%d", Count);
		wsprintf(szKey2, "RemoveWorkDir_%d_Dir", Count);
		
		wsprintf(szBuf, "%s", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
			
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
	}

	Local_PMhost(Host);
	wsprintf(ConfigKey, "ii.%s.rcp.log.log_file_parts", Host);
	if(Local_PMget(ConfigKey, tchValue) == ERROR_SUCCESS)
	{
		int num_logs, i;
		
		num_logs=atoi(tchValue);
		for(i=1; i<=num_logs; i++)
		{
			wsprintf(ConfigKey, "ii.%s.rcp.log.log_file_%d", Host, i);
			if(Local_PMget(ConfigKey, tchValue) == ERROR_SUCCESS)
			{
				int KeyCount;
				char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];
				
				StringReplace(tchValue);
				wsprintf(szBuf, "%s\\ingres\\log", tchValue);
				Count=-1;
				CreateDirList(szBuf);
				for(KeyCount=0; KeyCount<=Count; KeyCount++)
				{
					wsprintf(szKey, "RemoveLogDir_%d", KeyCount);
					wsprintf(szKey2, "RemoveLogDir_%d_Dir", KeyCount);
					
					MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
					
					MsiRecordSetString(hRecord, 1, szKey);
					MsiRecordSetString(hRecord, 2, bin_id);
					MsiRecordSetString(hRecord, 3, "*.*");
					MsiRecordSetString(hRecord, 4, szKey);
					MsiRecordSetInteger(hRecord, 5, 2);
					if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
						return ERROR_INSTALL_FAILURE;
					
					MsiRecordSetString(hRecord, 1, szKey2);
					MsiRecordSetString(hRecord, 2, bin_id);
					MsiRecordSetString(hRecord, 3, "");
					MsiRecordSetString(hRecord, 4, szKey);
					MsiRecordSetInteger(hRecord, 5, 2);
					if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
						return ERROR_INSTALL_FAILURE;
				}
				
				Count++;
				wsprintf(szKey, "RemoveLogDir_%d", Count);
				wsprintf(szKey2, "RemoveLogDir_%d_Dir", Count);
				
				wsprintf(szBuf, "%s\\ingres", tchValue);
				MsiSetProperty(hInstall, szKey, szBuf);
				
				MsiRecordSetString(hRecord, 1, szKey2);
				MsiRecordSetString(hRecord, 2, bin_id);
				MsiRecordSetString(hRecord, 3, "");
				MsiRecordSetString(hRecord, 4, szKey);
				MsiRecordSetInteger(hRecord, 5, 2);
				if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
					return ERROR_INSTALL_FAILURE;
				
				Count++;
				wsprintf(szKey, "RemoveLogDir_%d", Count);
				wsprintf(szKey2, "RemoveLogDir_%d_Dir", Count);
				
				wsprintf(szBuf, "%s", tchValue);
				MsiSetProperty(hInstall, szKey, szBuf);
				
				MsiRecordSetString(hRecord, 1, szKey2);
				MsiRecordSetString(hRecord, 2, bin_id);
				MsiRecordSetString(hRecord, 3, "");
				MsiRecordSetString(hRecord, 4, szKey);
				MsiRecordSetInteger(hRecord, 5, 2);
				if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
					return ERROR_INSTALL_FAILURE;
			}
		}
	}
	
	wsprintf(ConfigKey, "ii.%s.rcp.log.dual_log_1", Host);
	if(Local_PMget(ConfigKey, tchValue) == ERROR_SUCCESS)
	{
		int KeyCount;
		char szKey[MAX_PATH+1], szKey2[MAX_PATH+1];
		
		StringReplace(tchValue);
		wsprintf(szBuf, "%s\\ingres\\log", tchValue);
		Count=-1;
		CreateDirList(szBuf);
		for(KeyCount=0; KeyCount<=Count; KeyCount++)
		{
			wsprintf(szKey, "RemoveDuallogDir_%d", KeyCount);
			wsprintf(szKey2, "RemoveDuallogDir_%d_Dir", KeyCount);

			MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName);
			
			MsiRecordSetString(hRecord, 1, szKey);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "*.*");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;

			MsiRecordSetString(hRecord, 1, szKey2);
			MsiRecordSetString(hRecord, 2, bin_id);
			MsiRecordSetString(hRecord, 3, "");
			MsiRecordSetString(hRecord, 4, szKey);
			MsiRecordSetInteger(hRecord, 5, 2);
			if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
				return ERROR_INSTALL_FAILURE;
		}

		Count++;
		wsprintf(szKey, "RemoveDuallogDir_%d", Count);
		wsprintf(szKey2, "RemoveDuallogDir_%d_Dir", Count);
				
		wsprintf(szBuf, "%s\\ingres", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
				
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
		
		Count++;
		wsprintf(szKey, "RemoveDuallogDir_%d", Count);
		wsprintf(szKey2, "RemoveDuallogDir_%d_Dir", Count);
		
		wsprintf(szBuf, "%s", tchValue);
		MsiSetProperty(hInstall, szKey, szBuf);
		
		MsiRecordSetString(hRecord, 1, szKey2);
		MsiRecordSetString(hRecord, 2, bin_id);
		MsiRecordSetString(hRecord, 3, "");
		MsiRecordSetString(hRecord, 4, szKey);
		MsiRecordSetInteger(hRecord, 5, 2);
		if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS)
			return ERROR_INSTALL_FAILURE;
	}

	MsiCloseHandle(hRecord);
	MsiCloseHandle(hView);
	MsiCloseHandle(hDatabase);

	return ERROR_SUCCESS;
}
Example #15
0
MSICA_IMP
ReplaceEula(MSIHANDLE hInstall)
{
	// ::DebugBreak();

	_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
	_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
	
	//
	// EULA File Content is MBCS (RTF) not Unicode
	//
	XTL::AutoProcessHeapPtr<CHAR> lpEula = pReadEulaFromFile(hInstall);
	if (NULL == (LPSTR) lpEula)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: ReadEulaFromFile failed, error=0x%X"), 
			GetLastError());

		return ERROR_INSTALL_FAILURE;
	}

	//
	// Replacing EULA text control in the database
	//
	PMSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);

	if (0 == hDatabase)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiGetActiveDatabase failed, error=0x%X"), 
			GetLastError());

		return ERROR_INSTALL_FAILURE;
	}

	PMSIHANDLE hView;
	LPCTSTR query = _T("SELECT * FROM `Control` ")
		_T(" WHERE `Dialog_` = 'LicenseAgreement' AND `Control` = 'Memo' ");
	UINT ret = MsiDatabaseOpenView(hDatabase, query, &hView);

	if (ERROR_SUCCESS != ret)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiDatabaseOpenView failed, error=0x%X"), 
			ret);

		return ERROR_INSTALL_FAILURE;
	}

	ret = MsiViewExecute(hView, 0);

	if (ERROR_SUCCESS != ret)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiViewExecute failed, error=0x%X"), 
			ret);

		return ERROR_INSTALL_FAILURE;
	}

	PMSIHANDLE hRecord;
	ret = MsiViewFetch(hView, &hRecord);

	if (ERROR_SUCCESS != ret)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiViewFetch failed, error=0x%X"), 
			ret);

		return ERROR_INSTALL_FAILURE;
	}

	ret = MsiViewModify(hView, MSIMODIFY_DELETE, hRecord);

	if (ERROR_SUCCESS != ret)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiViewModify failed, error=0x%X"), 
			ret);

		return ERROR_INSTALL_FAILURE;
	}

	//
	// 10th field is the Text column
	//
	// Dialog_, Control, Type, X, Y, 
	// Width, Height, Attributes, Property, Text
	// Control_Next, Help
	//
	ret = MsiRecordSetStringA(hRecord, 10, lpEula);
	
	if (ERROR_SUCCESS != ret)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiRecordSetString failed, error=0x%X"), 
			ret);

		return ERROR_INSTALL_FAILURE;
	}

	//
	// Commit the changes temporarily
	//
	ret = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord);
	
	if (ERROR_SUCCESS != ret)
	{
		pMsiLogMessage(
			hInstall, 
			_T("EULACA: MsiViewModify failed, error=0x%X"), 
			ret);

		return ERROR_INSTALL_FAILURE;
	}

	pMsiLogMessage(
		hInstall,
		_T("EULACA: EULA is replaced successfully."));

	return ERROR_SUCCESS;
}
Example #16
0
static void test_fieldzero(void)
{
    MSIHANDLE hdb, hview, rec;
    CHAR buf[MAX_PATH];
    LPCSTR query;
    DWORD sz;
    UINT r;

    rec = MsiCreateRecord(1);
    ok(rec != 0, "Expected a valid handle\n");

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
    ok(sz == 0, "Expectd 0, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    r = MsiRecordGetInteger(rec, 1);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    r = MsiRecordSetInteger(rec, 1, 42);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
    ok(sz == 0, "Expectd 0, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    r = MsiRecordGetInteger(rec, 1);
    ok(r == 42, "Expected 42, got %d\n", r);

    r = MsiRecordSetString(rec, 1, "bologna");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
    ok(sz == 0, "Expectd 0, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 1, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, "bologna"), "Expected \"bologna\", got \"%s\"\n", buf);
    ok(sz == 7, "Expectd 7, got %d\n", sz);

    MsiCloseHandle(rec);

    r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
    ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");

    query = "CREATE TABLE `drone` ( "
           "`id` INT, `name` CHAR(32), `number` CHAR(32) "
           "PRIMARY KEY `id`)";
    r = MsiDatabaseOpenView(hdb, query, &hview);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewExecute(hview, 0);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewClose(hview);
    ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
    r = MsiCloseHandle(hview);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    query = "INSERT INTO `drone` ( `id`, `name`, `number` )"
           "VALUES('1', 'Abe', '8675309')";
    r = MsiDatabaseOpenView(hdb, query, &hview);
    ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
    r = MsiViewExecute(hview, 0);
    ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
    r = MsiViewClose(hview);
    ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
    r = MsiCloseHandle(hview);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    r = MsiDatabaseGetPrimaryKeysA(hdb, "drone", &rec);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, "drone"), "Expected \"drone\", got \"%s\"\n", buf);
    ok(sz == 5, "Expectd 5, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == FALSE, "Expected FALSE, got %d\n", r);

    MsiCloseHandle(rec);

    r = MsiDatabaseGetPrimaryKeysA(hdb, "nosuchtable", &rec);
    ok(r == ERROR_INVALID_TABLE, "Expected ERROR_INVALID_TABLE, got %d\n", r);

    query = "SELECT * FROM `drone` WHERE `id` = 1";
    r = MsiDatabaseOpenView(hdb, query, &hview);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewExecute(hview, 0);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewFetch(hview, &rec);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r != MSI_NULL_INTEGER && r != 0, "Expected non-NULL value, got %d\n", r);

    r = MsiRecordIsNull(rec, 0);
    ok(r == FALSE, "Expected FALSE, got %d\n", r);

    r = MsiCloseHandle(hview);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
    MsiCloseHandle(rec);
    MsiCloseHandle(hdb);
    DeleteFileA(msifile);
}
Example #17
0
UINT KillRunningProcessesSlave( MSIHANDLE hInstall, BOOL bKill )
{
    UINT rv = ERROR_SUCCESS;
    _KillProc * kpList;
    int nKpList = 0;
    int i;
    int rowNum = 1;
    DWORD size;
    BOOL found = FALSE;

    MSIHANDLE hDatabase = NULL;
    MSIHANDLE hView = NULL;
    MSIHANDLE hViewInsert = NULL;
    MSIHANDLE hRecord = NULL;
    MSIHANDLE hRecordInsert = NULL;

    HANDLE hSnapshot = NULL;

    PROCESSENTRY32 pe;

    kpList = new _KillProc[MAX_KILL_PROCESSES];
    memset(kpList, 0, sizeof(*kpList) * MAX_KILL_PROCESSES);

    hDatabase = MsiGetActiveDatabase( hInstall );
    if( hDatabase == NULL ) {
        rv = GetLastError();
        goto _cleanup;
    }

    // If we are only going to list out the processes, delete all the existing
    // entries first.

    if(!bKill) {

        rv = MsiDatabaseOpenView( hDatabase,
            _T( "DELETE FROM `ListBox` WHERE `ListBox`.`Property` = 'KillableProcesses'" ),
            &hView); RV_BAIL;

        rv = MsiViewExecute( hView, NULL ); RV_BAIL;

        MsiCloseHandle( hView );

        hView = NULL;
        
        rv = MsiDatabaseOpenView( hDatabase,
              _T( "SELECT * FROM `ListBox` WHERE `Property` = 'KillableProcesses'" ),
            &hViewInsert); RV_BAIL;

        MsiViewExecute(hViewInsert, NULL);

        hRecordInsert = MsiCreateRecord(4);

        if(hRecordInsert == NULL) {
            rv = GetLastError();
            goto _cleanup;
        }
    }

    // Open a view
    rv = MsiDatabaseOpenView( hDatabase, 
        _T( "SELECT `Image`,`Desc` FROM `KillProcess`" ),
        &hView); RV_BAIL;

    rv = MsiViewExecute( hView, NULL ); RV_BAIL;

    do {
        rv = MsiViewFetch( hView, &hRecord );
        if(rv != ERROR_SUCCESS) {
            if(hRecord) 
                MsiCloseHandle(hRecord);
            hRecord = NULL;
            break;
        }

        kpList[nKpList].image = new TCHAR[ FIELD_SIZE ]; kpList[nKpList].image[0] = _T('\0');
        kpList[nKpList].desc = new TCHAR[ FIELD_SIZE ];  kpList[nKpList].desc[0] = _T('\0');
        nKpList++;

        size = FIELD_SIZE;
        rv = MsiRecordGetString(hRecord, 1, kpList[nKpList-1].image, &size); RV_BAIL;

        size = FIELD_SIZE;
        rv = MsiRecordGetString(hRecord, 2, kpList[nKpList-1].desc, &size); RV_BAIL;

        MsiCloseHandle(hRecord);
    } while(nKpList < MAX_KILL_PROCESSES);

    hRecord = NULL;

    // now we have all the processes in the array.  Check if they are running.
    
    hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
    if(hSnapshot == INVALID_HANDLE_VALUE) {
        rv = GetLastError();
        goto _cleanup;
    }

    pe.dwSize = sizeof( PROCESSENTRY32 );

    if(!Process32First( hSnapshot, &pe )) {
        // technically we should at least find the MSI process, but we let this pass
        rv = ERROR_SUCCESS;
        goto _cleanup;
    }

    do {
        for(i=0; i<nKpList; i++) {
            if(!_tcsicmp( kpList[i].image, pe.szExeFile )) {
                // got one
                if(bKill) {
                    // try to kill the process
                    HANDLE hProcess = NULL;

                    // If we encounter an error, instead of bailing
                    // out, we continue on to the next process.  We
                    // may not have permission to kill all the
                    // processes we want to kill anyway.  If there are
                    // any files that we want to replace that is in
                    // use, Windows Installer will schedule a reboot.
                    // Also, it's not like we have an exhaustive list
                    // of all the programs that use Kerberos anyway.

                    hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID);
                    if(hProcess == NULL) {
                        rv = GetLastError();
                        break;
                    }

                    if(!TerminateProcess(hProcess, 0)) {
                        rv = GetLastError();
                        CloseHandle(hProcess);
                        break;
                    }

                    CloseHandle(hProcess);

                } else {
                    TCHAR buf[256];

                    // we are supposed to just list out the processes
                    rv = MsiRecordClearData( hRecordInsert ); RV_BAIL;
                    rv = MsiRecordSetString( hRecordInsert, 1, _T("KillableProcesses"));
                    rv = MsiRecordSetInteger( hRecordInsert, 2, rowNum++ ); RV_BAIL;
                    _itot( rowNum, buf, 10 );
                    rv = MsiRecordSetString( hRecordInsert, 3, buf ); RV_BAIL;
                    if(_tcslen(kpList[i].desc)) {
                        rv = MsiRecordSetString( hRecordInsert, 4, kpList[i].desc ); RV_BAIL;
                    } else {
                        rv = MsiRecordSetString( hRecordInsert, 4, kpList[i].image ); RV_BAIL;
                    }
                    MsiViewModify(hViewInsert, MSIMODIFY_INSERT_TEMPORARY, hRecordInsert); RV_BAIL;

                    found = TRUE;
                }
                break;
            }
        }
   } while( Process32Next( hSnapshot, &pe ) );

    if(!bKill) {
        // set the 'FoundProcceses' property
        if(found) {
            MsiSetProperty( hInstall, _T("FoundProcesses"), _T("1"));
        } else {
            MsiSetProperty( hInstall, _T("FoundProcesses"), _T(""));
        }
    }

    // Finally:
    rv = ERROR_SUCCESS;

_cleanup:

    if(hRecordInsert) MsiCloseHandle(hRecordInsert);
    if(hViewInsert) MsiCloseHandle(hView);

    if(hSnapshot && hSnapshot != INVALID_HANDLE_VALUE) CloseHandle(hSnapshot);

    while(nKpList) {
        nKpList--;
        delete kpList[nKpList].image;
        delete kpList[nKpList].desc;
    }
    delete kpList;

    if(hRecord) MsiCloseHandle(hRecord);
    if(hView) MsiCloseHandle(hView);

    if(hDatabase) MsiCloseHandle(hDatabase);

    if(rv != ERROR_SUCCESS) {
        ShowMsiError(hInstall, ERR_PROC_LIST, rv);
    }

    return rv;
}
Example #18
0
static void test_system_tables( void )
{
    UINT r;
    const char *query;
    MSIHANDLE hproduct, hdb, hview, hrec;

    if (!pMsiApplyPatchA)
    {
        win_skip("MsiApplyPatchA is not available\n");
        return;
    }
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    CreateDirectoryA( "msitest", NULL );
    create_file( "msitest\\patch.txt", 1000 );

    create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) );
    create_patch( mspfile );

    MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );

    r = MsiInstallProductA( msifile, NULL );
    if (r != ERROR_SUCCESS)
    {
        skip("Product installation failed with error code %d\n", r);
        goto cleanup;
    }

    r = MsiOpenProductA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &hproduct );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    hdb = MsiGetActiveDatabase( hproduct );
    ok( hdb, "failed to get database handle\n" );

    r = find_entry( hdb, "_Streams", "\5SummaryInformation" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    query = "SELECT * FROM `_Storages`";
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r );

    r = find_entry( hdb, "_Tables", "Directory" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "File" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Component" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Feature" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "FeatureComponents" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Property" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "InstallExecuteSequence" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Media" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "_Property" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );
    MsiCloseHandle( hdb );
    MsiCloseHandle( hproduct );

    r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL );
    ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */
        "expected ERROR_SUCCESS, got %u\n", r );

    if (r == ERROR_PATCH_PACKAGE_INVALID)
    {
        win_skip("Windows Installer < 3.0 detected\n");
        goto uninstall;
    }

    r = MsiOpenProductA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &hproduct );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    hdb = MsiGetActiveDatabase( hproduct );
    ok( hdb, "failed to get database handle\n" );

    r = find_entry( hdb, "_Streams", "\5SummaryInformation" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    query = "SELECT * FROM `_Storages`";
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r );

    r = find_entry( hdb, "_Tables", "Directory" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "File" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Component" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Feature" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "FeatureComponents" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Property" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "InstallExecuteSequence" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Media" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "_Property" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "MsiPatchHeaders" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "Patch" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    r = find_entry( hdb, "_Tables", "PatchPackage" );
    ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );
    MsiCloseHandle( hdb );
    MsiCloseHandle( hproduct );

uninstall:
    r = MsiInstallProductA( msifile, "REMOVE=ALL" );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

cleanup:
    DeleteFileA( msifile );
    DeleteFileA( mspfile );
    DeleteFileA( "msitest\\patch.txt" );
    RemoveDirectoryA( "msitest" );
}
Example #19
0
static void test_simple_patch( void )
{
    UINT r;
    DWORD size;
    char path[MAX_PATH], install_source[MAX_PATH], buffer[32];
    const char *query;
    MSIHANDLE hpackage, hdb, hview, hrec;

    if (!pMsiApplyPatchA)
    {
        win_skip("MsiApplyPatchA is not available\n");
        return;
    }
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    CreateDirectoryA( "msitest", NULL );
    create_file( "msitest\\patch.txt", 1000 );

    create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) );
    create_patch( mspfile );

    MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );

    r = MsiInstallProductA( msifile, NULL );
    if (r != ERROR_SUCCESS)
    {
        skip("Product installation failed with error code %u\n", r);
        goto cleanup;
    }

    size = get_pf_file_size( "msitest\\patch.txt" );
    ok( size == 1000, "expected 1000, got %u\n", size );

    size = sizeof(install_source);
    r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}",
                            "InstallSource", install_source, &size );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    strcpy( path, CURR_DIR );
    strcat( path, "\\" );
    strcat( path, msifile );

    r = MsiOpenPackageA( path, &hpackage );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    hdb = MsiGetActiveDatabase( hpackage );
    ok( hdb, "failed to get database handle\n" );

    query = "SELECT * FROM `Property` where `Property` = 'PATCHNEWPACKAGECODE'";
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );

    query = "SELECT * FROM `Property` WHERE `Property` = 'PATCHNEWSUMMARYSUBJECT' "
            "AND `Value` = 'Installer Database'";
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );

    buffer[0] = 0;
    size = sizeof(buffer);
    r = MsiGetProperty( hpackage, "PATCHNEWSUMMARYSUBJECT", buffer, &size );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );
    ok( !strcmp( buffer, "Installer Database" ), "expected \'Installer Database\', got \'%s\'\n", buffer );

    MsiCloseHandle( hdb );
    MsiCloseHandle( hpackage );

    r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL );
    ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */
        "expected ERROR_SUCCESS, got %u\n", r );

    if (r == ERROR_PATCH_PACKAGE_INVALID)
    {
        win_skip("Windows Installer < 3.0 detected\n");
        goto uninstall;
    }

    size = get_pf_file_size( "msitest\\patch.txt" );
    ok( size == 1002, "expected 1002, got %u\n", size );

    /* show that MsiOpenPackage applies registered patches */
    r = MsiOpenPackageA( path, &hpackage );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    hdb = MsiGetActiveDatabase( hpackage );
    ok( hdb, "failed to get database handle\n" );

    query = "SELECT * FROM `Property` where `Property` = 'PATCHNEWPACKAGECODE'";
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );

    query = "SELECT * FROM `Property` WHERE `Property` = 'PATCHNEWSUMMARYSUBJECT' "
            "AND `Value` = 'Installation Database'";
    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );

    buffer[0] = 0;
    size = sizeof(buffer);
    r = MsiGetProperty( hpackage, "PATCHNEWSUMMARYSUBJECT", buffer, &size );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );
    ok( !strcmp( buffer, "Installation Database" ), "expected \'Installation Database\', got \'%s\'\n", buffer );

    MsiCloseHandle( hdb );
    MsiCloseHandle( hpackage );

    /* show that patches are not committed to the local package database */
    size = sizeof(path);
    r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}",
                            "LocalPackage", path, &size );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiOpenDatabaseA( path, MSIDBOPEN_READONLY, &hdb );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiDatabaseOpenView( hdb, query, &hview );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewExecute( hview, 0 );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    r = MsiViewFetch( hview, &hrec );
    ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r );

    MsiCloseHandle( hrec );
    MsiViewClose( hview );
    MsiCloseHandle( hview );
    MsiCloseHandle( hdb );

uninstall:
    size = sizeof(path);
    r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}",
                            "InstallSource", path, &size );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );
    ok( !strcasecmp( path, install_source ), "wrong path %s\n", path );

    r = MsiInstallProductA( msifile, "REMOVE=ALL" );
    ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r );

    ok( !delete_pf( "msitest\\patch.txt", TRUE ), "file not removed\n" );
    ok( !delete_pf( "msitest", FALSE ), "directory not removed\n" );

cleanup:
    DeleteFileA( msifile );
    DeleteFileA( mspfile );
    DeleteFileA( "msitest\\patch.txt" );
    RemoveDirectoryA( "msitest" );
}
Example #20
0
/////////////////////////////////////////////////////////////////////
// 
// Function:    GetComponentKeyFilename
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT BOINCCABase::GetComponentKeyFilename( 
    const tstring strComponentName, 
    tstring&      strComponentKeyFilename
    )
{
    UINT        uiReturnValue = 0;
    tstring     strMessage;
    tstring     strQuery;
    TCHAR       szBuffer[256];
    DWORD       dwBufferSize = sizeof(szBuffer);
    MSIHANDLE   hDatabase;
    MSIHANDLE   hView;
    MSIHANDLE   hRecComponentName;
    MSIHANDLE   hRec;


	// Get the handle to the MSI package we are executing for.
	hDatabase = MsiGetActiveDatabase(m_hMSIHandle);
	if (!hDatabase) return ERROR_INSTALL_FAILURE;

	// Construct the query that is going to give us the result we need.
    strQuery  = _T("SELECT `KeyPath` FROM `Component` WHERE `Component`= ?");

	// Create the view
    uiReturnValue = MsiDatabaseOpenView(hDatabase, strQuery.c_str(), &hView);
    switch(uiReturnValue)
    {
    case ERROR_BAD_QUERY_SYNTAX:
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiDatabaseOpenView reports an invalid query was issued")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_HANDLE:
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiDatabaseOpenView reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }

    // Create query parameter
    hRecComponentName = MsiCreateRecord(1);
    uiReturnValue = MsiRecordSetString(hRecComponentName, 1, strComponentName.c_str());
    switch(uiReturnValue)
    {
    case ERROR_INVALID_HANDLE:
        MsiCloseHandle(hRecComponentName);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiRecordSetString reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_PARAMETER:
        MsiCloseHandle(hRecComponentName);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiRecordSetString reports an invalid parameter was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }


    // Execute the query
    uiReturnValue = MsiViewExecute(hView, hRecComponentName);
    switch(uiReturnValue)
    {
    case ERROR_FUNCTION_FAILED:
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);
        
        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiViewExecute failed to execute the view")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_HANDLE:
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiViewExecute reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }

    // Only one row should be returned by the resultset, so there is no need
    //   to execute MsiViewFetch more than once.
    uiReturnValue = MsiViewFetch(hView, &hRec);
    switch(uiReturnValue)
    {
    case ERROR_FUNCTION_FAILED:
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);
        
        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiViewFetch: An error occurred during fetching")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_HANDLE:
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiViewFetch reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_HANDLE_STATE:
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiViewFetch reports the handle was in an invalid state")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }

    // Okay, now it is time to parse the string that was returned.
    uiReturnValue = MsiRecordGetString(hRec, 1, (LPTSTR)&szBuffer, &dwBufferSize);
    switch(uiReturnValue)
    {
    case ERROR_INVALID_HANDLE:
        MsiCloseHandle(hRec);
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiRecordGetString reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_PARAMETER:
        MsiCloseHandle(hRec);
        MsiViewClose(hView);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiRecordGetString reports an invalid parameter was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }

    // Save the string
    strComponentKeyFilename = szBuffer;

    strMessage  = _T("The key filename for component '");
    strMessage += strComponentName;
    strMessage += _T("' is '");
    strMessage += strComponentKeyFilename;
    strMessage += _T("'");

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        strMessage.c_str()
    );

    return ERROR_SUCCESS;
}