mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 21:36:11 +00:00
[WINESYNC] msi: Make MsiGetSourcePath() RPC-compatible.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id d2b0981a2ceb8371460f009e0250ad2690ca0e93 by Zebediah Figura <z.figura12@gmail.com>
This commit is contained in:
parent
a5e210012b
commit
4253f35129
4 changed files with 106 additions and 43 deletions
|
@ -334,50 +334,19 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
|
||||||
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
||||||
if (!package)
|
if (!package)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
|
||||||
LPWSTR value = NULL;
|
LPWSTR value = NULL;
|
||||||
MSIHANDLE remote;
|
MSIHANDLE remote;
|
||||||
BSTR folder;
|
|
||||||
DWORD len;
|
|
||||||
|
|
||||||
if (!(remote = msi_get_remote(hInstall)))
|
if (!(remote = msi_get_remote(hInstall)))
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
folder = SysAllocString( szFolder );
|
r = remote_GetSourcePath(remote, szFolder, &value);
|
||||||
if (!folder)
|
if (r != ERROR_SUCCESS)
|
||||||
return ERROR_OUTOFMEMORY;
|
return r;
|
||||||
|
|
||||||
len = 0;
|
r = msi_strcpy_to_awstring(value, -1, szPathBuf, pcchPathBuf);
|
||||||
hr = remote_GetSourcePath(remote, folder, NULL, &len);
|
|
||||||
if (FAILED(hr))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
len++;
|
|
||||||
value = msi_alloc(len * sizeof(WCHAR));
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
r = ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = remote_GetSourcePath(remote, folder, value, &len);
|
|
||||||
if (FAILED(hr))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
r = msi_strcpy_to_awstring( value, len, szPathBuf, pcchPathBuf );
|
|
||||||
|
|
||||||
done:
|
|
||||||
SysFreeString( folder );
|
|
||||||
msi_free( value );
|
|
||||||
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
||||||
return HRESULT_CODE(hr);
|
|
||||||
|
|
||||||
return ERROR_FUNCTION_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
midl_user_free(value);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2503,10 +2503,21 @@ UINT __cdecl remote_SetTargetPath(MSIHANDLE hinst, LPCWSTR folder, LPCWSTR value
|
||||||
return MsiSetTargetPathW(hinst, folder, value);
|
return MsiSetTargetPathW(hinst, folder, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT __cdecl remote_GetSourcePath(MSIHANDLE hinst, BSTR folder, BSTR value, DWORD *size)
|
UINT __cdecl remote_GetSourcePath(MSIHANDLE hinst, LPCWSTR folder, LPWSTR *value)
|
||||||
{
|
{
|
||||||
UINT r = MsiGetSourcePathW(hinst, folder, value, size);
|
WCHAR empty[1];
|
||||||
return HRESULT_FROM_WIN32(r);
|
DWORD size = 1;
|
||||||
|
UINT r;
|
||||||
|
|
||||||
|
r = MsiGetSourcePathW(hinst, folder, empty, &size);
|
||||||
|
if (r == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
*value = midl_user_allocate(++size * sizeof(WCHAR));
|
||||||
|
if (!*value)
|
||||||
|
return ERROR_OUTOFMEMORY;
|
||||||
|
r = MsiGetSourcePathW(hinst, folder, *value, &size);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT __cdecl remote_GetMode(MSIHANDLE hinst, MSIRUNMODE mode, BOOL *ret)
|
HRESULT __cdecl remote_GetMode(MSIHANDLE hinst, MSIRUNMODE mode, BOOL *ret)
|
||||||
|
|
|
@ -78,7 +78,7 @@ interface IWineMsiRemote
|
||||||
UINT remote_Sequence( [in] MSIHANDLE hinst, [in, string] LPCWSTR table, [in] int sequence );
|
UINT remote_Sequence( [in] MSIHANDLE hinst, [in, string] LPCWSTR table, [in] int sequence );
|
||||||
UINT remote_GetTargetPath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [out, string] LPWSTR *value );
|
UINT remote_GetTargetPath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [out, string] LPWSTR *value );
|
||||||
UINT remote_SetTargetPath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [in, string] LPCWSTR value );
|
UINT remote_SetTargetPath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [in, string] LPCWSTR value );
|
||||||
HRESULT remote_GetSourcePath( [in] MSIHANDLE hinst, [in] BSTR folder, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
|
UINT remote_GetSourcePath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [out, string] LPWSTR *value );
|
||||||
HRESULT remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [out] BOOL *ret );
|
HRESULT remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [out] BOOL *ret );
|
||||||
HRESULT remote_SetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [in] BOOL state );
|
HRESULT remote_SetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [in] BOOL state );
|
||||||
HRESULT remote_GetFeatureState( [in] MSIHANDLE hinst, [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
|
HRESULT remote_GetFeatureState( [in] MSIHANDLE hinst, [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
|
||||||
|
|
|
@ -458,9 +458,9 @@ static void test_targetpath(MSIHANDLE hinst)
|
||||||
static const WCHAR targetdirW[] = {'T','A','R','G','E','T','D','I','R',0};
|
static const WCHAR targetdirW[] = {'T','A','R','G','E','T','D','I','R',0};
|
||||||
static const WCHAR xyzW[] = {'C',':','\\',0};
|
static const WCHAR xyzW[] = {'C',':','\\',0};
|
||||||
static const WCHAR xyW[] = {'C',':',0};
|
static const WCHAR xyW[] = {'C',':',0};
|
||||||
char buffer[20];
|
WCHAR bufferW[100];
|
||||||
WCHAR bufferW[20];
|
char buffer[100];
|
||||||
DWORD sz;
|
DWORD sz, srcsz;
|
||||||
UINT r;
|
UINT r;
|
||||||
|
|
||||||
/* test invalid values */
|
/* test invalid values */
|
||||||
|
@ -557,6 +557,89 @@ static void test_targetpath(MSIHANDLE hinst)
|
||||||
ok(hinst, !strcmp(buffer, "C:\\subdir\\"), "got \"%s\"\n", buffer);
|
ok(hinst, !strcmp(buffer, "C:\\subdir\\"), "got \"%s\"\n", buffer);
|
||||||
|
|
||||||
r = MsiSetTargetPathA(hinst, "TARGETDIR", "C:\\");
|
r = MsiSetTargetPathA(hinst, "TARGETDIR", "C:\\");
|
||||||
|
|
||||||
|
/* test GetSourcePath() */
|
||||||
|
|
||||||
|
r = MsiGetSourcePathA(hinst, NULL, NULL, NULL);
|
||||||
|
ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
|
||||||
|
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", NULL, NULL );
|
||||||
|
ok(hinst, !r, "got %u\n", r);
|
||||||
|
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, NULL );
|
||||||
|
ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
|
||||||
|
|
||||||
|
/* Returned size is in bytes, not chars, but only for custom actions.
|
||||||
|
* Seems to be a casualty of RPC... */
|
||||||
|
|
||||||
|
srcsz = 0;
|
||||||
|
MsiGetSourcePathW(hinst, targetdirW, NULL, &srcsz);
|
||||||
|
|
||||||
|
sz = 0;
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", NULL, &sz);
|
||||||
|
ok(hinst, !r, "got %u\n", r);
|
||||||
|
todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = 0;
|
||||||
|
strcpy(buffer,"q");
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
|
||||||
|
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
|
||||||
|
ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n", buffer);
|
||||||
|
todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = 1;
|
||||||
|
strcpy(buffer,"x");
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
|
||||||
|
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
|
||||||
|
ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
|
||||||
|
todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = srcsz;
|
||||||
|
strcpy(buffer,"x");
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
|
||||||
|
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
|
||||||
|
ok(hinst, strlen(buffer) == srcsz - 1, "wrong buffer length %d\n", strlen(buffer));
|
||||||
|
todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = srcsz + 1;
|
||||||
|
strcpy(buffer,"x");
|
||||||
|
r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
|
||||||
|
ok(hinst, !r, "got %u\n", r);
|
||||||
|
ok(hinst, strlen(buffer) == srcsz, "wrong buffer length %d\n", strlen(buffer));
|
||||||
|
ok(hinst, sz == srcsz, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = 0;
|
||||||
|
r = MsiGetSourcePathW(hinst, targetdirW, NULL, &sz);
|
||||||
|
ok(hinst, !r, "got %u\n", r);
|
||||||
|
ok(hinst, sz == srcsz, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = 0;
|
||||||
|
bufferW[0] = 'q';
|
||||||
|
r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
|
||||||
|
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
|
||||||
|
ok(hinst, bufferW[0] == 'q', "got %s\n", dbgstr_w(bufferW));
|
||||||
|
ok(hinst, sz == srcsz, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = 1;
|
||||||
|
bufferW[0] = 'q';
|
||||||
|
r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
|
||||||
|
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
|
||||||
|
ok(hinst, !bufferW[0], "got %s\n", dbgstr_w(bufferW));
|
||||||
|
ok(hinst, sz == srcsz, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = srcsz;
|
||||||
|
bufferW[0] = 'q';
|
||||||
|
r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
|
||||||
|
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
|
||||||
|
ok(hinst, lstrlenW(bufferW) == srcsz - 1, "wrong buffer length %d\n", lstrlenW(bufferW));
|
||||||
|
ok(hinst, sz == srcsz, "got size %u\n", sz);
|
||||||
|
|
||||||
|
sz = srcsz + 1;
|
||||||
|
bufferW[0] = 'q';
|
||||||
|
r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
|
||||||
|
ok(hinst, !r, "got %u\n", r);
|
||||||
|
ok(hinst, lstrlenW(bufferW) == srcsz, "wrong buffer length %d\n", lstrlenW(bufferW));
|
||||||
|
ok(hinst, sz == srcsz, "got size %u\n", sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main test. Anything that doesn't depend on a specific install configuration
|
/* Main test. Anything that doesn't depend on a specific install configuration
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue