1 /* 2 * Copyright 2007 Jacek Caban for CodeWeavers 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 */ 18 19 #include "ntstatus.h" 20 #define WIN32_NO_STATUS 21 #include "wine/test.h" 22 #include <winbase.h> 23 #include <windef.h> 24 #include <winnt.h> 25 #include <winternl.h> 26 #include <winnls.h> 27 #include <stdio.h> 28 29 #include "oaidl.h" 30 #include "initguid.h" 31 32 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*); 33 static HANDLE (WINAPI *pCreateActCtxA)(PCACTCTXA); 34 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW); 35 static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR); 36 static BOOL (WINAPI *pFindActCtxSectionStringA)(DWORD,const GUID *,ULONG,LPCSTR,PACTCTX_SECTION_KEYED_DATA); 37 static BOOL (WINAPI *pFindActCtxSectionStringW)(DWORD,const GUID *,ULONG,LPCWSTR,PACTCTX_SECTION_KEYED_DATA); 38 static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *); 39 static BOOL (WINAPI *pIsDebuggerPresent)(void); 40 static BOOL (WINAPI *pQueryActCtxW)(DWORD,HANDLE,PVOID,ULONG,PVOID,SIZE_T,SIZE_T*); 41 static VOID (WINAPI *pReleaseActCtx)(HANDLE); 42 static BOOL (WINAPI *pFindActCtxSectionGuid)(DWORD,const GUID*,ULONG,const GUID*,PACTCTX_SECTION_KEYED_DATA); 43 static BOOL (WINAPI *pZombifyActCtx)(HANDLE); 44 45 static NTSTATUS(NTAPI *pRtlFindActivationContextSectionString)(DWORD,const GUID *,ULONG,PUNICODE_STRING,PACTCTX_SECTION_KEYED_DATA); 46 static BOOLEAN (NTAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, PCSZ); 47 static VOID (NTAPI *pRtlFreeUnicodeString)(PUNICODE_STRING); 48 49 static const char* strw(LPCWSTR x) 50 { 51 static char buffer[1024]; 52 char* p = buffer; 53 54 if (!x) return "(nil)"; 55 else while ((*p++ = *x++)); 56 return buffer; 57 } 58 59 #ifdef __i386__ 60 #define ARCH "x86" 61 #elif defined __x86_64__ 62 #define ARCH "amd64" 63 #elif defined __arm__ 64 #define ARCH "arm" 65 #elif defined __aarch64__ 66 #define ARCH "arm64" 67 #else 68 #define ARCH "none" 69 #endif 70 71 static const char manifest1[] = 72 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 73 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 74 "</assembly>"; 75 76 static const char manifest1_1[] = 77 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">" 78 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>" 79 "</assembly>"; 80 81 static const char manifest2[] = 82 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 83 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">" 84 "</assemblyIdentity>" 85 "<dependency>" 86 "<dependentAssembly>" 87 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\">" 88 "</assemblyIdentity>" 89 "</dependentAssembly>" 90 "</dependency>" 91 "</assembly>"; 92 93 DEFINE_GUID(IID_CoTest, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33); 94 DEFINE_GUID(IID_CoTest2, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34); 95 DEFINE_GUID(CLSID_clrclass,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33); 96 DEFINE_GUID(IID_TlibTest, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55); 97 DEFINE_GUID(IID_TlibTest2, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56); 98 DEFINE_GUID(IID_TlibTest3, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57); 99 DEFINE_GUID(IID_TlibTest4, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58); 100 DEFINE_GUID(IID_Iifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55); 101 DEFINE_GUID(IID_Ibifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57); 102 DEFINE_GUID(IID_Iifaceps2, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55); 103 DEFINE_GUID(IID_Iifaceps3, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55); 104 DEFINE_GUID(IID_Iiface, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55); 105 DEFINE_GUID(IID_PS32, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56); 106 107 static const char manifest3[] = 108 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 109 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"" 110 " publicKeyToken=\"6595b6414666f1df\" />" 111 "<description />" 112 "<file name=\"testlib.dll\">" 113 "<windowClass>wndClass</windowClass>" 114 " <comClass description=\"Test com class\"" 115 " clsid=\"{12345678-1234-5678-1234-111122223333}\"" 116 " tlbid=\"{99999999-8888-7777-6666-555555555555}\"" 117 " threadingModel=\"Neutral\"" 118 " progid=\"ProgId.ProgId\"" 119 " miscStatus=\"cantlinkinside\"" 120 " miscStatusIcon=\"recomposeonresize\"" 121 " miscStatusContent=\"insideout\"" 122 " miscStatusThumbnail=\"alignable\"" 123 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\"" 124 " >" 125 " <progid>ProgId.ProgId.1</progid>" 126 " <progid>ProgId.ProgId.2</progid>" 127 " <progid>ProgId.ProgId.3</progid>" 128 " <progid>ProgId.ProgId.4</progid>" 129 " <progid>ProgId.ProgId.5</progid>" 130 " <progid>ProgId.ProgId.6</progid>" 131 " </comClass>" 132 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >" 133 " <progid>ProgId.ProgId.7</progid>" 134 " </comClass>" 135 " <comInterfaceProxyStub " 136 " name=\"Iifaceps\"" 137 " tlbid=\"{99999999-8888-7777-6666-555555555558}\"" 138 " iid=\"{66666666-8888-7777-6666-555555555555}\"" 139 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\"" 140 " threadingModel=\"Free\"" 141 " numMethods=\"10\"" 142 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\"" 143 " />" 144 "</file>" 145 " <comInterfaceExternalProxyStub " 146 " name=\"Iifaceps2\"" 147 " tlbid=\"{99999999-8888-7777-6666-555555555558}\"" 148 " iid=\"{76666666-8888-7777-6666-555555555555}\"" 149 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\"" 150 " numMethods=\"10\"" 151 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\"" 152 " />" 153 " <comInterfaceExternalProxyStub " 154 " name=\"Iifaceps3\"" 155 " tlbid=\"{99999999-8888-7777-6666-555555555558}\"" 156 " iid=\"{86666666-8888-7777-6666-555555555555}\"" 157 " numMethods=\"10\"" 158 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\"" 159 " />" 160 " <clrSurrogate " 161 " clsid=\"{96666666-8888-7777-6666-555555555555}\"" 162 " name=\"testsurrogate\"" 163 " runtimeVersion=\"v2.0.50727\"" 164 " />" 165 " <clrClass " 166 " clsid=\"{22345678-1234-5678-1234-111122223333}\"" 167 " name=\"clrclass\"" 168 " progid=\"clrprogid\"" 169 " description=\"test description\"" 170 " tlbid=\"{99999999-8888-7777-6666-555555555555}\"" 171 " runtimeVersion=\"1.2.3.4\"" 172 " threadingModel=\"Neutral\"" 173 " >" 174 " <progid>clrprogid.1</progid>" 175 " <progid>clrprogid.2</progid>" 176 " <progid>clrprogid.3</progid>" 177 " <progid>clrprogid.4</progid>" 178 " <progid>clrprogid.5</progid>" 179 " <progid>clrprogid.6</progid>" 180 " </clrClass>" 181 "</assembly>"; 182 183 static const char manifest_wndcls1[] = 184 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 185 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>" 186 "<file name=\"testlib1.dll\">" 187 "<windowClass versioned=\"yes\">wndClass1</windowClass>" 188 "<windowClass>wndClass2</windowClass>" 189 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />" 190 "</file>" 191 "<file name=\"testlib1_2.dll\" />" 192 "</assembly>"; 193 194 static const char manifest_wndcls2[] = 195 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 196 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH "\" />" 197 "<file name=\"testlib2.dll\">" 198 " <windowClass versioned=\"no\">wndClass3</windowClass>" 199 " <windowClass>wndClass4</windowClass>" 200 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\"" 201 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />" 202 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />" 203 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />" 204 "</file>" 205 "<file name=\"testlib2_2.dll\" />" 206 "</assembly>"; 207 208 static const char manifest_wndcls_main[] = 209 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 210 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />" 211 "<dependency>" 212 " <dependentAssembly>" 213 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />" 214 " </dependentAssembly>" 215 "</dependency>" 216 "<dependency>" 217 " <dependentAssembly>" 218 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH "\" />" 219 " </dependentAssembly>" 220 "</dependency>" 221 "</assembly>"; 222 223 static const char manifest4[] = 224 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 225 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">" 226 "</assemblyIdentity>" 227 "<dependency>" 228 "<dependentAssembly>" 229 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" " 230 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH "\" publicKeyToken=\"6595b64144ccf1df\">" 231 "</assemblyIdentity>" 232 "</dependentAssembly>" 233 "</dependency>" 234 "</assembly>"; 235 236 static const char manifest5[] = 237 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 238 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">" 239 "</assemblyIdentity>" 240 "<dependency>" 241 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">" 242 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />" 243 " </dependentAssembly>" 244 "</dependency>" 245 "</assembly>"; 246 247 static const char manifest6[] = 248 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 249 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 250 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v1\">" 251 " <security>" 252 " <requestedPrivileges>" 253 " <requestedExecutionLevel level=\"ASINVOKER\" uiAccess=\"false\"/>" 254 " </requestedPrivileges>" 255 " </security>" 256 "</trustInfo>" 257 "</assembly>"; 258 259 static const char manifest7[] = 260 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 261 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 262 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 263 " <security>" 264 " <requestedPrivileges>" 265 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"TRUE\"/>" 266 " </requestedPrivileges>" 267 " </security>" 268 "</trustInfo>" 269 "</assembly>"; 270 271 static const char manifest8[] = 272 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 273 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 274 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 275 " <security>" 276 " <requestedPrivileges>" 277 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\">" 278 " </requestedExecutionLevel>" 279 " </requestedPrivileges>" 280 " </security>" 281 "</trustInfo>" 282 "</assembly>"; 283 284 static const char manifest9[] = 285 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 286 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 287 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 288 " <security>" 289 " <requestedPrivileges>" 290 " <requestedExecutionLevel level=\"requireAdministrator\"/>" 291 " </requestedPrivileges>" 292 " </security>" 293 "</trustInfo>" 294 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 295 " <security>" 296 " <requestedPrivileges>" 297 " </requestedPrivileges>" 298 " </security>" 299 "</trustInfo>" 300 "</assembly>"; 301 302 static const char testdep_manifest1[] = 303 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 304 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>" 305 "</assembly>"; 306 307 static const char testdep_manifest2[] = 308 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 309 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />" 310 "<file name=\"testlib.dll\"></file>" 311 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />" 312 "</assembly>"; 313 314 static const char testdep_manifest3[] = 315 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> " 316 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>" 317 "<file name=\"testlib.dll\"/>" 318 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">" 319 "<windowClass>wndClass</windowClass>" 320 "<windowClass>wndClass2</windowClass>" 321 "</file>" 322 "</assembly>"; 323 324 static const char wrong_manifest1[] = 325 "<assembly manifestVersion=\"1.0\">" 326 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 327 "</assembly>"; 328 329 static const char wrong_manifest2[] = 330 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">" 331 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 332 "</assembly>"; 333 334 static const char wrong_manifest3[] = 335 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 336 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 337 "</assembly>"; 338 339 static const char wrong_manifest4[] = 340 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 341 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 342 "<test></test>" 343 "</assembly>"; 344 345 static const char wrong_manifest5[] = 346 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 347 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 348 "</assembly>" 349 "<test></test>"; 350 351 static const char wrong_manifest6[] = 352 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">" 353 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 354 "</assembly>"; 355 356 static const char wrong_manifest7[] = 357 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 358 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />" 359 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />" 360 "</assembly>"; 361 362 static const char wrong_manifest8[] = 363 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 364 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 365 "<file></file>" 366 "</assembly>"; 367 368 static const char wrong_manifest9[] = 369 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 370 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 371 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 372 " <security>" 373 " <requestedPrivileges>" 374 " <requestedExecutionLevel level=\"requireAdministrator\"/>" 375 " <requestedExecutionLevel uiAccess=\"true\"/>" 376 " </requestedPrivileges>" 377 " </security>" 378 "</trustInfo>" 379 "</assembly>"; 380 381 static const char wrong_manifest10[] = 382 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 383 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 384 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 385 " <security>" 386 " <requestedPrivileges>" 387 " <requestedExecutionLevel level=\"requireAdministrator\"/>" 388 " </requestedPrivileges>" 389 " </security>" 390 "</trustInfo>" 391 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" 392 " <security>" 393 " <requestedPrivileges>" 394 " <requestedExecutionLevel uiAccess=\"true\"/>" 395 " </requestedPrivileges>" 396 " </security>" 397 "</trustInfo>" 398 "</assembly>"; 399 400 static const char wrong_depmanifest1[] = 401 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 402 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH "\" />" 403 "</assembly>"; 404 405 static const char compat_manifest_no_supportedOs[] = 406 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 407 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 408 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">" 409 " <application>" 410 " </application>" 411 " </compatibility>" 412 "</assembly>"; 413 414 static const char compat_manifest_vista[] = 415 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 416 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 417 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">" 418 " <application>" 419 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */ 420 " </application>" 421 " </compatibility>" 422 "</assembly>"; 423 424 static const char compat_manifest_vista_7_8_10_81[] = 425 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 426 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 427 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">" 428 " <application>" 429 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" ></supportedOS>" /* Windows Vista */ 430 " <supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" />" /* Windows 7 */ 431 " <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" ></supportedOS>" /* Windows 8 */ 432 " <supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" />" /* Windows 10 */ 433 " <supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" />" /* Windows 8.1 */ 434 " </application>" 435 " </compatibility>" 436 "</assembly>"; 437 438 static const char compat_manifest_other_guid[] = 439 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" 440 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 441 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">" 442 " <application>" 443 " <supportedOS Id=\"{12345566-1111-2222-3333-444444444444}\" />" 444 " </application>" 445 " </compatibility>" 446 "</assembly>"; 447 448 DEFINE_GUID(VISTA_COMPAT_GUID, 0xe2011457, 0x1546, 0x43c5, 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0); 449 DEFINE_GUID(WIN7_COMPAT_GUID, 0x35138b9a, 0x5d96, 0x4fbd, 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a); 450 DEFINE_GUID(WIN8_COMPAT_GUID, 0x4a2f28e3, 0x53b9, 0x4441, 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38); 451 DEFINE_GUID(WIN81_COMPAT_GUID, 0x1f676c76, 0x80e1, 0x4239, 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78); 452 DEFINE_GUID(WIN10_COMPAT_GUID, 0x8e0f7a12, 0xbfb3, 0x4fe8, 0xb9, 0xa5, 0x48, 0xfd, 0x50, 0xa1, 0x5a, 0x9a); 453 DEFINE_GUID(OTHER_COMPAT_GUID, 0x12345566, 0x1111, 0x2222, 0x33, 0x33, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44); 454 455 456 static const WCHAR testlib_dll[] = 457 {'t','e','s','t','l','i','b','.','d','l','l',0}; 458 static const WCHAR testlib2_dll[] = 459 {'t','e','s','t','l','i','b','2','.','d','l','l',0}; 460 static const WCHAR wndClassW[] = 461 {'w','n','d','C','l','a','s','s',0}; 462 static const WCHAR wndClass1W[] = 463 {'w','n','d','C','l','a','s','s','1',0}; 464 static const WCHAR wndClass2W[] = 465 {'w','n','d','C','l','a','s','s','2',0}; 466 static const WCHAR wndClass3W[] = 467 {'w','n','d','C','l','a','s','s','3',0}; 468 469 static WCHAR app_dir[MAX_PATH], exe_path[MAX_PATH], work_dir[MAX_PATH], work_dir_subdir[MAX_PATH]; 470 static WCHAR app_manifest_path[MAX_PATH], manifest_path[MAX_PATH], depmanifest_path[MAX_PATH]; 471 472 static int strcmp_aw(LPCWSTR strw, const char *stra) 473 { 474 WCHAR buf[1024]; 475 476 if (!stra) return 1; 477 MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR)); 478 return lstrcmpW(strw, buf); 479 } 480 481 static DWORD strlen_aw(const char *str) 482 { 483 return MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0) - 1; 484 } 485 486 static BOOL create_manifest_file(const char *filename, const char *manifest, int manifest_len, 487 const char *depfile, const char *depmanifest) 488 { 489 DWORD size; 490 HANDLE file; 491 WCHAR path[MAX_PATH]; 492 493 MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH ); 494 GetFullPathNameW(path, sizeof(manifest_path)/sizeof(WCHAR), manifest_path, NULL); 495 496 if (manifest_len == -1) 497 manifest_len = strlen(manifest); 498 499 file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 500 FILE_ATTRIBUTE_NORMAL, NULL); 501 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError()); 502 if(file == INVALID_HANDLE_VALUE) 503 return FALSE; 504 WriteFile(file, manifest, manifest_len, &size, NULL); 505 CloseHandle(file); 506 507 if (depmanifest) 508 { 509 MultiByteToWideChar( CP_ACP, 0, depfile, -1, path, MAX_PATH ); 510 GetFullPathNameW(path, sizeof(depmanifest_path)/sizeof(WCHAR), depmanifest_path, NULL); 511 file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 512 FILE_ATTRIBUTE_NORMAL, NULL); 513 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError()); 514 if(file == INVALID_HANDLE_VALUE) 515 return FALSE; 516 WriteFile(file, depmanifest, strlen(depmanifest), &size, NULL); 517 CloseHandle(file); 518 } 519 return TRUE; 520 } 521 522 static BOOL create_wide_manifest(const char *filename, const char *manifest, BOOL fBOM, BOOL fReverse) 523 { 524 WCHAR *wmanifest = HeapAlloc(GetProcessHeap(), 0, (strlen(manifest)+2) * sizeof(WCHAR)); 525 BOOL ret; 526 int offset = (fBOM ? 0 : 1); 527 528 MultiByteToWideChar(CP_ACP, 0, manifest, -1, &wmanifest[1], (strlen(manifest)+1)); 529 wmanifest[0] = 0xfeff; 530 if (fReverse) 531 { 532 size_t i; 533 for (i = 0; i < strlen(manifest)+1; i++) 534 wmanifest[i] = (wmanifest[i] << 8) | ((wmanifest[i] >> 8) & 0xff); 535 } 536 ret = create_manifest_file(filename, (char *)&wmanifest[offset], (strlen(manifest)+1-offset) * sizeof(WCHAR), NULL, NULL); 537 HeapFree(GetProcessHeap(), 0, wmanifest); 538 return ret; 539 } 540 541 typedef struct { 542 ULONG format_version; 543 ULONG assembly_cnt_min; 544 ULONG assembly_cnt_max; 545 ULONG root_manifest_type; 546 LPWSTR root_manifest_path; 547 ULONG root_config_type; 548 ULONG app_dir_type; 549 LPCWSTR app_dir; 550 } detailed_info_t; 551 552 static const detailed_info_t detailed_info0 = { 553 0, 0, 0, 0, NULL, 0, 0, NULL 554 }; 555 556 static const detailed_info_t detailed_info1 = { 557 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path, 558 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, 559 work_dir, 560 }; 561 562 static const detailed_info_t detailed_info1_child = { 563 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, app_manifest_path, 564 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, 565 app_dir, 566 }; 567 568 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */ 569 static const detailed_info_t detailed_info2 = { 570 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path, 571 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, 572 work_dir, 573 }; 574 575 static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int line) 576 { 577 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp, *detailed_info; 578 SIZE_T size, exsize, retsize; 579 BOOL b; 580 581 exsize = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION) 582 + (exinfo->root_manifest_path ? (lstrlenW(exinfo->root_manifest_path)+1)*sizeof(WCHAR):0) 583 + (exinfo->app_dir ? (lstrlenW(exinfo->app_dir)+1)*sizeof(WCHAR) : 0); 584 585 if(exsize != sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)) { 586 size = 0xdeadbeef; 587 b = pQueryActCtxW(0, handle, NULL, 588 ActivationContextDetailedInformation, &detailed_info_tmp, 589 sizeof(detailed_info_tmp), &size); 590 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n"); 591 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); 592 ok_(__FILE__, line)(size == exsize, "size=%ld, expected %ld\n", size, exsize); 593 }else { 594 size = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION); 595 } 596 597 detailed_info = HeapAlloc(GetProcessHeap(), 0, size); 598 memset(detailed_info, 0xfe, size); 599 b = pQueryActCtxW(0, handle, NULL, 600 ActivationContextDetailedInformation, detailed_info, 601 size, &retsize); 602 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); 603 ok_(__FILE__, line)(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize); 604 605 ok_(__FILE__, line)(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags); 606 ok_(__FILE__, line)(detailed_info->ulFormatVersion == exinfo->format_version, 607 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info->ulFormatVersion, 608 exinfo->format_version); 609 ok_(__FILE__, line)(exinfo->assembly_cnt_min <= detailed_info->ulAssemblyCount && 610 detailed_info->ulAssemblyCount <= exinfo->assembly_cnt_max, 611 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info->ulAssemblyCount, 612 exinfo->assembly_cnt_min, exinfo->assembly_cnt_max); 613 ok_(__FILE__, line)(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type, 614 "detailed_info->ulRootManifestPathType=%u, expected %u\n", 615 detailed_info->ulRootManifestPathType, exinfo->root_manifest_type); 616 ok_(__FILE__, line)(detailed_info->ulRootManifestPathChars == 617 (exinfo->root_manifest_path ? lstrlenW(exinfo->root_manifest_path) : 0), 618 "detailed_info->ulRootManifestPathChars=%u, expected %u\n", 619 detailed_info->ulRootManifestPathChars, 620 exinfo->root_manifest_path ?lstrlenW(exinfo->root_manifest_path) : 0); 621 ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type, 622 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n", 623 detailed_info->ulRootConfigurationPathType, exinfo->root_config_type); 624 ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathChars == 0, 625 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info->ulRootConfigurationPathChars); 626 ok_(__FILE__, line)(detailed_info->ulAppDirPathType == exinfo->app_dir_type, 627 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info->ulAppDirPathType, 628 exinfo->app_dir_type); 629 ok_(__FILE__, line)(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0), 630 "detailed_info->ulAppDirPathChars=%u, expected %u\n", 631 detailed_info->ulAppDirPathChars, exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0); 632 if(exinfo->root_manifest_path) { 633 ok_(__FILE__, line)(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n"); 634 if(detailed_info->lpRootManifestPath) 635 ok_(__FILE__, line)(!lstrcmpiW(detailed_info->lpRootManifestPath, exinfo->root_manifest_path), 636 "unexpected detailed_info->lpRootManifestPath\n"); 637 }else { 638 ok_(__FILE__, line)(detailed_info->lpRootManifestPath == NULL, "detailed_info->lpRootManifestPath != NULL\n"); 639 } 640 ok_(__FILE__, line)(detailed_info->lpRootConfigurationPath == NULL, 641 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info->lpRootConfigurationPath); 642 if(exinfo->app_dir) { 643 ok_(__FILE__, line)(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n"); 644 if(detailed_info->lpAppDirPath) 645 ok_(__FILE__, line)(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath), 646 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info->lpAppDirPath)); 647 }else { 648 ok_(__FILE__, line)(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n"); 649 } 650 651 HeapFree(GetProcessHeap(), 0, detailed_info); 652 } 653 654 typedef struct { 655 ULONG flags; 656 /* ULONG manifest_path_type; FIXME */ 657 LPCWSTR manifest_path; 658 LPCSTR encoded_assembly_id; 659 BOOL has_assembly_dir; 660 } info_in_assembly; 661 662 static const info_in_assembly manifest1_info = { 663 1, manifest_path, 664 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"", 665 FALSE 666 }; 667 668 static const info_in_assembly manifest1_child_info = { 669 1, app_manifest_path, 670 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"", 671 FALSE 672 }; 673 674 static const info_in_assembly manifest2_info = { 675 1, manifest_path, 676 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"", 677 FALSE 678 }; 679 680 static const info_in_assembly manifest3_info = { 681 1, manifest_path, 682 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"", 683 FALSE 684 }; 685 686 static const info_in_assembly manifest4_info = { 687 1, manifest_path, 688 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"", 689 FALSE 690 }; 691 692 static const info_in_assembly depmanifest1_info = { 693 0x10, depmanifest_path, 694 "testdep,processorArchitecture=\"" ARCH "\"," 695 "type=\"win32\",version=\"6.5.4.3\"", 696 TRUE 697 }; 698 699 static const info_in_assembly depmanifest2_info = { 700 0x10, depmanifest_path, 701 "testdep,processorArchitecture=\"" ARCH "\"," 702 "type=\"win32\",version=\"6.5.4.3\"", 703 TRUE 704 }; 705 706 static const info_in_assembly depmanifest3_info = { 707 0x10, depmanifest_path, 708 "testdep,processorArchitecture=\"" ARCH "\",type=\"win32\",version=\"6.5.4.3\"", 709 TRUE 710 }; 711 712 static const info_in_assembly manifest_comctrl_info = { 713 0, NULL, NULL, TRUE /* These values may differ between Windows installations */ 714 }; 715 716 static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembly *exinfo, int line) 717 { 718 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info, info_tmp; 719 SIZE_T size, exsize; 720 ULONG len; 721 BOOL b; 722 723 exsize = sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION); 724 if (exinfo->manifest_path) exsize += (lstrlenW(exinfo->manifest_path)+1) * sizeof(WCHAR); 725 if (exinfo->encoded_assembly_id) exsize += (strlen_aw(exinfo->encoded_assembly_id) + 1) * sizeof(WCHAR); 726 727 size = 0xdeadbeef; 728 b = pQueryActCtxW(0, handle, &id, 729 AssemblyDetailedInformationInActivationContext, &info_tmp, 730 sizeof(info_tmp), &size); 731 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n"); 732 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); 733 734 ok_(__FILE__, line)(size >= exsize, "size=%lu, expected %lu\n", size, exsize); 735 736 if (size == 0xdeadbeef) 737 { 738 skip("bad size\n"); 739 return; 740 } 741 742 info = HeapAlloc(GetProcessHeap(), 0, size); 743 memset(info, 0xfe, size); 744 745 size = 0xdeadbeef; 746 b = pQueryActCtxW(0, handle, &id, 747 AssemblyDetailedInformationInActivationContext, info, size, &size); 748 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); 749 if (!exinfo->manifest_path) 750 exsize += info->ulManifestPathLength + sizeof(WCHAR); 751 if (!exinfo->encoded_assembly_id) 752 exsize += info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR); 753 if (exinfo->has_assembly_dir) 754 exsize += info->ulAssemblyDirectoryNameLength + sizeof(WCHAR); 755 ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize); 756 757 if (0) /* FIXME: flags meaning unknown */ 758 { 759 ok_(__FILE__, line)((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n", 760 info->ulFlags, exinfo->flags); 761 } 762 if(exinfo->encoded_assembly_id) { 763 len = strlen_aw(exinfo->encoded_assembly_id)*sizeof(WCHAR); 764 ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength == len, 765 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n", 766 info->ulEncodedAssemblyIdentityLength, len); 767 } else { 768 ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength != 0, 769 "info->ulEncodedAssemblyIdentityLength == 0\n"); 770 } 771 ok_(__FILE__, line)(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, 772 "info->ulManifestPathType = %x\n", info->ulManifestPathType); 773 if(exinfo->manifest_path) { 774 len = lstrlenW(exinfo->manifest_path)*sizeof(WCHAR); 775 ok_(__FILE__, line)(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n", 776 info->ulManifestPathLength, len); 777 } else { 778 ok_(__FILE__, line)(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n"); 779 } 780 781 ok_(__FILE__, line)(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE, 782 "info->ulPolicyPathType = %x\n", info->ulPolicyPathType); 783 ok_(__FILE__, line)(info->ulPolicyPathLength == 0, 784 "info->ulPolicyPathLength = %u, expected 0\n", info->ulPolicyPathLength); 785 ok_(__FILE__, line)(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n", 786 info->ulMetadataSatelliteRosterIndex); 787 ok_(__FILE__, line)(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n", 788 info->ulManifestVersionMajor); 789 ok_(__FILE__, line)(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n", 790 info->ulManifestVersionMinor); 791 ok_(__FILE__, line)(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n", 792 info->ulPolicyVersionMajor); 793 ok_(__FILE__, line)(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n", 794 info->ulPolicyVersionMinor); 795 if(exinfo->has_assembly_dir) 796 ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength != 0, 797 "info->ulAssemblyDirectoryNameLength == 0\n"); 798 else 799 ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength == 0, 800 "info->ulAssemblyDirectoryNameLength != 0\n"); 801 802 ok_(__FILE__, line)(info->lpAssemblyEncodedAssemblyIdentity != NULL, 803 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n"); 804 if(info->lpAssemblyEncodedAssemblyIdentity && exinfo->encoded_assembly_id) { 805 ok_(__FILE__, line)(!strcmp_aw(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id), 806 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n", 807 strw(info->lpAssemblyEncodedAssemblyIdentity), exinfo->encoded_assembly_id); 808 } 809 if(exinfo->manifest_path) { 810 ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n"); 811 if(info->lpAssemblyManifestPath) 812 ok_(__FILE__, line)(!lstrcmpiW(info->lpAssemblyManifestPath, exinfo->manifest_path), 813 "unexpected info->lpAssemblyManifestPath\n"); 814 }else { 815 ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n"); 816 } 817 818 ok_(__FILE__, line)(info->lpAssemblyPolicyPath == NULL, "info->lpAssemblyPolicyPath != NULL\n"); 819 if(info->lpAssemblyPolicyPath) 820 ok_(__FILE__, line)(*(WORD*)info->lpAssemblyPolicyPath == 0, "info->lpAssemblyPolicyPath is not empty\n"); 821 if(exinfo->has_assembly_dir) 822 ok_(__FILE__, line)(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n"); 823 else 824 ok_(__FILE__, line)(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n", 825 strw(info->lpAssemblyDirectoryName)); 826 HeapFree(GetProcessHeap(), 0, info); 827 } 828 829 static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR filename, int line) 830 { 831 ASSEMBLY_FILE_DETAILED_INFORMATION *info, info_tmp; 832 ACTIVATION_CONTEXT_QUERY_INDEX index = {assid, fileid}; 833 SIZE_T size, exsize; 834 BOOL b; 835 836 exsize = sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION) 837 +(lstrlenW(filename)+1)*sizeof(WCHAR); 838 839 size = 0xdeadbeef; 840 b = pQueryActCtxW(0, handle, &index, 841 FileInformationInAssemblyOfAssemblyInActivationContext, &info_tmp, 842 sizeof(info_tmp), &size); 843 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n"); 844 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); 845 ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize); 846 847 if(size == 0xdeadbeef) 848 { 849 skip("bad size\n"); 850 return; 851 } 852 853 info = HeapAlloc(GetProcessHeap(), 0, size); 854 memset(info, 0xfe, size); 855 856 b = pQueryActCtxW(0, handle, &index, 857 FileInformationInAssemblyOfAssemblyInActivationContext, info, size, &size); 858 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); 859 ok_(__FILE__, line)(!size, "size=%lu, expected 0\n", size); 860 861 ok_(__FILE__, line)(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags); 862 ok_(__FILE__, line)(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR), 863 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n", 864 info->ulFilenameLength, lstrlenW(filename)); 865 ok_(__FILE__, line)(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength); 866 ok_(__FILE__, line)(info->lpFileName != NULL, "info->lpFileName == NULL\n"); 867 if(info->lpFileName) 868 ok_(__FILE__, line)(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n"); 869 ok_(__FILE__, line)(info->lpFilePath == NULL, "info->lpFilePath != NULL\n"); 870 HeapFree(GetProcessHeap(), 0, info); 871 } 872 873 typedef struct { 874 ACTCTX_REQUESTED_RUN_LEVEL run_level; 875 DWORD ui_access; 876 } runlevel_info_t; 877 878 static const runlevel_info_t runlevel_info0 = { 879 ACTCTX_RUN_LEVEL_UNSPECIFIED, FALSE, 880 }; 881 882 static const runlevel_info_t runlevel_info6 = { 883 ACTCTX_RUN_LEVEL_AS_INVOKER, FALSE, 884 }; 885 886 static const runlevel_info_t runlevel_info7 = { 887 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, TRUE, 888 }; 889 890 static const runlevel_info_t runlevel_info8 = { 891 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, TRUE, 892 }; 893 894 static const runlevel_info_t runlevel_info9 = { 895 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, FALSE, 896 }; 897 898 static void test_runlevel_info(HANDLE handle, const runlevel_info_t *exinfo, int line) 899 { 900 ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel_info; 901 SIZE_T size, retsize; 902 BOOL b; 903 904 size = sizeof(runlevel_info); 905 b = pQueryActCtxW(0, handle, NULL, 906 RunlevelInformationInActivationContext, &runlevel_info, 907 sizeof(runlevel_info), &retsize); 908 if (!b && GetLastError() == ERROR_INVALID_PARAMETER) 909 { 910 win_skip("RunlevelInformationInActivationContext not supported.\n"); 911 return; 912 } 913 914 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); 915 ok_(__FILE__, line)(retsize == size, "size=%ld, expected %ld\n", retsize, size); 916 917 ok_(__FILE__, line)(runlevel_info.ulFlags == 0, "runlevel_info.ulFlags=%x\n", runlevel_info.ulFlags); 918 ok_(__FILE__, line)(runlevel_info.RunLevel == exinfo->run_level, 919 "runlevel_info.RunLevel=%u, expected %u\n", runlevel_info.RunLevel, exinfo->run_level); 920 ok_(__FILE__, line)(runlevel_info.UiAccess == exinfo->ui_access, 921 "runlevel_info.UiAccess=%u, expected %u\n", runlevel_info.UiAccess, exinfo->ui_access); 922 } 923 924 static HANDLE test_create(const char *file) 925 { 926 ACTCTXW actctx; 927 HANDLE handle; 928 WCHAR path[MAX_PATH]; 929 930 MultiByteToWideChar( CP_ACP, 0, file, -1, path, MAX_PATH ); 931 memset(&actctx, 0, sizeof(ACTCTXW)); 932 actctx.cbSize = sizeof(ACTCTXW); 933 actctx.lpSource = path; 934 935 handle = pCreateActCtxW(&actctx); 936 /* to be tested outside of this helper, including last error */ 937 if (handle == INVALID_HANDLE_VALUE) return handle; 938 939 ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize); 940 ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags); 941 ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource); 942 ok(actctx.wProcessorArchitecture == 0, 943 "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture); 944 ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId); 945 ok(actctx.lpAssemblyDirectory == NULL, 946 "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory); 947 ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName); 948 ok(actctx.lpApplicationName == NULL, "actctx.lpApplicationName=%p\n", 949 actctx.lpApplicationName); 950 ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule); 951 952 return handle; 953 } 954 955 static void test_create_and_fail(const char *manifest, const char *depmanifest, int todo, BOOL is_broken) 956 { 957 ACTCTXW actctx; 958 HANDLE handle; 959 WCHAR path[MAX_PATH]; 960 961 MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH ); 962 memset(&actctx, 0, sizeof(ACTCTXW)); 963 actctx.cbSize = sizeof(ACTCTXW); 964 actctx.lpSource = path; 965 966 create_manifest_file("bad.manifest", manifest, -1, "testdep.manifest", depmanifest); 967 handle = pCreateActCtxW(&actctx); 968 todo_wine_if(todo) 969 { 970 if (is_broken) 971 ok(broken(handle != INVALID_HANDLE_VALUE) || handle == INVALID_HANDLE_VALUE, 972 "Unexpected context handle %p.\n", handle); 973 else 974 ok(handle == INVALID_HANDLE_VALUE, "Unexpected context handle %p.\n", handle); 975 976 if (handle == INVALID_HANDLE_VALUE) 977 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "Unexpected error %d.\n", GetLastError()); 978 } 979 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle ); 980 DeleteFileA("bad.manifest"); 981 DeleteFileA("testdep.manifest"); 982 } 983 984 static void test_create_wide_and_fail(const char *manifest, BOOL fBOM) 985 { 986 ACTCTXW actctx; 987 HANDLE handle; 988 WCHAR path[MAX_PATH]; 989 990 MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH ); 991 memset(&actctx, 0, sizeof(ACTCTXW)); 992 actctx.cbSize = sizeof(ACTCTXW); 993 actctx.lpSource = path; 994 995 create_wide_manifest("bad.manifest", manifest, fBOM, FALSE); 996 handle = pCreateActCtxW(&actctx); 997 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n"); 998 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError()); 999 1000 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle ); 1001 DeleteFileA("bad.manifest"); 1002 } 1003 1004 static void test_create_fail(void) 1005 { 1006 ACTCTXW actctx; 1007 HANDLE handle; 1008 WCHAR path[MAX_PATH]; 1009 1010 MultiByteToWideChar( CP_ACP, 0, "nonexistent.manifest", -1, path, MAX_PATH ); 1011 memset(&actctx, 0, sizeof(ACTCTXW)); 1012 actctx.cbSize = sizeof(ACTCTXW); 1013 actctx.lpSource = path; 1014 1015 handle = pCreateActCtxW(&actctx); 1016 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n"); 1017 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError == %u\n", GetLastError()); 1018 1019 trace("wrong_manifest1\n"); 1020 test_create_and_fail(wrong_manifest1, NULL, 0, FALSE); 1021 trace("wrong_manifest2\n"); 1022 test_create_and_fail(wrong_manifest2, NULL, 0, FALSE); 1023 trace("wrong_manifest3\n"); 1024 test_create_and_fail(wrong_manifest3, NULL, 1, FALSE); 1025 trace("wrong_manifest4\n"); 1026 test_create_and_fail(wrong_manifest4, NULL, 1, FALSE); 1027 trace("wrong_manifest5\n"); 1028 test_create_and_fail(wrong_manifest5, NULL, 0, FALSE); 1029 trace("wrong_manifest6\n"); 1030 test_create_and_fail(wrong_manifest6, NULL, 0, FALSE); 1031 trace("wrong_manifest7\n"); 1032 test_create_and_fail(wrong_manifest7, NULL, 1, FALSE); 1033 trace("wrong_manifest8\n"); 1034 test_create_and_fail(wrong_manifest8, NULL, 0, FALSE); 1035 trace("wrong_manifest9\n"); 1036 test_create_and_fail(wrong_manifest9, NULL, 0, TRUE /* WinXP */); 1037 trace("wrong_manifest10\n"); 1038 test_create_and_fail(wrong_manifest10, NULL, 0, TRUE /* WinXP */); 1039 trace("UTF-16 manifest1 without BOM\n"); 1040 test_create_wide_and_fail(manifest1, FALSE ); 1041 trace("manifest2\n"); 1042 test_create_and_fail(manifest2, NULL, 0, FALSE); 1043 trace("manifest2+depmanifest1\n"); 1044 test_create_and_fail(manifest2, wrong_depmanifest1, 0, FALSE); 1045 } 1046 1047 struct strsection_header 1048 { 1049 DWORD magic; 1050 ULONG size; 1051 DWORD unk1[3]; 1052 ULONG count; 1053 ULONG index_offset; 1054 DWORD unk2[2]; 1055 ULONG global_offset; 1056 ULONG global_len; 1057 }; 1058 1059 struct string_index 1060 { 1061 ULONG hash; 1062 ULONG name_offset; 1063 ULONG name_len; 1064 ULONG data_offset; 1065 ULONG data_len; 1066 ULONG rosterindex; 1067 }; 1068 1069 struct guidsection_header 1070 { 1071 DWORD magic; 1072 ULONG size; 1073 DWORD unk[3]; 1074 ULONG count; 1075 ULONG index_offset; 1076 DWORD unk2; 1077 ULONG names_offset; 1078 ULONG names_len; 1079 }; 1080 1081 struct guid_index 1082 { 1083 GUID guid; 1084 ULONG data_offset; 1085 ULONG data_len; 1086 ULONG rosterindex; 1087 }; 1088 1089 struct wndclass_redirect_data 1090 { 1091 ULONG size; 1092 DWORD res; 1093 ULONG name_len; 1094 ULONG name_offset; /* versioned name offset */ 1095 ULONG module_len; 1096 ULONG module_offset;/* container name offset */ 1097 }; 1098 1099 struct dllredirect_data 1100 { 1101 ULONG size; 1102 ULONG unk; 1103 DWORD res[3]; 1104 }; 1105 1106 struct tlibredirect_data 1107 { 1108 ULONG size; 1109 DWORD res; 1110 ULONG name_len; 1111 ULONG name_offset; 1112 LANGID langid; 1113 WORD flags; 1114 ULONG help_len; 1115 ULONG help_offset; 1116 WORD major_version; 1117 WORD minor_version; 1118 }; 1119 1120 struct progidredirect_data 1121 { 1122 ULONG size; 1123 DWORD reserved; 1124 ULONG clsid_offset; 1125 }; 1126 1127 static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid, int line) 1128 { 1129 ACTCTX_SECTION_KEYED_DATA data; 1130 BOOL ret; 1131 1132 memset(&data, 0xfe, sizeof(data)); 1133 data.cbSize = sizeof(data); 1134 1135 ret = pFindActCtxSectionStringW(0, NULL, 1136 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1137 libname, &data); 1138 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); 1139 if (!ret) return; 1140 1141 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1142 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1143 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1144 ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength); 1145 1146 if (data.lpData) 1147 { 1148 struct dllredirect_data *dlldata = (struct dllredirect_data*)data.lpData; 1149 ok_(__FILE__, line)(dlldata->size == data.ulLength, "got wrong size %d\n", dlldata->size); 1150 ok_(__FILE__, line)(dlldata->unk == 2, "got wrong field value %d\n", dlldata->unk); 1151 ok_(__FILE__, line)(dlldata->res[0] == 0, "got wrong res[0] value %d\n", dlldata->res[0]); 1152 ok_(__FILE__, line)(dlldata->res[1] == 0, "got wrong res[1] value %d\n", dlldata->res[1]); 1153 ok_(__FILE__, line)(dlldata->res[2] == 0, "got wrong res[2] value %d\n", dlldata->res[2]); 1154 } 1155 1156 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); 1157 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", 1158 data.ulSectionGlobalDataLength); 1159 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1160 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", 1161 data.ulSectionTotalLength); 1162 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); 1163 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1164 data.ulAssemblyRosterIndex, exid); 1165 1166 memset(&data, 0xfe, sizeof(data)); 1167 data.cbSize = sizeof(data); 1168 1169 ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL, 1170 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1171 libname, &data); 1172 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); 1173 if (!ret) return; 1174 1175 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1176 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1177 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1178 ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength); 1179 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); 1180 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", 1181 data.ulSectionGlobalDataLength); 1182 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1183 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", 1184 data.ulSectionTotalLength); 1185 ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx); 1186 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1187 data.ulAssemblyRosterIndex, exid); 1188 1189 pReleaseActCtx(handle); 1190 } 1191 1192 static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, int line) 1193 { 1194 struct wndclass_redirect_data *wnddata; 1195 struct strsection_header *header; 1196 ACTCTX_SECTION_KEYED_DATA data; 1197 BOOL ret; 1198 1199 memset(&data, 0xfe, sizeof(data)); 1200 data.cbSize = sizeof(data); 1201 1202 ret = pFindActCtxSectionStringW(0, NULL, 1203 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, 1204 clsname, &data); 1205 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(), 1206 wine_dbgstr_w(clsname)); 1207 if (!ret) return; 1208 1209 header = (struct strsection_header*)data.lpSectionBase; 1210 wnddata = (struct wndclass_redirect_data*)data.lpData; 1211 1212 ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08x\n", header->magic); 1213 ok_(__FILE__, line)(header->count > 0, "got count %d\n", header->count); 1214 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1215 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1216 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1217 ok_(__FILE__, line)(wnddata->size == sizeof(*wnddata), "got %d for header size\n", wnddata->size); 1218 if (data.lpData && wnddata->size == sizeof(*wnddata)) 1219 { 1220 static const WCHAR verW[] = {'6','.','5','.','4','.','3','!',0}; 1221 WCHAR buff[50]; 1222 WCHAR *ptr; 1223 ULONG len; 1224 1225 ok_(__FILE__, line)(wnddata->res == 0, "got reserved as %d\n", wnddata->res); 1226 /* redirect class name (versioned or not) is stored just after header data */ 1227 ok_(__FILE__, line)(wnddata->name_offset == wnddata->size, "got name offset as %d\n", wnddata->name_offset); 1228 ok_(__FILE__, line)(wnddata->module_len > 0, "got module name length as %d\n", wnddata->module_len); 1229 1230 /* expected versioned name */ 1231 lstrcpyW(buff, verW); 1232 lstrcatW(buff, clsname); 1233 ptr = (WCHAR*)((BYTE*)wnddata + wnddata->name_offset); 1234 ok_(__FILE__, line)(!lstrcmpW(ptr, buff), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(buff)); 1235 ok_(__FILE__, line)(lstrlenW(ptr)*sizeof(WCHAR) == wnddata->name_len, 1236 "got wrong class name length %d, expected %d\n", wnddata->name_len, lstrlenW(ptr)); 1237 1238 /* data length is simply header length + string data length including nulls */ 1239 len = wnddata->size + wnddata->name_len + wnddata->module_len + 2*sizeof(WCHAR); 1240 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len); 1241 1242 if (data.ulSectionTotalLength > wnddata->module_offset) 1243 { 1244 WCHAR *modulename, *sectionptr; 1245 1246 /* just compare pointers */ 1247 modulename = (WCHAR*)((BYTE*)wnddata + wnddata->size + wnddata->name_len + sizeof(WCHAR)); 1248 sectionptr = (WCHAR*)((BYTE*)data.lpSectionBase + wnddata->module_offset); 1249 ok_(__FILE__, line)(modulename == sectionptr, "got wrong name offset %p, expected %p\n", sectionptr, modulename); 1250 } 1251 } 1252 1253 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); 1254 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", 1255 data.ulSectionGlobalDataLength); 1256 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1257 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", 1258 data.ulSectionTotalLength); 1259 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); 1260 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1261 data.ulAssemblyRosterIndex, exid); 1262 1263 memset(&data, 0xfe, sizeof(data)); 1264 data.cbSize = sizeof(data); 1265 1266 ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL, 1267 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, 1268 clsname, &data); 1269 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(), 1270 wine_dbgstr_w(clsname)); 1271 if (!ret) return; 1272 1273 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1274 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1275 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1276 ok_(__FILE__, line)(data.ulLength > 0, "data.ulLength=%u\n", data.ulLength); 1277 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); 1278 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", 1279 data.ulSectionGlobalDataLength); 1280 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1281 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength); 1282 ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx); 1283 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1284 data.ulAssemblyRosterIndex, exid); 1285 1286 pReleaseActCtx(handle); 1287 } 1288 1289 static void test_find_string_fail(void) 1290 { 1291 ACTCTX_SECTION_KEYED_DATA data = {sizeof(data)}; 1292 BOOL ret; 1293 1294 ret = pFindActCtxSectionStringW(0, NULL, 100, testlib_dll, &data); 1295 ok(!ret, "FindActCtxSectionStringW succeeded\n"); 1296 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND, "GetLastError()=%u\n", GetLastError()); 1297 1298 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1299 testlib2_dll, &data); 1300 ok(!ret, "FindActCtxSectionStringW succeeded\n"); 1301 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "GetLastError()=%u\n", GetLastError()); 1302 1303 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1304 testlib_dll, NULL); 1305 ok(!ret, "FindActCtxSectionStringW succeeded\n"); 1306 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError()); 1307 1308 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1309 NULL, &data); 1310 ok(!ret, "FindActCtxSectionStringW succeeded\n"); 1311 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError()); 1312 1313 data.cbSize = 0; 1314 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1315 testlib_dll, &data); 1316 ok(!ret, "FindActCtxSectionStringW succeeded\n"); 1317 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError()); 1318 1319 data.cbSize = 35; 1320 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1321 testlib_dll, &data); 1322 ok(!ret, "FindActCtxSectionStringW succeeded\n"); 1323 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError()); 1324 } 1325 1326 1327 static void test_basic_info(HANDLE handle, int line) 1328 { 1329 ACTIVATION_CONTEXT_BASIC_INFORMATION basic; 1330 SIZE_T size; 1331 BOOL b; 1332 1333 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL, 1334 ActivationContextBasicInformation, &basic, 1335 sizeof(basic), &size); 1336 1337 ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n"); 1338 ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n"); 1339 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); 1340 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n"); 1341 1342 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX | 1343 QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL, 1344 ActivationContextBasicInformation, &basic, 1345 sizeof(basic), &size); 1346 if (handle) 1347 { 1348 ok_(__FILE__, line) (!b,"ActivationContextBasicInformation succeeded\n"); 1349 ok_(__FILE__, line) (size == 0,"size mismatch\n"); 1350 ok_(__FILE__, line) (GetLastError() == ERROR_INVALID_PARAMETER, "Wrong last error\n"); 1351 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); 1352 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n"); 1353 } 1354 else 1355 { 1356 ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n"); 1357 ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n"); 1358 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); 1359 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n"); 1360 } 1361 } 1362 1363 enum comclass_threadingmodel { 1364 ThreadingModel_Apartment = 1, 1365 ThreadingModel_Free = 2, 1366 ThreadingModel_No = 3, 1367 ThreadingModel_Both = 4, 1368 ThreadingModel_Neutral = 5 1369 }; 1370 1371 enum comclass_miscfields { 1372 MiscStatus = 1, 1373 MiscStatusIcon = 2, 1374 MiscStatusContent = 4, 1375 MiscStatusThumbnail = 8, 1376 MiscStatusDocPrint = 16 1377 }; 1378 1379 struct comclassredirect_data { 1380 ULONG size; 1381 BYTE res; 1382 BYTE miscmask; 1383 BYTE res1[2]; 1384 DWORD model; 1385 GUID clsid; 1386 GUID alias; 1387 GUID clsid2; 1388 GUID tlid; 1389 ULONG name_len; 1390 ULONG name_offset; 1391 ULONG progid_len; 1392 ULONG progid_offset; 1393 ULONG clrdata_len; 1394 ULONG clrdata_offset; 1395 DWORD miscstatus; 1396 DWORD miscstatuscontent; 1397 DWORD miscstatusthumbnail; 1398 DWORD miscstatusicon; 1399 DWORD miscstatusdocprint; 1400 }; 1401 1402 struct clrclass_data { 1403 ULONG size; 1404 DWORD res[2]; 1405 ULONG module_len; 1406 ULONG module_offset; 1407 ULONG name_len; 1408 ULONG name_offset; 1409 ULONG version_len; 1410 ULONG version_offset; 1411 DWORD res2[2]; 1412 }; 1413 1414 static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GUID *tlid, const WCHAR *progid, ULONG exid, int line) 1415 { 1416 struct comclassredirect_data *comclass, *comclass2; 1417 ACTCTX_SECTION_KEYED_DATA data, data2; 1418 struct guidsection_header *header; 1419 BOOL ret; 1420 1421 memset(&data, 0xfe, sizeof(data)); 1422 data.cbSize = sizeof(data); 1423 1424 ret = pFindActCtxSectionGuid(0, NULL, 1425 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, 1426 clsid, &data); 1427 if (!ret) 1428 { 1429 skip("failed for guid %s\n", wine_dbgstr_guid(clsid)); 1430 return; 1431 } 1432 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError()); 1433 1434 comclass = (struct comclassredirect_data*)data.lpData; 1435 1436 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1437 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1438 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1439 ok_(__FILE__, line)(comclass->size == sizeof(*comclass), "got %d for header size\n", comclass->size); 1440 if (data.lpData && comclass->size == sizeof(*comclass)) 1441 { 1442 WCHAR *ptr; 1443 ULONG len; 1444 1445 ok_(__FILE__, line)(comclass->res == 0, "got res as %d\n", comclass->res); 1446 ok_(__FILE__, line)(comclass->res1[0] == 0, "got res1[0] as %02x\n", comclass->res1[0]); 1447 ok_(__FILE__, line)(comclass->res1[1] == 0, "got res1[1] as %02x\n", comclass->res1[1]); 1448 ok_(__FILE__, line)(comclass->model == ThreadingModel_Neutral, "got model %d\n", comclass->model); 1449 ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass->clsid)); 1450 ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid2, clsid), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass->clsid2)); 1451 if (tlid) 1452 ok_(__FILE__, line)(IsEqualGUID(&comclass->tlid, tlid), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass->tlid)); 1453 ok_(__FILE__, line)(comclass->name_len > 0, "got modulename len %d\n", comclass->name_len); 1454 1455 if (progid) 1456 { 1457 len = comclass->size + comclass->clrdata_len; 1458 ok_(__FILE__, line)(comclass->progid_offset == len, "got progid offset %d, expected %d\n", comclass->progid_offset, len); 1459 } 1460 else 1461 ok_(__FILE__, line)(comclass->progid_offset == 0, "got progid offset %d, expected 0\n", comclass->progid_offset); 1462 1463 if (comclass->progid_offset) 1464 { 1465 ptr = (WCHAR*)((BYTE*)comclass + comclass->progid_offset); 1466 ok_(__FILE__, line)(!lstrcmpW(ptr, progid), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(progid)); 1467 ok_(__FILE__, line)(lstrlenW(progid)*sizeof(WCHAR) == comclass->progid_len, 1468 "got progid name length %d\n", comclass->progid_len); 1469 } 1470 1471 /* data length is simply header length + string data length including nulls */ 1472 len = comclass->size + comclass->clrdata_len; 1473 if (comclass->progid_len) len += comclass->progid_len + sizeof(WCHAR); 1474 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len); 1475 1476 /* keyed data structure doesn't include module name, it's available from section data */ 1477 ok_(__FILE__, line)(data.ulSectionTotalLength > comclass->name_offset, "got wrong offset %d\n", comclass->name_offset); 1478 1479 /* check misc fields are set */ 1480 if (comclass->miscmask) 1481 { 1482 if (comclass->miscmask & MiscStatus) 1483 ok_(__FILE__, line)(comclass->miscstatus != 0, "got miscstatus 0x%08x\n", comclass->miscstatus); 1484 if (comclass->miscmask & MiscStatusIcon) 1485 ok_(__FILE__, line)(comclass->miscstatusicon != 0, "got miscstatusicon 0x%08x\n", comclass->miscstatusicon); 1486 if (comclass->miscmask & MiscStatusContent) 1487 ok_(__FILE__, line)(comclass->miscstatuscontent != 0, "got miscstatuscontent 0x%08x\n", comclass->miscstatuscontent); 1488 if (comclass->miscmask & MiscStatusThumbnail) 1489 ok_(__FILE__, line)(comclass->miscstatusthumbnail != 0, "got miscstatusthumbnail 0x%08x\n", comclass->miscstatusthumbnail); 1490 if (comclass->miscmask & MiscStatusDocPrint) 1491 ok_(__FILE__, line)(comclass->miscstatusdocprint != 0, "got miscstatusdocprint 0x%08x\n", comclass->miscstatusdocprint); 1492 } 1493 1494 /* part used for clrClass only */ 1495 if (comclass->clrdata_len) 1496 { 1497 static const WCHAR mscoreeW[] = {'M','S','C','O','R','E','E','.','D','L','L',0}; 1498 static const WCHAR mscoree2W[] = {'m','s','c','o','r','e','e','.','d','l','l',0}; 1499 struct clrclass_data *clrclass; 1500 WCHAR *ptrW; 1501 1502 clrclass = (struct clrclass_data*)((BYTE*)data.lpData + comclass->clrdata_offset); 1503 ok_(__FILE__, line)(clrclass->size == sizeof(*clrclass), "clrclass: got size %d\n", clrclass->size); 1504 ok_(__FILE__, line)(clrclass->res[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass->res[0]); 1505 ok_(__FILE__, line)(clrclass->res[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass->res[1]); 1506 ok_(__FILE__, line)(clrclass->module_len == lstrlenW(mscoreeW)*sizeof(WCHAR), "clrclass: got module len %d\n", clrclass->module_len); 1507 ok_(__FILE__, line)(clrclass->module_offset > 0, "clrclass: got module offset %d\n", clrclass->module_offset); 1508 1509 ok_(__FILE__, line)(clrclass->name_len > 0, "clrclass: got name len %d\n", clrclass->name_len); 1510 ok_(__FILE__, line)(clrclass->name_offset == clrclass->size, "clrclass: got name offset %d\n", clrclass->name_offset); 1511 ok_(__FILE__, line)(clrclass->version_len > 0, "clrclass: got version len %d\n", clrclass->version_len); 1512 ok_(__FILE__, line)(clrclass->version_offset > 0, "clrclass: got version offset %d\n", clrclass->version_offset); 1513 1514 ok_(__FILE__, line)(clrclass->res2[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass->res2[0]); 1515 ok_(__FILE__, line)(clrclass->res2[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass->res2[1]); 1516 1517 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name 1518 in lower case, clsclass subsection - in upper case */ 1519 ok_(__FILE__, line)(comclass->name_len == lstrlenW(mscoree2W)*sizeof(WCHAR), "clrclass: got com name len %d\n", comclass->name_len); 1520 ok_(__FILE__, line)(comclass->name_offset > 0, "clrclass: got name offset %d\n", clrclass->name_offset); 1521 1522 ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + comclass->name_offset); 1523 ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoreeW), "clrclass: module name %s\n", wine_dbgstr_w(ptrW)); 1524 1525 ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + clrclass->module_offset); 1526 ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoree2W), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW)); 1527 } 1528 } 1529 1530 header = (struct guidsection_header*)data.lpSectionBase; 1531 ok_(__FILE__, line)(data.lpSectionGlobalData == ((BYTE*)header + header->names_offset), "data.lpSectionGlobalData == NULL\n"); 1532 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%u\n", 1533 data.ulSectionGlobalDataLength); 1534 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1535 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", 1536 data.ulSectionTotalLength); 1537 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); 1538 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1539 data.ulAssemblyRosterIndex, exid); 1540 1541 /* generated guid for this class works as key guid in search */ 1542 memset(&data2, 0xfe, sizeof(data2)); 1543 data2.cbSize = sizeof(data2); 1544 ret = pFindActCtxSectionGuid(0, NULL, 1545 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, 1546 &comclass->alias, &data2); 1547 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError()); 1548 1549 comclass2 = (struct comclassredirect_data*)data2.lpData; 1550 ok_(__FILE__, line)(comclass->size == comclass2->size, "got wrong data length %d, expected %d\n", comclass2->size, comclass->size); 1551 ok_(__FILE__, line)(!memcmp(comclass, comclass2, comclass->size), "got wrong data\n"); 1552 } 1553 1554 enum ifaceps_mask 1555 { 1556 NumMethods = 1, 1557 BaseIface = 2 1558 }; 1559 1560 struct ifacepsredirect_data 1561 { 1562 ULONG size; 1563 DWORD mask; 1564 GUID iid; 1565 ULONG nummethods; 1566 GUID tlbid; 1567 GUID base; 1568 ULONG name_len; 1569 ULONG name_offset; 1570 }; 1571 1572 static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const GUID *tlbid, const GUID *base, 1573 const GUID *ps32, ULONG exid, int line) 1574 { 1575 struct ifacepsredirect_data *ifaceps; 1576 ACTCTX_SECTION_KEYED_DATA data; 1577 BOOL ret; 1578 1579 memset(&data, 0xfe, sizeof(data)); 1580 data.cbSize = sizeof(data); 1581 1582 ret = pFindActCtxSectionGuid(0, NULL, 1583 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION, 1584 iid, &data); 1585 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError()); 1586 1587 ifaceps = (struct ifacepsredirect_data*)data.lpData; 1588 1589 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1590 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1591 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1592 ok_(__FILE__, line)(ifaceps->size == sizeof(*ifaceps), "got %d for header size\n", ifaceps->size); 1593 if (data.lpData && ifaceps->size == sizeof(*ifaceps)) 1594 { 1595 ULONG len; 1596 1597 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */ 1598 if (ps32) 1599 { 1600 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, ps32), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid)); 1601 } 1602 else 1603 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, iid), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid)); 1604 1605 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->tlbid, tlbid), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps->tlbid)); 1606 ok_(__FILE__, line)(ifaceps->name_len > 0, "got modulename len %d\n", ifaceps->name_len); 1607 ok_(__FILE__, line)(ifaceps->name_offset == ifaceps->size, "got progid offset %d\n", ifaceps->name_offset); 1608 1609 /* data length is simply header length + string data length including nulls */ 1610 len = ifaceps->size + ifaceps->name_len + sizeof(WCHAR); 1611 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len); 1612 1613 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest 1614 always has non-zero value for it */ 1615 if (ifaceps->mask & NumMethods) 1616 ok_(__FILE__, line)(ifaceps->nummethods != 0, "got nummethods %d\n", ifaceps->nummethods); 1617 if (ifaceps->mask & BaseIface) 1618 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->base, base), "got base %s\n", wine_dbgstr_guid(&ifaceps->base)); 1619 } 1620 1621 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); 1622 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", 1623 data.ulSectionGlobalDataLength); 1624 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1625 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", 1626 data.ulSectionTotalLength); 1627 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); 1628 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1629 data.ulAssemblyRosterIndex, exid); 1630 } 1631 1632 struct clrsurrogate_data 1633 { 1634 ULONG size; 1635 DWORD res; 1636 GUID clsid; 1637 ULONG version_offset; 1638 ULONG version_len; 1639 ULONG name_offset; 1640 ULONG name_len; 1641 }; 1642 1643 static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *name, const WCHAR *version, 1644 ULONG exid, int line) 1645 { 1646 struct clrsurrogate_data *surrogate; 1647 ACTCTX_SECTION_KEYED_DATA data; 1648 BOOL ret; 1649 1650 memset(&data, 0xfe, sizeof(data)); 1651 data.cbSize = sizeof(data); 1652 1653 ret = pFindActCtxSectionGuid(0, NULL, 1654 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES, 1655 clsid, &data); 1656 if (!ret) 1657 { 1658 skip("surrogate sections are not supported\n"); 1659 return; 1660 } 1661 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError()); 1662 1663 surrogate = (struct clrsurrogate_data*)data.lpData; 1664 1665 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1666 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1667 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1668 ok_(__FILE__, line)(surrogate->size == sizeof(*surrogate), "got %d for header size\n", surrogate->size); 1669 if (data.lpData && surrogate->size == sizeof(*surrogate)) 1670 { 1671 WCHAR *ptrW; 1672 ULONG len; 1673 1674 ok_(__FILE__, line)(surrogate->res == 0, "invalid res value %d\n", surrogate->res); 1675 ok_(__FILE__, line)(IsEqualGUID(&surrogate->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate->clsid)); 1676 1677 ok_(__FILE__, line)(surrogate->version_len == lstrlenW(version)*sizeof(WCHAR), "got version len %d\n", surrogate->version_len); 1678 ok_(__FILE__, line)(surrogate->version_offset == surrogate->size, "got version offset %d\n", surrogate->version_offset); 1679 1680 ok_(__FILE__, line)(surrogate->name_len == lstrlenW(name)*sizeof(WCHAR), "got name len %d\n", surrogate->name_len); 1681 ok_(__FILE__, line)(surrogate->name_offset > surrogate->version_offset, "got name offset %d\n", surrogate->name_offset); 1682 1683 len = surrogate->size + surrogate->name_len + surrogate->version_len + 2*sizeof(WCHAR); 1684 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len); 1685 1686 ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->name_offset); 1687 ok(!lstrcmpW(ptrW, name), "got wrong name %s\n", wine_dbgstr_w(ptrW)); 1688 1689 ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->version_offset); 1690 ok(!lstrcmpW(ptrW, version), "got wrong name %s\n", wine_dbgstr_w(ptrW)); 1691 } 1692 1693 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); 1694 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", 1695 data.ulSectionGlobalDataLength); 1696 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1697 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", 1698 data.ulSectionTotalLength); 1699 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); 1700 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1701 data.ulAssemblyRosterIndex, exid); 1702 } 1703 1704 static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const char *progid, ULONG exid, int line) 1705 { 1706 struct progidredirect_data *progiddata; 1707 struct comclassredirect_data *comclass; 1708 ACTCTX_SECTION_KEYED_DATA data, data2; 1709 struct strsection_header *header; 1710 BOOL ret; 1711 1712 memset(&data, 0xfe, sizeof(data)); 1713 data.cbSize = sizeof(data); 1714 1715 ret = pFindActCtxSectionStringA(0, NULL, 1716 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION, 1717 progid, &data); 1718 ok_(__FILE__, line)(ret, "FindActCtxSectionStringA failed: %u\n", GetLastError()); 1719 1720 progiddata = (struct progidredirect_data*)data.lpData; 1721 1722 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); 1723 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); 1724 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); 1725 ok_(__FILE__, line)(progiddata->size == sizeof(*progiddata), "got %d for header size\n", progiddata->size); 1726 if (data.lpData && progiddata->size == sizeof(*progiddata)) 1727 { 1728 GUID *guid; 1729 1730 ok_(__FILE__, line)(progiddata->reserved == 0, "got reserved as %d\n", progiddata->reserved); 1731 ok_(__FILE__, line)(progiddata->clsid_offset > 0, "got clsid_offset as %d\n", progiddata->clsid_offset); 1732 1733 /* progid data points to generated alias guid */ 1734 guid = (GUID*)((BYTE*)data.lpSectionBase + progiddata->clsid_offset); 1735 1736 memset(&data2, 0, sizeof(data2)); 1737 data2.cbSize = sizeof(data2); 1738 ret = pFindActCtxSectionGuid(0, NULL, 1739 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, 1740 guid, &data2); 1741 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError()); 1742 1743 comclass = (struct comclassredirect_data*)data2.lpData; 1744 ok_(__FILE__, line)(IsEqualGUID(guid, &comclass->alias), "got wrong alias referenced from progid %s, %s\n", progid, wine_dbgstr_guid(guid)); 1745 ok_(__FILE__, line)(IsEqualGUID(clsid, &comclass->clsid), "got wrong class referenced from progid %s, %s\n", progid, wine_dbgstr_guid(clsid)); 1746 } 1747 1748 header = (struct strsection_header*)data.lpSectionBase; 1749 ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE*)header + header->global_offset, "data.lpSectionGlobalData == NULL\n"); 1750 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength); 1751 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); 1752 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength); 1753 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); 1754 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", 1755 data.ulAssemblyRosterIndex, exid); 1756 } 1757 1758 static void test_wndclass_section(void) 1759 { 1760 static const WCHAR cls1W[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0}; 1761 ACTCTX_SECTION_KEYED_DATA data, data2; 1762 struct wndclass_redirect_data *classdata; 1763 struct strsection_header *section; 1764 ULONG_PTR cookie; 1765 HANDLE handle; 1766 WCHAR *ptrW; 1767 BOOL ret; 1768 1769 /* use two dependent manifests, each defines 2 window class redirects */ 1770 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL); 1771 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL); 1772 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL); 1773 1774 handle = test_create("main_wndcls.manifest"); 1775 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 1776 1777 DeleteFileA("testdep1.manifest"); 1778 DeleteFileA("testdep2.manifest"); 1779 DeleteFileA("main_wndcls.manifest"); 1780 1781 ret = pActivateActCtx(handle, &cookie); 1782 ok(ret, "ActivateActCtx failed: %u\n", GetLastError()); 1783 1784 memset(&data, 0, sizeof(data)); 1785 memset(&data2, 0, sizeof(data2)); 1786 data.cbSize = sizeof(data); 1787 data2.cbSize = sizeof(data2); 1788 1789 /* get data for two classes from different assemblies */ 1790 ret = pFindActCtxSectionStringW(0, NULL, 1791 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, 1792 wndClass1W, &data); 1793 ok(ret, "got %d\n", ret); 1794 ret = pFindActCtxSectionStringW(0, NULL, 1795 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, 1796 wndClass3W, &data2); 1797 ok(ret, "got %d\n", ret); 1798 1799 section = (struct strsection_header*)data.lpSectionBase; 1800 ok(section->count == 4, "got %d\n", section->count); 1801 ok(section->size == sizeof(*section), "got %d\n", section->size); 1802 1803 /* For both string same section is returned, meaning it's one wndclass section per context */ 1804 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase); 1805 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength, 1806 data2.ulSectionTotalLength); 1807 1808 /* wndClass1 is versioned, wndClass3 is not */ 1809 classdata = (struct wndclass_redirect_data*)data.lpData; 1810 ptrW = (WCHAR*)((BYTE*)data.lpData + classdata->name_offset); 1811 ok(!lstrcmpW(ptrW, cls1W), "got %s\n", wine_dbgstr_w(ptrW)); 1812 1813 classdata = (struct wndclass_redirect_data*)data2.lpData; 1814 ptrW = (WCHAR*)((BYTE*)data2.lpData + classdata->name_offset); 1815 ok(!lstrcmpW(ptrW, wndClass3W), "got %s\n", wine_dbgstr_w(ptrW)); 1816 1817 ret = pDeactivateActCtx(0, cookie); 1818 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError()); 1819 1820 pReleaseActCtx(handle); 1821 } 1822 1823 static void test_dllredirect_section(void) 1824 { 1825 static const WCHAR testlib1W[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0}; 1826 static const WCHAR testlib2W[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0}; 1827 ACTCTX_SECTION_KEYED_DATA data, data2; 1828 struct strsection_header *section; 1829 ULONG_PTR cookie; 1830 HANDLE handle; 1831 BOOL ret; 1832 1833 /* use two dependent manifests, 4 'files' total */ 1834 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL); 1835 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL); 1836 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL); 1837 1838 handle = test_create("main_wndcls.manifest"); 1839 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 1840 1841 DeleteFileA("testdep1.manifest"); 1842 DeleteFileA("testdep2.manifest"); 1843 DeleteFileA("main_wndcls.manifest"); 1844 1845 ret = pActivateActCtx(handle, &cookie); 1846 ok(ret, "ActivateActCtx failed: %u\n", GetLastError()); 1847 1848 memset(&data, 0, sizeof(data)); 1849 memset(&data2, 0, sizeof(data2)); 1850 data.cbSize = sizeof(data); 1851 data2.cbSize = sizeof(data2); 1852 1853 /* get data for two files from different assemblies */ 1854 ret = pFindActCtxSectionStringW(0, NULL, 1855 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1856 testlib1W, &data); 1857 ok(ret, "got %d\n", ret); 1858 ret = pFindActCtxSectionStringW(0, NULL, 1859 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1860 testlib2W, &data2); 1861 ok(ret, "got %d\n", ret); 1862 1863 section = (struct strsection_header*)data.lpSectionBase; 1864 ok(section->count == 4, "got %d\n", section->count); 1865 ok(section->size == sizeof(*section), "got %d\n", section->size); 1866 1867 /* For both string same section is returned, meaning it's one dll redirect section per context */ 1868 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase); 1869 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength, 1870 data2.ulSectionTotalLength); 1871 1872 ret = pDeactivateActCtx(0, cookie); 1873 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError()); 1874 1875 pReleaseActCtx(handle); 1876 } 1877 1878 static void test_typelib_section(void) 1879 { 1880 static const WCHAR helpW[] = {'h','e','l','p'}; 1881 ACTCTX_SECTION_KEYED_DATA data, data2; 1882 struct guidsection_header *section; 1883 struct tlibredirect_data *tlib; 1884 ULONG_PTR cookie; 1885 HANDLE handle; 1886 BOOL ret; 1887 1888 /* use two dependent manifests, 4 'files' total */ 1889 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL); 1890 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL); 1891 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL); 1892 1893 handle = test_create("main_wndcls.manifest"); 1894 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 1895 1896 DeleteFileA("testdep1.manifest"); 1897 DeleteFileA("testdep2.manifest"); 1898 DeleteFileA("main_wndcls.manifest"); 1899 1900 ret = pActivateActCtx(handle, &cookie); 1901 ok(ret, "ActivateActCtx failed: %u\n", GetLastError()); 1902 1903 memset(&data, 0, sizeof(data)); 1904 memset(&data2, 0, sizeof(data2)); 1905 data.cbSize = sizeof(data); 1906 data2.cbSize = sizeof(data2); 1907 1908 /* get data for two typelibs from different assemblies */ 1909 ret = pFindActCtxSectionGuid(0, NULL, 1910 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION, 1911 &IID_TlibTest, &data); 1912 ok(ret, "got %d\n", ret); 1913 1914 ret = pFindActCtxSectionGuid(0, NULL, 1915 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION, 1916 &IID_TlibTest4, &data2); 1917 ok(ret, "got %d\n", ret); 1918 1919 section = (struct guidsection_header*)data.lpSectionBase; 1920 ok(section->count == 4, "got %d\n", section->count); 1921 ok(section->size == sizeof(*section), "got %d\n", section->size); 1922 1923 /* For both GUIDs same section is returned */ 1924 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase); 1925 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength, 1926 data2.ulSectionTotalLength); 1927 1928 ok(data.lpSectionGlobalData == ((BYTE*)section + section->names_offset), "data.lpSectionGlobalData == NULL\n"); 1929 ok(data.ulSectionGlobalDataLength == section->names_len, "data.ulSectionGlobalDataLength=%u\n", 1930 data.ulSectionGlobalDataLength); 1931 1932 /* test some actual data */ 1933 tlib = (struct tlibredirect_data*)data.lpData; 1934 ok(tlib->size == sizeof(*tlib), "got %d\n", tlib->size); 1935 ok(tlib->major_version == 1, "got %d\n", tlib->major_version); 1936 ok(tlib->minor_version == 0, "got %d\n", tlib->minor_version); 1937 ok(tlib->help_offset > 0, "got %d\n", tlib->help_offset); 1938 ok(tlib->help_len == sizeof(helpW), "got %d\n", tlib->help_len); 1939 ok(tlib->flags == (LIBFLAG_FHIDDEN|LIBFLAG_FCONTROL|LIBFLAG_FRESTRICTED), "got %x\n", tlib->flags); 1940 1941 ret = pDeactivateActCtx(0, cookie); 1942 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError()); 1943 1944 pReleaseActCtx(handle); 1945 } 1946 1947 static void test_allowDelayedBinding(void) 1948 { 1949 HANDLE handle; 1950 1951 if (!create_manifest_file("test5.manifest", manifest5, -1, NULL, NULL)) { 1952 skip("Could not create manifest file\n"); 1953 return; 1954 } 1955 1956 handle = test_create("test5.manifest"); 1957 if (handle == INVALID_HANDLE_VALUE) { 1958 win_skip("allowDelayedBinding attribute is not supported.\n"); 1959 return; 1960 } 1961 1962 DeleteFileA("test5.manifest"); 1963 DeleteFileA("testdep.manifest"); 1964 if (handle != INVALID_HANDLE_VALUE) { 1965 test_basic_info(handle, __LINE__); 1966 pReleaseActCtx(handle); 1967 } 1968 } 1969 1970 static void test_actctx(void) 1971 { 1972 ULONG_PTR cookie; 1973 HANDLE handle; 1974 BOOL b; 1975 1976 trace("default actctx\n"); 1977 1978 b = pGetCurrentActCtx(&handle); 1979 ok(handle == NULL, "handle = %p, expected NULL\n", handle); 1980 ok(b, "GetCurrentActCtx failed: %u\n", GetLastError()); 1981 if(b) { 1982 test_basic_info(handle, __LINE__); 1983 test_detailed_info(handle, &detailed_info0, __LINE__); 1984 test_runlevel_info(handle, &runlevel_info0, __LINE__); 1985 pReleaseActCtx(handle); 1986 } 1987 1988 /* test for whitespace handling in Eq ::= S? '=' S? */ 1989 create_manifest_file("test1_1.manifest", manifest1_1, -1, NULL, NULL); 1990 handle = test_create("test1_1.manifest"); 1991 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 1992 DeleteFileA("test1_1.manifest"); 1993 pReleaseActCtx(handle); 1994 1995 if(!create_manifest_file("test1.manifest", manifest1, -1, NULL, NULL)) { 1996 skip("Could not create manifest file\n"); 1997 return; 1998 } 1999 2000 trace("manifest1\n"); 2001 2002 handle = test_create("test1.manifest"); 2003 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2004 DeleteFileA("test1.manifest"); 2005 if(handle != INVALID_HANDLE_VALUE) { 2006 test_basic_info(handle, __LINE__); 2007 test_detailed_info(handle, &detailed_info1, __LINE__); 2008 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); 2009 2010 if (pIsDebuggerPresent && !pIsDebuggerPresent()) 2011 { 2012 /* CloseHandle will generate an exception if a debugger is present */ 2013 b = CloseHandle(handle); 2014 ok(!b, "CloseHandle succeeded\n"); 2015 ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() == %u\n", GetLastError()); 2016 } 2017 2018 pReleaseActCtx(handle); 2019 } 2020 2021 if(!create_manifest_file("test2.manifest", manifest2, -1, "testdep.manifest", testdep_manifest1)) { 2022 skip("Could not create manifest file\n"); 2023 return; 2024 } 2025 2026 trace("manifest2 depmanifest1\n"); 2027 2028 handle = test_create("test2.manifest"); 2029 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2030 DeleteFileA("test2.manifest"); 2031 DeleteFileA("testdep.manifest"); 2032 if(handle != INVALID_HANDLE_VALUE) { 2033 test_basic_info(handle, __LINE__); 2034 test_detailed_info(handle, &detailed_info2, __LINE__); 2035 test_info_in_assembly(handle, 1, &manifest2_info, __LINE__); 2036 test_info_in_assembly(handle, 2, &depmanifest1_info, __LINE__); 2037 pReleaseActCtx(handle); 2038 } 2039 2040 if(!create_manifest_file("test2-2.manifest", manifest2, -1, "testdep.manifest", testdep_manifest2)) { 2041 skip("Could not create manifest file\n"); 2042 return; 2043 } 2044 2045 trace("manifest2 depmanifest2\n"); 2046 2047 handle = test_create("test2-2.manifest"); 2048 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2049 DeleteFileA("test2-2.manifest"); 2050 DeleteFileA("testdep.manifest"); 2051 if(handle != INVALID_HANDLE_VALUE) { 2052 test_basic_info(handle, __LINE__); 2053 test_detailed_info(handle, &detailed_info2, __LINE__); 2054 test_info_in_assembly(handle, 1, &manifest2_info, __LINE__); 2055 test_info_in_assembly(handle, 2, &depmanifest2_info, __LINE__); 2056 test_file_info(handle, 1, 0, testlib_dll, __LINE__); 2057 test_file_info(handle, 1, 1, testlib2_dll, __LINE__); 2058 2059 b = pActivateActCtx(handle, &cookie); 2060 ok(b, "ActivateActCtx failed: %u\n", GetLastError()); 2061 test_find_dll_redirection(handle, testlib_dll, 2, __LINE__); 2062 test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__); 2063 b = pDeactivateActCtx(0, cookie); 2064 ok(b, "DeactivateActCtx failed: %u\n", GetLastError()); 2065 2066 pReleaseActCtx(handle); 2067 } 2068 2069 trace("manifest2 depmanifest3\n"); 2070 2071 if(!create_manifest_file("test2-3.manifest", manifest2, -1, "testdep.manifest", testdep_manifest3)) { 2072 skip("Could not create manifest file\n"); 2073 return; 2074 } 2075 2076 handle = test_create("test2-3.manifest"); 2077 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2078 DeleteFileA("test2-3.manifest"); 2079 DeleteFileA("testdep.manifest"); 2080 if(handle != INVALID_HANDLE_VALUE) { 2081 test_basic_info(handle, __LINE__); 2082 test_detailed_info(handle, &detailed_info2, __LINE__); 2083 test_info_in_assembly(handle, 1, &manifest2_info, __LINE__); 2084 test_info_in_assembly(handle, 2, &depmanifest3_info, __LINE__); 2085 test_file_info(handle, 1, 0, testlib_dll, __LINE__); 2086 test_file_info(handle, 1, 1, testlib2_dll, __LINE__); 2087 2088 b = pActivateActCtx(handle, &cookie); 2089 ok(b, "ActivateActCtx failed: %u\n", GetLastError()); 2090 test_find_dll_redirection(handle, testlib_dll, 2, __LINE__); 2091 test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__); 2092 test_find_window_class(handle, wndClassW, 2, __LINE__); 2093 test_find_window_class(handle, wndClass2W, 2, __LINE__); 2094 b = pDeactivateActCtx(0, cookie); 2095 ok(b, "DeactivateActCtx failed: %u\n", GetLastError()); 2096 2097 pReleaseActCtx(handle); 2098 } 2099 2100 trace("manifest3\n"); 2101 2102 if(!create_manifest_file("test3.manifest", manifest3, -1, NULL, NULL)) { 2103 skip("Could not create manifest file\n"); 2104 return; 2105 } 2106 2107 handle = test_create("test3.manifest"); 2108 ok(handle != INVALID_HANDLE_VALUE || broken(handle == INVALID_HANDLE_VALUE) /* XP pre-SP2, win2k3 w/o SP */, 2109 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2110 if (handle == INVALID_HANDLE_VALUE) 2111 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n"); 2112 DeleteFileA("test3.manifest"); 2113 if(handle != INVALID_HANDLE_VALUE) { 2114 static const WCHAR nameW[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0}; 2115 static const WCHAR versionW[] = {'v','2','.','0','.','5','0','7','2','7',0}; 2116 static const WCHAR progidW[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0}; 2117 static const WCHAR clrprogidW[] = {'c','l','r','p','r','o','g','i','d',0}; 2118 2119 test_basic_info(handle, __LINE__); 2120 test_detailed_info(handle, &detailed_info1, __LINE__); 2121 test_info_in_assembly(handle, 1, &manifest3_info, __LINE__); 2122 test_file_info(handle, 0, 0, testlib_dll, __LINE__); 2123 2124 b = pActivateActCtx(handle, &cookie); 2125 ok(b, "ActivateActCtx failed: %u\n", GetLastError()); 2126 test_find_dll_redirection(handle, testlib_dll, 1, __LINE__); 2127 test_find_dll_redirection(handle, testlib_dll, 1, __LINE__); 2128 test_find_com_redirection(handle, &IID_CoTest, &IID_TlibTest, progidW, 1, __LINE__); 2129 test_find_com_redirection(handle, &IID_CoTest2, NULL, NULL, 1, __LINE__); 2130 test_find_com_redirection(handle, &CLSID_clrclass, &IID_TlibTest, clrprogidW, 1, __LINE__); 2131 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId", 1, __LINE__); 2132 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.1", 1, __LINE__); 2133 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.2", 1, __LINE__); 2134 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.3", 1, __LINE__); 2135 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.4", 1, __LINE__); 2136 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.5", 1, __LINE__); 2137 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.6", 1, __LINE__); 2138 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid", 1, __LINE__); 2139 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.1", 1, __LINE__); 2140 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.2", 1, __LINE__); 2141 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.3", 1, __LINE__); 2142 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.4", 1, __LINE__); 2143 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.5", 1, __LINE__); 2144 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.6", 1, __LINE__); 2145 test_find_surrogate(handle, &IID_Iiface, nameW, versionW, 1, __LINE__); 2146 test_find_ifaceps_redirection(handle, &IID_Iifaceps, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__); 2147 test_find_ifaceps_redirection(handle, &IID_Iifaceps2, &IID_TlibTest4, &IID_Ibifaceps, &IID_PS32, 1, __LINE__); 2148 test_find_ifaceps_redirection(handle, &IID_Iifaceps3, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__); 2149 test_find_string_fail(); 2150 2151 b = pDeactivateActCtx(0, cookie); 2152 ok(b, "DeactivateActCtx failed: %u\n", GetLastError()); 2153 pReleaseActCtx(handle); 2154 } 2155 2156 trace("manifest6\n"); 2157 2158 if(create_manifest_file("test6.manifest", manifest6, -1, NULL, NULL)) { 2159 handle = test_create("test6.manifest"); 2160 ok(handle != INVALID_HANDLE_VALUE || broken(handle == INVALID_HANDLE_VALUE) /* WinXP */, 2161 "Unexpected context handle %p.\n", handle); 2162 DeleteFileA("test6.manifest"); 2163 DeleteFileA("testdep.manifest"); 2164 if(handle != INVALID_HANDLE_VALUE) 2165 { 2166 test_runlevel_info(handle, &runlevel_info6, __LINE__); 2167 pReleaseActCtx(handle); 2168 } 2169 } 2170 else 2171 skip("Could not create manifest file 6\n"); 2172 2173 trace("manifest7\n"); 2174 2175 if(create_manifest_file("test7.manifest", manifest7, -1, NULL, NULL)) { 2176 handle = test_create("test7.manifest"); 2177 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2178 DeleteFileA("test7.manifest"); 2179 DeleteFileA("testdep.manifest"); 2180 if(handle != INVALID_HANDLE_VALUE) 2181 { 2182 test_runlevel_info(handle, &runlevel_info7, __LINE__); 2183 pReleaseActCtx(handle); 2184 } 2185 } 2186 else 2187 skip("Could not create manifest file 7\n"); 2188 2189 trace("manifest8\n"); 2190 2191 if(create_manifest_file("test8.manifest", manifest8, -1, NULL, NULL)) { 2192 handle = test_create("test8.manifest"); 2193 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2194 DeleteFileA("test8.manifest"); 2195 DeleteFileA("testdep.manifest"); 2196 if(handle != INVALID_HANDLE_VALUE) 2197 { 2198 test_runlevel_info(handle, &runlevel_info8, __LINE__); 2199 pReleaseActCtx(handle); 2200 } 2201 } 2202 else 2203 skip("Could not create manifest file 8\n"); 2204 2205 trace("manifest9\n"); 2206 2207 if(create_manifest_file("test9.manifest", manifest9, -1, NULL, NULL)) { 2208 handle = test_create("test9.manifest"); 2209 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2210 DeleteFileA("test9.manifest"); 2211 DeleteFileA("testdep.manifest"); 2212 if(handle != INVALID_HANDLE_VALUE) 2213 { 2214 test_runlevel_info(handle, &runlevel_info9, __LINE__); 2215 pReleaseActCtx(handle); 2216 } 2217 } 2218 else 2219 skip("Could not create manifest file 9\n"); 2220 2221 trace("manifest4\n"); 2222 2223 if(!create_manifest_file("test4.manifest", manifest4, -1, NULL, NULL)) { 2224 skip("Could not create manifest file\n"); 2225 return; 2226 } 2227 2228 handle = test_create("test4.manifest"); 2229 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2230 DeleteFileA("test4.manifest"); 2231 DeleteFileA("testdep.manifest"); 2232 if(handle != INVALID_HANDLE_VALUE) { 2233 test_basic_info(handle, __LINE__); 2234 test_detailed_info(handle, &detailed_info2, __LINE__); 2235 test_info_in_assembly(handle, 1, &manifest4_info, __LINE__); 2236 test_info_in_assembly(handle, 2, &manifest_comctrl_info, __LINE__); 2237 pReleaseActCtx(handle); 2238 } 2239 2240 trace("manifest1 in subdir\n"); 2241 2242 CreateDirectoryW(work_dir_subdir, NULL); 2243 if (SetCurrentDirectoryW(work_dir_subdir)) 2244 { 2245 if(!create_manifest_file("..\\test1.manifest", manifest1, -1, NULL, NULL)) { 2246 skip("Could not create manifest file\n"); 2247 return; 2248 } 2249 handle = test_create("..\\test1.manifest"); 2250 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2251 DeleteFileA("..\\test1.manifest"); 2252 if(handle != INVALID_HANDLE_VALUE) { 2253 test_basic_info(handle, __LINE__); 2254 test_detailed_info(handle, &detailed_info1, __LINE__); 2255 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); 2256 pReleaseActCtx(handle); 2257 } 2258 SetCurrentDirectoryW(work_dir); 2259 } 2260 else 2261 skip("Couldn't change directory\n"); 2262 RemoveDirectoryW(work_dir_subdir); 2263 2264 trace("UTF-16 manifest1, with BOM\n"); 2265 if(!create_wide_manifest("test1.manifest", manifest1, TRUE, FALSE)) { 2266 skip("Could not create manifest file\n"); 2267 return; 2268 } 2269 2270 handle = test_create("test1.manifest"); 2271 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2272 DeleteFileA("test1.manifest"); 2273 if (handle != INVALID_HANDLE_VALUE) { 2274 test_basic_info(handle, __LINE__); 2275 test_detailed_info(handle, &detailed_info1, __LINE__); 2276 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); 2277 pReleaseActCtx(handle); 2278 } 2279 2280 trace("UTF-16 manifest1, reverse endian, with BOM\n"); 2281 if(!create_wide_manifest("test1.manifest", manifest1, TRUE, TRUE)) { 2282 skip("Could not create manifest file\n"); 2283 return; 2284 } 2285 2286 handle = test_create("test1.manifest"); 2287 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2288 DeleteFileA("test1.manifest"); 2289 if (handle != INVALID_HANDLE_VALUE) { 2290 test_basic_info(handle, __LINE__); 2291 test_detailed_info(handle, &detailed_info1, __LINE__); 2292 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); 2293 pReleaseActCtx(handle); 2294 } 2295 2296 test_wndclass_section(); 2297 test_dllredirect_section(); 2298 test_typelib_section(); 2299 test_allowDelayedBinding(); 2300 } 2301 2302 static void test_app_manifest(void) 2303 { 2304 HANDLE handle; 2305 BOOL b; 2306 2307 trace("child process manifest1\n"); 2308 2309 b = pGetCurrentActCtx(&handle); 2310 ok(handle == NULL, "handle != NULL\n"); 2311 ok(b, "GetCurrentActCtx failed: %u\n", GetLastError()); 2312 if(b) { 2313 test_basic_info(handle, __LINE__); 2314 test_detailed_info(handle, &detailed_info1_child, __LINE__); 2315 test_info_in_assembly(handle, 1, &manifest1_child_info, __LINE__); 2316 pReleaseActCtx(handle); 2317 } 2318 } 2319 2320 static HANDLE create_manifest(const char *filename, const char *data, int line) 2321 { 2322 HANDLE handle; 2323 create_manifest_file(filename, data, -1, NULL, NULL); 2324 2325 handle = test_create(filename); 2326 ok_(__FILE__, line)(handle != INVALID_HANDLE_VALUE, 2327 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2328 2329 DeleteFileA(filename); 2330 return handle; 2331 } 2332 2333 static void kernel32_find(ULONG section, const char *string_to_find, BOOL should_find, int line) 2334 { 2335 UNICODE_STRING string_to_findW; 2336 ACTCTX_SECTION_KEYED_DATA data; 2337 BOOL ret; 2338 DWORD err; 2339 2340 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW, string_to_find); 2341 2342 memset(&data, 0xfe, sizeof(data)); 2343 data.cbSize = sizeof(data); 2344 2345 SetLastError(0); 2346 ret = pFindActCtxSectionStringA(0, NULL, section, string_to_find, &data); 2347 err = GetLastError(); 2348 ok_(__FILE__, line)(ret == should_find, 2349 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find, ret); 2350 ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND), 2351 "FindActCtxSectionStringA: unexpected error %u\n", err); 2352 2353 memset(&data, 0xfe, sizeof(data)); 2354 data.cbSize = sizeof(data); 2355 2356 SetLastError(0); 2357 ret = pFindActCtxSectionStringW(0, NULL, section, string_to_findW.Buffer, &data); 2358 err = GetLastError(); 2359 ok_(__FILE__, line)(ret == should_find, 2360 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find, ret); 2361 ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND), 2362 "FindActCtxSectionStringW: unexpected error %u\n", err); 2363 2364 SetLastError(0); 2365 ret = pFindActCtxSectionStringA(0, NULL, section, string_to_find, NULL); 2366 err = GetLastError(); 2367 ok_(__FILE__, line)(!ret, 2368 "FindActCtxSectionStringA: expected failure, got %u\n", ret); 2369 ok_(__FILE__, line)(err == ERROR_INVALID_PARAMETER, 2370 "FindActCtxSectionStringA: unexpected error %u\n", err); 2371 2372 SetLastError(0); 2373 ret = pFindActCtxSectionStringW(0, NULL, section, string_to_findW.Buffer, NULL); 2374 err = GetLastError(); 2375 ok_(__FILE__, line)(!ret, 2376 "FindActCtxSectionStringW: expected failure, got %u\n", ret); 2377 ok_(__FILE__, line)(err == ERROR_INVALID_PARAMETER, 2378 "FindActCtxSectionStringW: unexpected error %u\n", err); 2379 2380 pRtlFreeUnicodeString(&string_to_findW); 2381 } 2382 2383 static void ntdll_find(ULONG section, const char *string_to_find, BOOL should_find, int line) 2384 { 2385 UNICODE_STRING string_to_findW; 2386 ACTCTX_SECTION_KEYED_DATA data; 2387 NTSTATUS ret; 2388 2389 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW, string_to_find); 2390 2391 memset(&data, 0xfe, sizeof(data)); 2392 data.cbSize = sizeof(data); 2393 2394 ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, &data); 2395 ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND), 2396 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret); 2397 2398 ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, NULL); 2399 ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND), 2400 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret); 2401 2402 pRtlFreeUnicodeString(&string_to_findW); 2403 } 2404 2405 static void test_findsectionstring(void) 2406 { 2407 HANDLE handle; 2408 BOOL ret; 2409 ULONG_PTR cookie; 2410 2411 handle = create_manifest("test.manifest", testdep_manifest3, __LINE__); 2412 ret = pActivateActCtx(handle, &cookie); 2413 ok(ret, "ActivateActCtx failed: %u\n", GetLastError()); 2414 2415 /* first we show the parameter validation from kernel32 */ 2416 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, __LINE__); 2417 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib.dll", TRUE, __LINE__); 2418 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib2.dll", TRUE, __LINE__); 2419 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib3.dll", FALSE, __LINE__); 2420 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass", TRUE, __LINE__); 2421 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass2", TRUE, __LINE__); 2422 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, __LINE__); 2423 2424 /* then we show that ntdll plays by different rules */ 2425 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, __LINE__); 2426 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib.dll", TRUE, __LINE__); 2427 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib2.dll", TRUE, __LINE__); 2428 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib3.dll", FALSE, __LINE__); 2429 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass", TRUE, __LINE__); 2430 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass2", TRUE, __LINE__); 2431 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, __LINE__); 2432 2433 ret = pDeactivateActCtx(0, cookie); 2434 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError()); 2435 pReleaseActCtx(handle); 2436 } 2437 2438 static void run_child_process(void) 2439 { 2440 char cmdline[MAX_PATH]; 2441 char path[MAX_PATH]; 2442 char **argv; 2443 PROCESS_INFORMATION pi; 2444 STARTUPINFOA si = { 0 }; 2445 HANDLE file; 2446 FILETIME now; 2447 BOOL ret; 2448 2449 GetModuleFileNameA(NULL, path, MAX_PATH); 2450 strcat(path, ".manifest"); 2451 if(!create_manifest_file(path, manifest1, -1, NULL, NULL)) { 2452 skip("Could not create manifest file\n"); 2453 return; 2454 } 2455 2456 si.cb = sizeof(si); 2457 winetest_get_mainargs( &argv ); 2458 /* Vista+ seems to cache presence of .manifest files. Change last modified 2459 date to defeat the cache */ 2460 file = CreateFileA(argv[0], FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, 2461 NULL, OPEN_EXISTING, 0, NULL); 2462 if (file != INVALID_HANDLE_VALUE) { 2463 GetSystemTimeAsFileTime(&now); 2464 SetFileTime(file, NULL, NULL, &now); 2465 CloseHandle(file); 2466 } 2467 sprintf(cmdline, "\"%s\" %s manifest1", argv[0], argv[1]); 2468 ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); 2469 ok(ret, "Could not create process: %u\n", GetLastError()); 2470 winetest_wait_child_process( pi.hProcess ); 2471 CloseHandle(pi.hThread); 2472 CloseHandle(pi.hProcess); 2473 DeleteFileA(path); 2474 } 2475 2476 static void init_paths(void) 2477 { 2478 LPWSTR ptr; 2479 2480 static const WCHAR dot_manifest[] = {'.','M','a','n','i','f','e','s','t',0}; 2481 static const WCHAR backslash[] = {'\\',0}; 2482 static const WCHAR subdir[] = {'T','e','s','t','S','u','b','d','i','r','\\',0}; 2483 2484 GetModuleFileNameW(NULL, exe_path, sizeof(exe_path)/sizeof(WCHAR)); 2485 lstrcpyW(app_dir, exe_path); 2486 for(ptr=app_dir+lstrlenW(app_dir); *ptr != '\\' && *ptr != '/'; ptr--); 2487 ptr[1] = 0; 2488 2489 GetCurrentDirectoryW(MAX_PATH, work_dir); 2490 ptr = work_dir + lstrlenW( work_dir ) - 1; 2491 if (*ptr != '\\' && *ptr != '/') 2492 lstrcatW(work_dir, backslash); 2493 lstrcpyW(work_dir_subdir, work_dir); 2494 lstrcatW(work_dir_subdir, subdir); 2495 2496 GetModuleFileNameW(NULL, app_manifest_path, sizeof(app_manifest_path)/sizeof(WCHAR)); 2497 lstrcpyW(app_manifest_path+lstrlenW(app_manifest_path), dot_manifest); 2498 } 2499 2500 static void write_manifest(const char *filename, const char *manifest) 2501 { 2502 HANDLE file; 2503 DWORD size; 2504 CHAR path[MAX_PATH]; 2505 2506 GetTempPathA(sizeof(path)/sizeof(CHAR), path); 2507 strcat(path, filename); 2508 2509 file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 2510 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError()); 2511 WriteFile(file, manifest, strlen(manifest), &size, NULL); 2512 CloseHandle(file); 2513 } 2514 2515 static void delete_manifest_file(const char *filename) 2516 { 2517 CHAR path[MAX_PATH]; 2518 2519 GetTempPathA(sizeof(path)/sizeof(CHAR), path); 2520 strcat(path, filename); 2521 DeleteFileA(path); 2522 } 2523 2524 static void test_CreateActCtx(void) 2525 { 2526 CHAR path[MAX_PATH], dir[MAX_PATH]; 2527 ACTCTXA actctx; 2528 HANDLE handle; 2529 2530 GetTempPathA(sizeof(path)/sizeof(CHAR), path); 2531 strcat(path, "main_wndcls.manifest"); 2532 2533 write_manifest("testdep1.manifest", manifest_wndcls1); 2534 write_manifest("testdep2.manifest", manifest_wndcls2); 2535 write_manifest("main_wndcls.manifest", manifest_wndcls_main); 2536 2537 memset(&actctx, 0, sizeof(ACTCTXA)); 2538 actctx.cbSize = sizeof(ACTCTXA); 2539 actctx.lpSource = path; 2540 2541 /* create using lpSource without specified directory */ 2542 handle = pCreateActCtxA(&actctx); 2543 ok(handle != INVALID_HANDLE_VALUE, "failed to generate context, error %u\n", GetLastError()); 2544 pReleaseActCtx(handle); 2545 2546 /* with specified directory, that doesn't contain dependent assembly */ 2547 GetWindowsDirectoryA(dir, sizeof(dir)/sizeof(CHAR)); 2548 2549 memset(&actctx, 0, sizeof(ACTCTXA)); 2550 actctx.cbSize = sizeof(ACTCTXA); 2551 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; 2552 actctx.lpAssemblyDirectory = dir; 2553 actctx.lpSource = path; 2554 2555 SetLastError(0xdeadbeef); 2556 handle = pCreateActCtxA(&actctx); 2557 todo_wine { 2558 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2559 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "got error %d\n", GetLastError()); 2560 } 2561 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx(handle); 2562 2563 delete_manifest_file("main_wndcls.manifest"); 2564 delete_manifest_file("testdep1.manifest"); 2565 delete_manifest_file("testdep2.manifest"); 2566 2567 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */ 2568 memset(&actctx, 0, sizeof(ACTCTXA)); 2569 actctx.cbSize = sizeof(ACTCTXA); 2570 actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID; 2571 SetLastError(0xdeadbeef); 2572 handle = pCreateActCtxA(&actctx); 2573 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2574 todo_wine 2575 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY) /* XP, win2k3 */, 2576 "got error %d\n", GetLastError()); 2577 2578 /* create from HMODULE - resource doesn't exist, lpSource is set */ 2579 memset(&actctx, 0, sizeof(ACTCTXA)); 2580 actctx.cbSize = sizeof(ACTCTXA); 2581 actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID; 2582 actctx.lpSource = "dummyfile.dll"; 2583 actctx.lpResourceName = MAKEINTRESOURCEA(20); 2584 actctx.hModule = GetModuleHandleA(NULL); 2585 2586 SetLastError(0xdeadbeef); 2587 handle = pCreateActCtxA(&actctx); 2588 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2589 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "got error %d\n", GetLastError()); 2590 2591 /* load manifest from lpAssemblyDirectory directory */ 2592 write_manifest("testdir.manifest", manifest1); 2593 GetTempPathA(sizeof(path)/sizeof(path[0]), path); 2594 SetCurrentDirectoryA(path); 2595 strcat(path, "assembly_dir"); 2596 strcpy(dir, path); 2597 strcat(path, "\\testdir.manifest"); 2598 2599 memset(&actctx, 0, sizeof(actctx)); 2600 actctx.cbSize = sizeof(actctx); 2601 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; 2602 actctx.lpSource = "testdir.manifest"; 2603 actctx.lpAssemblyDirectory = dir; 2604 2605 SetLastError(0xdeadbeef); 2606 handle = pCreateActCtxA(&actctx); 2607 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2608 ok(GetLastError()==ERROR_PATH_NOT_FOUND || 2609 broken(GetLastError()==ERROR_FILE_NOT_FOUND) /* WinXP */, 2610 "got error %d\n", GetLastError()); 2611 2612 CreateDirectoryA(dir, NULL); 2613 memset(&actctx, 0, sizeof(actctx)); 2614 actctx.cbSize = sizeof(actctx); 2615 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; 2616 actctx.lpSource = "testdir.manifest"; 2617 actctx.lpAssemblyDirectory = dir; 2618 2619 SetLastError(0xdeadbeef); 2620 handle = pCreateActCtxA(&actctx); 2621 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2622 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %d\n", GetLastError()); 2623 SetCurrentDirectoryW(work_dir); 2624 2625 write_manifest("assembly_dir\\testdir.manifest", manifest1); 2626 memset(&actctx, 0, sizeof(actctx)); 2627 actctx.cbSize = sizeof(actctx); 2628 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; 2629 actctx.lpSource = "testdir.manifest"; 2630 actctx.lpAssemblyDirectory = dir; 2631 2632 handle = pCreateActCtxA(&actctx); 2633 ok(handle != INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2634 pReleaseActCtx(handle); 2635 2636 memset(&actctx, 0, sizeof(actctx)); 2637 actctx.cbSize = sizeof(actctx); 2638 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; 2639 actctx.lpSource = path; 2640 actctx.lpAssemblyDirectory = dir; 2641 2642 handle = pCreateActCtxA(&actctx); 2643 ok(handle != INVALID_HANDLE_VALUE, "got handle %p\n", handle); 2644 pReleaseActCtx(handle); 2645 2646 delete_manifest_file("testdir.manifest"); 2647 delete_manifest_file("assembly_dir\\testdir.manifest"); 2648 RemoveDirectoryA(dir); 2649 } 2650 2651 static BOOL init_funcs(void) 2652 { 2653 HMODULE hLibrary = GetModuleHandleA("kernel32.dll"); 2654 2655 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE; 2656 X(ActivateActCtx); 2657 X(CreateActCtxA); 2658 X(CreateActCtxW); 2659 X(DeactivateActCtx); 2660 X(FindActCtxSectionStringA); 2661 X(FindActCtxSectionStringW); 2662 X(GetCurrentActCtx); 2663 X(IsDebuggerPresent); 2664 X(QueryActCtxW); 2665 X(ReleaseActCtx); 2666 X(FindActCtxSectionGuid); 2667 X(ZombifyActCtx); 2668 2669 hLibrary = GetModuleHandleA("ntdll.dll"); 2670 X(RtlFindActivationContextSectionString); 2671 X(RtlCreateUnicodeStringFromAsciiz); 2672 X(RtlFreeUnicodeString); 2673 #undef X 2674 2675 return TRUE; 2676 } 2677 2678 static void test_ZombifyActCtx(void) 2679 { 2680 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo; 2681 ULONG_PTR cookie; 2682 HANDLE handle, current; 2683 BOOL ret; 2684 2685 SetLastError(0xdeadbeef); 2686 ret = pZombifyActCtx(NULL); 2687 todo_wine 2688 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError()); 2689 2690 handle = create_manifest("test.manifest", testdep_manifest3, __LINE__); 2691 2692 ret = pGetCurrentActCtx(¤t); 2693 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2694 ok(current == NULL, "got %p\n", current); 2695 2696 ret = pActivateActCtx(handle, &cookie); 2697 ok(ret, "ActivateActCtx failed: %u\n", GetLastError()); 2698 2699 ret = pGetCurrentActCtx(¤t); 2700 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2701 ok(handle == current, "got %p, %p\n", current, handle); 2702 2703 memset(&basicinfo, 0xff, sizeof(basicinfo)); 2704 ret = pQueryActCtxW(0, handle, 0, ActivationContextBasicInformation, 2705 &basicinfo, sizeof(basicinfo), NULL); 2706 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2707 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx); 2708 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags); 2709 2710 memset(&basicinfo, 0xff, sizeof(basicinfo)); 2711 ret = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, 0, ActivationContextBasicInformation, 2712 &basicinfo, sizeof(basicinfo), NULL); 2713 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2714 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx); 2715 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags); 2716 2717 ret = pZombifyActCtx(handle); 2718 todo_wine 2719 ok(ret, "got %d\n", ret); 2720 2721 memset(&basicinfo, 0xff, sizeof(basicinfo)); 2722 ret = pQueryActCtxW(0, handle, 0, ActivationContextBasicInformation, 2723 &basicinfo, sizeof(basicinfo), NULL); 2724 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2725 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx); 2726 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags); 2727 2728 memset(&basicinfo, 0xff, sizeof(basicinfo)); 2729 ret = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, 0, ActivationContextBasicInformation, 2730 &basicinfo, sizeof(basicinfo), NULL); 2731 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2732 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx); 2733 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags); 2734 2735 ret = pGetCurrentActCtx(¤t); 2736 ok(ret, "got %d, error %d\n", ret, GetLastError()); 2737 ok(current == handle, "got %p\n", current); 2738 2739 /* one more time */ 2740 ret = pZombifyActCtx(handle); 2741 todo_wine 2742 ok(ret, "got %d\n", ret); 2743 2744 ret = pDeactivateActCtx(0, cookie); 2745 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError()); 2746 pReleaseActCtx(handle); 2747 } 2748 2749 /* Test structure to verify alignment */ 2750 typedef struct _test_act_ctx_compat_info { 2751 DWORD ElementCount; 2752 COMPATIBILITY_CONTEXT_ELEMENT Elements[10]; 2753 } test_act_ctx_compat_info; 2754 2755 static void test_no_compat(HANDLE handle, int line) 2756 { 2757 test_act_ctx_compat_info compat_info; 2758 SIZE_T size; 2759 BOOL b; 2760 2761 memset(&compat_info, 0, sizeof(compat_info)); 2762 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL, 2763 CompatibilityInformationInActivationContext, &compat_info, 2764 sizeof(compat_info), &size); 2765 2766 ok_(__FILE__, line)(b, "CompatibilityInformationInActivationContext failed\n"); 2767 ok_(__FILE__, line)(size == sizeof(DWORD), "size mismatch (got %lu, expected 4)\n", size); 2768 ok_(__FILE__, line)(compat_info.ElementCount == 0, "unexpected ElementCount %u\n", compat_info.ElementCount); 2769 } 2770 2771 static void test_with_compat(HANDLE handle, DWORD num_compat, const GUID* expected_compat[], int line) 2772 { 2773 test_act_ctx_compat_info compat_info; 2774 SIZE_T size; 2775 SIZE_T expected = sizeof(COMPATIBILITY_CONTEXT_ELEMENT) * num_compat + sizeof(DWORD); 2776 DWORD n; 2777 BOOL b; 2778 2779 memset(&compat_info, 0, sizeof(compat_info)); 2780 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL, 2781 CompatibilityInformationInActivationContext, &compat_info, 2782 sizeof(compat_info), &size); 2783 2784 ok_(__FILE__, line)(b, "CompatibilityInformationInActivationContext failed\n"); 2785 ok_(__FILE__, line)(size == expected, "size mismatch (got %lu, expected %lu)\n", size, expected); 2786 ok_(__FILE__, line)(compat_info.ElementCount == num_compat, "unexpected ElementCount %u\n", compat_info.ElementCount); 2787 2788 for (n = 0; n < num_compat; ++n) 2789 { 2790 ok_(__FILE__, line)(IsEqualGUID(&compat_info.Elements[n].Id, expected_compat[n]), 2791 "got wrong clsid %s, expected %s for %u\n", 2792 wine_dbgstr_guid(&compat_info.Elements[n].Id), 2793 wine_dbgstr_guid(expected_compat[n]), 2794 n); 2795 ok_(__FILE__, line)(compat_info.Elements[n].Type == ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS, 2796 "Wrong type, got %u for %u\n", (DWORD)compat_info.Elements[n].Type, n); 2797 } 2798 } 2799 2800 static void test_compatibility(void) 2801 { 2802 HANDLE handle; 2803 2804 /* No compat results returned */ 2805 trace("manifest1\n"); 2806 if(!create_manifest_file("test1.manifest", manifest1, -1, NULL, NULL)) 2807 { 2808 skip("Could not create manifest file\n"); 2809 return; 2810 } 2811 handle = test_create("test1.manifest"); 2812 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2813 DeleteFileA("test1.manifest"); 2814 if(handle != INVALID_HANDLE_VALUE) 2815 { 2816 char buffer[sizeof(COMPATIBILITY_CONTEXT_ELEMENT) * 2 + sizeof(DWORD)]; 2817 SIZE_T size; 2818 BOOL b; 2819 2820 memset(buffer, 0, sizeof(buffer)); 2821 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL, 2822 CompatibilityInformationInActivationContext, buffer, 2823 sizeof(buffer), &size); 2824 2825 if (!b && GetLastError() == ERROR_INVALID_PARAMETER) 2826 { 2827 win_skip("CompatibilityInformationInActivationContext not supported.\n"); 2828 pReleaseActCtx(handle); 2829 return; 2830 } 2831 2832 test_basic_info(handle, __LINE__); 2833 test_no_compat(handle, __LINE__); 2834 pReleaseActCtx(handle); 2835 } 2836 2837 /* Still no compat results returned */ 2838 trace("no_supportedOs\n"); 2839 if(!create_manifest_file("no_supportedOs.manifest", compat_manifest_no_supportedOs, -1, NULL, NULL)) 2840 { 2841 skip("Could not create manifest file\n"); 2842 return; 2843 } 2844 handle = test_create("no_supportedOs.manifest"); 2845 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2846 DeleteFileA("no_supportedOs.manifest"); 2847 if(handle != INVALID_HANDLE_VALUE) 2848 { 2849 test_basic_info(handle, __LINE__); 2850 test_no_compat(handle, __LINE__); 2851 pReleaseActCtx(handle); 2852 } 2853 2854 /* Just one result returned */ 2855 trace("manifest_vista\n"); 2856 if(!create_manifest_file("manifest_vista.manifest", compat_manifest_vista, -1, NULL, NULL)) 2857 { 2858 skip("Could not create manifest file\n"); 2859 return; 2860 } 2861 handle = test_create("manifest_vista.manifest"); 2862 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2863 DeleteFileA("manifest_vista.manifest"); 2864 if(handle != INVALID_HANDLE_VALUE) 2865 { 2866 static const GUID* expect_manifest[] = 2867 { 2868 &VISTA_COMPAT_GUID 2869 }; 2870 test_basic_info(handle, __LINE__); 2871 test_with_compat(handle, 1, expect_manifest, __LINE__); 2872 pReleaseActCtx(handle); 2873 } 2874 2875 /* Show that the order is retained */ 2876 trace("manifest_vista_7_8_10_81\n"); 2877 if(!create_manifest_file("manifest_vista_7_8_10_81.manifest", compat_manifest_vista_7_8_10_81, -1, NULL, NULL)) 2878 { 2879 skip("Could not create manifest file\n"); 2880 return; 2881 } 2882 handle = test_create("manifest_vista_7_8_10_81.manifest"); 2883 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2884 DeleteFileA("manifest_vista_7_8_10_81.manifest"); 2885 if(handle != INVALID_HANDLE_VALUE) 2886 { 2887 static const GUID* expect_manifest[] = 2888 { 2889 &VISTA_COMPAT_GUID, 2890 &WIN7_COMPAT_GUID, 2891 &WIN8_COMPAT_GUID, 2892 &WIN10_COMPAT_GUID, 2893 &WIN81_COMPAT_GUID, 2894 }; 2895 test_basic_info(handle, __LINE__); 2896 test_with_compat(handle, 5, expect_manifest, __LINE__); 2897 pReleaseActCtx(handle); 2898 } 2899 2900 /* Show that even unknown GUID's are stored */ 2901 trace("manifest_other_guid\n"); 2902 if(!create_manifest_file("manifest_other_guid.manifest", compat_manifest_other_guid, -1, NULL, NULL)) 2903 { 2904 skip("Could not create manifest file\n"); 2905 return; 2906 } 2907 handle = test_create("manifest_other_guid.manifest"); 2908 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); 2909 DeleteFileA("manifest_other_guid.manifest"); 2910 if(handle != INVALID_HANDLE_VALUE) 2911 { 2912 static const GUID* expect_manifest[] = 2913 { 2914 &OTHER_COMPAT_GUID, 2915 }; 2916 test_basic_info(handle, __LINE__); 2917 test_with_compat(handle, 1, expect_manifest, __LINE__); 2918 pReleaseActCtx(handle); 2919 } 2920 } 2921 2922 START_TEST(actctx) 2923 { 2924 int argc; 2925 char **argv; 2926 2927 argc = winetest_get_mainargs(&argv); 2928 2929 if (!init_funcs()) 2930 { 2931 win_skip("Needed functions are not available\n"); 2932 return; 2933 } 2934 init_paths(); 2935 2936 if(argc > 2 && !strcmp(argv[2], "manifest1")) { 2937 test_app_manifest(); 2938 return; 2939 } 2940 2941 test_actctx(); 2942 test_create_fail(); 2943 test_CreateActCtx(); 2944 test_findsectionstring(); 2945 test_ZombifyActCtx(); 2946 run_child_process(); 2947 test_compatibility(); 2948 } 2949