ReactOS  0.4.14-dev-41-g31d7680
source.c File Reference
#include <stdio.h>
#include <windows.h>
#include <msiquery.h>
#include <msidefs.h>
#include <msi.h>
#include <sddl.h>
#include <secext.h>
#include <objbase.h>
#include "wine/test.h"
Include dependency graph for source.c:

Go to the source code of this file.

Macros

#define _WIN32_MSI   300
 
#define GET_PROC(dll, func)
 
#define CHECK_REG_STR(prodkey, name, expected)   check_reg_str(prodkey, name, expected, TRUE, __LINE__);
 

Functions

static BOOL (WINAPI *pConvertSidToStringSidA)(PSID
 
static LPSTR *static LONG (WINAPI *pRegDeleteKeyExA)(HKEY
 
static BOOLEAN (WINAPI *pGetUserNameExA)(EXTENDED_NAME_FORMAT
 
static UINT (WINAPI *pMsiSourceListAddMediaDiskA)(LPCSTR
 
static void init_functionpointers (void)
 
static BOOL squash_guid (LPCWSTR in, LPWSTR out)
 
static void create_test_guid (LPSTR prodcode, LPSTR squashed)
 
static charget_user_sid (void)
 
static void check_reg_str (HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
 
static void test_MsiSourceListGetInfo (void)
 
static LONG delete_key (HKEY key, LPCSTR subkey, REGSAM access)
 
static void test_MsiSourceListAddSourceEx (void)
 
static void test_MsiSourceListEnumSources (void)
 
static void test_MsiSourceListSetInfo (void)
 
static void test_MsiSourceListAddMediaDisk (void)
 
static void test_MsiSourceListEnumMediaDisks (void)
 
static void test_MsiSourceListAddSource (void)
 
 START_TEST (source)
 

Variables

static BOOL is_wow64
 
static LPSTR *static LPCSTR
 
static LPSTR *static REGSAM
 
static LPSTR *static DWORD
 
static LPSTR
 
static PULONG
 
static PBOOL
 
static MSIINSTALLCONTEXT
 
static LPDWORD
 

Macro Definition Documentation

◆ _WIN32_MSI

#define _WIN32_MSI   300

Definition at line 21 of file source.c.

◆ CHECK_REG_STR

#define CHECK_REG_STR (   prodkey,
  name,
  expected 
)    check_reg_str(prodkey, name, expected, TRUE, __LINE__);

Definition at line 189 of file source.c.

◆ GET_PROC

#define GET_PROC (   dll,
  func 
)
Value:
p ## func = (void *)GetProcAddress(dll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GLenum func
Definition: glext.h:6028
static HMODULE dll
Definition: str.c:188
#define GetProcAddress(x, y)
Definition: compat.h:410
GLfloat GLfloat p
Definition: glext.h:8902

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pConvertSidToStringSidA)
static

◆ BOOLEAN()

static BOOLEAN ( WINAPI pGetUserNameExA)
static

◆ check_reg_str()

static void check_reg_str ( HKEY  prodkey,
LPCSTR  name,
LPCSTR  expected,
BOOL  bcase,
DWORD  line 
)
static

Definition at line 162 of file source.c.

163 {
164  char val[MAX_PATH];
165  DWORD size, type;
166  LONG res;
167 
168  size = MAX_PATH;
169  val[0] = '\0';
170  res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
171 
172  if (res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ))
173  {
174  ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
175  return;
176  }
177 
178  if (!expected)
179  ok_(__FILE__, line)(!val[0], "Expected empty string, got %s\n", val);
180  else
181  {
182  if (bcase)
183  ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
184  else
185  ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
186  }
187 }
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
GLuint GLfloat * val
Definition: glext.h:7180
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
Definition: name.c:36
GLuint res
Definition: glext.h:9613
BOOL expected
Definition: store.c:2063
#define ok_(x1, x2)
Definition: atltest.h:61
#define REG_SZ
Definition: layer.c:22

◆ create_test_guid()

static void create_test_guid ( LPSTR  prodcode,
LPSTR  squashed 
)
static

Definition at line 119 of file source.c.

120 {
121  WCHAR guidW[MAX_PATH];
122  WCHAR squashedW[MAX_PATH];
123  GUID guid;
124  HRESULT hr;
125  int size;
126 
127  hr = CoCreateGuid(&guid);
128  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
129 
130  size = StringFromGUID2(&guid, guidW, MAX_PATH);
131  ok(size == 39, "Expected 39, got %d\n", hr);
132 
133  WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
134  squash_guid(guidW, squashedW);
135  WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
136 }
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
const GUID * guid
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2343
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2115
#define S_OK
Definition: intsafe.h:59
static BOOL squash_guid(LPCWSTR in, LPWSTR out)
Definition: source.c:87
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListGetInfo(), and test_MsiSourceListSetInfo().

◆ delete_key()

static LONG delete_key ( HKEY  key,
LPCSTR  subkey,
REGSAM  access 
)
static

Definition at line 640 of file source.c.

641 {
642  if (pRegDeleteKeyExA)
643  return pRegDeleteKeyExA( key, subkey, access, 0 );
644  return RegDeleteKeyA( key, subkey );
645 }
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
Definition: path.c:42

Referenced by test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), and test_MsiSourceListSetInfo().

◆ get_user_sid()

static char* get_user_sid ( void  )
static

Definition at line 138 of file source.c.

139 {
140  HANDLE token;
141  DWORD size = 0;
142  TOKEN_USER *user;
143  char *usersid = NULL;
144 
145  if (!pConvertSidToStringSidA)
146  {
147  win_skip("ConvertSidToStringSidA is not available\n");
148  return NULL;
149  }
152 
155  pConvertSidToStringSidA(user->User.Sid, &usersid);
157 
159  return usersid;
160 }
#define CloseHandle
Definition: compat.h:398
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
#define win_skip
Definition: test.h:141
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListGetInfo(), and test_MsiSourceListSetInfo().

◆ init_functionpointers()

static void init_functionpointers ( void  )
static

Definition at line 58 of file source.c.

59 {
60  HMODULE hmsi = GetModuleHandleA("msi.dll");
61  HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
62  HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
63  HMODULE hsecur32 = LoadLibraryA("secur32.dll");
64 
65 #define GET_PROC(dll, func) \
66  p ## func = (void *)GetProcAddress(dll, #func); \
67  if(!p ## func) \
68  trace("GetProcAddress(%s) failed\n", #func);
69 
77 
79  GET_PROC(hadvapi32, RegDeleteKeyExA)
81  GET_PROC(hsecur32, GetUserNameExA)
82 
83 #undef GET_PROC
84 }
UINT WINAPI MsiSourceListAddSourceExA(LPCSTR szProduct, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szSource, DWORD dwIndex)
Definition: source.c:936
LONG WINAPI RegDeleteKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
Definition: reg.c:1252
static HINSTANCE hkernel32
Definition: process.c:66
BOOLEAN WINAPI GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize)
Definition: sspi.c:1044
UINT WINAPI MsiSourceListEnumSourcesA(LPCSTR szProductCodeOrPatch, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwIndex, LPSTR szSource, LPDWORD pcchSource)
Definition: source.c:339
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
UINT WINAPI MsiSourceListAddSourceA(LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved, LPCSTR szSource)
Definition: source.c:912
UINT WINAPI MsiSourceListSetInfoA(LPCSTR szProduct, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szProperty, LPCSTR szValue)
Definition: source.c:676
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1974
BOOL WINAPI ConvertSidToStringSidA(PSID Sid, LPSTR *StringSid)
Definition: security.c:3313
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
UINT WINAPI MsiSourceListAddMediaDiskA(LPCSTR szProduct, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwDiskId, LPCSTR szVolumeLabel, LPCSTR szDiskPrompt)
Definition: source.c:1180
UINT WINAPI MsiSourceListGetInfoA(LPCSTR szProduct, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szProperty, LPSTR szValue, LPDWORD pcchValue)
Definition: source.c:485
UINT WINAPI MsiSourceListEnumMediaDisksA(LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwIndex, LPDWORD pdwDiskId, LPSTR szVolumeLabel, LPDWORD pcchVolumeLabel, LPSTR szDiskPrompt, LPDWORD pcchDiskPrompt)
Definition: source.c:148
#define GET_PROC(dll, func)

Referenced by START_TEST().

◆ LONG()

static LPSTR* static LONG ( WINAPI pRegDeleteKeyExA)
static

◆ squash_guid()

static BOOL squash_guid ( LPCWSTR  in,
LPWSTR  out 
)
static

Definition at line 87 of file source.c.

88 {
89  DWORD i,n=1;
90  GUID guid;
91 
92  if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
93  return FALSE;
94 
95  for(i=0; i<8; i++)
96  out[7-i] = in[n++];
97  n++;
98  for(i=0; i<4; i++)
99  out[11-i] = in[n++];
100  n++;
101  for(i=0; i<4; i++)
102  out[15-i] = in[n++];
103  n++;
104  for(i=0; i<2; i++)
105  {
106  out[17+i*2] = in[n++];
107  out[16+i*2] = in[n++];
108  }
109  n++;
110  for( ; i<8; i++)
111  {
112  out[17+i*2] = in[n++];
113  out[16+i*2] = in[n++];
114  }
115  out[32]=0;
116  return TRUE;
117 }
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const GUID * guid
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint in
Definition: glext.h:9616
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2247

Referenced by create_test_guid(), MsiSourceListAddMediaDiskW(), MsiSourceListAddSourceExW(), MsiSourceListAddSourceW(), MsiSourceListEnumMediaDisksW(), MsiSourceListEnumSourcesW(), MsiSourceListGetInfoW(), and MsiSourceListSetInfoW().

◆ START_TEST()

START_TEST ( source  )

Definition at line 3519 of file source.c.

3520 {
3522 
3523  if (pIsWow64Process)
3524  pIsWow64Process(GetCurrentProcess(), &is_wow64);
3525 
3533 }
static void test_MsiSourceListAddMediaDisk(void)
Definition: source.c:2088
static void test_MsiSourceListGetInfo(void)
Definition: source.c:192
static void test_MsiSourceListEnumMediaDisks(void)
Definition: source.c:2406
static void test_MsiSourceListAddSourceEx(void)
Definition: source.c:647
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
static void test_MsiSourceListSetInfo(void)
Definition: source.c:1657
static BOOL is_wow64
Definition: source.c:35
static void init_functionpointers(void)
Definition: source.c:58
static void test_MsiSourceListEnumSources(void)
Definition: source.c:1038
static void test_MsiSourceListAddSource(void)
Definition: source.c:3238

◆ test_MsiSourceListAddMediaDisk()

static void test_MsiSourceListAddMediaDisk ( void  )
static

Definition at line 2088 of file source.c.

2089 {
2090  CHAR prodcode[MAX_PATH];
2091  CHAR prod_squashed[MAX_PATH];
2092  CHAR keypath[MAX_PATH*2];
2093  HKEY prodkey, userkey;
2094  HKEY media, source;
2095  LPSTR usersid;
2096  LONG res;
2097  UINT r;
2099 
2100  if (!pMsiSourceListAddMediaDiskA)
2101  {
2102  win_skip("MsiSourceListAddMediaDiskA is not available\n");
2103  return;
2104  }
2105 
2106  create_test_guid(prodcode, prod_squashed);
2107  if (!(usersid = get_user_sid()))
2108  {
2109  skip("User SID not available -> skipping MsiSourceListAddMediaDiskA tests\n");
2110  return;
2111  }
2112 
2113  if (is_wow64)
2115 
2116  /* GetLastError is not set by the function */
2117 
2118  /* NULL szProductCodeOrPatchCode */
2119  r = pMsiSourceListAddMediaDiskA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2120  MSICODE_PRODUCT, 1, "label", "prompt");
2122  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2123 
2124  /* empty szProductCodeOrPatchCode */
2125  r = pMsiSourceListAddMediaDiskA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2126  MSICODE_PRODUCT, 1, "label", "prompt");
2128  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2129 
2130  /* garbage szProductCodeOrPatchCode */
2131  r = pMsiSourceListAddMediaDiskA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2132  MSICODE_PRODUCT, 1, "label", "prompt");
2134  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2135 
2136  /* guid without brackets */
2137  r = pMsiSourceListAddMediaDiskA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
2139  MSICODE_PRODUCT, 1, "label", "prompt");
2141  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2142 
2143  /* guid with brackets */
2144  r = pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2146  MSICODE_PRODUCT, 1, "label", "prompt");
2148  "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2149 
2150  /* dwOptions has MSISOURCETYPE_NETWORK */
2151  r = pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2154  1, "label", "prompt");
2156  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2157 
2158  /* dwOptions has MSISOURCETYPE_URL */
2159  r = pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2162  1, "label", "prompt");
2164  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2165 
2166  /* dwOptions has MSISOURCETYPE_MEDIA */
2167  r = pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2170  1, "label", "prompt");
2172  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2173 
2174  /* MSIINSTALLCONTEXT_USERUNMANAGED */
2175 
2176  lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2177  lstrcatA(keypath, prod_squashed);
2178 
2179  res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
2180  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2181 
2182  /* user product key exists */
2183  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2185  MSICODE_PRODUCT, 1, "label", "prompt");
2187  "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
2188 
2189  res = RegCreateKeyA(userkey, "SourceList", &source);
2190  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2191 
2192  /* SourceList key exists */
2193  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2195  MSICODE_PRODUCT, 1, "label", "prompt");
2196  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2197 
2198  /* Media subkey is created by MsiSourceListAddMediaDisk */
2199  res = RegOpenKeyA(source, "Media", &media);
2200  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2201 
2202  CHECK_REG_STR(media, "1", "label;prompt");
2203 
2204  /* dwDiskId is random */
2205  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2207  MSICODE_PRODUCT, 42, "label42", "prompt42");
2208  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2209 
2210  CHECK_REG_STR(media, "1", "label;prompt");
2211  CHECK_REG_STR(media, "42", "label42;prompt42");
2212 
2213  /* dwDiskId is 0 */
2214  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2216  MSICODE_PRODUCT, 0, "label0", "prompt0");
2217  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2218 
2219  CHECK_REG_STR(media, "0", "label0;prompt0");
2220  CHECK_REG_STR(media, "1", "label;prompt");
2221  CHECK_REG_STR(media, "42", "label42;prompt42");
2222 
2223  /* dwDiskId is < 0 */
2224  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2226  MSICODE_PRODUCT, -1, "label-1", "prompt-1");
2227  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2228 
2229  CHECK_REG_STR(media, "-1", "label-1;prompt-1");
2230  CHECK_REG_STR(media, "0", "label0;prompt0");
2231  CHECK_REG_STR(media, "1", "label;prompt");
2232  CHECK_REG_STR(media, "42", "label42;prompt42");
2233 
2234  /* update dwDiskId 1 */
2235  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2237  MSICODE_PRODUCT, 1, "newlabel", "newprompt");
2238  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2239 
2240  CHECK_REG_STR(media, "-1", "label-1;prompt-1");
2241  CHECK_REG_STR(media, "0", "label0;prompt0");
2242  CHECK_REG_STR(media, "1", "newlabel;newprompt");
2243  CHECK_REG_STR(media, "42", "label42;prompt42");
2244 
2245  /* update dwDiskId 1, szPrompt is NULL */
2246  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2248  MSICODE_PRODUCT, 1, "etiqueta", NULL);
2249  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2250 
2251  CHECK_REG_STR(media, "-1", "label-1;prompt-1");
2252  CHECK_REG_STR(media, "0", "label0;prompt0");
2253  CHECK_REG_STR(media, "1", "etiqueta;");
2254  CHECK_REG_STR(media, "42", "label42;prompt42");
2255 
2256  /* update dwDiskId 1, szPrompt is empty */
2257  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2259  MSICODE_PRODUCT, 1, "etikett", "");
2261  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2262 
2263  /* update dwDiskId 1, szVolumeLabel is NULL */
2264  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2266  MSICODE_PRODUCT, 1, NULL, "provocar");
2267  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2268 
2269  CHECK_REG_STR(media, "-1", "label-1;prompt-1");
2270  CHECK_REG_STR(media, "0", "label0;prompt0");
2271  CHECK_REG_STR(media, "1", ";provocar");
2272  CHECK_REG_STR(media, "42", "label42;prompt42");
2273 
2274  /* update dwDiskId 1, szVolumeLabel is empty */
2275  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2277  MSICODE_PRODUCT, 1, "", "provoquer");
2279  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2280 
2281  /* szUserSid is NULL */
2282  r = pMsiSourceListAddMediaDiskA(prodcode, NULL,
2284  MSICODE_PRODUCT, 1, NULL, "provoquer");
2285  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2286 
2287  CHECK_REG_STR(media, "-1", "label-1;prompt-1");
2288  CHECK_REG_STR(media, "0", "label0;prompt0");
2289  CHECK_REG_STR(media, "1", ";provoquer");
2290  CHECK_REG_STR(media, "42", "label42;prompt42");
2291 
2292  RegDeleteValueA(media, "-1");
2293  RegDeleteValueA(media, "0");
2294  RegDeleteValueA(media, "1");
2295  RegDeleteValueA(media, "42");
2296  RegDeleteKeyA(media, "");
2297  RegCloseKey(media);
2298  RegDeleteKeyA(source, "");
2300  RegDeleteKeyA(userkey, "");
2301  RegCloseKey(userkey);
2302 
2303  /* MSIINSTALLCONTEXT_USERMANAGED */
2304 
2305  lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2306  lstrcatA(keypath, usersid);
2307  lstrcatA(keypath, "\\Installer\\Products\\");
2308  lstrcatA(keypath, prod_squashed);
2309 
2310  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
2311  if (res != ERROR_SUCCESS)
2312  {
2313  skip("Product key creation failed with error code %u\n", res);
2314  goto machine_tests;
2315  }
2316 
2317  /* user product key exists */
2318  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2320  MSICODE_PRODUCT, 1, "label", "prompt");
2322  "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
2323 
2324  res = RegCreateKeyExA(userkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
2325  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2326 
2327  /* SourceList key exists */
2328  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2330  MSICODE_PRODUCT, 1, "label", "prompt");
2331  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2332 
2333  /* Media subkey is created by MsiSourceListAddMediaDisk */
2334  res = RegOpenKeyExA(source, "Media", 0, access, &media);
2335  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2336 
2337  CHECK_REG_STR(media, "1", "label;prompt");
2338 
2339  RegDeleteValueA(media, "1");
2340  delete_key(media, "", access);
2341  RegCloseKey(media);
2342  delete_key(source, "", access);
2344  delete_key(userkey, "", access);
2345  RegCloseKey(userkey);
2346 
2347  /* MSIINSTALLCONTEXT_MACHINE */
2348 
2349 machine_tests:
2350  lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2351  lstrcatA(keypath, prod_squashed);
2352 
2353  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2354  if (res != ERROR_SUCCESS)
2355  {
2356  skip("Product key creation failed with error code %u\n", res);
2357  LocalFree(usersid);
2358  return;
2359  }
2360 
2361  /* machine product key exists */
2362  r = pMsiSourceListAddMediaDiskA(prodcode, NULL,
2364  MSICODE_PRODUCT, 1, "label", "prompt");
2366  "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
2367 
2368  res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
2369  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2370 
2371  /* SourceList key exists */
2372  r = pMsiSourceListAddMediaDiskA(prodcode, NULL,
2374  MSICODE_PRODUCT, 1, "label", "prompt");
2375  if (r == ERROR_ACCESS_DENIED)
2376  {
2377  skip("MsiSourceListAddMediaDisk (insufficient privileges)\n");
2378  goto done;
2379  }
2380  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2381 
2382  /* Media subkey is created by MsiSourceListAddMediaDisk */
2383  res = RegOpenKeyExA(source, "Media", 0, access, &media);
2384  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2385 
2386  CHECK_REG_STR(media, "1", "label;prompt");
2387 
2388  /* szUserSid is non-NULL */
2389  r = pMsiSourceListAddMediaDiskA(prodcode, usersid,
2391  MSICODE_PRODUCT, 1, "label", "prompt");
2393  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2394  RegDeleteValueA(media, "1");
2395  delete_key(media, "", access);
2396  RegCloseKey(media);
2397 
2398 done:
2399  delete_key(source, "", access);
2401  delete_key(prodkey, "", access);
2402  RegCloseKey(prodkey);
2403  LocalFree(usersid);
2404 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
char * LPSTR
Definition: xmlstorage.h:182
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
__u8 media
Definition: mkdosfs.c:367
#define ERROR_BAD_CONFIGURATION
Definition: winerror.h:968
#define ERROR_UNKNOWN_PRODUCT
Definition: winerror.h:963
#define MAX_PATH
Definition: compat.h:26
static void create_test_guid(LPSTR prodcode, LPSTR squashed)
Definition: source.c:119
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define CHECK_REG_STR(prodkey, name, expected)
Definition: source.c:189
static BOOL is_wow64
Definition: source.c:35
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static char * get_user_sid(void)
Definition: source.c:138
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ok(value,...)
Definition: atltest.h:57
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
ACCESS_MASK REGSAM
Definition: winreg.h:69
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define win_skip
Definition: test.h:141
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
static LONG delete_key(HKEY key, LPCSTR subkey, REGSAM access)
Definition: source.c:640

Referenced by START_TEST().

◆ test_MsiSourceListAddSource()

static void test_MsiSourceListAddSource ( void  )
static

Definition at line 3238 of file source.c.

3239 {
3240  CHAR prodcode[MAX_PATH];
3241  CHAR prod_squashed[MAX_PATH];
3242  CHAR keypath[MAX_PATH*2];
3244  LPSTR usersid, ptr;
3245  LONG res;
3246  UINT r;
3247  HKEY prodkey, userkey, net, source;
3248  DWORD size;
3250 
3251  if (!pMsiSourceListAddSourceA)
3252  {
3253  win_skip("Skipping MsiSourceListAddSourceA tests\n");
3254  return;
3255  }
3256 
3257  create_test_guid(prodcode, prod_squashed);
3258  if (!(usersid = get_user_sid()))
3259  {
3260  skip("User SID not available -> skipping MsiSourceListAddSourceA tests\n");
3261  return;
3262  }
3263 
3264  /* MACHINENAME\username */
3265  size = MAX_PATH;
3266  if (pGetUserNameExA != NULL)
3267  pGetUserNameExA(NameSamCompatible, username, &size);
3268  else
3269  {
3271  lstrcatA(username, "\\");
3273  size = MAX_PATH - (ptr - username);
3274  GetUserNameA(ptr, &size);
3275  }
3276  trace("username: %s\n", username);
3277 
3278  if (is_wow64)
3280 
3281  /* GetLastError is not set by the function */
3282 
3283  /* NULL szProduct */
3284  r = pMsiSourceListAddSourceA(NULL, username, 0, "source");
3285  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3286 
3287  /* empty szProduct */
3288  r = pMsiSourceListAddSourceA("", username, 0, "source");
3289  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3290 
3291  /* garbage szProduct */
3292  r = pMsiSourceListAddSourceA("garbage", username, 0, "source");
3293  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3294 
3295  /* guid without brackets */
3296  r = pMsiSourceListAddSourceA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", username, 0, "source");
3297  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3298 
3299  /* guid with brackets */
3300  r = pMsiSourceListAddSourceA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}", username, 0, "source");
3301  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3302 
3303  /* dwReserved is not 0 */
3304  r = pMsiSourceListAddSourceA(prodcode, username, 42, "source");
3305  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3306 
3307  /* szSource is NULL */
3308  r = pMsiSourceListAddSourceA(prodcode, username, 0, NULL);
3309  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3310 
3311  /* szSource is empty */
3312  r = pMsiSourceListAddSourceA(prodcode, username, 0, "");
3313  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3314 
3315  /* MSIINSTALLCONTEXT_USERMANAGED */
3316 
3317  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3318  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3319 
3320  lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
3321  lstrcatA(keypath, usersid);
3322  lstrcatA(keypath, "\\Installer\\Products\\");
3323  lstrcatA(keypath, prod_squashed);
3324 
3325  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
3326  if (res != ERROR_SUCCESS)
3327  {
3328  skip("Product key creation failed with error code %u\n", res);
3329  goto userunmanaged_tests;
3330  }
3331 
3332  /* user product key exists */
3333  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3334  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3335 
3336  res = RegCreateKeyExA(userkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
3337  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3338 
3339  /* SourceList key exists */
3340  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3341  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3342 
3343  /* Net key is created */
3344  res = RegOpenKeyExA(source, "Net", 0, access, &net);
3345  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3346 
3347  /* LastUsedSource does not exist and it is not created */
3348  res = RegQueryValueExA(source, "LastUsedSource", 0, NULL, NULL, NULL);
3349  ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3350 
3351  CHECK_REG_STR(net, "1", "source\\");
3352 
3353  RegDeleteValueA(net, "1");
3354  delete_key(net, "", access);
3355  RegCloseKey(net);
3356 
3357  res = RegSetValueExA(source, "LastUsedSource", 0, REG_SZ, (LPBYTE)"blah", 5);
3358  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3359 
3360  /* LastUsedSource value exists */
3361  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3362  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3363 
3364  /* Net key is created */
3365  res = RegOpenKeyExA(source, "Net", 0, access, &net);
3366  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3367 
3368  CHECK_REG_STR(source, "LastUsedSource", "blah");
3369  CHECK_REG_STR(net, "1", "source\\");
3370 
3371  RegDeleteValueA(net, "1");
3372  delete_key(net, "", access);
3373  RegCloseKey(net);
3374 
3375  res = RegSetValueExA(source, "LastUsedSource", 0, REG_SZ, (LPBYTE)"5", 2);
3376  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3377 
3378  /* LastUsedSource is an integer */
3379  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3380  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3381 
3382  /* Net key is created */
3383  res = RegOpenKeyExA(source, "Net", 0, access, &net);
3384  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3385 
3386  CHECK_REG_STR(source, "LastUsedSource", "5");
3387  CHECK_REG_STR(net, "1", "source\\");
3388 
3389  /* Add a second source, has trailing backslash */
3390  r = pMsiSourceListAddSourceA(prodcode, username, 0, "another\\");
3391  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3392 
3393  CHECK_REG_STR(source, "LastUsedSource", "5");
3394  CHECK_REG_STR(net, "1", "source\\");
3395  CHECK_REG_STR(net, "2", "another\\");
3396 
3397  res = RegSetValueExA(source, "LastUsedSource", 0, REG_SZ, (LPBYTE)"2", 2);
3398  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3399 
3400  /* LastUsedSource is in the source list */
3401  r = pMsiSourceListAddSourceA(prodcode, username, 0, "third/");
3402  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3403 
3404  CHECK_REG_STR(source, "LastUsedSource", "2");
3405  CHECK_REG_STR(net, "1", "source\\");
3406  CHECK_REG_STR(net, "2", "another\\");
3407  CHECK_REG_STR(net, "3", "third/\\");
3408 
3409  RegDeleteValueA(net, "1");
3410  RegDeleteValueA(net, "2");
3411  RegDeleteValueA(net, "3");
3412  delete_key(net, "", access);
3413  RegCloseKey(net);
3414  delete_key(source, "", access);
3416  delete_key(userkey, "", access);
3417  RegCloseKey(userkey);
3418 
3419  /* MSIINSTALLCONTEXT_USERUNMANAGED */
3420 
3421 userunmanaged_tests:
3422  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3423  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3424 
3425  lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3426  lstrcatA(keypath, prod_squashed);
3427 
3428  res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
3429  if (res != ERROR_SUCCESS)
3430  {
3431  skip("Product key creation failed with error code %u\n", res);
3432  goto machine_tests;
3433  }
3434 
3435  /* user product key exists */
3436  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3437  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3438 
3439  res = RegCreateKeyA(userkey, "SourceList", &source);
3440  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3441 
3442  /* SourceList key exists */
3443  r = pMsiSourceListAddSourceA(prodcode, username, 0, "source");
3444  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3445 
3446  /* Net key is created */
3447  res = RegOpenKeyA(source, "Net", &net);
3448  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3449 
3450  CHECK_REG_STR(net, "1", "source\\");
3451 
3452  RegDeleteValueA(net, "1");
3453  RegDeleteKeyA(net, "");
3454  RegCloseKey(net);
3455  RegDeleteKeyA(source, "");
3457  RegDeleteKeyA(userkey, "");
3458  RegCloseKey(userkey);
3459 
3460  /* MSIINSTALLCONTEXT_MACHINE */
3461 
3462 machine_tests:
3463  r = pMsiSourceListAddSourceA(prodcode, NULL, 0, "source");
3464  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3465 
3466  lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3467  lstrcatA(keypath, prod_squashed);
3468 
3469  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3470  if (res != ERROR_SUCCESS)
3471  {
3472  skip("Product key creation failed with error code %u\n", res);
3473  LocalFree(usersid);
3474  return;
3475  }
3476 
3477  /* machine product key exists */
3478  r = pMsiSourceListAddSourceA(prodcode, NULL, 0, "source");
3479  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3480 
3481  res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
3482  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3483 
3484  /* SourceList key exists */
3485  r = pMsiSourceListAddSourceA(prodcode, NULL, 0, "source");
3486  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3487 
3488  /* Net key is created */
3489  res = RegOpenKeyExA(source, "Net", 0, access, &net);
3490  if (res == ERROR_ACCESS_DENIED)
3491  {
3492  skip("MsiSourceListAddSource (insufficient privileges)\n");
3493  goto done;
3494  }
3495  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3496 
3497  CHECK_REG_STR(net, "1", "source\\");
3498 
3499  /* empty szUserName */
3500  r = pMsiSourceListAddSourceA(prodcode, "", 0, "another");
3501  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3502 
3503  CHECK_REG_STR(net, "1", "source\\");
3504  CHECK_REG_STR(net, "2", "another\\");
3505 
3506  RegDeleteValueA(net, "2");
3507  RegDeleteValueA(net, "1");
3508  delete_key(net, "", access);
3509  RegCloseKey(net);
3510 
3511 done:
3512  delete_key(source, "", access);
3514  delete_key(prodkey, "", access);
3515  RegCloseKey(prodkey);
3516  LocalFree(usersid);
3517 }
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
char * LPSTR
Definition: xmlstorage.h:182
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
static WCHAR username[]
Definition: url.c:32
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
#define ERROR_BAD_CONFIGURATION
Definition: winerror.h:968
#define ERROR_UNKNOWN_PRODUCT
Definition: winerror.h:963
#define MAX_PATH
Definition: compat.h:26
static void create_test_guid(LPSTR prodcode, LPSTR squashed)
Definition: source.c:119
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
Definition: misc.c:246
#define CHECK_REG_STR(prodkey, name, expected)
Definition: source.c:189
static BOOL is_wow64
Definition: source.c:35
static TNetwork net
Definition: tncon.cpp:351
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static char * get_user_sid(void)
Definition: source.c:138
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ok(value,...)
Definition: atltest.h:57
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
ACCESS_MASK REGSAM
Definition: winreg.h:69
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define win_skip
Definition: test.h:141
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22
static LONG delete_key(HKEY key, LPCSTR subkey, REGSAM access)
Definition: source.c:640

Referenced by START_TEST().

◆ test_MsiSourceListAddSourceEx()

static void test_MsiSourceListAddSourceEx ( void  )
static

Definition at line 647 of file source.c.

648 {
649  CHAR prodcode[MAX_PATH];
650  CHAR prod_squashed[MAX_PATH];
651  CHAR keypath[MAX_PATH*2];
653  LPSTR usersid;
654  LONG res;
655  UINT r;
656  HKEY prodkey, userkey, hkey, url, net;
657  DWORD size;
659 
660  if (!pMsiSourceListAddSourceExA)
661  {
662  win_skip("Skipping MsiSourceListAddSourceExA tests\n");
663  return;
664  }
665 
666  create_test_guid(prodcode, prod_squashed);
667  if (!(usersid = get_user_sid()))
668  {
669  skip("User SID not available -> skipping MsiSourceListAddSourceExA tests\n");
670  return;
671  }
672 
673  if (is_wow64)
675 
676  /* GetLastError is not set by the function */
677 
678  /* NULL szProductCodeOrPatchCode */
679  r = pMsiSourceListAddSourceExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
680  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
681  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
682 
683  /* empty szProductCodeOrPatchCode */
684  r = pMsiSourceListAddSourceExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
685  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
686  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
687 
688  /* garbage szProductCodeOrPatchCode */
689  r = pMsiSourceListAddSourceExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
690  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
691  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
692 
693  /* guid without brackets */
694  r = pMsiSourceListAddSourceExA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", usersid,
696  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
697  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
698 
699  /* guid with brackets */
700  r = pMsiSourceListAddSourceExA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}", usersid,
702  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
703  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
704 
705  /* MSIINSTALLCONTEXT_USERUNMANAGED */
706 
707  r = pMsiSourceListAddSourceExA(prodcode, usersid,
709  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
710  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
711 
712  lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
713  lstrcatA(keypath, prod_squashed);
714 
715  res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
716  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
717 
718  /* user product key exists */
719  r = pMsiSourceListAddSourceExA(prodcode, usersid,
721  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
722  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
723 
724  res = RegCreateKeyA(userkey, "SourceList", &url);
725  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
726  RegCloseKey(url);
727 
728  /* SourceList key exists */
729  r = pMsiSourceListAddSourceExA(prodcode, usersid,
731  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
732  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
733 
734  res = RegOpenKeyA(userkey, "SourceList\\URL", &url);
735  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
736 
737  size = MAX_PATH;
739  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
740  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
741  ok(size == 11, "Expected 11, got %d\n", size);
742 
743  /* add another source, index 0 */
744  r = pMsiSourceListAddSourceExA(prodcode, usersid,
746  MSICODE_PRODUCT | MSISOURCETYPE_URL, "another", 0);
747  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
748 
749  size = MAX_PATH;
751  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
752  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
753  ok(size == 11, "Expected 11, got %d\n", size);
754 
755  size = MAX_PATH;
757  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
758  ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
759  ok(size == 9, "Expected 9, got %d\n", size);
760 
761  /* add another source, index 1 */
762  r = pMsiSourceListAddSourceExA(prodcode, usersid,
764  MSICODE_PRODUCT | MSISOURCETYPE_URL, "third/", 1);
765  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
766 
767  size = MAX_PATH;
769  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
770  ok(!lstrcmpA(value, "third/"), "Expected 'third/', got %s\n", value);
771  ok(size == 7, "Expected 7, got %d\n", size);
772 
773  size = MAX_PATH;
775  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
776  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
777  ok(size == 11, "Expected 11, got %d\n", size);
778 
779  size = MAX_PATH;
781  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
782  ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
783  ok(size == 9, "Expected 9, got %d\n", size);
784 
785  /* add another source, index > N */
786  r = pMsiSourceListAddSourceExA(prodcode, usersid,
788  MSICODE_PRODUCT | MSISOURCETYPE_URL, "last/", 5);
789  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
790 
791  size = MAX_PATH;
793  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
794  ok(!lstrcmpA(value, "third/"), "Expected 'third/', got %s\n", value);
795  ok(size == 7, "Expected 7, got %d\n", size);
796 
797  size = MAX_PATH;
799  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
800  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
801  ok(size == 11, "Expected 11, got %d\n", size);
802 
803  size = MAX_PATH;
805  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
806  ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
807  ok(size == 9, "Expected 9, got %d\n", size);
808 
809  size = MAX_PATH;
811  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
812  ok(!lstrcmpA(value, "last/"), "Expected 'last/', got %s\n", value);
813  ok(size == 6, "Expected 6, got %d\n", size);
814 
815  /* just MSISOURCETYPE_NETWORK */
816  r = pMsiSourceListAddSourceExA(prodcode, usersid,
818  MSISOURCETYPE_NETWORK, "source", 0);
819  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
820 
821  res = RegOpenKeyA(userkey, "SourceList\\Net", &net);
822  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
823 
824  size = MAX_PATH;
826  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
827  ok(!lstrcmpA(value, "source\\"), "Expected 'source\\', got %s\n", value);
828  ok(size == 8, "Expected 8, got %d\n", size);
829 
830  /* just MSISOURCETYPE_URL */
831  r = pMsiSourceListAddSourceExA(prodcode, usersid,
833  MSISOURCETYPE_URL, "source", 0);
834  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
835 
836  size = MAX_PATH;
838  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
839  ok(!lstrcmpA(value, "third/"), "Expected 'third/', got %s\n", value);
840  ok(size == 7, "Expected 7, got %d\n", size);
841 
842  size = MAX_PATH;
844  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
845  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
846  ok(size == 11, "Expected 11, got %d\n", size);
847 
848  size = MAX_PATH;
850  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
851  ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
852  ok(size == 9, "Expected 9, got %d\n", size);
853 
854  size = MAX_PATH;
856  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
857  ok(!lstrcmpA(value, "last/"), "Expected 'last/', got %s\n", value);
858  ok(size == 6, "Expected 6, got %d\n", size);
859 
860  size = MAX_PATH;
862  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
863  ok(!lstrcmpA(value, "source/"), "Expected 'source/', got %s\n", value);
864  ok(size == 8, "Expected 8, got %d\n", size);
865 
866  /* NULL szUserSid */
867  r = pMsiSourceListAddSourceExA(prodcode, NULL,
869  MSISOURCETYPE_NETWORK, "nousersid", 0);
870  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
871 
872  size = MAX_PATH;
874  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
875  ok(!lstrcmpA(value, "source\\"), "Expected 'source\\', got %s\n", value);
876  ok(size == 8, "Expected 8, got %d\n", size);
877 
878  size = MAX_PATH;
880  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
881  ok(!lstrcmpA(value, "nousersid\\"), "Expected 'nousersid\\', got %s\n", value);
882  ok(size == 11, "Expected 11, got %d\n", size);
883 
884  /* invalid options, must have source type */
885  r = pMsiSourceListAddSourceExA(prodcode, usersid,
887  MSICODE_PRODUCT, "source", 0);
888  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
889 
890  r = pMsiSourceListAddSourceExA(prodcode, usersid,
892  MSICODE_PATCH, "source", 0);
893  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
894 
895  /* NULL szSource */
896  r = pMsiSourceListAddSourceExA(prodcode, usersid,
898  MSISOURCETYPE_URL, NULL, 1);
899  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
900 
901  /* empty szSource */
902  r = pMsiSourceListAddSourceExA(prodcode, usersid,
904  MSISOURCETYPE_URL, "", 1);
905  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
906 
907  /* MSIINSTALLCONTEXT_USERMANAGED, non-NULL szUserSid */
908 
909  r = pMsiSourceListAddSourceExA(prodcode, usersid,
911  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
912  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
913 
914  lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
915  lstrcatA(keypath, usersid);
916  lstrcatA(keypath, "\\Installer\\Products\\");
917  lstrcatA(keypath, prod_squashed);
918 
919  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
920  if (res != ERROR_SUCCESS)
921  {
922  skip("Product key creation failed with error code %u\n", res);
923  goto machine_tests;
924  }
925 
926  /* product key exists */
927  r = pMsiSourceListAddSourceExA(prodcode, usersid,
929  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
930  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
931 
932  res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &hkey, NULL);
933  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
934  RegCloseKey(hkey);
935 
936  /* SourceList exists */
937  r = pMsiSourceListAddSourceExA(prodcode, usersid,
939  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
940  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
941 
942  res = RegOpenKeyExA(prodkey, "SourceList\\URL", 0, access, &url);
943  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
944 
945  size = MAX_PATH;
947  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
948  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
949  ok(size == 11, "Expected 11, got %d\n", size);
950 
951  RegCloseKey(url);
952 
953  /* MSIINSTALLCONTEXT_USERMANAGED, NULL szUserSid */
954 
955  r = pMsiSourceListAddSourceExA(prodcode, NULL,
957  MSICODE_PRODUCT | MSISOURCETYPE_URL, "another", 0);
958  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
959 
960  res = RegOpenKeyExA(prodkey, "SourceList\\URL", 0, access, &url);
961  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
962 
963  size = MAX_PATH;
965  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
966  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
967  ok(size == 11, "Expected 11, got %d\n", size);
968 
969  size = MAX_PATH;
971  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
972  ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
973  ok(size == 9, "Expected 9, got %d\n", size);
974 
975  RegCloseKey(url);
976  RegCloseKey(prodkey);
977 
978  /* MSIINSTALLCONTEXT_MACHINE */
979 
980 machine_tests:
981  /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
982  r = pMsiSourceListAddSourceExA(prodcode, usersid,
984  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
985  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
986 
987  r = pMsiSourceListAddSourceExA(prodcode, NULL,
989  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
990  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
991 
992  lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
993  lstrcatA(keypath, prod_squashed);
994 
995  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
996  if (res != ERROR_SUCCESS)
997  {
998  skip("Product key creation failed with error code %u\n", res);
999  LocalFree(usersid);
1000  return;
1001  }
1002 
1003  /* product key exists */
1004  r = pMsiSourceListAddSourceExA(prodcode, NULL,
1006  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
1007  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
1008 
1009  res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &hkey, NULL);
1010  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1011  RegCloseKey(hkey);
1012 
1013  /* SourceList exists */
1014  r = pMsiSourceListAddSourceExA(prodcode, NULL,
1016  MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0);
1017  if (r == ERROR_ACCESS_DENIED)
1018  skip("MsiSourceListAddSourceEx (insufficient privileges)\n");
1019  else
1020  {
1021  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1022 
1023  res = RegOpenKeyExA(prodkey, "SourceList\\URL", 0, access, &url);
1024  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1025 
1026  size = MAX_PATH;
1027  res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size);
1028  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1029  ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
1030  ok(size == 11, "Expected 11, got %d\n", size);
1031 
1032  RegCloseKey(url);
1033  RegCloseKey(prodkey);
1034  }
1035  LocalFree(usersid);
1036 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
char * LPSTR
Definition: xmlstorage.h:182
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
GLsizeiptr size
Definition: glext.h:5919
#define ERROR_BAD_CONFIGURATION
Definition: winerror.h:968
static const WCHAR url[]
Definition: encode.c:1432
#define ERROR_UNKNOWN_PRODUCT
Definition: winerror.h:963
#define MAX_PATH
Definition: compat.h:26
static void create_test_guid(LPSTR prodcode, LPSTR squashed)
Definition: source.c:119
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static BOOL is_wow64
Definition: source.c:35
static TNetwork net
Definition: tncon.cpp:351
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static char * get_user_sid(void)
Definition: source.c:138
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ok(value,...)
Definition: atltest.h:57
ACCESS_MASK REGSAM
Definition: winreg.h:69
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define win_skip
Definition: test.h:141
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by START_TEST().

◆ test_MsiSourceListEnumMediaDisks()

static void test_MsiSourceListEnumMediaDisks ( void  )
static

Definition at line 2406 of file source.c.

2407 {
2408  CHAR prodcode[MAX_PATH];
2409  CHAR prod_squashed[MAX_PATH];
2410  CHAR keypath[MAX_PATH*2];
2411  CHAR label[MAX_PATH];
2412  CHAR prompt[MAX_PATH];
2413  HKEY prodkey, userkey, media, source;
2414  DWORD labelsz, promptsz, val, id;
2415  LPSTR usersid;
2416  LONG res;
2417  UINT r;
2419 
2420  if (!pMsiSourceListEnumMediaDisksA)
2421  {
2422  win_skip("MsiSourceListEnumMediaDisksA is not available\n");
2423  return;
2424  }
2425 
2426  create_test_guid(prodcode, prod_squashed);
2427  if (!(usersid = get_user_sid()))
2428  {
2429  skip("User SID not available -> skipping MsiSourceListEnumMediaDisksA tests\n");
2430  return;
2431  }
2432 
2433  if (is_wow64)
2435 
2436  /* GetLastError is not set by the function */
2437 
2438  /* NULL szProductCodeOrPatchCode */
2439  labelsz = sizeof(label);
2440  promptsz = sizeof(prompt);
2441  r = pMsiSourceListEnumMediaDisksA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2442  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2443  prompt, &promptsz);
2445  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2446 
2447  /* empty szProductCodeOrPatchCode */
2448  labelsz = sizeof(label);
2449  promptsz = sizeof(prompt);
2450  r = pMsiSourceListEnumMediaDisksA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2451  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2452  prompt, &promptsz);
2454  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2455 
2456  /* garbage szProductCodeOrPatchCode */
2457  labelsz = sizeof(label);
2458  promptsz = sizeof(prompt);
2459  r = pMsiSourceListEnumMediaDisksA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2460  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2461  prompt, &promptsz);
2463  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2464 
2465  /* guid without brackets */
2466  labelsz = sizeof(label);
2467  promptsz = sizeof(prompt);
2468  r = pMsiSourceListEnumMediaDisksA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
2470  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2471  prompt, &promptsz);
2473  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2474 
2475  /* guid with brackets */
2476  labelsz = sizeof(label);
2477  promptsz = sizeof(prompt);
2478  r = pMsiSourceListEnumMediaDisksA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2480  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2481  prompt, &promptsz);
2483  "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2484 
2485  /* dwOptions has MSISOURCETYPE_NETWORK */
2486  labelsz = sizeof(label);
2487  promptsz = sizeof(prompt);
2488  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2490  0, &id, label, &labelsz,
2491  prompt, &promptsz);
2493  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2494 
2495  /* dwOptions has MSISOURCETYPE_URL */
2496  labelsz = sizeof(label);
2497  promptsz = sizeof(prompt);
2498  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2500  0, &id, label, &labelsz,
2501  prompt, &promptsz);
2503  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2504 
2505  /* dwIndex is non-zero */
2506  labelsz = sizeof(label);
2507  promptsz = sizeof(prompt);
2508  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2509  MSICODE_PRODUCT, 1, &id, label, &labelsz,
2510  prompt, &promptsz);
2512  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2513 
2514  /* MSIINSTALLCONTEXT_USERUNMANAGED */
2515 
2516  lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2517  lstrcatA(keypath, prod_squashed);
2518 
2519  res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
2520  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2521 
2522  /* user product key exists */
2523  labelsz = sizeof(label);
2524  promptsz = sizeof(prompt);
2525  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2526  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2527  prompt, &promptsz);
2529  "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
2530 
2531  res = RegCreateKeyA(userkey, "SourceList", &source);
2532  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2533 
2534  /* SourceList key exists */
2535  id = 0xbeef;
2536  lstrcpyA(label, "aaa");
2537  labelsz = 0xdeadbeef;
2538  lstrcpyA(prompt, "bbb");
2539  promptsz = 0xdeadbeef;
2540  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2541  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2542  prompt, &promptsz);
2544  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2545  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2546  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2547  ok(labelsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz);
2548  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2549  ok(promptsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz);
2550 
2551  res = RegCreateKeyA(source, "Media", &media);
2552  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2553 
2554  /* Media key exists */
2555  id = 0xbeef;
2556  lstrcpyA(label, "aaa");
2557  labelsz = 0xdeadbeef;
2558  lstrcpyA(prompt, "bbb");
2559  promptsz = 0xdeadbeef;
2560  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2561  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2562  prompt, &promptsz);
2564  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2565  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2566  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2567  ok(labelsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz);
2568  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2569  ok(promptsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz);
2570 
2571  res = RegSetValueExA(media, "1", 0, REG_SZ, (LPBYTE)"label;prompt", 13);
2572  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2573 
2574  /* disk exists */
2575  id = 0;
2576  lstrcpyA(label, "aaa");
2577  labelsz = MAX_PATH;
2578  lstrcpyA(prompt, "bbb");
2579  promptsz = MAX_PATH;
2580  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2581  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2582  prompt, &promptsz);
2583  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2584  ok(id == 1, "Expected 1, got %d\n", id);
2585  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2586  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2587  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2588  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2589 
2590  res = RegSetValueExA(media, "2", 0, REG_SZ, (LPBYTE)"one;two", 8);
2591  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2592 
2593  /* now disk 2 exists, get the sizes */
2594  id = 0;
2595  labelsz = MAX_PATH;
2596  promptsz = MAX_PATH;
2597  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2598  MSICODE_PRODUCT, 1, &id, NULL, &labelsz,
2599  NULL, &promptsz);
2601  "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r);
2602  if (r == ERROR_SUCCESS)
2603  {
2604  ok(id == 2, "Expected 2, got %d\n", id);
2605  ok(labelsz == 3, "Expected 3, got %d\n", labelsz);
2606  ok(promptsz == 3, "Expected 3, got %d\n", promptsz);
2607  }
2608 
2609  /* now fill in the values */
2610  id = 0xbeef;
2611  lstrcpyA(label, "aaa");
2612  labelsz = MAX_PATH;
2613  lstrcpyA(prompt, "bbb");
2614  promptsz = MAX_PATH;
2615  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2616  MSICODE_PRODUCT, 1, &id, label, &labelsz,
2617  prompt, &promptsz);
2619  "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r);
2620  if (r == ERROR_SUCCESS)
2621  {
2622  ok(id == 2, "Expected 2, got %d\n", id);
2623  ok(!lstrcmpA(label, "one"), "Expected \"one\", got \"%s\"\n", label);
2624  ok(labelsz == 3, "Expected 3, got %d\n", labelsz);
2625  ok(!lstrcmpA(prompt, "two"), "Expected \"two\", got \"%s\"\n", prompt);
2626  ok(promptsz == 3, "Expected 3, got %d\n", promptsz);
2627  }
2628  else if (r == ERROR_INVALID_PARAMETER)
2629  {
2630  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2631  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2632  ok(labelsz == MAX_PATH, "Expected MAX_PATH, got %d\n", labelsz);
2633  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2634  ok(promptsz == MAX_PATH, "Expected MAX_PATH, got %d\n", promptsz);
2635  }
2636 
2637  res = RegSetValueExA(media, "4", 0, REG_SZ, (LPBYTE)"three;four", 11);
2638  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2639 
2640  /* disks 1, 2, 4 exist, reset the enumeration */
2641  id = 0;
2642  lstrcpyA(label, "aaa");
2643  labelsz = MAX_PATH;
2644  lstrcpyA(prompt, "bbb");
2645  promptsz = MAX_PATH;
2646  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2647  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2648  prompt, &promptsz);
2649  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2650  ok(id == 1, "Expected 1, got %d\n", id);
2651  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2652  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2653  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2654  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2655 
2656  /* disks 1, 2, 4 exist, index 1 */
2657  id = 0;
2658  lstrcpyA(label, "aaa");
2659  labelsz = MAX_PATH;
2660  lstrcpyA(prompt, "bbb");
2661  promptsz = MAX_PATH;
2662  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2663  MSICODE_PRODUCT, 1, &id, label, &labelsz,
2664  prompt, &promptsz);
2665  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2666  ok(id == 2, "Expected 2, got %d\n", id);
2667  ok(!lstrcmpA(label, "one"), "Expected \"one\", got \"%s\"\n", label);
2668  ok(labelsz == 3, "Expected 3, got %d\n", labelsz);
2669  ok(!lstrcmpA(prompt, "two"), "Expected \"two\", got \"%s\"\n", prompt);
2670  ok(promptsz == 3, "Expected 3, got %d\n", promptsz);
2671 
2672  /* disks 1, 2, 4 exist, index 2 */
2673  id = 0;
2674  lstrcpyA(label, "aaa");
2675  labelsz = MAX_PATH;
2676  lstrcpyA(prompt, "bbb");
2677  promptsz = MAX_PATH;
2678  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2679  MSICODE_PRODUCT, 2, &id, label, &labelsz,
2680  prompt, &promptsz);
2681  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2682  ok(id == 4, "Expected 4, got %d\n", id);
2683  ok(!lstrcmpA(label, "three"), "Expected \"three\", got \"%s\"\n", label);
2684  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2685  ok(!lstrcmpA(prompt, "four"), "Expected \"four\", got \"%s\"\n", prompt);
2686  ok(promptsz == 4, "Expected 4, got %d\n", promptsz);
2687 
2688  /* disks 1, 2, 4 exist, index 3, invalid */
2689  id = 0xbeef;
2690  lstrcpyA(label, "aaa");
2691  labelsz = MAX_PATH;
2692  lstrcpyA(prompt, "bbb");
2693  promptsz = MAX_PATH;
2694  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2695  MSICODE_PRODUCT, 3, &id, label, &labelsz,
2696  prompt, &promptsz);
2698  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2699  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2700  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2701  ok(labelsz == MAX_PATH, "Expected MAX_PATH, got %d\n", labelsz);
2702  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2703  ok(promptsz == MAX_PATH, "Expected MAX_PATH, got %d\n", promptsz);
2704 
2705  /* disks 1, 2, 4 exist, reset the enumeration */
2706  id = 0;
2707  lstrcpyA(label, "aaa");
2708  labelsz = MAX_PATH;
2709  lstrcpyA(prompt, "bbb");
2710  promptsz = MAX_PATH;
2711  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2712  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2713  prompt, &promptsz);
2714  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2715  ok(id == 1, "Expected 1, got %d\n", id);
2716  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2717  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2718  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2719  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2720 
2721  /* try index 0 again */
2722  id = 0;
2723  lstrcpyA(label, "aaa");
2724  labelsz = MAX_PATH;
2725  lstrcpyA(prompt, "bbb");
2726  promptsz = MAX_PATH;
2727  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2728  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2729  prompt, &promptsz);
2730  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2731  ok(id == 1, "Expected 1, got %d\n", id);
2732  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2733  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2734  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2735  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2736 
2737  /* jump to index 2 */
2738  id = 0xbeef;
2739  lstrcpyA(label, "aaa");
2740  labelsz = MAX_PATH;
2741  lstrcpyA(prompt, "bbb");
2742  promptsz = MAX_PATH;
2743  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2744  MSICODE_PRODUCT, 2, &id, label, &labelsz,
2745  prompt, &promptsz);
2746  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2747  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2748  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2749  ok(labelsz == MAX_PATH, "Expected MAX_PATH, got %d\n", labelsz);
2750  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2751  ok(promptsz == MAX_PATH, "Expected MAX_PATH, got %d\n", promptsz);
2752 
2753  /* after error, try index 1 */
2754  id = 0xbeef;
2755  lstrcpyA(label, "aaa");
2756  labelsz = MAX_PATH;
2757  lstrcpyA(prompt, "bbb");
2758  promptsz = MAX_PATH;
2759  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2760  MSICODE_PRODUCT, 1, &id, label, &labelsz,
2761  prompt, &promptsz);
2762  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2763  ok(id == 2, "Expected 2, got %d\n", id);
2764  ok(!lstrcmpA(label, "one"), "Expected \"one\", got \"%s\"\n", label);
2765  ok(labelsz == 3, "Expected 3, got %d\n", labelsz);
2766  ok(!lstrcmpA(prompt, "two"), "Expected \"two\", got \"%s\"\n", prompt);
2767  ok(promptsz == 3, "Expected 3, got %d\n", promptsz);
2768 
2769  /* try index 1 again */
2770  id = 0xbeef;
2771  lstrcpyA(label, "aaa");
2772  labelsz = MAX_PATH;
2773  lstrcpyA(prompt, "bbb");
2774  promptsz = MAX_PATH;
2775  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2776  MSICODE_PRODUCT, 1, &id, label, &labelsz,
2777  prompt, &promptsz);
2778  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2779  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2780  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2781  ok(labelsz == MAX_PATH, "Expected MAX_PATH, got %d\n", labelsz);
2782  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2783  ok(promptsz == MAX_PATH, "Expected MAX_PATH, got %d\n", promptsz);
2784 
2785  /* NULL pdwDiskId */
2786  lstrcpyA(label, "aaa");
2787  labelsz = MAX_PATH;
2788  lstrcpyA(prompt, "bbb");
2789  promptsz = MAX_PATH;
2790  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2791  MSICODE_PRODUCT, 0, NULL, label, &labelsz,
2792  prompt, &promptsz);
2793  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2794  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2795  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2796  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2797  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2798 
2799  /* szVolumeLabel is NULL */
2800  id = 0;
2801  labelsz = MAX_PATH;
2802  lstrcpyA(prompt, "bbb");
2803  promptsz = MAX_PATH;
2804  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2805  MSICODE_PRODUCT, 0, &id, NULL, &labelsz,
2806  prompt, &promptsz);
2808  "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r);
2809  if (r == ERROR_SUCCESS)
2810  {
2811  ok(id == 1, "Expected 1, got %d\n", id);
2812  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2813  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2814  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2815  }
2816 
2817  /* szVolumeLabel and pcchVolumeLabel are NULL */
2818  id = 0;
2819  lstrcpyA(prompt, "bbb");
2820  promptsz = MAX_PATH;
2821  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2822  MSICODE_PRODUCT, 0, &id, NULL, NULL,
2823  prompt, &promptsz);
2824  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2825  ok(id == 1, "Expected 1, got %d\n", id);
2826  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2827  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2828 
2829  /* szVolumeLabel is non-NULL while pcchVolumeLabel is NULL */
2830  id = 0xbeef;
2831  lstrcpyA(label, "aaa");
2832  lstrcpyA(prompt, "bbb");
2833  promptsz = MAX_PATH;
2834  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2835  MSICODE_PRODUCT, 0, &id, label, NULL,
2836  prompt, &promptsz);
2838  "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r);
2839  if (r == ERROR_SUCCESS)
2840  {
2841  ok(id == 1, "Expected 1, got %d\n", id);
2842  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2843  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2844  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2845  }
2846 
2847  /* szDiskPrompt is NULL */
2848  id = 0;
2849  lstrcpyA(label, "aaa");
2850  labelsz = MAX_PATH;
2851  promptsz = MAX_PATH;
2852  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2853  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2854  NULL, &promptsz);
2855  ok(r == ERROR_SUCCESS || r == ERROR_INVALID_PARAMETER, "Expected ERROR_SUCCESS, got %d\n", r);
2856  if (r == ERROR_SUCCESS)
2857  {
2858  ok(id == 1, "Expected 1, got %d\n", id);
2859  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2860  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2861  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2862  }
2863 
2864  /* szDiskPrompt and pcchDiskPrompt are NULL */
2865  id = 0;
2866  lstrcpyA(label, "aaa");
2867  labelsz = MAX_PATH;
2868  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2869  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2870  NULL, NULL);
2871  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2872  ok(id == 1, "Expected 1, got %d\n", id);
2873  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2874  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2875 
2876  /* szDiskPrompt is non-NULL while pcchDiskPrompt is NULL */
2877  id = 0xbeef;
2878  lstrcpyA(label, "aaa");
2879  labelsz = MAX_PATH;
2880  lstrcpyA(prompt, "bbb");
2881  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2882  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2883  prompt, NULL);
2885  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2886  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
2887  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2888  ok(labelsz == MAX_PATH, "Expected MAX_PATH, got %d\n", labelsz);
2889  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2890 
2891  /* pcchVolumeLabel, szDiskPrompt and pcchDiskPrompt are NULL */
2892  id = 0;
2893  lstrcpyA(label, "aaa");
2894  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2895  MSICODE_PRODUCT, 0, &id, label, NULL,
2896  NULL, NULL);
2897  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2898  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2899  ok(id == 1, "Expected 1, got %d\n", id);
2900 
2901  /* szVolumeLabel, pcchVolumeLabel, szDiskPrompt and pcchDiskPrompt are NULL */
2902  id = 0;
2903  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2904  MSICODE_PRODUCT, 0, &id, NULL, NULL,
2905  NULL, NULL);
2906  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2907  ok(id == 1, "Expected 1, got %d\n", id);
2908 
2909  /* pcchVolumeLabel is exactly 5 */
2910  lstrcpyA(label, "aaa");
2911  labelsz = 5;
2912  lstrcpyA(prompt, "bbb");
2913  promptsz = MAX_PATH;
2914  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2915  MSICODE_PRODUCT, 0, NULL, label, &labelsz,
2916  prompt, &promptsz);
2917  ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2918  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2919  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2920  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2921  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2922 
2923  /* pcchDiskPrompt is exactly 6 */
2924  lstrcpyA(label, "aaa");
2925  labelsz = MAX_PATH;
2926  lstrcpyA(prompt, "bbb");
2927  promptsz = 6;
2928  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2929  MSICODE_PRODUCT, 0, NULL, label, &labelsz,
2930  prompt, &promptsz);
2931  ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2932  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
2933  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2934  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
2935  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2936 
2937  res = RegSetValueExA(media, "1", 0, REG_SZ, (LPBYTE)"label", 13);
2938  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2939 
2940  /* no semicolon */
2941  id = 0;
2942  lstrcpyA(label, "aaa");
2943  labelsz = MAX_PATH;
2944  lstrcpyA(prompt, "bbb");
2945  promptsz = MAX_PATH;
2946  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2947  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2948  prompt, &promptsz);
2949  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2950  ok(id == 1, "Expected 1, got %d\n", id);
2951  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2952  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2953  ok(!lstrcmpA(prompt, "label"), "Expected \"label\", got \"%s\"\n", prompt);
2954  ok(promptsz == 5, "Expected 5, got %d\n", promptsz);
2955 
2956  res = RegSetValueExA(media, "1", 0, REG_SZ, (LPBYTE)"label;", 13);
2957  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2958 
2959  /* semicolon, no disk prompt */
2960  id = 0;
2961  lstrcpyA(label, "aaa");
2962  labelsz = MAX_PATH;
2963  lstrcpyA(prompt, "bbb");
2964  promptsz = MAX_PATH;
2965  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2966  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2967  prompt, &promptsz);
2968  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2969  ok(id == 1, "Expected 1, got %d\n", id);
2970  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
2971  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
2972  ok(!lstrcmpA(prompt, ""), "Expected \"\", got \"%s\"\n", prompt);
2973  ok(promptsz == 0, "Expected 0, got %d\n", promptsz);
2974 
2975  res = RegSetValueExA(media, "1", 0, REG_SZ, (LPBYTE)";prompt", 13);
2976  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2977 
2978  /* semicolon, label doesn't exist */
2979  id = 0;
2980  lstrcpyA(label, "aaa");
2981  labelsz = MAX_PATH;
2982  lstrcpyA(prompt, "bbb");
2983  promptsz = MAX_PATH;
2984  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
2985  MSICODE_PRODUCT, 0, &id, label, &labelsz,
2986  prompt, &promptsz);
2987  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2988  ok(id == 1, "Expected 1, got %d\n", id);
2989  ok(!lstrcmpA(label, ""), "Expected \"\", got \"%s\"\n", label);
2990  ok(labelsz == 0, "Expected 0, got %d\n", labelsz);
2991  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
2992  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
2993 
2994  res = RegSetValueExA(media, "1", 0, REG_SZ, (LPBYTE)";", 13);
2995  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2996 
2997  /* semicolon, neither label nor disk prompt exist */
2998  id = 0;
2999  lstrcpyA(label, "aaa");
3000  labelsz = MAX_PATH;
3001  lstrcpyA(prompt, "bbb");
3002  promptsz = MAX_PATH;
3003  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3004  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3005  prompt, &promptsz);
3006  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3007  ok(id == 1, "Expected 1, got %d\n", id);
3008  ok(!lstrcmpA(label, ""), "Expected \"\", got \"%s\"\n", label);
3009  ok(labelsz == 0, "Expected 0, got %d\n", labelsz);
3010  ok(!lstrcmpA(prompt, ""), "Expected \"\", got \"%s\"\n", prompt);
3011  ok(promptsz == 0, "Expected 0, got %d\n", promptsz);
3012 
3013  val = 42;
3014  res = RegSetValueExA(media, "1", 0, REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
3015  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3016 
3017  /* type is REG_DWORD */
3018  id = 0;
3019  lstrcpyA(label, "aaa");
3020  labelsz = MAX_PATH;
3021  lstrcpyA(prompt, "bbb");
3022  promptsz = MAX_PATH;
3023  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3024  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3025  prompt, &promptsz);
3026  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3027  ok(id == 1, "Expected 1, got %d\n", id);
3028  ok(!lstrcmpA(label, "#42"), "Expected \"#42\", got \"%s\"\n", label);
3029  ok(labelsz == 3, "Expected 3, got %d\n", labelsz);
3030  ok(!lstrcmpA(prompt, "#42"), "Expected \"#42\", got \"%s\"\n", prompt);
3031  ok(promptsz == 3, "Expected 3, got %d\n", promptsz);
3032 
3033  RegDeleteValueA(media, "1");
3034  RegDeleteValueA(media, "2");
3035  RegDeleteValueA(media, "4");
3036  RegDeleteKeyA(media, "");
3037  RegCloseKey(media);
3038  RegDeleteKeyA(source, "");
3040  RegDeleteKeyA(userkey, "");
3041  RegCloseKey(userkey);
3042 
3043  /* MSIINSTALLCONTEXT_USERMANAGED */
3044 
3045  lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
3046  lstrcatA(keypath, usersid);
3047  lstrcatA(keypath, "\\Installer\\Products\\");
3048  lstrcatA(keypath, prod_squashed);
3049 
3050  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
3051  if (res != ERROR_SUCCESS)
3052  {
3053  skip("Product key creation failed with error code %u\n", res);
3054  goto machine_tests;
3055  }
3056 
3057  /* user product key exists */
3058  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
3059  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3060  prompt, &promptsz);
3062  "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3063 
3064  res = RegCreateKeyExA(userkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
3065  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3066 
3067  /* SourceList key exists */
3068  id = 0xbeef;
3069  lstrcpyA(label, "aaa");
3070  labelsz = 0xdeadbeef;
3071  lstrcpyA(prompt, "bbb");
3072  promptsz = 0xdeadbeef;
3073  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
3074  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3075  prompt, &promptsz);
3077  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3078  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
3079  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
3080  ok(labelsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz);
3081  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
3082  ok(promptsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz);
3083 
3084  res = RegCreateKeyExA(source, "Media", 0, NULL, 0, access, NULL, &media, NULL);
3085  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3086 
3087  /* Media key exists */
3088  id = 0xbeef;
3089  lstrcpyA(label, "aaa");
3090  labelsz = 0xdeadbeef;
3091  lstrcpyA(prompt, "bbb");
3092  promptsz = 0xdeadbeef;
3093  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
3094  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3095  prompt, &promptsz);
3097  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3098  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
3099  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
3100  ok(labelsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz);
3101  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
3102  ok(promptsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz);
3103 
3104  res = RegSetValueExA(media, "2", 0, REG_SZ, (LPBYTE)"label;prompt", 13);
3105  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3106 
3107  /* disk exists, but no id 1 */
3108  id = 0;
3109  lstrcpyA(label, "aaa");
3110  labelsz = MAX_PATH;
3111  lstrcpyA(prompt, "bbb");
3112  promptsz = MAX_PATH;
3113  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
3114  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3115  prompt, &promptsz);
3116  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3117  ok(id == 2, "Expected 2, got %d\n", id);
3118  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
3119  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
3120  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
3121  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
3122 
3123  RegDeleteValueA(media, "2");
3124  delete_key(media, "", access);
3125  RegCloseKey(media);
3126  delete_key(source, "", access);
3128  delete_key(userkey, "", access);
3129  RegCloseKey(userkey);
3130 
3131  /* MSIINSTALLCONTEXT_MACHINE */
3132 
3133 machine_tests:
3134  lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3135  lstrcatA(keypath, prod_squashed);
3136 
3137  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3138  if (res != ERROR_SUCCESS)
3139  {
3140  skip("Product key creation failed with error code %u\n", res);
3141  LocalFree(usersid);
3142  return;
3143  }
3144 
3145  /* machine product key exists */
3146  r = pMsiSourceListEnumMediaDisksA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
3147  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3148  prompt, &promptsz);
3150  "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3151 
3152  res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
3153  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3154 
3155  /* SourceList key exists */
3156  id = 0xbeef;
3157  lstrcpyA(label, "aaa");
3158  labelsz = 0xdeadbeef;
3159  lstrcpyA(prompt, "bbb");
3160  promptsz = 0xdeadbeef;
3161  r = pMsiSourceListEnumMediaDisksA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
3162  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3163  prompt, &promptsz);
3165  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3166  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
3167  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
3168  ok(labelsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz);
3169  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
3170  ok(promptsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz);
3171 
3172  res = RegCreateKeyExA(source, "Media", 0, NULL, 0, access, NULL, &media, NULL);
3173  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3174 
3175  /* Media key exists */
3176  id = 0xbeef;
3177  lstrcpyA(label, "aaa");
3178  labelsz = 0xdeadbeef;
3179  lstrcpyA(prompt, "bbb");
3180  promptsz = 0xdeadbeef;
3181  r = pMsiSourceListEnumMediaDisksA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
3182  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3183  prompt, &promptsz);
3185  "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3186  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
3187  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
3188  ok(labelsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz);
3189  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
3190  ok(promptsz == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz);
3191 
3192  res = RegSetValueExA(media, "2", 0, REG_SZ, (LPBYTE)"label;prompt", 13);
3193  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3194 
3195  /* disk exists, but no id 1 */
3196  id = 0;
3197  lstrcpyA(label, "aaa");
3198  labelsz = MAX_PATH;
3199  lstrcpyA(prompt, "bbb");
3200  promptsz = MAX_PATH;
3201  r = pMsiSourceListEnumMediaDisksA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
3202  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3203  prompt, &promptsz);
3204  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3205  ok(id == 2, "Expected 2, got %d\n", id);
3206  ok(!lstrcmpA(label, "label"), "Expected \"label\", got \"%s\"\n", label);
3207  ok(labelsz == 5, "Expected 5, got %d\n", labelsz);
3208  ok(!lstrcmpA(prompt, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt);
3209  ok(promptsz == 6, "Expected 6, got %d\n", promptsz);
3210 
3211  /* szUserSid is non-NULL */
3212  id = 0xbeef;
3213  lstrcpyA(label, "aaa");
3214  labelsz = MAX_PATH;
3215  lstrcpyA(prompt, "bbb");
3216  promptsz = MAX_PATH;
3217  r = pMsiSourceListEnumMediaDisksA(prodcode, usersid, MSIINSTALLCONTEXT_MACHINE,
3218  MSICODE_PRODUCT, 0, &id, label, &labelsz,
3219  prompt, &promptsz);
3221  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3222  ok(id == 0xbeef, "Expected 0xbeef, got %d\n", id);
3223  ok(!lstrcmpA(label, "aaa"), "Expected \"aaa\", got \"%s\"\n", label);
3224  ok(labelsz == MAX_PATH, "Expected MAX_PATH, got %d\n", labelsz);
3225  ok(!lstrcmpA(prompt, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt);
3226  ok(promptsz == MAX_PATH, "Expected MAX_PATH, got %d\n", promptsz);
3227 
3228  RegDeleteValueA(media, "2");
3229  delete_key(media, "", access);
3230  RegCloseKey(media);
3231  delete_key(source, "", access);
3233  delete_key(prodkey, "", access);
3234  RegCloseKey(prodkey);
3235  LocalFree(usersid);
3236 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
char * LPSTR
Definition: xmlstorage.h:182
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
GLuint GLfloat * val
Definition: glext.h:7180
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
__u8 media
Definition: mkdosfs.c:367
#define ERROR_BAD_CONFIGURATION
Definition: winerror.h:968
#define ERROR_UNKNOWN_PRODUCT
Definition: winerror.h:963
#define MAX_PATH
Definition: compat.h:26
static void create_test_guid(LPSTR prodcode, LPSTR squashed)
Definition: source.c:119
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static BOOL is_wow64
Definition: source.c:35
#define ERROR_MORE_DATA
Definition: dderror.h:13
uint8_t label[11]
Definition: fsck.fat.h:65
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static char * get_user_sid(void)
Definition: source.c:138
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ok(value,...)
Definition: atltest.h:57
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
ACCESS_MASK REGSAM
Definition: winreg.h:69
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
GLenum GLuint id
Definition: glext.h:5579
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define REG_DWORD
Definition: sdbapi.c:596
#define win_skip
Definition: test.h:141
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22
static LONG delete_key(HKEY key, LPCSTR subkey, REGSAM access)
Definition: source.c:640

Referenced by START_TEST().

◆ test_MsiSourceListEnumSources()

static void test_MsiSourceListEnumSources ( void  )
static

Definition at line 1038 of file source.c.

1039 {
1040  CHAR prodcode[MAX_PATH];
1041  CHAR prod_squashed[MAX_PATH];
1042  CHAR keypath[MAX_PATH*2];
1043  CHAR value[MAX_PATH];
1044  LPSTR usersid;
1045  LONG res;
1046  UINT r;
1047  HKEY prodkey, userkey;
1048  HKEY url, net, source;
1049  DWORD size;
1051 
1052  if (!pMsiSourceListEnumSourcesA)
1053  {
1054  win_skip("MsiSourceListEnumSourcesA is not available\n");
1055  return;
1056  }
1057 
1058  create_test_guid(prodcode, prod_squashed);
1059  if (!(usersid = get_user_sid()))
1060  {
1061  skip("User SID not available -> skipping MsiSourceListEnumSourcesA tests\n");
1062  return;
1063  }
1064 
1065  if (is_wow64)
1067 
1068  /* GetLastError is not set by the function */
1069 
1070  /* NULL szProductCodeOrPatchCode */
1071  size = 0xdeadbeef;
1072  r = pMsiSourceListEnumSourcesA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
1074  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1075  ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
1076 
1077  /* empty szProductCodeOrPatchCode */
1078  size = 0xdeadbeef;
1079  r = pMsiSourceListEnumSourcesA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
1081  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1082  ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
1083 
1084  /* garbage szProductCodeOrPatchCode */
1085  size = 0xdeadbeef;
1086  r = pMsiSourceListEnumSourcesA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
1088  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1089  ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
1090 
1091  /* guid without brackets */
1092  size = 0xdeadbeef;
1093  r = pMsiSourceListEnumSourcesA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
1096  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1097  ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
1098 
1099  /* guid with brackets */
1100  size = 0xdeadbeef;
1101  r = pMsiSourceListEnumSourcesA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
1104  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1105  ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
1106 
1107  /* MSIINSTALLCONTEXT_USERUNMANAGED */
1108 
1109  size = MAX_PATH;
1110  lstrcpyA(value, "aaa");
1111  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1114  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1115  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1116  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1117 
1118  lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1119  lstrcatA(keypath, prod_squashed);
1120 
1121  res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
1122  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1123 
1124  /* user product key exists */
1125  size = MAX_PATH;
1126  lstrcpyA(value, "aaa");
1127  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1130  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
1131  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1132  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1133 
1134  res = RegCreateKeyA(userkey, "SourceList", &source);
1135  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1136 
1137  /* SourceList key exists */
1138  size = MAX_PATH;
1139  lstrcpyA(value, "aaa");
1140  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1143  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1144  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1145  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1146 
1147  res = RegCreateKeyA(source, "URL", &url);
1148  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1149 
1150  /* URL key exists */
1151  size = MAX_PATH;
1152  lstrcpyA(value, "aaa");
1153  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1156  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1157  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1158  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1159 
1160  res = RegSetValueExA(url, "1", 0, REG_SZ, (LPBYTE)"first", 6);
1161  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1162 
1163  res = RegSetValueExA(url, "2", 0, REG_SZ, (LPBYTE)"second", 7);
1164  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1165 
1166  res = RegSetValueExA(url, "4", 0, REG_SZ, (LPBYTE)"fourth", 7);
1167  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1168 
1169  /* sources exist */
1170  size = MAX_PATH;
1171  lstrcpyA(value, "aaa");
1172  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1175  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1176  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1177  ok(size == 5, "Expected 5, got %d\n", size);
1178 
1179  /* try index 0 again */
1180  size = MAX_PATH;
1181  lstrcpyA(value, "aaa");
1182  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1185  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1186  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1187  ok(size == 5, "Expected 5, got %d\n", size);
1188 
1189  /* both szSource and pcchSource are NULL, index 0 */
1190  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1193  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1194 
1195  /* both szSource and pcchSource are NULL, index 1 */
1196  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1199  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1200 
1201  /* size is exactly 5 */
1202  size = 5;
1203  lstrcpyA(value, "aaa");
1204  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1207  ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
1208  ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got %s\n", value);
1209  ok(size == 5, "Expected 5, got %d\n", size);
1210 
1211  /* szSource is non-NULL while pcchSource is NULL */
1212  lstrcpyA(value, "aaa");
1213  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1216  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1217  ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got %s\n", value);
1218 
1219  /* try index 1 after failure */
1220  size = MAX_PATH;
1221  lstrcpyA(value, "aaa");
1222  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1226  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1227  ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got %s\n", value);
1228  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1229 
1230  /* reset the enumeration */
1231  size = MAX_PATH;
1232  lstrcpyA(value, "aaa");
1233  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1236  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1237  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1238  ok(size == 5, "Expected 5, got %d\n", size);
1239 
1240  /* try index 1 */
1241  size = MAX_PATH;
1242  lstrcpyA(value, "aaa");
1243  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1246  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1247  ok(!lstrcmpA(value, "second"), "Expected \"second\", got %s\n", value);
1248  ok(size == 6, "Expected 6, got %d\n", size);
1249 
1250  /* try index 1 again */
1251  size = MAX_PATH;
1252  lstrcpyA(value, "aaa");
1253  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1257  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1258  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1259  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1260 
1261  /* try index 2 */
1262  size = MAX_PATH;
1263  lstrcpyA(value, "aaa");
1264  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1267  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1268  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1269  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1270 
1271  /* try index < 0 */
1272  size = MAX_PATH;
1273  lstrcpyA(value, "aaa");
1274  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1278  "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1279  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1280  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1281 
1282  /* NULL szUserSid */
1283  size = MAX_PATH;
1284  lstrcpyA(value, "aaa");
1285  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1288  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1289  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1290  ok(size == 5, "Expected 5, got %d\n", size);
1291 
1292  /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1293  size = MAX_PATH;
1294  lstrcpyA(value, "aaa");
1295  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1297  MSICODE_PRODUCT, 0, value, &size);
1298  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1299  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1300  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1301 
1302  /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1303  size = MAX_PATH;
1304  lstrcpyA(value, "aaa");
1305  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1307  MSICODE_PATCH, 0, value, &size);
1308  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1309  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1310  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1311 
1312  /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1313  size = MAX_PATH;
1314  lstrcpyA(value, "aaa");
1315  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1318  0, value, &size);
1319  ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
1320  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1321  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1322 
1323  /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1324  size = MAX_PATH;
1325  lstrcpyA(value, "aaa");
1326  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1329  0, value, &size);
1330  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1331  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1332  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1333 
1334  RegDeleteValueA(url, "1");
1335  RegDeleteValueA(url, "2");
1336  RegDeleteValueA(url, "4");
1337  RegDeleteKeyA(url, "");
1338  RegCloseKey(url);
1339 
1340  /* SourceList key exists */
1341  size = MAX_PATH;
1342  lstrcpyA(value, "aaa");
1343  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1346  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1347  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1348  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1349 
1350  res = RegCreateKeyA(source, "Net", &net);
1351  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1352 
1353  /* Net key exists */
1354  size = MAX_PATH;
1355  lstrcpyA(value, "aaa");
1356  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1359  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1360  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1361  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1362 
1363  res = RegSetValueExA(net, "1", 0, REG_SZ, (LPBYTE)"first", 6);
1364  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1365 
1366  /* sources exist */
1367  size = MAX_PATH;
1368  lstrcpyA(value, "aaa");
1369  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1372  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1373  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1374  ok(size == 5, "Expected 5, got %d\n", size);
1375 
1376  RegDeleteValueA(net, "1");
1377  RegDeleteKeyA(net, "");
1378  RegCloseKey(net);
1379  RegDeleteKeyA(source, "");
1381  RegDeleteKeyA(userkey, "");
1382  RegCloseKey(userkey);
1383 
1384  /* MSIINSTALLCONTEXT_USERMANAGED */
1385 
1386  size = MAX_PATH;
1387  lstrcpyA(value, "aaa");
1388  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1391  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1392  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1393  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1394 
1395  lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1396  lstrcatA(keypath, usersid);
1397  lstrcatA(keypath, "\\Installer\\Products\\");
1398  lstrcatA(keypath, prod_squashed);
1399 
1400  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
1401  if (res != ERROR_SUCCESS)
1402  {
1403  skip("Product key creation failed with error code %u\n", res);
1404  goto machine_tests;
1405  }
1406 
1407  /* user product key exists */
1408  size = MAX_PATH;
1409  lstrcpyA(value, "aaa");
1410  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1413  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
1414  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1415  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1416 
1417  res = RegCreateKeyExA(userkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
1418  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1419 
1420  /* SourceList key exists */
1421  size = MAX_PATH;
1422  lstrcpyA(value, "aaa");
1423  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1426  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1427  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1428  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1429 
1430  res = RegCreateKeyExA(source, "URL", 0, NULL, 0, access, NULL, &url, NULL);
1431  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1432 
1433  /* URL key exists */
1434  size = MAX_PATH;
1435  lstrcpyA(value, "aaa");
1436  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1439  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1440  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1441  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1442 
1443  res = RegSetValueExA(url, "1", 0, REG_SZ, (LPBYTE)"first", 6);
1444  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1445 
1446  /* sources exist */
1447  size = MAX_PATH;
1448  lstrcpyA(value, "aaa");
1449  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1452  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1453  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1454  ok(size == 5, "Expected 5, got %d\n", size);
1455 
1456  /* NULL szUserSid */
1457  size = MAX_PATH;
1458  lstrcpyA(value, "aaa");
1459  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1462  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1463  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1464  ok(size == 5, "Expected 5, got %d\n", size);
1465 
1466  RegDeleteValueA(url, "1");
1467  delete_key(url, "", access);
1468  RegCloseKey(url);
1469 
1470  /* SourceList key exists */
1471  size = MAX_PATH;
1472  lstrcpyA(value, "aaa");
1473  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1476  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1477  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1478  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1479 
1480  res = RegCreateKeyExA(source, "Net", 0, NULL, 0, access, NULL, &net, NULL);
1481  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1482 
1483  /* Net key exists */
1484  size = MAX_PATH;
1485  lstrcpyA(value, "aaa");
1486  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1489  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1490  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1491  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1492 
1493  res = RegSetValueExA(net, "1", 0, REG_SZ, (LPBYTE)"first", 6);
1494  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1495 
1496  /* sources exist */
1497  size = MAX_PATH;
1498  lstrcpyA(value, "aaa");
1499  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1502  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1503  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1504  ok(size == 5, "Expected 5, got %d\n", size);
1505 
1506  RegDeleteValueA(net, "1");
1507  delete_key(net, "", access);
1508  RegCloseKey(net);
1509  delete_key(source, "", access);
1511  delete_key(userkey, "", access);
1512  RegCloseKey(userkey);
1513 
1514  /* MSIINSTALLCONTEXT_MACHINE */
1515 
1516 machine_tests:
1517  /* szUserSid is non-NULL */
1518  size = MAX_PATH;
1519  lstrcpyA(value, "aaa");
1520  r = pMsiSourceListEnumSourcesA(prodcode, usersid,
1523  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1524  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1525  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1526 
1527  /* szUserSid is NULL */
1528  size = MAX_PATH;
1529  lstrcpyA(value, "aaa");
1530  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1533  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1534  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1535  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1536 
1537  lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1538  lstrcatA(keypath, prod_squashed);
1539 
1540  res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
1541  if (res != ERROR_SUCCESS)
1542  {
1543  skip("Product key creation failed with error code %u\n", res);
1544  LocalFree(usersid);
1545  return;
1546  }
1547 
1548  /* user product key exists */
1549  size = MAX_PATH;
1550  lstrcpyA(value, "aaa");
1551  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1554  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
1555  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1556  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1557 
1558  res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
1559  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1560 
1561  /* SourceList key exists */
1562  size = MAX_PATH;
1563  lstrcpyA(value, "aaa");
1564  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1567  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1568  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1569  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1570 
1571  res = RegCreateKeyExA(source, "URL", 0, NULL, 0, access, NULL, &url, NULL);
1572  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1573 
1574  /* URL key exists */
1575  size = MAX_PATH;
1576  lstrcpyA(value, "aaa");
1577  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1580  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1581  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1582  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1583 
1584  res = RegSetValueExA(url, "1", 0, REG_SZ, (LPBYTE)"first", 6);
1585  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1586 
1587  /* sources exist */
1588  size = MAX_PATH;
1589  lstrcpyA(value, "aaa");
1590  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1593  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1594  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1595  ok(size == 5, "Expected 5, got %d\n", size);
1596 
1597  /* NULL szUserSid */
1598  size = MAX_PATH;
1599  lstrcpyA(value, "aaa");
1600  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1603  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1604  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1605  ok(size == 5, "Expected 5, got %d\n", size);
1606 
1607  RegDeleteValueA(url, "1");
1608  delete_key(url, "", access);
1609  RegCloseKey(url);
1610 
1611  /* SourceList key exists */
1612  size = MAX_PATH;
1613  lstrcpyA(value, "aaa");
1614  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1617  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1618  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1619  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1620 
1621  res = RegCreateKeyExA(source, "Net", 0, NULL, 0, access, NULL, &net, NULL);
1622  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1623 
1624  /* Net key exists */
1625  size = MAX_PATH;
1626  lstrcpyA(value, "aaa");
1627  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1630  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1631  ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
1632  ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
1633 
1634  res = RegSetValueExA(net, "1", 0, REG_SZ, (LPBYTE)"first", 6);
1635  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1636 
1637  /* sources exist */
1638  size = MAX_PATH;
1639  lstrcpyA(value, "aaa");
1640  r = pMsiSourceListEnumSourcesA(prodcode, NULL,
1643  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1644  ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
1645  ok(size == 5, "Expected 5, got %d\n", size);
1646 
1647  RegDeleteValueA(net, "1");
1648  delete_key(net, "", access);
1649  RegCloseKey(net);
1650  delete_key(source, "", access);
1652  delete_key(prodkey, "", access);
1653  RegCloseKey(prodkey);
1654  LocalFree(usersid);
1655 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
char * LPSTR
Definition: xmlstorage.h:182
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
#define ERROR_UNKNOWN_PATCH
Definition: winerror.h:1005
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
GLsizeiptr size
Definition: glext.h:5919
#define ERROR_BAD_CONFIGURATION
Definition: winerror.h:968
static const WCHAR url[]
Definition: encode.c:1432
#define ERROR_UNKNOWN_PRODUCT
Definition: winerror.h:963
#define MAX_PATH
Definition: compat.h:26
static void create_test_guid(LPSTR prodcode, LPSTR squashed)
Definition: source.c:119
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static BOOL is_wow64
Definition: source.c:35
#define ERROR_MORE_DATA
Definition: dderror.h:13
static TNetwork net
Definition: tncon.cpp:351
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static char * get_user_sid(void)
Definition: source.c:138
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ok(value,...)
Definition: atltest.h:57
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
ACCESS_MASK REGSAM
Definition: winreg.h:69
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define win_skip
Definition: test.h:141
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22
static LONG delete_key(HKEY key, LPCSTR subkey, REGSAM access)
Definition: source.c:640

Referenced by START_TEST().

◆ test_MsiSourceListGetInfo()

static void test_MsiSourceListGetInfo ( void  )
static

Definition at line 192 of file source.c.

193 {
194  CHAR prodcode[MAX_PATH];
195  CHAR prod_squashed[MAX_PATH];
196  CHAR keypath[MAX_PATH*2];
198  LPSTR usersid;
199  LPCSTR data;
200  LONG res;
201  UINT r;
202  HKEY userkey, hkey, media;
203  DWORD size;
204 
205  if (!pMsiSourceListGetInfoA)
206  {
207  win_skip("Skipping MsiSourceListGetInfoA tests\n");
208  return;
209  }
210 
211  create_test_guid(prodcode, prod_squashed);
212  if (!(usersid = get_user_sid()))
213  {
214  skip("User SID not available -> skipping MsiSourceListGetInfoA tests\n");
215  return;
216  }
217 
218  /* NULL szProductCodeOrPatchCode */
219  r = pMsiSourceListGetInfoA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
221  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
222 
223  /* empty szProductCodeOrPatchCode */
224  r = pMsiSourceListGetInfoA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
226  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
227 
228  /* garbage szProductCodeOrPatchCode */
229  r = pMsiSourceListGetInfoA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
231  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
232 
233  /* guid without brackets */
234  r = pMsiSourceListGetInfoA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
236  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
237 
238  /* guid with brackets */
239  r = pMsiSourceListGetInfoA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
241  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
242 
243  /* same length as guid, but random */
244  r = pMsiSourceListGetInfoA("ADKD-2KSDFF2-DKK1KNFJASD9GLKWME-1I3KAD", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
246  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
247 
248  /* invalid context */
249  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_NONE,
251  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
252 
253  /* another invalid context */
254  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_ALLUSERMANAGED,
256  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
257 
258  /* yet another invalid context */
259  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_ALL,
261  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
262 
263  /* mix two valid contexts */
264  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED | MSIINSTALLCONTEXT_USERUNMANAGED,
266  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
267 
268  /* invalid option */
269  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
271  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
272 
273  /* NULL property */
274  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
276  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
277 
278  /* empty property */
279  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
280  MSICODE_PRODUCT, "", NULL, NULL);
281  ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
282 
283  /* value is non-NULL while size is NULL */
284  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
286  ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
287 
288  /* size is non-NULL while value is NULL */
289  size = MAX_PATH;
290  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
293  "Expected ERROR_UNKNOWN_PRODUCT or ERROR_INVALID_PARAMETER, got %d\n", r);
294 
295  lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
296  lstrcatA(keypath, prod_squashed);
297 
298  res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
299  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
300 
301  /* user product key exists */
302  size = MAX_PATH;
303  lstrcpyA(value, "aaa");
304  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
306  ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
307  ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
308 
309  res = RegCreateKeyA(userkey, "SourceList", &hkey);
310  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
311 
312  /* SourceList key exists */
313  size = MAX_PATH;
314  lstrcpyA(value, "aaa");
315  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
317  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
318  ok(size == 0, "Expected 0, got %d\n", size);
319  ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
320 
321  data = "msitest.msi";
322  res = RegSetValueExA(hkey, "PackageName", 0, REG_SZ, (const BYTE *)data, lstrlenA(data) + 1);
323  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
324 
325  /* PackageName value exists */
326  size = 0xdeadbeef;
327  r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,