2003-08-13 01:27:48 +00:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2004-07-09 22:25:34 +00:00
|
|
|
* Copyright 2002-2004 Mike McCormack for CodeWeavers
|
2003-08-13 01:27:48 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-08-11 19:43:45 +00:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
|
|
|
|
#include "query.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
#define MSIFIELD_NULL 0
|
|
|
|
#define MSIFIELD_INT 1
|
|
|
|
#define MSIFIELD_STR 2
|
|
|
|
#define MSIFIELD_WSTR 3
|
|
|
|
#define MSIFIELD_STREAM 4
|
|
|
|
|
|
|
|
void MSI_FreeField( MSIFIELD *field )
|
|
|
|
{
|
|
|
|
switch( field->type )
|
|
|
|
{
|
|
|
|
case MSIFIELD_NULL:
|
|
|
|
case MSIFIELD_INT:
|
|
|
|
break;
|
|
|
|
case MSIFIELD_WSTR:
|
|
|
|
HeapFree( GetProcessHeap(), 0, field->u.szwVal);
|
|
|
|
break;
|
|
|
|
case MSIFIELD_STREAM:
|
|
|
|
IStream_Release( field->u.stream );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Invalid field type %d\n", field->type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
void MSI_CloseRecord( MSIOBJECTHDR *arg )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec = (MSIRECORD *) arg;
|
|
|
|
UINT i;
|
|
|
|
|
2004-06-29 03:49:54 +00:00
|
|
|
for( i=0; i<=rec->count; i++ )
|
2003-08-13 01:27:48 +00:00
|
|
|
MSI_FreeField( &rec->fields[i] );
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
MSIRECORD *MSI_CreateRecord( unsigned int cParams )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT len;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
TRACE("%d\n", cParams);
|
|
|
|
|
2005-01-06 20:42:25 +00:00
|
|
|
if( cParams>65535 )
|
|
|
|
return NULL;
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
len = sizeof (MSIRECORD) + sizeof (MSIFIELD)*cParams;
|
|
|
|
rec = alloc_msiobject( MSIHANDLETYPE_RECORD, len, MSI_CloseRecord );
|
|
|
|
if( rec )
|
2005-01-06 20:42:25 +00:00
|
|
|
rec->count = cParams;
|
2004-07-09 22:25:34 +00:00
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSIHANDLE WINAPI MsiCreateRecord( unsigned int cParams )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
MSIHANDLE ret = 0;
|
|
|
|
|
|
|
|
TRACE("%d\n", cParams);
|
|
|
|
|
|
|
|
rec = MSI_CreateRecord( cParams );
|
|
|
|
if( rec )
|
|
|
|
ret = alloc_msihandle( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
unsigned int MSI_RecordGetFieldCount( MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
return rec->count;
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int WINAPI MsiRecordGetFieldCount( MSIHANDLE handle )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT ret;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
TRACE("%ld\n", handle );
|
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
2005-01-06 20:42:25 +00:00
|
|
|
return -1;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordGetFieldCount( rec );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
|
|
|
|
return ret;
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL string2intW( LPCWSTR str, int *out )
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
LPCWSTR p = str;
|
|
|
|
|
|
|
|
if( *p == '-' ) /* skip the minus sign */
|
|
|
|
p++;
|
|
|
|
while ( *p )
|
|
|
|
{
|
|
|
|
if( (*p < '0') || (*p > '9') )
|
|
|
|
return FALSE;
|
|
|
|
x *= 10;
|
|
|
|
x += (*p - '0');
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( str[0] == '-' ) /* check if it's negative */
|
|
|
|
x = -x;
|
|
|
|
*out = x;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
int MSI_RecordGetInteger( MSIRECORD *rec, unsigned int iField)
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%p %d\n", rec, iField );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return MSI_NULL_INTEGER;
|
|
|
|
|
|
|
|
switch( rec->fields[iField].type )
|
|
|
|
{
|
|
|
|
case MSIFIELD_INT:
|
|
|
|
return rec->fields[iField].u.iVal;
|
|
|
|
case MSIFIELD_WSTR:
|
|
|
|
if( string2intW( rec->fields[iField].u.szwVal, &ret ) )
|
|
|
|
return ret;
|
|
|
|
return MSI_NULL_INTEGER;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MSI_NULL_INTEGER;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
int WINAPI MsiRecordGetInteger( MSIHANDLE handle, unsigned int iField)
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%ld %d\n", handle, iField );
|
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return MSI_NULL_INTEGER;
|
|
|
|
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordGetInteger( rec, iField );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
UINT WINAPI MsiRecordClearData( MSIHANDLE handle )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
TRACE("%ld\n", handle );
|
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2003-08-13 01:27:48 +00:00
|
|
|
for( i=0; i<=rec->count; i++)
|
|
|
|
{
|
|
|
|
MSI_FreeField( &rec->fields[i] );
|
|
|
|
rec->fields[i].type = MSIFIELD_NULL;
|
|
|
|
rec->fields[i].u.iVal = 0;
|
|
|
|
}
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT MSI_RecordSetInteger( MSIRECORD *rec, unsigned int iField, int iVal )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%p %u %d\n", rec, iField, iVal);
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2005-01-06 20:42:25 +00:00
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
MSI_FreeField( &rec->fields[iField] );
|
|
|
|
rec->fields[iField].type = MSIFIELD_INT;
|
|
|
|
rec->fields[iField].u.iVal = iVal;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT WINAPI MsiRecordSetInteger( MSIHANDLE handle, unsigned int iField, int iVal )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT ret;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%ld %u %d\n", handle, iField, iVal);
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordSetInteger( rec, iField, iVal );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL MSI_RecordIsNull( MSIRECORD *rec, unsigned int iField )
|
|
|
|
{
|
|
|
|
BOOL r = TRUE;
|
|
|
|
|
|
|
|
TRACE("%p %d\n", rec, iField );
|
|
|
|
|
2004-03-19 19:14:12 +00:00
|
|
|
r = ( iField > rec->count ) ||
|
|
|
|
( rec->fields[iField].type == MSIFIELD_NULL );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-03-19 19:14:12 +00:00
|
|
|
return r;
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
BOOL WINAPI MsiRecordIsNull( MSIHANDLE handle, unsigned int iField )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT ret;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%ld %d\n", handle, iField );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
2005-01-06 20:42:25 +00:00
|
|
|
return 0;
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordIsNull( rec, iField );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_RecordGetStringA(MSIRECORD *rec, unsigned int iField,
|
|
|
|
LPSTR szValue, DWORD *pcchValue)
|
|
|
|
{
|
|
|
|
UINT len=0, ret;
|
|
|
|
CHAR buffer[16];
|
|
|
|
|
|
|
|
TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue);
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
switch( rec->fields[iField].type )
|
|
|
|
{
|
|
|
|
case MSIFIELD_INT:
|
|
|
|
wsprintfA(buffer, "%d", rec->fields[iField].u.iVal);
|
|
|
|
len = lstrlenA( buffer );
|
|
|
|
lstrcpynA(szValue, buffer, *pcchValue);
|
|
|
|
break;
|
|
|
|
case MSIFIELD_WSTR:
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
|
|
|
|
NULL, 0 , NULL, NULL);
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
|
|
|
|
szValue, *pcchValue, NULL, NULL);
|
2005-01-06 20:42:25 +00:00
|
|
|
if( *pcchValue && len>*pcchValue )
|
|
|
|
szValue[*pcchValue-1] = 0;
|
|
|
|
if( len )
|
|
|
|
len--;
|
2003-08-13 01:27:48 +00:00
|
|
|
break;
|
2004-06-30 19:46:25 +00:00
|
|
|
case MSIFIELD_NULL:
|
|
|
|
if( *pcchValue > 0 )
|
|
|
|
szValue[0] = 0;
|
2004-08-24 20:56:08 +00:00
|
|
|
break;
|
2003-08-13 01:27:48 +00:00
|
|
|
default:
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( *pcchValue < len )
|
|
|
|
ret = ERROR_MORE_DATA;
|
|
|
|
*pcchValue = len;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, unsigned int iField,
|
|
|
|
LPSTR szValue, DWORD *pcchValue)
|
2004-06-30 18:18:27 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%ld %d %p %p\n", handle, iField, szValue, pcchValue);
|
2004-06-30 18:18:27 +00:00
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
2004-07-09 22:25:34 +00:00
|
|
|
return ERROR_INVALID_HANDLE;
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordGetStringA( rec, iField, szValue, pcchValue);
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
2004-06-30 18:18:27 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
const WCHAR *MSI_RecordGetString( MSIRECORD *rec, unsigned int iField )
|
|
|
|
{
|
2004-06-30 18:18:27 +00:00
|
|
|
if( iField > rec->count )
|
|
|
|
return NULL;
|
|
|
|
|
2004-06-30 18:42:02 +00:00
|
|
|
if( rec->fields[iField].type != MSIFIELD_WSTR )
|
|
|
|
return NULL;
|
|
|
|
|
2004-06-30 18:18:27 +00:00
|
|
|
return rec->fields[iField].u.szwVal;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT MSI_RecordGetStringW(MSIRECORD *rec, unsigned int iField,
|
2003-08-13 01:27:48 +00:00
|
|
|
LPWSTR szValue, DWORD *pcchValue)
|
|
|
|
{
|
|
|
|
UINT len=0, ret;
|
|
|
|
WCHAR buffer[16];
|
2004-04-19 20:12:14 +00:00
|
|
|
static const WCHAR szFormat[] = { '%','d',0 };
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue);
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
switch( rec->fields[iField].type )
|
|
|
|
{
|
|
|
|
case MSIFIELD_INT:
|
|
|
|
wsprintfW(buffer, szFormat, rec->fields[iField].u.iVal);
|
|
|
|
len = lstrlenW( buffer );
|
|
|
|
lstrcpynW(szValue, buffer, *pcchValue);
|
|
|
|
break;
|
|
|
|
case MSIFIELD_WSTR:
|
|
|
|
len = lstrlenW( rec->fields[iField].u.szwVal );
|
|
|
|
lstrcpynW(szValue, rec->fields[iField].u.szwVal, *pcchValue);
|
|
|
|
break;
|
2004-06-30 19:46:25 +00:00
|
|
|
case MSIFIELD_NULL:
|
|
|
|
len = 1;
|
|
|
|
if( *pcchValue > 0 )
|
|
|
|
szValue[0] = 0;
|
2003-08-13 01:27:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( *pcchValue < len )
|
|
|
|
ret = ERROR_MORE_DATA;
|
|
|
|
*pcchValue = len;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, unsigned int iField,
|
|
|
|
LPWSTR szValue, DWORD *pcchValue)
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%ld %d %p %p\n", handle, iField, szValue, pcchValue);
|
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordGetStringW( rec, iField, szValue, pcchValue );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-01-06 20:42:25 +00:00
|
|
|
UINT MSI_RecordDataSize(MSIRECORD *rec, unsigned int iField)
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
2005-01-06 20:42:25 +00:00
|
|
|
TRACE("%p %d\n", rec, iField);
|
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch( rec->fields[iField].type )
|
|
|
|
{
|
|
|
|
case MSIFIELD_INT:
|
|
|
|
return sizeof (INT);
|
|
|
|
case MSIFIELD_WSTR:
|
|
|
|
return lstrlenW( rec->fields[iField].u.szwVal );
|
|
|
|
case MSIFIELD_NULL:
|
|
|
|
break;
|
|
|
|
}
|
2003-08-13 01:27:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-06 20:42:25 +00:00
|
|
|
UINT WINAPI MsiRecordDataSize(MSIHANDLE handle, unsigned int iField)
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%ld %d\n", handle, iField);
|
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return 0;
|
|
|
|
msiobj_lock( &rec->hdr );
|
|
|
|
ret = MSI_RecordDataSize( rec, iField);
|
|
|
|
msiobj_unlock( &rec->hdr );
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
2004-06-30 18:18:27 +00:00
|
|
|
LPWSTR str;
|
|
|
|
UINT len;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%p %d %s\n", rec, iField, debugstr_a(szValue));
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_FIELD;
|
|
|
|
|
2004-06-30 18:18:27 +00:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, szValue, -1, NULL, 0 );
|
2004-06-30 18:27:23 +00:00
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
2004-06-30 18:18:27 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, szValue, -1, str, len );
|
2003-08-13 01:27:48 +00:00
|
|
|
MSI_FreeField( &rec->fields[iField] );
|
2004-06-30 18:18:27 +00:00
|
|
|
rec->fields[iField].type = MSIFIELD_WSTR;
|
|
|
|
rec->fields[iField].u.szwVal = str;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, unsigned int iField, LPCSTR szValue )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT ret;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%ld %d %s\n", handle, iField, debugstr_a(szValue));
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordSetStringA( rec, iField, szValue );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue )
|
|
|
|
{
|
|
|
|
LPWSTR str;
|
|
|
|
UINT len;
|
|
|
|
|
|
|
|
TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue));
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_FIELD;
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
len = lstrlenW(szValue) + 1;
|
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR));
|
2003-08-13 01:27:48 +00:00
|
|
|
lstrcpyW( str, szValue );
|
|
|
|
|
|
|
|
MSI_FreeField( &rec->fields[iField] );
|
|
|
|
rec->fields[iField].type = MSIFIELD_WSTR;
|
|
|
|
rec->fields[iField].u.szwVal = str;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT WINAPI MsiRecordSetStringW( MSIHANDLE handle, unsigned int iField, LPCWSTR szValue )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%ld %d %s\n", handle, iField, debugstr_w(szValue));
|
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordSetStringW( rec, iField, szValue );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
UINT WINAPI MsiFormatRecordA(MSIHANDLE hInstall, MSIHANDLE hRecord, LPSTR szResult, DWORD *sz)
|
|
|
|
{
|
|
|
|
FIXME("%ld %ld %p %p\n", hInstall, hRecord, szResult, sz);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiFormatRecordW(MSIHANDLE hInstall, MSIHANDLE hRecord, LPWSTR szResult, DWORD *sz)
|
|
|
|
{
|
|
|
|
FIXME("%ld %ld %p %p\n", hInstall, hRecord, szResult, sz);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, unsigned int iField, LPCSTR szFilename)
|
|
|
|
{
|
|
|
|
FIXME("%ld %d %s\n", hRecord, iField, debugstr_a(szFilename));
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiRecordSetStreamW(MSIHANDLE hRecord, unsigned int iField, LPCWSTR szFilename)
|
|
|
|
{
|
|
|
|
FIXME("%ld %d %s\n", hRecord, iField, debugstr_w(szFilename));
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT MSI_RecordReadStream(MSIRECORD *rec, unsigned int iField, char *buf, DWORD *sz)
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
2004-06-29 03:41:28 +00:00
|
|
|
ULONG count;
|
|
|
|
HRESULT r;
|
|
|
|
IStream *stm;
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%p %d %p %p\n", rec, iField, buf, sz);
|
2004-06-29 03:41:28 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_FIELD;
|
|
|
|
|
|
|
|
if( rec->fields[iField].type != MSIFIELD_STREAM )
|
2004-07-09 19:33:45 +00:00
|
|
|
{
|
|
|
|
*sz = 0;
|
2004-06-29 03:41:28 +00:00
|
|
|
return ERROR_INVALID_FIELD;
|
2004-07-09 19:33:45 +00:00
|
|
|
}
|
2004-06-29 03:41:28 +00:00
|
|
|
|
|
|
|
stm = rec->fields[iField].u.stream;
|
|
|
|
if( !stm )
|
|
|
|
return ERROR_INVALID_FIELD;
|
|
|
|
|
|
|
|
/* if there's no buffer pointer, calculate the length to the end */
|
|
|
|
if( !buf )
|
|
|
|
{
|
|
|
|
LARGE_INTEGER ofs;
|
|
|
|
ULARGE_INTEGER end, cur;
|
|
|
|
|
|
|
|
ofs.QuadPart = cur.QuadPart = 0;
|
|
|
|
end.QuadPart = 0;
|
|
|
|
r = IStream_Seek( stm, ofs, STREAM_SEEK_SET, &cur );
|
|
|
|
IStream_Seek( stm, ofs, STREAM_SEEK_END, &end );
|
|
|
|
ofs.QuadPart = cur.QuadPart;
|
|
|
|
IStream_Seek( stm, ofs, STREAM_SEEK_SET, &cur );
|
|
|
|
*sz = end.QuadPart - cur.QuadPart;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read the data */
|
|
|
|
count = 0;
|
|
|
|
r = IStream_Read( stm, buf, *sz, &count );
|
|
|
|
if( FAILED( r ) )
|
2004-12-06 16:18:22 +00:00
|
|
|
{
|
|
|
|
*sz = 0;
|
2004-06-29 03:41:28 +00:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2004-12-06 16:18:22 +00:00
|
|
|
}
|
2004-06-29 03:41:28 +00:00
|
|
|
|
|
|
|
*sz = count;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT WINAPI MsiRecordReadStream(MSIHANDLE handle, unsigned int iField, char *buf, DWORD *sz)
|
2004-06-29 03:41:28 +00:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
2004-07-09 22:25:34 +00:00
|
|
|
UINT ret;
|
2004-06-29 03:41:28 +00:00
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%ld %d %p %p\n", handle, iField, buf, sz);
|
2004-06-29 03:41:28 +00:00
|
|
|
|
|
|
|
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
ret = MSI_RecordReadStream( rec, iField, buf, sz );
|
2004-12-27 19:29:33 +00:00
|
|
|
msiobj_unlock( &rec->hdr );
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_RecordSetIStream( MSIRECORD *rec, unsigned int iField, IStream *stm )
|
|
|
|
{
|
|
|
|
TRACE("%p %d %p\n", rec, iField, stm);
|
2004-06-29 03:41:28 +00:00
|
|
|
|
|
|
|
if( iField > rec->count )
|
|
|
|
return ERROR_INVALID_FIELD;
|
|
|
|
|
|
|
|
MSI_FreeField( &rec->fields[iField] );
|
|
|
|
|
|
|
|
rec->fields[iField].type = MSIFIELD_STREAM;
|
|
|
|
rec->fields[iField].u.stream = stm;
|
|
|
|
IStream_AddRef( stm );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|