Reactos

[KERNEL32_WINETEST] Sync everything except file.c and virtual.c with Wine Staging 3.3. CORE-14434

+2295 -1037
-1
modules/rostests/winetests/kernel32/CMakeLists.txt
··· 10 10 codepage.c 11 11 comm.c 12 12 console.c 13 - cpu.c 14 13 debugger.c 15 14 directory.c 16 15 drive.c
+29 -26
modules/rostests/winetests/kernel32/actctx.c
··· 16 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 17 */ 18 18 19 - #include "precomp.h" 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> 20 28 21 - #include <objbase.h> 22 - #include <oaidl.h> 23 - #include <initguid.h> 29 + #include "oaidl.h" 30 + #include "initguid.h" 24 31 25 32 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*); 26 33 static HANDLE (WINAPI *pCreateActCtxA)(PCACTCTXA); ··· 419 426 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>" 420 427 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">" 421 428 " <application>" 422 - " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */ 429 + " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" ></supportedOS>" /* Windows Vista */ 423 430 " <supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" />" /* Windows 7 */ 424 - " <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" />" /* Windows 8 */ 431 + " <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" ></supportedOS>" /* Windows 8 */ 425 432 " <supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" />" /* Windows 10 */ 426 433 " <supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" />" /* Windows 8.1 */ 427 434 " </application>" ··· 2323 2330 return handle; 2324 2331 } 2325 2332 2326 - static void kernel32_find(ULONG section, const char *string_to_find, BOOL should_find, BOOL todo, int line) 2333 + static void kernel32_find(ULONG section, const char *string_to_find, BOOL should_find, int line) 2327 2334 { 2328 2335 UNICODE_STRING string_to_findW; 2329 2336 ACTCTX_SECTION_KEYED_DATA data; ··· 2340 2347 err = GetLastError(); 2341 2348 ok_(__FILE__, line)(ret == should_find, 2342 2349 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find, ret); 2343 - todo_wine_if(todo) 2344 2350 ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND), 2345 2351 "FindActCtxSectionStringA: unexpected error %u\n", err); 2346 2352 ··· 2352 2358 err = GetLastError(); 2353 2359 ok_(__FILE__, line)(ret == should_find, 2354 2360 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find, ret); 2355 - todo_wine_if(todo) 2356 2361 ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND), 2357 2362 "FindActCtxSectionStringW: unexpected error %u\n", err); 2358 2363 ··· 2375 2380 pRtlFreeUnicodeString(&string_to_findW); 2376 2381 } 2377 2382 2378 - static void ntdll_find(ULONG section, const char *string_to_find, BOOL should_find, BOOL todo, int line) 2383 + static void ntdll_find(ULONG section, const char *string_to_find, BOOL should_find, int line) 2379 2384 { 2380 2385 UNICODE_STRING string_to_findW; 2381 2386 ACTCTX_SECTION_KEYED_DATA data; ··· 2387 2392 data.cbSize = sizeof(data); 2388 2393 2389 2394 ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, &data); 2390 - todo_wine_if(todo) 2391 2395 ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND), 2392 2396 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret); 2393 2397 2394 2398 ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, NULL); 2395 - todo_wine_if(todo) 2396 2399 ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND), 2397 2400 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret); 2398 2401 ··· 2410 2413 ok(ret, "ActivateActCtx failed: %u\n", GetLastError()); 2411 2414 2412 2415 /* first we show the parameter validation from kernel32 */ 2413 - kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, TRUE, __LINE__); 2414 - kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib.dll", TRUE, FALSE, __LINE__); 2415 - kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib2.dll", TRUE, FALSE, __LINE__); 2416 - kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib3.dll", FALSE, FALSE, __LINE__); 2417 - kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass", TRUE, FALSE, __LINE__); 2418 - kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass2", TRUE, FALSE, __LINE__); 2419 - kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, FALSE, __LINE__); 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__); 2420 2423 2421 2424 /* then we show that ntdll plays by different rules */ 2422 - ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, TRUE, __LINE__); 2423 - ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib.dll", TRUE, FALSE, __LINE__); 2424 - ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib2.dll", TRUE, FALSE, __LINE__); 2425 - ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib3.dll", FALSE, FALSE, __LINE__); 2426 - ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass", TRUE, FALSE, __LINE__); 2427 - ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass2", TRUE, FALSE, __LINE__); 2428 - ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, FALSE, __LINE__); 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__); 2429 2432 2430 2433 ret = pDeactivateActCtx(0, cookie); 2431 2434 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+8 -1
modules/rostests/winetests/kernel32/atom.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + #include <stdio.h> 23 + 24 + #include "wine/test.h" 25 + #include "windef.h" 26 + #include "winbase.h" 27 + #include "winerror.h" 28 + #include "winuser.h" 22 29 23 30 #define DOUBLE(x) (WCHAR)((x<<8)|(x)) 24 31
+41 -18
modules/rostests/winetests/kernel32/change.c
··· 26 26 * FILE_NOTIFY_CHANGE_CREATION 27 27 */ 28 28 29 - #include "precomp.h" 29 + #include <stdarg.h> 30 + #include <stdio.h> 31 + 32 + #include "ntstatus.h" 33 + #define WIN32_NO_STATUS 34 + #include "wine/test.h" 35 + #include <windef.h> 36 + #include <winbase.h> 37 + #include <winternl.h> 30 38 31 39 static DWORD CALLBACK NotificationThread(LPVOID arg) 32 40 { ··· 375 383 static const WCHAR szHoo[] = { '\\','h','o','o',0 }; 376 384 static const WCHAR szGa[] = { '\\','h','o','o','\\','g','a',0 }; 377 385 PFILE_NOTIFY_INFORMATION pfni; 386 + BOOL got_subdir_change = FALSE; 378 387 379 388 if (!pReadDirectoryChangesW) 380 389 { ··· 542 551 r = CreateDirectoryW( subsubdir, NULL ); 543 552 ok( r == TRUE, "failed to create directory\n"); 544 553 545 - r = WaitForSingleObject( ov.hEvent, 1000 ); 546 - ok( r == WAIT_OBJECT_0, "should be ready\n" ); 554 + while (1) 555 + { 556 + r = WaitForSingleObject( ov.hEvent, 1000 ); 557 + ok(r == WAIT_OBJECT_0, "should be ready\n" ); 558 + if (r == WAIT_TIMEOUT) break; 547 559 548 - ok( (NTSTATUS)ov.Internal == STATUS_SUCCESS, "ov.Internal wrong\n"); 549 - ok( ov.InternalHigh == 0x18 || ov.InternalHigh == 0x12 + 0x18, 550 - "ov.InternalHigh wrong %lx\n", ov.InternalHigh); 560 + ok((NTSTATUS) ov.Internal == STATUS_SUCCESS, "ov.Internal wrong\n"); 551 561 552 - pfni = (PFILE_NOTIFY_INFORMATION) buffer; 553 - if (pfni->NextEntryOffset) /* we may get a modified event on the parent dir */ 554 - { 555 - ok( pfni->NextEntryOffset == 0x12, "offset wrong %x\n", pfni->NextEntryOffset ); 556 - ok( pfni->Action == FILE_ACTION_MODIFIED, "action wrong %d\n", pfni->Action ); 557 - ok( pfni->FileNameLength == 3*sizeof(WCHAR), "len wrong\n" ); 558 - ok( !memcmp(pfni->FileName,&szGa[1],3*sizeof(WCHAR)), "name wrong\n"); 559 - pfni = (PFILE_NOTIFY_INFORMATION)((char *)pfni + pfni->NextEntryOffset); 562 + pfni = (PFILE_NOTIFY_INFORMATION) buffer; 563 + while (1) 564 + { 565 + /* We might get one or more modified events on the parent dir */ 566 + if (pfni->Action == FILE_ACTION_MODIFIED) 567 + { 568 + ok(pfni->FileNameLength == 3 * sizeof(WCHAR), "len wrong\n" ); 569 + ok(!memcmp(pfni->FileName, &szGa[1], 3 * sizeof(WCHAR)), "name wrong\n"); 570 + } 571 + else 572 + { 573 + ok(pfni->Action == FILE_ACTION_ADDED, "action wrong\n"); 574 + ok(pfni->FileNameLength == 6 * sizeof(WCHAR), "len wrong\n" ); 575 + ok(!memcmp(pfni->FileName, &szGa[1], 6 * sizeof(WCHAR)), "name wrong\n"); 576 + got_subdir_change = TRUE; 577 + } 578 + if (!pfni->NextEntryOffset) break; 579 + pfni = (PFILE_NOTIFY_INFORMATION)((char *)pfni + pfni->NextEntryOffset); 580 + } 581 + 582 + if (got_subdir_change) break; 583 + 584 + r = pReadDirectoryChangesW(hdir,buffer,sizeof buffer,FALSE,filter,NULL,&ov,NULL); 585 + ok(r==TRUE, "should return true\n"); 560 586 } 561 - ok( pfni->NextEntryOffset == 0, "offset wrong\n" ); 562 - ok( pfni->Action == FILE_ACTION_ADDED, "action wrong\n" ); 563 - ok( pfni->FileNameLength == 6*sizeof(WCHAR), "len wrong\n" ); 564 - ok( !memcmp(pfni->FileName,&szGa[1],6*sizeof(WCHAR)), "name wrong\n" ); 587 + ok(got_subdir_change, "didn't get subdir change\n"); 565 588 566 589 r = RemoveDirectoryW( subsubdir ); 567 590 ok( r == TRUE, "failed to remove directory\n");
+8 -1
modules/rostests/winetests/kernel32/codepage.c
··· 19 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 20 */ 21 21 22 - #include "precomp.h" 22 + #include <stdarg.h> 23 + #include <stdio.h> 24 + #include <limits.h> 25 + 26 + #include "wine/test.h" 27 + #include "windef.h" 28 + #include "winbase.h" 29 + #include "winnls.h" 23 30 24 31 static const char foobarA[] = "foobar"; 25 32 static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
+8 -1
modules/rostests/winetests/kernel32/comm.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdio.h> 22 + 23 + #include "ntstatus.h" 24 + #define WIN32_NO_STATUS 25 + #include "wine/test.h" 26 + #include "winternl.h" 27 + #include "winbase.h" 28 + #include "winnls.h" 22 29 23 30 #define TIMEOUT 1000 /* one second for Timeouts*/ 24 31 #define SLOWBAUD 150
+8 -1
modules/rostests/winetests/kernel32/console.c
··· 19 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 20 */ 21 21 22 - #include "precomp.h" 22 + #include "wine/test.h" 23 + #include <windows.h> 24 + #include <stdio.h> 23 25 24 26 static BOOL (WINAPI *pGetConsoleInputExeNameA)(DWORD, LPSTR); 25 27 static DWORD (WINAPI *pGetConsoleProcessList)(LPDWORD, DWORD); ··· 2580 2582 2581 2583 SetLastError(0xdeadbeef); 2582 2584 ret = GetFileSize(std_input, NULL); 2585 + if (GetLastError() == 0xdeadbeef) 2586 + { 2587 + skip("stdin is redirected\n"); 2588 + return; 2589 + } 2583 2590 ok(ret == INVALID_FILE_SIZE, "expected INVALID_FILE_SIZE, got %#x\n", ret); 2584 2591 ok(GetLastError() == ERROR_INVALID_HANDLE || 2585 2592 GetLastError() == ERROR_INVALID_FUNCTION, /* Win 8, 10 */
-75
modules/rostests/winetests/kernel32/cpu.c
··· 1 - /* 2 - * Unit test suite for cpu functions 3 - * 4 - * Copyright 2014 Michael Müller 5 - * 6 - * This library is free software; you can redistribute it and/or 7 - * modify it under the terms of the GNU Lesser General Public 8 - * License as published by the Free Software Foundation; either 9 - * version 2.1 of the License, or (at your option) any later version. 10 - * 11 - * This library is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 - * Lesser General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU Lesser General Public 17 - * License along with this library; if not, write to the Free Software 18 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 - */ 20 - 21 - #include "precomp.h" 22 - 23 - static BOOL (WINAPI *pGetNumaProcessorNode)(UCHAR, PUCHAR); 24 - 25 - static void InitFunctionPointers(void) 26 - { 27 - HMODULE hkernel32 = GetModuleHandleA("kernel32"); 28 - 29 - pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode"); 30 - } 31 - 32 - static void test_GetNumaProcessorNode(void) 33 - { 34 - SYSTEM_INFO si; 35 - UCHAR node; 36 - BOOL ret; 37 - int i; 38 - 39 - if (!pGetNumaProcessorNode) 40 - { 41 - win_skip("GetNumaProcessorNode() is missing\n"); 42 - return; 43 - } 44 - 45 - GetSystemInfo(&si); 46 - 47 - for (i = 0; i < 256; i++) 48 - { 49 - ret = pGetNumaProcessorNode(i, &node); 50 - if (i < si.dwNumberOfProcessors) 51 - { 52 - ok(ret, "expected TRUE, got FALSE for processor %d\n", i); 53 - ok(node != 0xFF, "expected node != 0xFF, but got 0xFF\n"); 54 - } 55 - else 56 - { 57 - ok(!ret, "expected FALSE, got TRUE for processor %d\n", i); 58 - ok(node == 0xFF, "expected node == 0xFF, but got %x\n", node); 59 - ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); 60 - } 61 - } 62 - 63 - /* crashes on windows */ 64 - if (0) 65 - { 66 - ok(!pGetNumaProcessorNode(0, NULL), "expected return value FALSE, got TRUE\n"); 67 - ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); 68 - } 69 - } 70 - 71 - START_TEST(cpu) 72 - { 73 - InitFunctionPointers(); 74 - test_GetNumaProcessorNode(); 75 - }
+7 -1
modules/rostests/winetests/kernel32/debugger.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdio.h> 22 + #include <assert.h> 23 + 24 + #include <windows.h> 25 + #include <winternl.h> 26 + #include <winreg.h> 27 + #include "wine/test.h" 22 28 23 29 #ifndef STATUS_DEBUGGER_INACTIVE 24 30 #define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354)
+7 -1
modules/rostests/winetests/kernel32/directory.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + 23 + #include "wine/test.h" 24 + #include "windef.h" 25 + #include "winbase.h" 26 + #include "winerror.h" 27 + #include "winternl.h" 22 28 23 29 static NTSTATUS (WINAPI *pNtQueryObject)(HANDLE,OBJECT_INFORMATION_CLASS,PVOID,ULONG,PULONG); 24 30
+6 -1
modules/rostests/winetests/kernel32/drive.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + 23 + #include "wine/test.h" 24 + #include "windef.h" 25 + #include "winbase.h" 26 + #include "winerror.h" 22 27 23 28 static DWORD (WINAPI *pGetDiskFreeSpaceExA)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); 24 29
+7 -1
modules/rostests/winetests/kernel32/environ.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + 23 + #include "wine/test.h" 24 + #include "windef.h" 25 + #include "winbase.h" 26 + #include "winerror.h" 27 + #include "winnls.h" 22 28 23 29 static CHAR string[MAX_PATH]; 24 30 #define ok_w(res, format, szString) \
+1 -1
modules/rostests/winetests/kernel32/fiber.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include "wine/test.h" 22 22 23 23 static LPVOID (WINAPI *pCreateFiber)(SIZE_T,LPFIBER_START_ROUTINE,LPVOID); 24 24 static LPVOID (WINAPI *pConvertThreadToFiber)(LPVOID);
+12 -3
modules/rostests/winetests/kernel32/format_msg.c
··· 17 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 18 */ 19 19 20 - #include "precomp.h" 20 + #include <stdarg.h> 21 + 22 + #include "wine/test.h" 23 + #include "windef.h" 24 + #include "winbase.h" 25 + #include "winnls.h" 21 26 22 27 #define ULL(a,b) (((ULONG64)(a) << 32) | (b)) 23 28 24 - static DWORD __cdecl doit(DWORD flags, LPCVOID src, DWORD msg_id, DWORD lang_id, 29 + static DWORD WINAPIV doit(DWORD flags, LPCVOID src, DWORD msg_id, DWORD lang_id, 25 30 LPSTR out, DWORD outsize, ... ) 26 31 { 27 32 __ms_va_list list; ··· 34 39 return r; 35 40 } 36 41 37 - static DWORD __cdecl doitW(DWORD flags, LPCVOID src, DWORD msg_id, DWORD lang_id, 42 + static DWORD WINAPIV doitW(DWORD flags, LPCVOID src, DWORD msg_id, DWORD lang_id, 38 43 LPWSTR out, DWORD outsize, ... ) 39 44 { 40 45 __ms_va_list list; ··· 1551 1556 1552 1557 /* Test HRESULT. It's not documented but in practice _com_error::ErrorMessage relies on this. */ 1553 1558 ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 0x80070005 /* E_ACCESSDENIED */, 1559 + MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, sizeof(out)/sizeof(CHAR), NULL); 1560 + ok(ret != 0, "FormatMessageA returned 0\n"); 1561 + 1562 + ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, TRUST_E_NOSIGNATURE, 1554 1563 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, sizeof(out)/sizeof(CHAR), NULL); 1555 1564 ok(ret != 0, "FormatMessageA returned 0\n"); 1556 1565
+25 -5
modules/rostests/winetests/kernel32/heap.c
··· 20 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 21 */ 22 22 23 - #include "precomp.h" 23 + #include <stdarg.h> 24 + #include <stdlib.h> 25 + #include <stdio.h> 26 + 27 + #include "windef.h" 28 + #include "winbase.h" 29 + #include "winreg.h" 30 + #include "winternl.h" 31 + #include "wine/test.h" 24 32 25 33 #define MAGIC_DEAD 0xdeadbeef 26 34 ··· 200 208 ((GetLastError() == ERROR_NOT_LOCKED) || (GetLastError() == MAGIC_DEAD)), 201 209 "returned %d with %d (expected '0' with: ERROR_NOT_LOCKED or " 202 210 "MAGIC_DEAD)\n", res, GetLastError()); 203 - 211 + 204 212 GlobalFree(gbl); 205 213 /* invalid handles are caught in windows: */ 206 214 SetLastError(MAGIC_DEAD); ··· 208 216 ok( (hsecond == gbl) && (GetLastError() == ERROR_INVALID_HANDLE), 209 217 "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n", 210 218 hsecond, GetLastError(), gbl); 219 + SetLastError(MAGIC_DEAD); 220 + hsecond = GlobalFree(LongToHandle(0xdeadbeef)); /* bogus handle */ 221 + ok( (hsecond == LongToHandle(0xdeadbeef)) && (GetLastError() == ERROR_INVALID_HANDLE), 222 + "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n", 223 + hsecond, GetLastError(), LongToHandle(0xdeadbeef)); 224 + SetLastError(MAGIC_DEAD); 225 + hsecond = GlobalFree(LongToHandle(0xdeadbee0)); /* bogus pointer */ 226 + ok( (hsecond == LongToHandle(0xdeadbee0)) && 227 + ((GetLastError() == ERROR_INVALID_HANDLE) || broken(GetLastError() == ERROR_NOACCESS) /* wvista+ */), 228 + "returned %p with 0x%08x (expected %p with ERROR_NOACCESS)\n", 229 + hsecond, GetLastError(), LongToHandle(0xdeadbee0)); 230 + 211 231 SetLastError(MAGIC_DEAD); 212 232 flags = GlobalFlags(gbl); 213 233 ok( (flags == GMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE), ··· 242 262 ok(mem == NULL, "Expected NULL, got %p\n", mem); 243 263 244 264 /* invalid free */ 245 - if (sizeof(void *) != 8) /* crashes on 64-bit Vista */ 265 + if (sizeof(void *) != 8) /* crashes on 64-bit */ 246 266 { 247 267 SetLastError(MAGIC_DEAD); 248 268 mem = GlobalFree(gbl); ··· 560 580 ok(HeapFree(heap,0,mem3),"HeapFree didn't pass successfully\n"); 561 581 } 562 582 563 - /* Check that HeapRealloc works */ 583 + /* Check that HeapReAlloc works */ 564 584 mem2a=HeapReAlloc(heap,HEAP_ZERO_MEMORY,mem2,memchunk+5*sysInfo.dwPageSize); 565 585 ok(mem2a!=NULL,"HeapReAlloc failed\n"); 566 586 if(mem2a) { ··· 574 594 ok(!error,"HeapReAlloc should have zeroed out its allocated memory\n"); 575 595 } 576 596 577 - /* Check that HeapRealloc honours HEAP_REALLOC_IN_PLACE_ONLY */ 597 + /* Check that HeapReAlloc honours HEAP_REALLOC_IN_PLACE_ONLY */ 578 598 error=FALSE; 579 599 mem1a=HeapReAlloc(heap,HEAP_REALLOC_IN_PLACE_ONLY,mem1,memchunk+sysInfo.dwPageSize); 580 600 if(mem1a!=NULL) {
+591 -80
modules/rostests/winetests/kernel32/loader.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #define NONAMELESSUNION 22 + #define NONAMELESSSTRUCT 23 + #include <stdarg.h> 24 + #include <stdio.h> 25 + #include <assert.h> 22 26 23 - #include <delayloadhandler.h> 27 + #include "ntstatus.h" 28 + #define WIN32_NO_STATUS 29 + #include "windef.h" 30 + #include "winbase.h" 31 + #include "winternl.h" 32 + #include "winuser.h" 33 + #include "wine/test.h" 34 + #include "delayloadhandler.h" 24 35 25 36 /* PROCESS_ALL_ACCESS in Vista+ PSDKs is incompatible with older Windows versions */ 26 37 #define PROCESS_ALL_ACCESS_NT4 (PROCESS_ALL_ACCESS & ~0xf000) ··· 40 51 static LONG *child_failures; 41 52 static WORD cb_count; 42 53 static DWORD page_size; 54 + static BOOL is_win64 = sizeof(void *) > sizeof(int); 55 + static BOOL is_wow64; 43 56 44 57 static NTSTATUS (WINAPI *pNtCreateSection)(HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES *, 45 58 const LARGE_INTEGER *, ULONG, ULONG, HANDLE ); 46 - static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *, ULONG, ULONG *); 59 + static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *, SIZE_T, SIZE_T *); 47 60 static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T, const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG); 48 61 static NTSTATUS (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID); 49 62 static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); ··· 65 78 static BOOL (WINAPI *pFlsSetValue)(DWORD, PVOID); 66 79 static PVOID (WINAPI *pFlsGetValue)(DWORD); 67 80 static BOOL (WINAPI *pFlsFree)(DWORD); 81 + static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL); 68 82 69 83 static PVOID RVAToAddr(DWORD_PTR rva, HMODULE module) 70 84 { ··· 154 168 static const char section_data[0x10] = "section data"; 155 169 156 170 static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size, 157 - const IMAGE_NT_HEADERS *nt_header, const char *dll_name ) 171 + const IMAGE_NT_HEADERS *nt_header, char dll_name[MAX_PATH] ) 158 172 { 173 + char temp_path[MAX_PATH]; 159 174 DWORD dummy, size, file_align; 160 175 HANDLE hfile; 161 176 BOOL ret; 162 177 178 + GetTempPathA(MAX_PATH, temp_path); 179 + GetTempFileNameA(temp_path, "ldr", 0, dll_name); 180 + 163 181 hfile = CreateFileA(dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0); 182 + ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %u\n", dll_name, GetLastError() ); 164 183 if (hfile == INVALID_HANDLE_VALUE) return 0; 165 184 166 185 SetLastError(0xdeadbeef); ··· 233 252 return size; 234 253 } 235 254 236 - static void query_image_section( int id, const char *dll_name, const IMAGE_NT_HEADERS *nt_header ) 255 + static DWORD create_test_dll_sections( const IMAGE_DOS_HEADER *dos_header, const IMAGE_NT_HEADERS *nt_header, 256 + const IMAGE_SECTION_HEADER *sections, const void *section_data, 257 + char dll_name[MAX_PATH] ) 237 258 { 259 + char temp_path[MAX_PATH]; 260 + DWORD dummy, i, size; 261 + HANDLE hfile; 262 + BOOL ret; 263 + 264 + GetTempPathA(MAX_PATH, temp_path); 265 + GetTempFileNameA(temp_path, "ldr", 0, dll_name); 266 + 267 + hfile = CreateFileA(dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0); 268 + ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %u\n", dll_name, GetLastError() ); 269 + if (hfile == INVALID_HANDLE_VALUE) return 0; 270 + 271 + SetLastError(0xdeadbeef); 272 + ret = WriteFile(hfile, dos_header, sizeof(*dos_header), &dummy, NULL); 273 + ok(ret, "WriteFile error %d\n", GetLastError()); 274 + 275 + SetLastError(0xdeadbeef); 276 + ret = WriteFile(hfile, nt_header, offsetof(IMAGE_NT_HEADERS, OptionalHeader) + nt_header->FileHeader.SizeOfOptionalHeader, &dummy, NULL); 277 + ok(ret, "WriteFile error %d\n", GetLastError()); 278 + 279 + SetLastError(0xdeadbeef); 280 + ret = WriteFile(hfile, sections, sizeof(*sections) * nt_header->FileHeader.NumberOfSections, 281 + &dummy, NULL); 282 + ok(ret, "WriteFile error %d\n", GetLastError()); 283 + 284 + for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++) 285 + { 286 + SetFilePointer(hfile, sections[i].PointerToRawData, NULL, FILE_BEGIN); 287 + SetLastError(0xdeadbeef); 288 + ret = WriteFile(hfile, section_data, sections[i].SizeOfRawData, &dummy, NULL); 289 + ok(ret, "WriteFile error %d\n", GetLastError()); 290 + } 291 + size = GetFileSize(hfile, NULL); 292 + CloseHandle(hfile); 293 + return size; 294 + } 295 + 296 + static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HEADERS *nt_header, 297 + const void *section_data ) 298 + { 299 + static BOOL is_winxp; 238 300 SECTION_BASIC_INFORMATION info; 239 301 SECTION_IMAGE_INFORMATION image; 240 - ULONG info_size = 0xdeadbeef; 302 + const IMAGE_COR20_HEADER *cor_header = NULL; 303 + SIZE_T info_size = (SIZE_T)0xdeadbeef << 16; 241 304 NTSTATUS status; 242 305 HANDLE file, mapping; 243 306 ULONG file_size; 244 307 LARGE_INTEGER map_size; 308 + SIZE_T max_stack, commit_stack; 309 + void *entry_point; 310 + 245 311 /* truncated header is not handled correctly in windows <= w2k3 */ 246 - BOOL truncated = nt_header->FileHeader.SizeOfOptionalHeader < sizeof(nt_header->OptionalHeader); 312 + BOOL truncated; 247 313 248 314 file = CreateFileA( dll_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, 249 315 NULL, OPEN_EXISTING, 0, 0 ); ··· 256 322 if (status) 257 323 { 258 324 CloseHandle( file ); 259 - return; 325 + return FALSE; 260 326 } 261 327 status = pNtQuerySection( mapping, SectionImageInformation, &image, sizeof(image), &info_size ); 262 328 ok( !status, "%u: NtQuerySection failed err %x\n", id, status ); 263 - ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %u\n", id, info_size ); 264 - ok( (char *)image.TransferAddress == (char *)nt_header->OptionalHeader.ImageBase + nt_header->OptionalHeader.AddressOfEntryPoint, 265 - "%u: TransferAddress wrong %p / %p+%08x\n", id, 266 - image.TransferAddress, (char *)nt_header->OptionalHeader.ImageBase, 267 - nt_header->OptionalHeader.AddressOfEntryPoint ); 329 + ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %lu\n", id, info_size ); 330 + if (nt_header->OptionalHeader.Magic == (is_win64 ? IMAGE_NT_OPTIONAL_HDR64_MAGIC 331 + : IMAGE_NT_OPTIONAL_HDR32_MAGIC)) 332 + { 333 + max_stack = nt_header->OptionalHeader.SizeOfStackReserve; 334 + commit_stack = nt_header->OptionalHeader.SizeOfStackCommit; 335 + entry_point = (char *)nt_header->OptionalHeader.ImageBase + nt_header->OptionalHeader.AddressOfEntryPoint; 336 + truncated = nt_header->FileHeader.SizeOfOptionalHeader < sizeof(IMAGE_OPTIONAL_HEADER); 337 + if (!truncated && 338 + nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress && 339 + nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size) 340 + cor_header = section_data; 341 + } 342 + else if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) 343 + { 344 + const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt_header; 345 + max_stack = 0x100000; 346 + commit_stack = 0x10000; 347 + entry_point = (void *)0x81231234; 348 + truncated = nt_header->FileHeader.SizeOfOptionalHeader < sizeof(IMAGE_OPTIONAL_HEADER64); 349 + if (!truncated && 350 + nt64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress && 351 + nt64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size) 352 + cor_header = section_data; 353 + } 354 + else 355 + { 356 + const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt_header; 357 + max_stack = nt32->OptionalHeader.SizeOfStackReserve; 358 + commit_stack = nt32->OptionalHeader.SizeOfStackCommit; 359 + entry_point = (char *)(ULONG_PTR)nt32->OptionalHeader.ImageBase + nt32->OptionalHeader.AddressOfEntryPoint; 360 + truncated = nt_header->FileHeader.SizeOfOptionalHeader < sizeof(IMAGE_OPTIONAL_HEADER32); 361 + if (!truncated && 362 + nt32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress && 363 + nt32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size) 364 + cor_header = section_data; 365 + } 366 + ok( (char *)image.TransferAddress == (char *)entry_point || 367 + (S(U(image)).ImageDynamicallyRelocated && LOWORD(image.TransferAddress) == LOWORD(entry_point)), 368 + "%u: TransferAddress wrong %p / %p (%08x)\n", id, 369 + image.TransferAddress, entry_point, nt_header->OptionalHeader.AddressOfEntryPoint ); 268 370 ok( image.ZeroBits == 0, "%u: ZeroBits wrong %08x\n", id, image.ZeroBits ); 269 - ok( image.MaximumStackSize == nt_header->OptionalHeader.SizeOfStackReserve || broken(truncated), 270 - "%u: MaximumStackSize wrong %lx / %lx\n", id, 271 - image.MaximumStackSize, (SIZE_T)nt_header->OptionalHeader.SizeOfStackReserve ); 272 - ok( image.CommittedStackSize == nt_header->OptionalHeader.SizeOfStackCommit || broken(truncated), 273 - "%u: CommittedStackSize wrong %lx / %lx\n", id, 274 - image.CommittedStackSize, (SIZE_T)nt_header->OptionalHeader.SizeOfStackCommit ); 371 + ok( image.MaximumStackSize == max_stack || broken(truncated), 372 + "%u: MaximumStackSize wrong %lx / %lx\n", id, image.MaximumStackSize, max_stack ); 373 + ok( image.CommittedStackSize == commit_stack || broken(truncated), 374 + "%u: CommittedStackSize wrong %lx / %lx\n", id, image.CommittedStackSize, commit_stack ); 275 375 if (truncated) 276 376 ok( !image.SubSystemType || broken(truncated), 277 377 "%u: SubSystemType wrong %08x / 00000000\n", id, image.SubSystemType ); ··· 293 393 image.DllCharacteristics, nt_header->OptionalHeader.DllCharacteristics ); 294 394 ok( image.Machine == nt_header->FileHeader.Machine, "%u: Machine wrong %04x / %04x\n", id, 295 395 image.Machine, nt_header->FileHeader.Machine ); 296 - ok( image.LoaderFlags == nt_header->OptionalHeader.LoaderFlags, 297 - "%u: LoaderFlags wrong %08x / %08x\n", id, 298 - image.LoaderFlags, nt_header->OptionalHeader.LoaderFlags ); 396 + ok( image.LoaderFlags == (cor_header != NULL), "%u: LoaderFlags wrong %08x\n", id, image.LoaderFlags ); 299 397 ok( image.ImageFileSize == file_size || broken(!image.ImageFileSize), /* winxpsp1 */ 300 398 "%u: ImageFileSize wrong %08x / %08x\n", id, image.ImageFileSize, file_size ); 301 399 ok( image.CheckSum == nt_header->OptionalHeader.CheckSum || broken(truncated), 302 400 "%u: CheckSum wrong %08x / %08x\n", id, 303 401 image.CheckSum, nt_header->OptionalHeader.CheckSum ); 402 + 403 + if (nt_header->OptionalHeader.SizeOfCode || nt_header->OptionalHeader.AddressOfEntryPoint) 404 + ok( image.ImageContainsCode == TRUE, "%u: ImageContainsCode wrong %u\n", id, 405 + image.ImageContainsCode ); 406 + else if ((nt_header->OptionalHeader.SectionAlignment % page_size) || 407 + (nt_header->FileHeader.NumberOfSections == 1 && 408 + (section.Characteristics & IMAGE_SCN_MEM_EXECUTE))) 409 + ok( image.ImageContainsCode == TRUE || broken(!image.ImageContainsCode), /* <= win8 */ 410 + "%u: ImageContainsCode wrong %u\n", id, image.ImageContainsCode ); 411 + else 412 + ok( !image.ImageContainsCode, "%u: ImageContainsCode wrong %u\n", id, image.ImageContainsCode ); 413 + 414 + if (cor_header && 415 + (cor_header->Flags & COMIMAGE_FLAGS_ILONLY) && 416 + (cor_header->MajorRuntimeVersion > 2 || 417 + (cor_header->MajorRuntimeVersion == 2 && cor_header->MinorRuntimeVersion >= 5))) 418 + { 419 + ok( S(U(image)).ComPlusILOnly || broken(is_winxp), 420 + "%u: wrong ComPlusILOnly flags %02x\n", id, U(image).ImageFlags ); 421 + if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC && 422 + !(cor_header->Flags & COMIMAGE_FLAGS_32BITREQUIRED)) 423 + ok( S(U(image)).ComPlusNativeReady || broken(is_winxp), 424 + "%u: wrong ComPlusNativeReady flags %02x\n", id, U(image).ImageFlags ); 425 + else 426 + ok( !S(U(image)).ComPlusNativeReady, 427 + "%u: wrong ComPlusNativeReady flags %02x\n", id, U(image).ImageFlags ); 428 + } 429 + else 430 + { 431 + ok( !S(U(image)).ComPlusILOnly, "%u: wrong ComPlusILOnly flags %02x\n", id, U(image).ImageFlags ); 432 + ok( !S(U(image)).ComPlusNativeReady, "%u: wrong ComPlusNativeReady flags %02x\n", id, U(image).ImageFlags ); 433 + } 434 + if (!(nt_header->OptionalHeader.SectionAlignment % page_size)) 435 + ok( !S(U(image)).ImageMappedFlat, "%u: wrong ImageMappedFlat flags %02x\n", id, U(image).ImageFlags ); 436 + else 437 + { 438 + /* winxp doesn't support any of the loader flags */ 439 + if (!S(U(image)).ImageMappedFlat) is_winxp = TRUE; 440 + ok( S(U(image)).ImageMappedFlat || broken(is_winxp), 441 + "%u: wrong ImageMappedFlat flags %02x\n", id, U(image).ImageFlags ); 442 + } 443 + if (!(nt_header->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE)) 444 + ok( !S(U(image)).ImageDynamicallyRelocated || broken( S(U(image)).ComPlusILOnly ), /* <= win7 */ 445 + "%u: wrong ImageDynamicallyRelocated flags %02x\n", id, U(image).ImageFlags ); 446 + else if (image.ImageContainsCode && !cor_header) 447 + ok( S(U(image)).ImageDynamicallyRelocated || broken(is_winxp), 448 + "%u: wrong ImageDynamicallyRelocated flags %02x\n", id, U(image).ImageFlags ); 449 + else 450 + ok( !S(U(image)).ImageDynamicallyRelocated || broken(TRUE), /* <= win8 */ 451 + "%u: wrong ImageDynamicallyRelocated flags %02x\n", id, U(image).ImageFlags ); 452 + ok( !S(U(image)).BaseBelow4gb, "%u: wrong BaseBelow4gb flags %02x\n", id, U(image).ImageFlags ); 453 + 304 454 /* FIXME: needs more work: */ 305 455 /* image.GpValue */ 306 - /* image.ImageFlags */ 307 - /* image.ImageContainsCode */ 308 456 309 457 map_size.QuadPart = (nt_header->OptionalHeader.SizeOfImage + page_size - 1) & ~(page_size - 1); 310 458 status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info), NULL ); ··· 345 493 CloseHandle( mapping ); 346 494 347 495 CloseHandle( file ); 496 + return image.ImageContainsCode && (!cor_header || !(cor_header->Flags & COMIMAGE_FLAGS_ILONLY)); 348 497 } 349 498 350 499 /* helper to test image section mapping */ 351 - static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header ) 500 + static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAGE_SECTION_HEADER *sections, 501 + const void *section_data, int line ) 352 502 { 353 - char temp_path[MAX_PATH]; 354 503 char dll_name[MAX_PATH]; 355 504 LARGE_INTEGER size; 356 505 HANDLE file, map; 357 506 NTSTATUS status; 358 507 ULONG file_size; 508 + BOOL has_code; 509 + HMODULE mod; 359 510 360 - GetTempPathA(MAX_PATH, temp_path); 361 - GetTempFileNameA(temp_path, "ldr", 0, dll_name); 362 - 363 - file_size = create_test_dll( &dos_header, sizeof(dos_header), nt_header, dll_name ); 364 - ok( file_size, "could not create %s\n", dll_name); 511 + file_size = create_test_dll_sections( &dos_header, nt_header, sections, section_data, dll_name ); 365 512 366 513 file = CreateFileA(dll_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); 367 514 ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError()); ··· 372 519 if (!status) 373 520 { 374 521 SECTION_BASIC_INFORMATION info; 375 - ULONG info_size = 0xdeadbeef; 522 + SIZE_T info_size = 0xdeadbeef; 376 523 NTSTATUS ret = pNtQuerySection( map, SectionBasicInformation, &info, sizeof(info), &info_size ); 377 524 ok( !ret, "NtQuerySection failed err %x\n", ret ); 378 - ok( info_size == sizeof(info), "NtQuerySection wrong size %u\n", info_size ); 525 + ok( info_size == sizeof(info), "NtQuerySection wrong size %lu\n", info_size ); 379 526 ok( info.Attributes == (SEC_IMAGE | SEC_FILE), "NtQuerySection wrong attr %x\n", info.Attributes ); 380 527 ok( info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", info.BaseAddress ); 381 528 ok( info.Size.QuadPart == file_size, "NtQuerySection wrong size %x%08x / %08x\n", 382 529 info.Size.u.HighPart, info.Size.u.LowPart, file_size ); 383 - query_image_section( 1000, dll_name, nt_header ); 530 + has_code = query_image_section( line, dll_name, nt_header, section_data ); 531 + /* test loading dll of wrong 32/64 bitness */ 532 + if (nt_header->OptionalHeader.Magic == (is_win64 ? IMAGE_NT_OPTIONAL_HDR32_MAGIC 533 + : IMAGE_NT_OPTIONAL_HDR64_MAGIC)) 534 + { 535 + SetLastError( 0xdeadbeef ); 536 + mod = LoadLibraryExA( dll_name, 0, DONT_RESOLVE_DLL_REFERENCES ); 537 + if (!has_code && nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) 538 + { 539 + BOOL il_only = FALSE; 540 + if (((const IMAGE_NT_HEADERS32 *)nt_header)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress) 541 + { 542 + const IMAGE_COR20_HEADER *cor_header = section_data; 543 + il_only = (cor_header->Flags & COMIMAGE_FLAGS_ILONLY) != 0; 544 + } 545 + ok( mod != NULL || broken(il_only), /* <= win7 */ 546 + "%u: loading failed err %u\n", line, GetLastError() ); 547 + } 548 + else 549 + { 550 + ok( !mod, "%u: loading succeeded\n", line ); 551 + ok( GetLastError() == ERROR_BAD_EXE_FORMAT, "%u: wrong error %u\n", line, GetLastError() ); 552 + } 553 + if (mod) FreeLibrary( mod ); 554 + } 384 555 } 385 556 if (map) CloseHandle( map ); 386 557 CloseHandle( file ); ··· 540 711 DWORD file_size; 541 712 HANDLE h; 542 713 HMODULE hlib, hlib_as_data_file; 543 - char temp_path[MAX_PATH]; 544 714 char dll_name[MAX_PATH]; 545 715 SIZE_T size; 546 716 BOOL ret; 547 717 NTSTATUS status; 548 - WORD orig_machine = nt_header_template.FileHeader.Machine; 718 + WORD alt_machine, orig_machine = nt_header_template.FileHeader.Machine; 549 719 IMAGE_NT_HEADERS nt_header; 720 + IMAGE_COR20_HEADER cor_header; 550 721 551 722 /* prevent displaying of the "Unable to load this DLL" message box */ 552 723 SetErrorMode(SEM_FAILCRITICALERRORS); 553 724 554 - GetTempPathA(MAX_PATH, temp_path); 555 - 556 725 for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) 557 726 { 558 - GetTempFileNameA(temp_path, "ldr", 0, dll_name); 559 - 560 727 nt_header = nt_header_template; 561 728 nt_header.FileHeader.NumberOfSections = td[i].number_of_sections; 562 729 nt_header.FileHeader.SizeOfOptionalHeader = td[i].size_of_optional_header; ··· 567 734 nt_header.OptionalHeader.SizeOfHeaders = td[i].size_of_headers; 568 735 569 736 file_size = create_test_dll( &dos_header, td[i].size_of_dos_header, &nt_header, dll_name ); 570 - if (!file_size) 571 - { 572 - ok(0, "could not create %s\n", dll_name); 573 - break; 574 - } 575 737 576 738 SetLastError(0xdeadbeef); 577 739 hlib = LoadLibraryA(dll_name); ··· 601 763 SetLastError(0xdeadbeef); 602 764 ptr = VirtualAlloc(hlib, page_size, MEM_COMMIT, info.Protect); 603 765 ok(!ptr, "%d: VirtualAlloc should fail\n", i); 604 - /* FIXME: Remove once Wine is fixed */ 605 - todo_wine_if (info.Protect == PAGE_WRITECOPY || info.Protect == PAGE_EXECUTE_WRITECOPY) 606 766 ok(GetLastError() == ERROR_ACCESS_DENIED, "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError()); 607 767 608 768 SetLastError(0xdeadbeef); ··· 687 847 SetLastError(0xdeadbeef); 688 848 ptr = VirtualAlloc((char *)hlib + section.VirtualAddress, page_size, MEM_COMMIT, info.Protect); 689 849 ok(!ptr, "%d: VirtualAlloc should fail\n", i); 690 - /* FIXME: Remove once Wine is fixed */ 691 - todo_wine_if (info.Protect == PAGE_WRITECOPY || info.Protect == PAGE_EXECUTE_WRITECOPY) 692 850 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == ERROR_INVALID_ADDRESS, 693 851 "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError()); 694 852 } ··· 716 874 SetLastError(0xdeadbeef); 717 875 hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE); 718 876 ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError()); 719 - ok((ULONG_PTR)hlib_as_data_file & 1, "hlib_as_data_file is even\n"); 877 + ok(((ULONG_PTR)hlib_as_data_file & 3) == 1, "hlib_as_data_file got %p\n", hlib_as_data_file); 720 878 721 879 hlib = GetModuleHandleA(dll_name); 722 880 ok(!hlib, "GetModuleHandle should fail\n"); ··· 732 890 733 891 SetLastError(0xdeadbeef); 734 892 hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE); 735 - if (!((ULONG_PTR)hlib_as_data_file & 1) || /* winxp */ 893 + if (!((ULONG_PTR)hlib_as_data_file & 3) || /* winxp */ 736 894 (!hlib_as_data_file && GetLastError() == ERROR_INVALID_PARAMETER)) /* w2k3 */ 737 895 { 738 896 win_skip( "LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE not supported\n" ); ··· 744 902 745 903 SetLastError(0xdeadbeef); 746 904 h = CreateFileA( dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 ); 747 - todo_wine ok( h == INVALID_HANDLE_VALUE, "open succeeded\n" ); 748 - todo_wine ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error %u\n", GetLastError() ); 905 + ok( h == INVALID_HANDLE_VALUE, "open succeeded\n" ); 906 + ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error %u\n", GetLastError() ); 907 + CloseHandle( h ); 908 + 909 + SetLastError(0xdeadbeef); 910 + h = CreateFileA( dll_name, GENERIC_READ | DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 ); 911 + ok( h != INVALID_HANDLE_VALUE, "open failed err %u\n", GetLastError() ); 749 912 CloseHandle( h ); 750 913 751 914 SetLastError(0xdeadbeef); ··· 754 917 } 755 918 756 919 SetLastError(0xdeadbeef); 920 + hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_IMAGE_RESOURCE); 921 + if (!((ULONG_PTR)hlib_as_data_file & 3) || /* winxp */ 922 + (!hlib_as_data_file && GetLastError() == ERROR_INVALID_PARAMETER)) /* w2k3 */ 923 + { 924 + win_skip( "LOAD_LIBRARY_AS_IMAGE_RESOURCE not supported\n" ); 925 + FreeLibrary(hlib_as_data_file); 926 + } 927 + else 928 + { 929 + ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError()); 930 + ok(((ULONG_PTR)hlib_as_data_file & 3) == 2, "hlib_as_data_file got %p\n", 931 + hlib_as_data_file); 932 + 933 + hlib = GetModuleHandleA(dll_name); 934 + ok(!hlib, "GetModuleHandle should fail\n"); 935 + 936 + SetLastError(0xdeadbeef); 937 + ret = FreeLibrary(hlib_as_data_file); 938 + ok(ret, "FreeLibrary error %d\n", GetLastError()); 939 + } 940 + 941 + SetLastError(0xdeadbeef); 757 942 ret = DeleteFileA(dll_name); 758 943 ok(ret, "DeleteFile error %d\n", GetLastError()); 759 944 ··· 764 949 ok(0, "could not create %s\n", dll_name); 765 950 break; 766 951 } 767 - query_image_section( i, dll_name, &nt_header ); 952 + 953 + query_image_section( i, dll_name, &nt_header, NULL ); 768 954 } 769 955 else 770 956 { ··· 797 983 nt_header.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER); 798 984 nt_header.OptionalHeader.SizeOfImage = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + page_size; 799 985 800 - status = map_image_section( &nt_header ); 986 + section.SizeOfRawData = sizeof(section_data); 987 + section.PointerToRawData = page_size; 988 + section.VirtualAddress = page_size; 989 + section.Misc.VirtualSize = page_size; 990 + 991 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 992 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 993 + 994 + nt_header.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE; 995 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 996 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 997 + 998 + nt_header.OptionalHeader.SizeOfCode = 0x1000; 999 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 801 1000 ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1001 + nt_header.OptionalHeader.SizeOfCode = 0; 1002 + nt_header.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_NX_COMPAT; 802 1003 803 1004 dos_header.e_magic = 0; 804 - status = map_image_section( &nt_header ); 1005 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 805 1006 ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection error %08x\n", status ); 806 1007 807 1008 dos_header.e_magic = IMAGE_DOS_SIGNATURE; 808 1009 nt_header.Signature = IMAGE_OS2_SIGNATURE; 809 - status = map_image_section( &nt_header ); 1010 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 810 1011 ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection error %08x\n", status ); 811 1012 812 1013 nt_header.Signature = 0xdeadbeef; 813 - status = map_image_section( &nt_header ); 1014 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 814 1015 ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08x\n", status ); 815 1016 816 1017 nt_header.Signature = IMAGE_NT_SIGNATURE; 817 1018 nt_header.OptionalHeader.Magic = 0xdead; 818 - status = map_image_section( &nt_header ); 1019 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 819 1020 ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08x\n", status ); 820 1021 821 1022 nt_header.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC; 822 1023 nt_header.FileHeader.Machine = 0xdead; 823 - status = map_image_section( &nt_header ); 1024 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 824 1025 ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */ 825 1026 "NtCreateSection error %08x\n", status ); 826 1027 827 1028 nt_header.FileHeader.Machine = IMAGE_FILE_MACHINE_UNKNOWN; 828 - status = map_image_section( &nt_header ); 1029 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 1030 + ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */ 1031 + "NtCreateSection error %08x\n", status ); 1032 + 1033 + switch (orig_machine) 1034 + { 1035 + case IMAGE_FILE_MACHINE_I386: alt_machine = IMAGE_FILE_MACHINE_ARMNT; break; 1036 + case IMAGE_FILE_MACHINE_AMD64: alt_machine = IMAGE_FILE_MACHINE_ARM64; break; 1037 + case IMAGE_FILE_MACHINE_ARMNT: alt_machine = IMAGE_FILE_MACHINE_I386; break; 1038 + case IMAGE_FILE_MACHINE_ARM64: alt_machine = IMAGE_FILE_MACHINE_AMD64; break; 1039 + } 1040 + nt_header.FileHeader.Machine = alt_machine; 1041 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 829 1042 ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */ 830 1043 "NtCreateSection error %08x\n", status ); 831 1044 832 1045 switch (orig_machine) 833 1046 { 834 - case IMAGE_FILE_MACHINE_I386: nt_header.FileHeader.Machine = IMAGE_FILE_MACHINE_AMD64; break; 835 - case IMAGE_FILE_MACHINE_AMD64: nt_header.FileHeader.Machine = IMAGE_FILE_MACHINE_I386; break; 836 - case IMAGE_FILE_MACHINE_ARMNT: nt_header.FileHeader.Machine = IMAGE_FILE_MACHINE_ARM64; break; 837 - case IMAGE_FILE_MACHINE_ARM64: nt_header.FileHeader.Machine = IMAGE_FILE_MACHINE_ARMNT; break; 1047 + case IMAGE_FILE_MACHINE_I386: alt_machine = IMAGE_FILE_MACHINE_AMD64; break; 1048 + case IMAGE_FILE_MACHINE_AMD64: alt_machine = IMAGE_FILE_MACHINE_I386; break; 1049 + case IMAGE_FILE_MACHINE_ARMNT: alt_machine = IMAGE_FILE_MACHINE_ARM64; break; 1050 + case IMAGE_FILE_MACHINE_ARM64: alt_machine = IMAGE_FILE_MACHINE_ARMNT; break; 838 1051 } 839 - status = map_image_section( &nt_header ); 1052 + nt_header.FileHeader.Machine = alt_machine; 1053 + status = map_image_section( &nt_header, &section, section_data, __LINE__ ); 840 1054 ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */ 841 1055 "NtCreateSection error %08x\n", status ); 842 1056 1057 + nt_header.FileHeader.Machine = orig_machine; 1058 + nt_header.OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; 1059 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = page_size; 1060 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = sizeof(cor_header); 1061 + section.SizeOfRawData = sizeof(cor_header); 1062 + 1063 + memset( &cor_header, 0, sizeof(cor_header) ); 1064 + cor_header.cb = sizeof(cor_header); 1065 + cor_header.MajorRuntimeVersion = 2; 1066 + cor_header.MinorRuntimeVersion = 4; 1067 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY; 1068 + U(cor_header).EntryPointToken = 0xbeef; 1069 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1070 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1071 + 1072 + cor_header.MinorRuntimeVersion = 5; 1073 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1074 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1075 + 1076 + cor_header.MajorRuntimeVersion = 3; 1077 + cor_header.MinorRuntimeVersion = 0; 1078 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1079 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1080 + 1081 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITREQUIRED; 1082 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1083 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1084 + 1085 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITPREFERRED; 1086 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1087 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1088 + 1089 + cor_header.Flags = 0; 1090 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1091 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1092 + 1093 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = 1; 1094 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = 1; 1095 + status = map_image_section( &nt_header, &section, &cor_header, __LINE__ ); 1096 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1097 + 843 1098 if (nt_header.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) 844 1099 { 845 1100 IMAGE_NT_HEADERS64 nt64; ··· 849 1104 nt64.FileHeader.Machine = orig_machine; 850 1105 nt64.FileHeader.NumberOfSections = 1; 851 1106 nt64.FileHeader.SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER64); 1107 + nt64.FileHeader.Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL; 852 1108 nt64.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR64_MAGIC; 853 1109 nt64.OptionalHeader.MajorLinkerVersion = 1; 1110 + nt64.OptionalHeader.SizeOfCode = 0x1000; 1111 + nt64.OptionalHeader.AddressOfEntryPoint = 0x1000; 854 1112 nt64.OptionalHeader.ImageBase = 0x10000000; 1113 + nt64.OptionalHeader.SectionAlignment = 0x1000; 1114 + nt64.OptionalHeader.FileAlignment = 0x1000; 855 1115 nt64.OptionalHeader.MajorOperatingSystemVersion = 4; 856 1116 nt64.OptionalHeader.MajorImageVersion = 1; 857 1117 nt64.OptionalHeader.MajorSubsystemVersion = 4; 858 1118 nt64.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt64) + sizeof(IMAGE_SECTION_HEADER); 859 1119 nt64.OptionalHeader.SizeOfImage = nt64.OptionalHeader.SizeOfHeaders + 0x1000; 860 1120 nt64.OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI; 861 - status = map_image_section( (IMAGE_NT_HEADERS *)&nt64 ); 862 - ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08x\n", status ); 1121 + nt64.OptionalHeader.SizeOfStackReserve = 0x321000; 1122 + nt64.OptionalHeader.SizeOfStackCommit = 0x123000; 1123 + section.Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE; 1124 + 1125 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1126 + ok( status == (is_wow64 ? STATUS_INVALID_IMAGE_FORMAT : STATUS_INVALID_IMAGE_WIN_64), 1127 + "NtCreateSection error %08x\n", status ); 1128 + 1129 + switch (orig_machine) 1130 + { 1131 + case IMAGE_FILE_MACHINE_I386: nt64.FileHeader.Machine = IMAGE_FILE_MACHINE_ARM64; break; 1132 + case IMAGE_FILE_MACHINE_ARMNT: nt64.FileHeader.Machine = IMAGE_FILE_MACHINE_AMD64; break; 1133 + } 1134 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1135 + ok( status == (is_wow64 ? STATUS_INVALID_IMAGE_FORMAT : STATUS_INVALID_IMAGE_WIN_64), 1136 + "NtCreateSection error %08x\n", status ); 1137 + 1138 + nt64.FileHeader.Machine = alt_machine; 1139 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1140 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1141 + "NtCreateSection error %08x\n", status ); 1142 + 1143 + nt64.OptionalHeader.SizeOfCode = 0; 1144 + nt64.OptionalHeader.AddressOfEntryPoint = 0x1000; 1145 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE; 1146 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1147 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1148 + "NtCreateSection error %08x\n", status ); 1149 + 1150 + nt64.OptionalHeader.SizeOfCode = 0; 1151 + nt64.OptionalHeader.AddressOfEntryPoint = 0; 1152 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE; 1153 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1154 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1155 + "NtCreateSection error %08x\n", status ); 1156 + 1157 + nt64.OptionalHeader.SizeOfCode = 0x1000; 1158 + nt64.OptionalHeader.AddressOfEntryPoint = 0; 1159 + nt64.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE; 1160 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE; 1161 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1162 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1163 + "NtCreateSection error %08x\n", status ); 1164 + 1165 + nt64.OptionalHeader.SizeOfCode = 0; 1166 + nt64.OptionalHeader.AddressOfEntryPoint = 0; 1167 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE; 1168 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ ); 1169 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1170 + "NtCreateSection error %08x\n", status ); 1171 + 1172 + nt64.OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; 1173 + nt64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = page_size; 1174 + nt64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = sizeof(cor_header); 1175 + cor_header.MajorRuntimeVersion = 2; 1176 + cor_header.MinorRuntimeVersion = 4; 1177 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY; 1178 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1179 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1180 + "NtCreateSection error %08x\n", status ); 1181 + 1182 + nt64.OptionalHeader.SizeOfCode = 0x1000; 1183 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1184 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1185 + "NtCreateSection error %08x\n", status ); 1186 + 1187 + cor_header.MinorRuntimeVersion = 5; 1188 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1189 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1190 + "NtCreateSection error %08x\n", status ); 1191 + 1192 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITREQUIRED; 1193 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1194 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1195 + "NtCreateSection error %08x\n", status ); 1196 + 1197 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITPREFERRED; 1198 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1199 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1200 + "NtCreateSection error %08x\n", status ); 1201 + 1202 + cor_header.Flags = 0; 1203 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1204 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1205 + "NtCreateSection error %08x\n", status ); 1206 + 1207 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = 1; 1208 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = 1; 1209 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ ); 1210 + ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64), 1211 + "NtCreateSection error %08x\n", status ); 863 1212 } 864 1213 else 865 1214 { ··· 870 1219 nt32.FileHeader.Machine = orig_machine; 871 1220 nt32.FileHeader.NumberOfSections = 1; 872 1221 nt32.FileHeader.SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER32); 1222 + nt32.FileHeader.Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL; 873 1223 nt32.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR32_MAGIC; 874 1224 nt32.OptionalHeader.MajorLinkerVersion = 1; 1225 + nt32.OptionalHeader.SizeOfCode = 0x1000; 1226 + nt32.OptionalHeader.AddressOfEntryPoint = 0x1000; 875 1227 nt32.OptionalHeader.ImageBase = 0x10000000; 1228 + nt32.OptionalHeader.SectionAlignment = 0x1000; 1229 + nt32.OptionalHeader.FileAlignment = 0x1000; 876 1230 nt32.OptionalHeader.MajorOperatingSystemVersion = 4; 877 1231 nt32.OptionalHeader.MajorImageVersion = 1; 878 1232 nt32.OptionalHeader.MajorSubsystemVersion = 4; 879 1233 nt32.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt32) + sizeof(IMAGE_SECTION_HEADER); 880 1234 nt32.OptionalHeader.SizeOfImage = nt32.OptionalHeader.SizeOfHeaders + 0x1000; 881 1235 nt32.OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI; 882 - status = map_image_section( (IMAGE_NT_HEADERS *)&nt32 ); 1236 + nt32.OptionalHeader.SizeOfStackReserve = 0x321000; 1237 + nt32.OptionalHeader.SizeOfStackCommit = 0x123000; 1238 + section.Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE; 1239 + 1240 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 883 1241 ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08x\n", status ); 1242 + 1243 + switch (orig_machine) 1244 + { 1245 + case IMAGE_FILE_MACHINE_AMD64: nt32.FileHeader.Machine = IMAGE_FILE_MACHINE_ARMNT; break; 1246 + case IMAGE_FILE_MACHINE_ARM64: nt32.FileHeader.Machine = IMAGE_FILE_MACHINE_I386; break; 1247 + } 1248 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 1249 + ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(!status) /* win8 */, 1250 + "NtCreateSection error %08x\n", status ); 1251 + 1252 + nt32.FileHeader.Machine = alt_machine; 1253 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 1254 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1255 + 1256 + nt32.OptionalHeader.SizeOfCode = 0; 1257 + nt32.OptionalHeader.AddressOfEntryPoint = 0x1000; 1258 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE; 1259 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 1260 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1261 + 1262 + nt32.OptionalHeader.SizeOfCode = 0; 1263 + nt32.OptionalHeader.AddressOfEntryPoint = 0; 1264 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE; 1265 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 1266 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1267 + 1268 + nt32.OptionalHeader.SizeOfCode = 0x1000; 1269 + nt32.OptionalHeader.AddressOfEntryPoint = 0; 1270 + nt32.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE; 1271 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE; 1272 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 1273 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1274 + 1275 + nt32.OptionalHeader.SizeOfCode = 0; 1276 + nt32.OptionalHeader.AddressOfEntryPoint = 0; 1277 + section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE; 1278 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ ); 1279 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1280 + 1281 + nt32.OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; 1282 + nt32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = page_size; 1283 + nt32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = sizeof(cor_header); 1284 + cor_header.MajorRuntimeVersion = 2; 1285 + cor_header.MinorRuntimeVersion = 4; 1286 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY; 1287 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1288 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1289 + 1290 + nt32.OptionalHeader.SizeOfCode = 0x1000; 1291 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1292 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1293 + 1294 + cor_header.MinorRuntimeVersion = 5; 1295 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1296 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1297 + 1298 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITREQUIRED; 1299 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1300 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1301 + 1302 + cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITPREFERRED; 1303 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1304 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1305 + 1306 + cor_header.Flags = 0; 1307 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1308 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 1309 + 1310 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = 1; 1311 + nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = 1; 1312 + status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ ); 1313 + ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status ); 884 1314 } 885 1315 886 - nt_header.FileHeader.Machine = orig_machine; /* restore it for the next tests */ 1316 + section.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ; 1317 + } 1318 + 1319 + static void test_filenames(void) 1320 + { 1321 + IMAGE_NT_HEADERS nt_header = nt_header_template; 1322 + char dll_name[MAX_PATH], long_path[MAX_PATH], short_path[MAX_PATH], buffer[MAX_PATH]; 1323 + HMODULE mod, mod2; 1324 + BOOL ret; 1325 + 1326 + nt_header.FileHeader.NumberOfSections = 1; 1327 + nt_header.FileHeader.SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER); 1328 + 1329 + nt_header.OptionalHeader.SectionAlignment = page_size; 1330 + nt_header.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_NX_COMPAT; 1331 + nt_header.OptionalHeader.FileAlignment = page_size; 1332 + nt_header.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER); 1333 + nt_header.OptionalHeader.SizeOfImage = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + page_size; 1334 + 1335 + create_test_dll( &dos_header, sizeof(dos_header), &nt_header, dll_name ); 1336 + strcpy( long_path, dll_name ); 1337 + strcpy( strrchr( long_path, '\\' ), "\\this-is-a-long-name.dll" ); 1338 + ret = MoveFileA( dll_name, long_path ); 1339 + ok( ret, "MoveFileA failed err %u\n", GetLastError() ); 1340 + GetShortPathNameA( long_path, short_path, MAX_PATH ); 1341 + 1342 + mod = LoadLibraryA( short_path ); 1343 + ok( mod != NULL, "loading failed err %u\n", GetLastError() ); 1344 + GetModuleFileNameA( mod, buffer, MAX_PATH ); 1345 + ok( !lstrcmpiA( buffer, short_path ), "got wrong path %s / %s\n", buffer, short_path ); 1346 + mod2 = GetModuleHandleA( short_path ); 1347 + ok( mod == mod2, "wrong module %p for %s\n", mod2, short_path ); 1348 + mod2 = GetModuleHandleA( long_path ); 1349 + ok( mod == mod2, "wrong module %p for %s\n", mod2, long_path ); 1350 + mod2 = LoadLibraryA( long_path ); 1351 + ok( mod2 != NULL, "loading failed err %u\n", GetLastError() ); 1352 + ok( mod == mod2, "library loaded twice\n" ); 1353 + GetModuleFileNameA( mod2, buffer, MAX_PATH ); 1354 + ok( !lstrcmpiA( buffer, short_path ), "got wrong path %s / %s\n", buffer, short_path ); 1355 + FreeLibrary( mod2 ); 1356 + FreeLibrary( mod ); 1357 + 1358 + mod = LoadLibraryA( long_path ); 1359 + ok( mod != NULL, "loading failed err %u\n", GetLastError() ); 1360 + GetModuleFileNameA( mod, buffer, MAX_PATH ); 1361 + ok( !lstrcmpiA( buffer, long_path ), "got wrong path %s / %s\n", buffer, long_path ); 1362 + mod2 = GetModuleHandleA( short_path ); 1363 + ok( mod == mod2, "wrong module %p for %s\n", mod2, short_path ); 1364 + mod2 = GetModuleHandleA( long_path ); 1365 + ok( mod == mod2, "wrong module %p for %s\n", mod2, long_path ); 1366 + mod2 = LoadLibraryA( short_path ); 1367 + ok( mod2 != NULL, "loading failed err %u\n", GetLastError() ); 1368 + ok( mod == mod2, "library loaded twice\n" ); 1369 + GetModuleFileNameA( mod2, buffer, MAX_PATH ); 1370 + ok( !lstrcmpiA( buffer, long_path ), "got wrong path %s / %s\n", buffer, long_path ); 1371 + FreeLibrary( mod2 ); 1372 + FreeLibrary( mod ); 1373 + 1374 + strcpy( dll_name, long_path ); 1375 + strcpy( strrchr( dll_name, '\\' ), "\\this-is-another-name.dll" ); 1376 + ret = CreateHardLinkA( dll_name, long_path, NULL ); 1377 + ok( ret, "CreateHardLinkA failed err %u\n", GetLastError() ); 1378 + if (ret) 1379 + { 1380 + mod = LoadLibraryA( dll_name ); 1381 + ok( mod != NULL, "loading failed err %u\n", GetLastError() ); 1382 + GetModuleFileNameA( mod, buffer, MAX_PATH ); 1383 + ok( !lstrcmpiA( buffer, dll_name ), "got wrong path %s / %s\n", buffer, dll_name ); 1384 + mod2 = GetModuleHandleA( long_path ); 1385 + ok( mod == mod2, "wrong module %p for %s\n", mod2, long_path ); 1386 + mod2 = LoadLibraryA( long_path ); 1387 + ok( mod2 != NULL, "loading failed err %u\n", GetLastError() ); 1388 + ok( mod == mod2, "library loaded twice\n" ); 1389 + GetModuleFileNameA( mod2, buffer, MAX_PATH ); 1390 + ok( !lstrcmpiA( buffer, dll_name ), "got wrong path %s / %s\n", buffer, short_path ); 1391 + FreeLibrary( mod2 ); 1392 + FreeLibrary( mod ); 1393 + DeleteFileA( dll_name ); 1394 + } 1395 + DeleteFileA( long_path ); 887 1396 } 888 1397 889 1398 static void test_FakeDLL(void) ··· 1536 2045 nt.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress = DATA_RVA(&data.tls); 1537 2046 1538 2047 memset( &data, 0, sizeof(data) ); 1539 - data.descr[0].OriginalFirstThunk = DATA_RVA( data.original_thunks ); 2048 + U(data.descr[0]).OriginalFirstThunk = DATA_RVA( data.original_thunks ); 1540 2049 data.descr[0].FirstThunk = DATA_RVA( data.thunks ); 1541 2050 data.descr[0].Name = DATA_RVA( data.module ); 1542 2051 strcpy( data.module, "kernel32.dll" ); ··· 1647 2156 wait_list[2] = peb_lock_event; 1648 2157 wait_list[3] = heap_lock_event; 1649 2158 1650 - trace("%04u: mutex_thread_proc: starting\n", GetCurrentThreadId()); 2159 + trace("%04x: mutex_thread_proc: starting\n", GetCurrentThreadId()); 1651 2160 while (1) 1652 2161 { 1653 2162 ret = WaitForMultipleObjects(sizeof(wait_list)/sizeof(wait_list[0]), wait_list, FALSE, 50); ··· 1655 2164 else if (ret == WAIT_OBJECT_0 + 1) 1656 2165 { 1657 2166 ULONG_PTR loader_lock_magic; 1658 - trace("%04u: mutex_thread_proc: Entering loader lock\n", GetCurrentThreadId()); 2167 + trace("%04x: mutex_thread_proc: Entering loader lock\n", GetCurrentThreadId()); 1659 2168 ret = pLdrLockLoaderLock(0, NULL, &loader_lock_magic); 1660 2169 ok(!ret, "LdrLockLoaderLock error %#x\n", ret); 1661 2170 inside_loader_lock++; ··· 1663 2172 } 1664 2173 else if (ret == WAIT_OBJECT_0 + 2) 1665 2174 { 1666 - trace("%04u: mutex_thread_proc: Entering PEB lock\n", GetCurrentThreadId()); 2175 + trace("%04x: mutex_thread_proc: Entering PEB lock\n", GetCurrentThreadId()); 1667 2176 pRtlAcquirePebLock(); 1668 2177 inside_peb_lock++; 1669 2178 SetEvent(ack_event); 1670 2179 } 1671 2180 else if (ret == WAIT_OBJECT_0 + 3) 1672 2181 { 1673 - trace("%04u: mutex_thread_proc: Entering heap lock\n", GetCurrentThreadId()); 2182 + trace("%04x: mutex_thread_proc: Entering heap lock\n", GetCurrentThreadId()); 1674 2183 HeapLock(GetProcessHeap()); 1675 2184 inside_heap_lock++; 1676 2185 SetEvent(ack_event); 1677 2186 } 1678 2187 } 1679 2188 1680 - trace("%04u: mutex_thread_proc: exiting\n", GetCurrentThreadId()); 2189 + trace("%04x: mutex_thread_proc: exiting\n", GetCurrentThreadId()); 1681 2190 return 196; 1682 2191 } 1683 2192 ··· 1693 2202 while (1) 1694 2203 { 1695 2204 if (winetest_debug > 1) 1696 - trace("%04u: semaphore_thread_proc: still alive\n", GetCurrentThreadId()); 2205 + trace("%04x: semaphore_thread_proc: still alive\n", GetCurrentThreadId()); 1697 2206 if (WaitForSingleObject(stop_event, 50) != WAIT_TIMEOUT) break; 1698 2207 } 1699 2208 1700 - trace("%04u: semaphore_thread_proc: exiting\n", GetCurrentThreadId()); 2209 + trace("%04x: semaphore_thread_proc: exiting\n", GetCurrentThreadId()); 1701 2210 return 196; 1702 2211 } 1703 2212 ··· 1709 2218 InterlockedIncrement(noop_thread_started); 1710 2219 } 1711 2220 1712 - trace("%04u: noop_thread_proc: exiting\n", GetCurrentThreadId()); 2221 + trace("%04x: noop_thread_proc: exiting\n", GetCurrentThreadId()); 1713 2222 return 195; 1714 2223 } 1715 2224 ··· 2273 2782 case 3: 2274 2783 trace("signalling thread exit\n"); 2275 2784 SetEvent(stop_event); 2276 - CloseHandle(stop_event); 2277 2785 break; 2278 2786 2279 2787 case 4: ··· 3262 3770 pFlsSetValue = (void *)GetProcAddress(kernel32, "FlsSetValue"); 3263 3771 pFlsGetValue = (void *)GetProcAddress(kernel32, "FlsGetValue"); 3264 3772 pFlsFree = (void *)GetProcAddress(kernel32, "FlsFree"); 3773 + pIsWow64Process = (void *)GetProcAddress(kernel32, "IsWow64Process"); 3265 3774 pResolveDelayLoadedAPI = (void *)GetProcAddress(kernel32, "ResolveDelayLoadedAPI"); 3266 3775 3776 + if (pIsWow64Process) pIsWow64Process( GetCurrentProcess(), &is_wow64 ); 3267 3777 GetSystemInfo( &si ); 3268 3778 page_size = si.dwPageSize; 3269 3779 dos_header.e_magic = IMAGE_DOS_SIGNATURE; ··· 3289 3799 3290 3800 test_Loader(); 3291 3801 test_FakeDLL(); 3802 + test_filenames(); 3292 3803 test_ResolveDelayLoadedAPI(); 3293 3804 test_ImportDescriptors(); 3294 3805 test_section_access();
+42 -16
modules/rostests/winetests/kernel32/locale.c
··· 25 25 * the control panel i8n page), we will still get the expected results. 26 26 */ 27 27 28 - #include "precomp.h" 28 + #include <assert.h> 29 + #include <stdlib.h> 30 + #include <stdarg.h> 31 + #include <stdio.h> 32 + 33 + #include "wine/test.h" 34 + #include "windef.h" 35 + #include "winbase.h" 36 + #include "winerror.h" 37 + #include "winnls.h" 29 38 30 39 static const WCHAR upper_case[] = {'\t','J','U','S','T','!',' ','A',',',' ','T','E','S','T',';',' ','S','T','R','I','N','G',' ','1','/','*','+','-','.','\r','\n',0}; 31 40 static const WCHAR lower_case[] = {'\t','j','u','s','t','!',' ','a',',',' ','t','e','s','t',';',' ','s','t','r','i','n','g',' ','1','/','*','+','-','.','\r','\n',0}; ··· 2471 2480 ok(ret == ret2, "%s ret %d, expected value %d\n", func_name, ret2, ret); 2472 2481 2473 2482 /* test LCMAP_FULLWIDTH | LCMAP_HIRAGANA 2474 - (half-width katakana is converted into full-wdith hiragana) */ 2483 + (half-width katakana is converted into full-width hiragana) */ 2475 2484 ret = func_ptr(LCMAP_FULLWIDTH | LCMAP_HIRAGANA, 2476 2485 halfwidth_text, -1, buf, sizeof(buf)/sizeof(WCHAR)); 2477 2486 ok(ret == lstrlenW(hiragana_text) + 1, "%s ret %d, error %d, expected value %d\n", func_name, ··· 2770 2779 ptr++; 2771 2780 } 2772 2781 2773 - /* zh-Hant */ 2782 + /* zh-Hant has LCID 0x7c04, but LocaleNameToLCID actually returns 0x0c04, which is the LCID of zh-HK */ 2774 2783 lcid = pLocaleNameToLCID(zhHantW, 0); 2775 - todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT), 2784 + ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT), 2776 2785 "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhHantW), lcid); 2777 2786 ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0); 2778 2787 ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHantW), ret); 2779 - todo_wine ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n", 2788 + ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n", 2789 + wine_dbgstr_w(zhHantW), wine_dbgstr_w(buffer)); 2790 + /* check that 0x7c04 also works and is mapped to zh-HK */ 2791 + ret = pLCIDToLocaleName(MAKELANGID(LANG_CHINESE_TRADITIONAL, SUBLANG_CHINESE_TRADITIONAL), buffer, sizeof(buffer)/sizeof(WCHAR), 0); 2792 + todo_wine ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHantW), ret); 2793 + ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n", 2780 2794 wine_dbgstr_w(zhHantW), wine_dbgstr_w(buffer)); 2781 2795 2782 2796 /* zh-hant */ 2783 2797 lcid = pLocaleNameToLCID(zhhantW, 0); 2784 - todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT), 2785 - "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhantW), 2786 - MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT)); 2798 + ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT), 2799 + "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhantW), lcid); 2787 2800 ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0); 2788 2801 ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhhantW), ret); 2789 - todo_wine ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n", 2802 + ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n", 2790 2803 wine_dbgstr_w(zhhantW), wine_dbgstr_w(buffer)); 2791 2804 2792 - /* zh-Hans */ 2805 + /* zh-Hans has LCID 0x0004, but LocaleNameToLCID actually returns 0x0804, which is the LCID of zh-CN */ 2793 2806 lcid = pLocaleNameToLCID(zhHansW, 0); 2794 - todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT), 2807 + /* check that LocaleNameToLCID actually returns 0x0804 */ 2808 + ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT), 2795 2809 "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhHansW), lcid); 2796 2810 ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0); 2797 2811 ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHansW), ret); 2798 - todo_wine ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n", 2812 + ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n", 2813 + wine_dbgstr_w(zhHansW), wine_dbgstr_w(buffer)); 2814 + /* check that 0x0004 also works and is mapped to zh-CN */ 2815 + ret = pLCIDToLocaleName(MAKELANGID(LANG_CHINESE, SUBLANG_NEUTRAL), buffer, sizeof(buffer)/sizeof(WCHAR), 0); 2816 + ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHansW), ret); 2817 + ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n", 2799 2818 wine_dbgstr_w(zhHansW), wine_dbgstr_w(buffer)); 2800 2819 2801 2820 /* zh-hans */ 2802 2821 lcid = pLocaleNameToLCID(zhhansW, 0); 2803 - todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT), 2804 - "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhansW), 2805 - MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); 2822 + ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT), 2823 + "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhansW), lcid); 2806 2824 ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0); 2807 2825 ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhhansW), ret); 2808 - todo_wine ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n", 2826 + ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n", 2809 2827 wine_dbgstr_w(zhhansW), wine_dbgstr_w(buffer)); 2810 2828 } 2811 2829 } ··· 4464 4482 ret = pGetLocaleInfoEx(enW, LOCALE_SABBREVLANGNAME, bufferW, sizeof(bufferW)/sizeof(WCHAR)); 4465 4483 ok(ret == lstrlenW(bufferW)+1, "got %d\n", ret); 4466 4484 ok(!lstrcmpW(bufferW, enuW), "got %s\n", wine_dbgstr_w(bufferW)); 4485 + 4486 + ret = pGetLocaleInfoEx(enusW, LOCALE_SPARENT, bufferW, sizeof(bufferW)/sizeof(WCHAR)); 4487 + ok(ret == lstrlenW(bufferW)+1, "got %d\n", ret); 4488 + ok(!lstrcmpW(bufferW, enW), "got %s\n", wine_dbgstr_w(bufferW)); 4489 + 4490 + ret = pGetLocaleInfoEx(enW, LOCALE_SPARENT, bufferW, sizeof(bufferW)/sizeof(WCHAR)); 4491 + ok(ret == 1, "got %d\n", ret); 4492 + ok(!bufferW[0], "got %s\n", wine_dbgstr_w(bufferW)); 4467 4493 4468 4494 ret = pGetLocaleInfoEx(enW, LOCALE_SCOUNTRY, bufferW, sizeof(bufferW)/sizeof(WCHAR)); 4469 4495 ok(ret == lstrlenW(bufferW)+1, "got %d\n", ret);
+8 -1
modules/rostests/winetests/kernel32/mailslot.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + #include <stdlib.h> 23 + #include <stdio.h> 24 + 25 + #include <windef.h> 26 + #include <winbase.h> 27 + 28 + #include "wine/test.h" 22 29 23 30 static const char szmspath[] = "\\\\.\\mailslot\\wine_mailslot_test"; 24 31
+59 -111
modules/rostests/winetests/kernel32/module.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 22 - 21 + #include "wine/test.h" 22 + #include <windows.h> 23 + #include <stdio.h> 23 24 #include <psapi.h> 24 25 25 26 static DWORD (WINAPI *pGetDllDirectoryA)(DWORD,LPSTR); ··· 28 29 static DLL_DIRECTORY_COOKIE (WINAPI *pAddDllDirectory)(const WCHAR*); 29 30 static BOOL (WINAPI *pRemoveDllDirectory)(DLL_DIRECTORY_COOKIE); 30 31 static BOOL (WINAPI *pSetDefaultDllDirectories)(DWORD); 31 - static BOOL (WINAPI *pGetModuleHandleExA)(DWORD,LPCSTR,HMODULE*); 32 - static BOOL (WINAPI *pGetModuleHandleExW)(DWORD,LPCWSTR,HMODULE*); 33 32 static BOOL (WINAPI *pK32GetModuleInformation)(HANDLE process, HMODULE module, 34 33 MODULEINFO *modinfo, DWORD cb); 35 34 ··· 179 178 ok(len1W / 2 == len2W, "Correct length in GetModuleFilenameW with buffer too small (%d/%d)\n", len1W / 2, len2W); 180 179 } 181 180 182 - ok(len1A / 2 == len2A || 183 - len1A / 2 == len2A + 1, /* Win9x */ 181 + ok(len1A / 2 == len2A, 184 182 "Correct length in GetModuleFilenameA with buffer too small (%d/%d)\n", len1A / 2, len2A); 185 183 } 186 184 ··· 199 197 200 198 bufA[0] = '*'; 201 199 ok(GetModuleFileNameA((void*)0xffffffff, bufA, sizeof(bufA)) == 0, "Unexpected success in module handle\n"); 202 - ok(bufA[0] == '*' || 203 - bufA[0] == 0 /* Win9x */, 204 - "When failing, buffer shouldn't be written to\n"); 200 + ok(bufA[0] == '*', "When failing, buffer shouldn't be written to\n"); 205 201 } 206 202 207 203 static void testLoadLibraryA(void) ··· 220 216 221 217 SetLastError(0xdeadbeef); 222 218 hModule1 = LoadLibraryA("kernel32 "); 223 - /* Only winNT does this */ 224 - if (GetLastError() != ERROR_DLL_NOT_FOUND) 225 - { 226 - ok( hModule1 != NULL, "\"kernel32 \" should be loadable\n"); 227 - ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError()); 228 - ok( hModule == hModule1, "Loaded wrong module\n"); 229 - FreeLibrary(hModule1); 230 - } 219 + ok( hModule1 != NULL, "\"kernel32 \" should be loadable\n" ); 220 + ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError() ); 221 + ok( hModule == hModule1, "Loaded wrong module\n" ); 222 + FreeLibrary(hModule1); 231 223 FreeLibrary(hModule); 232 224 } 233 225 ··· 252 244 hModule1 = LoadLibraryA(path1); 253 245 if (!hModule1) 254 246 { 255 - /* We must be on Windows NT, so we cannot test */ 247 + /* We must be on Windows, so we cannot test */ 256 248 return; 257 249 } 258 250 ··· 260 252 strcat(path2, "\\system32\\"); 261 253 strcat(path2, dllname); 262 254 hModule2 = LoadLibraryA(path2); 263 - if (!hModule2) 264 - { 265 - /* We must be on Windows 9x, so we cannot test */ 266 - ok(FreeLibrary(hModule1), "FreeLibrary() failed\n"); 267 - return; 268 - } 255 + ok(hModule2 != NULL, "LoadLibrary(%s) failed\n", path2); 269 256 270 257 /* The first LoadLibrary() call may have registered the dll under the 271 258 * system32 path. So load it, again, under the '...\system\...' path so ··· 295 282 SetLastError(0xdeadbeef); 296 283 hModule = LoadLibraryA("non_ex_pv.dll"); 297 284 ok( !hModule, "non_ex_pv.dll should be not loadable\n"); 298 - ok( GetLastError() == ERROR_MOD_NOT_FOUND || GetLastError() == ERROR_DLL_NOT_FOUND, 299 - "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND (win9x), got %d\n", GetLastError()); 285 + ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() ); 300 286 301 287 /* Just in case */ 302 288 FreeLibrary(hModule); ··· 309 295 SetLastError(0xdeadbeef); 310 296 fp = GetProcAddress(NULL, "non_ex_call"); 311 297 ok( !fp, "non_ex_call should not be found\n"); 312 - ok( GetLastError() == ERROR_PROC_NOT_FOUND || GetLastError() == ERROR_INVALID_HANDLE, 313 - "Expected ERROR_PROC_NOT_FOUND or ERROR_INVALID_HANDLE(win9x), got %d\n", GetLastError()); 298 + ok( GetLastError() == ERROR_PROC_NOT_FOUND, "Expected ERROR_PROC_NOT_FOUND, got %d\n", GetLastError() ); 314 299 315 300 SetLastError(0xdeadbeef); 316 301 fp = GetProcAddress((HMODULE)0xdeadbeef, "non_ex_call"); 317 302 ok( !fp, "non_ex_call should not be found\n"); 318 - ok( GetLastError() == ERROR_MOD_NOT_FOUND || GetLastError() == ERROR_INVALID_HANDLE, 319 - "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_HANDLE(win9x), got %d\n", GetLastError()); 303 + ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() ); 320 304 } 321 305 322 306 static void testLoadLibraryEx(void) ··· 332 316 ok(hfile != INVALID_HANDLE_VALUE, "Expected a valid file handle\n"); 333 317 334 318 /* NULL lpFileName */ 335 - if (is_unicode_enabled) 336 - { 337 - SetLastError(0xdeadbeef); 338 - hmodule = LoadLibraryExA(NULL, NULL, 0); 339 - ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 340 - ok(GetLastError() == ERROR_MOD_NOT_FOUND || 341 - GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ 342 - "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", 343 - GetLastError()); 344 - } 345 - else 346 - win_skip("NULL filename crashes on WinMe\n"); 319 + SetLastError(0xdeadbeef); 320 + hmodule = LoadLibraryExA(NULL, NULL, 0); 321 + ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 322 + ok(GetLastError() == ERROR_MOD_NOT_FOUND || 323 + GetLastError() == ERROR_INVALID_PARAMETER, 324 + "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); 347 325 348 326 /* empty lpFileName */ 349 327 SetLastError(0xdeadbeef); 350 328 hmodule = LoadLibraryExA("", NULL, 0); 351 329 ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 352 330 ok(GetLastError() == ERROR_MOD_NOT_FOUND || 353 - GetLastError() == ERROR_DLL_NOT_FOUND /* win9x */ || 354 331 GetLastError() == ERROR_INVALID_PARAMETER /* win8 */, 355 - "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %d\n", 356 - GetLastError()); 332 + "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %d\n", GetLastError()); 357 333 358 334 /* hFile is non-NULL */ 359 335 SetLastError(0xdeadbeef); ··· 362 338 todo_wine 363 339 { 364 340 ok(GetLastError() == ERROR_SHARING_VIOLATION || 365 - GetLastError() == ERROR_INVALID_PARAMETER || /* win2k3 */ 366 - GetLastError() == ERROR_FILE_NOT_FOUND, /* win9x */ 341 + GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */ 367 342 "Unexpected last error, got %d\n", GetLastError()); 368 343 } 369 344 ··· 373 348 todo_wine 374 349 { 375 350 ok(GetLastError() == ERROR_SHARING_VIOLATION || 376 - GetLastError() == ERROR_INVALID_PARAMETER || /* win2k3 */ 377 - GetLastError() == ERROR_FILE_NOT_FOUND, /* win9x */ 351 + GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */ 378 352 "Unexpected last error, got %d\n", GetLastError()); 379 353 } 380 354 ··· 384 358 ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 385 359 todo_wine 386 360 { 387 - ok(GetLastError() == ERROR_SHARING_VIOLATION || 388 - GetLastError() == ERROR_FILE_NOT_FOUND, /* win9x */ 389 - "Expected ERROR_SHARING_VIOLATION or ERROR_FILE_NOT_FOUND, got %d\n", 390 - GetLastError()); 361 + ok(GetLastError() == ERROR_SHARING_VIOLATION, 362 + "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError()); 391 363 } 392 364 393 365 /* lpFileName does not matter */ ··· 398 370 ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 399 371 ok(GetLastError() == ERROR_MOD_NOT_FOUND || 400 372 GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */ 401 - "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", 402 - GetLastError()); 373 + "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); 403 374 } 404 375 405 376 CloseHandle(hfile); ··· 410 381 ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 411 382 todo_wine 412 383 { 413 - ok(GetLastError() == ERROR_FILE_INVALID || 414 - GetLastError() == ERROR_BAD_FORMAT, /* win9x */ 415 - "Expected ERROR_FILE_INVALID or ERROR_BAD_FORMAT, got %d\n", 416 - GetLastError()); 384 + ok(GetLastError() == ERROR_FILE_INVALID, 385 + "Expected ERROR_FILE_INVALID, got %d\n", GetLastError()); 417 386 } 418 387 419 388 DeleteFileA("testfile.dll"); ··· 428 397 hmodule = LoadLibraryExA(path, NULL, LOAD_LIBRARY_AS_DATAFILE); 429 398 ok(hmodule != 0, "Expected valid module handle\n"); 430 399 ok(GetLastError() == 0xdeadbeef || 431 - GetLastError() == ERROR_SUCCESS, /* win9x */ 400 + GetLastError() == ERROR_SUCCESS, 432 401 "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n", GetLastError()); 433 402 434 403 /* try invalid file handle */ ··· 443 412 SetLastError(0xdeadbeef); 444 413 hmodule = LoadLibraryExA("kernel32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); 445 414 ok(hmodule != 0, "Expected valid module handle\n"); 446 - ok(GetLastError() == 0xdeadbeef || 447 - GetLastError() == ERROR_SUCCESS, /* win9x */ 448 - "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n", GetLastError()); 415 + ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); 449 416 450 417 FreeLibrary(hmodule); 451 418 ··· 461 428 { 462 429 ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 463 430 } 464 - ok(GetLastError() == ERROR_FILE_NOT_FOUND || 465 - broken(GetLastError() == ERROR_INVALID_HANDLE), /* nt4 */ 431 + ok(GetLastError() == ERROR_FILE_NOT_FOUND, 466 432 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); 467 433 468 434 /* Free the loaded dll when it's the first time this dll is loaded ··· 730 696 MAKEFUNC(AddDllDirectory); 731 697 MAKEFUNC(RemoveDllDirectory); 732 698 MAKEFUNC(SetDefaultDllDirectories); 733 - MAKEFUNC(GetModuleHandleExA); 734 - MAKEFUNC(GetModuleHandleExW); 735 699 MAKEFUNC(K32GetModuleInformation); 736 700 #undef MAKEFUNC 737 701 738 - /* not all Windows versions export this in kernel32 */ 702 + /* before Windows 7 this was not exported in kernel32 */ 739 703 if (!pK32GetModuleInformation) 740 704 { 741 705 HMODULE hPsapi = LoadLibraryA("psapi.dll"); 742 - if (hPsapi) 743 - { 744 - pK32GetModuleInformation = (void *)GetProcAddress(hPsapi, "GetModuleInformation"); 745 - if (!pK32GetModuleInformation) FreeLibrary(hPsapi); 746 - } 706 + pK32GetModuleInformation = (void *)GetProcAddress(hPsapi, "GetModuleInformation"); 747 707 } 748 - 749 708 } 750 709 751 710 static void testGetModuleHandleEx(void) ··· 756 715 DWORD error; 757 716 HMODULE mod, mod_kernel32; 758 717 759 - if (!pGetModuleHandleExA || !pGetModuleHandleExW) 760 - { 761 - win_skip( "GetModuleHandleEx not available\n" ); 762 - return; 763 - } 764 - 765 718 SetLastError( 0xdeadbeef ); 766 - ret = pGetModuleHandleExA( 0, NULL, NULL ); 719 + ret = GetModuleHandleExA( 0, NULL, NULL ); 767 720 error = GetLastError(); 768 721 ok( !ret, "unexpected success\n" ); 769 722 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 770 723 771 724 SetLastError( 0xdeadbeef ); 772 - ret = pGetModuleHandleExA( 0, "kernel32", NULL ); 725 + ret = GetModuleHandleExA( 0, "kernel32", NULL ); 773 726 error = GetLastError(); 774 727 ok( !ret, "unexpected success\n" ); 775 728 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 776 729 777 730 SetLastError( 0xdeadbeef ); 778 731 mod = (HMODULE)0xdeadbeef; 779 - ret = pGetModuleHandleExA( 0, "kernel32", &mod ); 732 + ret = GetModuleHandleExA( 0, "kernel32", &mod ); 780 733 ok( ret, "unexpected failure %u\n", GetLastError() ); 781 734 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod ); 782 735 FreeLibrary( mod ); 783 736 784 737 SetLastError( 0xdeadbeef ); 785 738 mod = (HMODULE)0xdeadbeef; 786 - ret = pGetModuleHandleExA( 0, "nosuchmod", &mod ); 739 + ret = GetModuleHandleExA( 0, "nosuchmod", &mod ); 787 740 error = GetLastError(); 788 741 ok( !ret, "unexpected success\n" ); 789 742 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error ); 790 743 ok( mod == NULL, "got %p\n", mod ); 791 744 792 745 SetLastError( 0xdeadbeef ); 793 - ret = pGetModuleHandleExW( 0, NULL, NULL ); 746 + ret = GetModuleHandleExW( 0, NULL, NULL ); 794 747 error = GetLastError(); 795 748 ok( !ret, "unexpected success\n" ); 796 749 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 797 750 798 751 SetLastError( 0xdeadbeef ); 799 - ret = pGetModuleHandleExW( 0, kernel32W, NULL ); 752 + ret = GetModuleHandleExW( 0, kernel32W, NULL ); 800 753 error = GetLastError(); 801 754 ok( !ret, "unexpected success\n" ); 802 755 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 803 756 804 757 SetLastError( 0xdeadbeef ); 805 758 mod = (HMODULE)0xdeadbeef; 806 - ret = pGetModuleHandleExW( 0, kernel32W, &mod ); 759 + ret = GetModuleHandleExW( 0, kernel32W, &mod ); 807 760 ok( ret, "unexpected failure %u\n", GetLastError() ); 808 761 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod ); 809 762 FreeLibrary( mod ); 810 763 811 764 SetLastError( 0xdeadbeef ); 812 765 mod = (HMODULE)0xdeadbeef; 813 - ret = pGetModuleHandleExW( 0, nosuchmodW, &mod ); 766 + ret = GetModuleHandleExW( 0, nosuchmodW, &mod ); 814 767 error = GetLastError(); 815 768 ok( !ret, "unexpected success\n" ); 816 769 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error ); 817 770 ok( mod == NULL, "got %p\n", mod ); 818 771 819 772 SetLastError( 0xdeadbeef ); 820 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL ); 773 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL ); 821 774 error = GetLastError(); 822 775 ok( !ret, "unexpected success\n" ); 823 776 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 824 777 825 778 SetLastError( 0xdeadbeef ); 826 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", NULL ); 779 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", NULL ); 827 780 error = GetLastError(); 828 781 ok( !ret, "unexpected success\n" ); 829 782 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 830 783 831 784 SetLastError( 0xdeadbeef ); 832 785 mod = (HMODULE)0xdeadbeef; 833 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", &mod ); 786 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", &mod ); 834 787 ok( ret, "unexpected failure %u\n", GetLastError() ); 835 788 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod ); 836 789 837 790 SetLastError( 0xdeadbeef ); 838 791 mod = (HMODULE)0xdeadbeef; 839 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "nosuchmod", &mod ); 792 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "nosuchmod", &mod ); 840 793 error = GetLastError(); 841 794 ok( !ret, "unexpected success\n" ); 842 795 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error ); 843 796 ok( mod == NULL, "got %p\n", mod ); 844 797 845 798 SetLastError( 0xdeadbeef ); 846 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL ); 799 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL ); 847 800 error = GetLastError(); 848 801 ok( !ret, "unexpected success\n" ); 849 802 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 850 803 851 804 SetLastError( 0xdeadbeef ); 852 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, NULL ); 805 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, NULL ); 853 806 error = GetLastError(); 854 807 ok( !ret, "unexpected success\n" ); 855 808 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 856 809 857 810 SetLastError( 0xdeadbeef ); 858 811 mod = (HMODULE)0xdeadbeef; 859 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, &mod ); 812 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, &mod ); 860 813 ok( ret, "unexpected failure %u\n", GetLastError() ); 861 814 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod ); 862 815 863 816 SetLastError( 0xdeadbeef ); 864 817 mod = (HMODULE)0xdeadbeef; 865 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, nosuchmodW, &mod ); 818 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, nosuchmodW, &mod ); 866 819 error = GetLastError(); 867 820 ok( !ret, "unexpected success\n" ); 868 821 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error ); ··· 871 824 mod_kernel32 = LoadLibraryA( "kernel32" ); 872 825 873 826 SetLastError( 0xdeadbeef ); 874 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL ); 827 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL ); 875 828 error = GetLastError(); 876 829 ok( !ret, "unexpected success\n" ); 877 830 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 878 831 879 832 SetLastError( 0xdeadbeef ); 880 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, NULL ); 833 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, NULL ); 881 834 error = GetLastError(); 882 835 ok( !ret, "unexpected success\n" ); 883 836 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 884 837 885 838 SetLastError( 0xdeadbeef ); 886 839 mod = (HMODULE)0xdeadbeef; 887 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, &mod ); 840 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, &mod ); 888 841 ok( ret, "unexpected failure %u\n", GetLastError() ); 889 842 ok( mod == mod_kernel32, "got %p\n", mod ); 890 843 FreeLibrary( mod ); 891 844 892 845 SetLastError( 0xdeadbeef ); 893 846 mod = (HMODULE)0xdeadbeef; 894 - ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)0xbeefdead, &mod ); 847 + ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)0xbeefdead, &mod ); 895 848 error = GetLastError(); 896 849 ok( !ret, "unexpected success\n" ); 897 850 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error ); 898 851 ok( mod == NULL, "got %p\n", mod ); 899 852 900 853 SetLastError( 0xdeadbeef ); 901 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL ); 854 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL ); 902 855 error = GetLastError(); 903 856 ok( !ret, "unexpected success\n" ); 904 857 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 905 858 906 859 SetLastError( 0xdeadbeef ); 907 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, NULL ); 860 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, NULL ); 908 861 error = GetLastError(); 909 862 ok( !ret, "unexpected success\n" ); 910 863 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); 911 864 912 865 SetLastError( 0xdeadbeef ); 913 866 mod = (HMODULE)0xdeadbeef; 914 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, &mod ); 867 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, &mod ); 915 868 ok( ret, "unexpected failure %u\n", GetLastError() ); 916 869 ok( mod == mod_kernel32, "got %p\n", mod ); 917 870 FreeLibrary( mod ); 918 871 919 872 SetLastError( 0xdeadbeef ); 920 873 mod = (HMODULE)0xdeadbeef; 921 - ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)0xbeefdead, &mod ); 874 + ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)0xbeefdead, &mod ); 922 875 error = GetLastError(); 923 876 ok( !ret, "unexpected success\n" ); 924 877 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error ); ··· 932 885 MODULEINFO info; 933 886 HMODULE mod; 934 887 BOOL ret; 935 - 936 - if (!pK32GetModuleInformation) 937 - { 938 - win_skip("K32GetModuleInformation not available\n"); 939 - return; 940 - } 941 888 942 889 mod = GetModuleHandleA(NULL); 943 890 memset(&info, 0xAA, sizeof(info)); ··· 971 918 972 919 buf[0] = '\0'; 973 920 GetTempPathW( sizeof(path)/sizeof(path[0]), path ); 974 - GetTempFileNameW( path, tmpW, 0, buf ); 921 + ret = GetTempFileNameW( path, tmpW, 0, buf ); 922 + ok( ret, "GetTempFileName failed err %u\n", GetLastError() ); 975 923 SetLastError( 0xdeadbeef ); 976 924 cookie = pAddDllDirectory( buf ); 977 925 ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
+9 -1
modules/rostests/winetests/kernel32/path.c
··· 19 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 20 */ 21 21 22 - #include "precomp.h" 22 + #include <stdarg.h> 23 + #include <stdio.h> 24 + #include <assert.h> 25 + #include "wine/test.h" 26 + #include "windef.h" 27 + #include "winbase.h" 28 + #include "winuser.h" 29 + #include "winerror.h" 30 + #include "winnls.h" 23 31 24 32 #define HAS_TRAIL_SLASH_A(string) (string[lstrlenA(string)-1]=='\\') 25 33
+215 -78
modules/rostests/winetests/kernel32/pipe.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + #include <stdio.h> 23 + 24 + #include "ntstatus.h" 25 + #define WIN32_NO_STATUS 26 + #include "windef.h" 27 + #include "winbase.h" 28 + #include "winternl.h" 29 + #include "winioctl.h" 30 + #include "wine/test.h" 22 31 23 32 #define PIPENAME "\\\\.\\PiPe\\tests_pipe.c" 24 33 #define PIPENAME_SPECIAL "\\\\.\\PiPe\\tests->pipe.c" ··· 54 63 static DWORD CALLBACK rpcThreadMain(LPVOID arg) 55 64 { 56 65 struct rpcThreadArgs *rpcargs = (struct rpcThreadArgs *)arg; 57 - trace("rpcThreadMain starting\n"); 66 + if (winetest_debug > 1) trace("rpcThreadMain starting\n"); 58 67 SetLastError( rpcargs->lastError ); 59 68 60 69 switch (rpcargs->op) ··· 74 83 } 75 84 76 85 rpcargs->lastError = GetLastError(); 77 - trace("rpcThreadMain returning\n"); 86 + if (winetest_debug > 1) trace("rpcThreadMain returning\n"); 78 87 return 0; 79 88 } 80 89 ··· 201 210 ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n"); 202 211 test_signaled(hnp); 203 212 213 + ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL); 214 + todo_wine 215 + ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n", 216 + ret, GetLastError()); 217 + 204 218 ret = WaitNamedPipeA(PIPENAME, 2000); 205 219 ok(ret, "WaitNamedPipe failed (%d)\n", GetLastError()); 206 220 ··· 210 224 ok(!WaitNamedPipeA(PIPENAME, 100), "WaitNamedPipe succeeded\n"); 211 225 212 226 ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError()); 227 + 228 + /* Test ConnectNamedPipe() in both directions */ 229 + ok(!ConnectNamedPipe(hnp, NULL), "ConnectNamedPipe(server) succeeded\n"); 230 + ok(GetLastError() == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %u\n", GetLastError()); 231 + ok(!ConnectNamedPipe(hFile, NULL), "ConnectNamedPipe(client) succeeded\n"); 232 + ok(GetLastError() == ERROR_INVALID_FUNCTION, "expected ERROR_INVALID_FUNCTION, got %u\n", GetLastError()); 213 233 214 234 /* don't try to do i/o if one side couldn't be opened, as it hangs */ 215 235 if (hFile != INVALID_HANDLE_VALUE) { ··· 343 363 ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail); 344 364 ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, &left), "Peek3\n"); 345 365 if (pipemode == PIPE_TYPE_BYTE) { 346 - /* currently the Wine behavior depends on the kernel version */ 347 - /* ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes\n", readden); */ 348 - if (readden != sizeof(obuf) + sizeof(obuf2)) todo_wine ok(0, "peek3 got %d bytes\n", readden); 366 + ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes\n", readden); 349 367 ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek3 got %d bytes left\n", left); 350 368 } 351 369 else ··· 382 400 ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail); 383 401 ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, &left), "Peek4\n"); 384 402 if (pipemode == PIPE_TYPE_BYTE) { 385 - /* currently the Wine behavior depends on the kernel version */ 386 - /* ok(readden == sizeof(obuf) + sizeof(obuf2), "peek4 got %d bytes\n", readden); */ 387 - if (readden != sizeof(obuf) + sizeof(obuf2)) todo_wine ok(0, "peek4 got %d bytes\n", readden); 403 + ok(readden == sizeof(obuf) + sizeof(obuf2), "peek4 got %d bytes\n", readden); 388 404 ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek4 got %d bytes left\n", left); 389 405 } 390 406 else ··· 621 637 ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe with special characters failed\n"); 622 638 ok(CloseHandle(hnp), "CloseHandle\n"); 623 639 624 - trace("test_CreateNamedPipe returning\n"); 640 + if (winetest_debug > 1) trace("test_CreateNamedPipe returning\n"); 625 641 } 626 642 627 643 static void test_CreateNamedPipe_instances_must_match(void) ··· 709 725 ok(CloseHandle(hnp2), "CloseHandle\n"); 710 726 } 711 727 728 + static void test_ReadFile(void) 729 + { 730 + HANDLE server, client; 731 + OVERLAPPED overlapped; 732 + DWORD size; 733 + BOOL res; 734 + 735 + static char buf[512]; 736 + 737 + server = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX, 738 + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 739 + 1, 1024, 1024, NMPWAIT_WAIT_FOREVER, NULL); 740 + ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError()); 741 + 742 + client = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, 743 + OPEN_EXISTING, 0, 0); 744 + ok(client != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError()); 745 + 746 + ok(WriteFile(client, buf, sizeof(buf), &size, NULL), "WriteFile\n"); 747 + 748 + res = ReadFile(server, buf, 1, &size, NULL); 749 + ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned %x(%u)\n", res, GetLastError()); 750 + ok(size == 1, "size = %u\n", size); 751 + 752 + /* pass both overlapped and ret read */ 753 + memset(&overlapped, 0, sizeof(overlapped)); 754 + res = ReadFile(server, buf, 1, &size, &overlapped); 755 + ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned %x(%u)\n", res, GetLastError()); 756 + ok(size == 0, "size = %u\n", size); 757 + ok((NTSTATUS)overlapped.Internal == STATUS_BUFFER_OVERFLOW, "Internal = %lx\n", overlapped.Internal); 758 + ok(overlapped.InternalHigh == 1, "InternalHigh = %lx\n", overlapped.InternalHigh); 759 + 760 + DisconnectNamedPipe(server); 761 + 762 + memset(&overlapped, 0, sizeof(overlapped)); 763 + overlapped.InternalHigh = 0xdeadbeef; 764 + res = ReadFile(server, buf, 1, &size, &overlapped); 765 + ok(!res && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "ReadFile returned %x(%u)\n", res, GetLastError()); 766 + ok(size == 0, "size = %u\n", size); 767 + ok(overlapped.Internal == STATUS_PENDING, "Internal = %lx\n", overlapped.Internal); 768 + ok(overlapped.InternalHigh == 0xdeadbeef, "InternalHigh = %lx\n", overlapped.InternalHigh); 769 + 770 + memset(&overlapped, 0, sizeof(overlapped)); 771 + overlapped.InternalHigh = 0xdeadbeef; 772 + res = WriteFile(server, buf, 1, &size, &overlapped); 773 + ok(!res && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "ReadFile returned %x(%u)\n", res, GetLastError()); 774 + ok(size == 0, "size = %u\n", size); 775 + ok(overlapped.Internal == STATUS_PENDING, "Internal = %lx\n", overlapped.Internal); 776 + ok(overlapped.InternalHigh == 0xdeadbeef, "InternalHigh = %lx\n", overlapped.InternalHigh); 777 + 778 + CloseHandle(server); 779 + CloseHandle(client); 780 + } 781 + 712 782 /** implementation of alarm() */ 713 783 static DWORD CALLBACK alarmThreadMain(LPVOID arg) 714 784 { 715 785 DWORD_PTR timeout = (DWORD_PTR) arg; 716 - trace("alarmThreadMain\n"); 786 + if (winetest_debug > 1) trace("alarmThreadMain\n"); 717 787 if (WaitForSingleObject( alarm_event, timeout ) == WAIT_TIMEOUT) 718 788 { 719 789 ok(FALSE, "alarm\n"); ··· 729 799 { 730 800 int i; 731 801 732 - trace("serverThreadMain1 start\n"); 802 + if (winetest_debug > 1) trace("serverThreadMain1 start\n"); 733 803 /* Set up a simple echo server */ 734 804 hnp = CreateNamedPipeA(PIPENAME "serverThreadMain1", PIPE_ACCESS_DUPLEX, 735 805 PIPE_TYPE_BYTE | PIPE_WAIT, ··· 747 817 BOOL success; 748 818 749 819 /* Wait for client to connect */ 750 - trace("Server calling ConnectNamedPipe...\n"); 820 + if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n"); 751 821 ok(ConnectNamedPipe(hnp, NULL) 752 822 || GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n"); 753 - trace("ConnectNamedPipe returned.\n"); 823 + if (winetest_debug > 1) trace("ConnectNamedPipe returned.\n"); 754 824 755 825 /* Echo bytes once */ 756 826 memset(buf, 0, sizeof(buf)); 757 827 758 - trace("Server reading...\n"); 828 + if (winetest_debug > 1) trace("Server reading...\n"); 759 829 success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL); 760 - trace("Server done reading.\n"); 830 + if (winetest_debug > 1) trace("Server done reading.\n"); 761 831 ok(success, "ReadFile\n"); 762 832 ok(readden, "short read\n"); 763 833 764 - trace("Server writing...\n"); 834 + if (winetest_debug > 1) trace("Server writing...\n"); 765 835 ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n"); 766 - trace("Server done writing.\n"); 836 + if (winetest_debug > 1) trace("Server done writing.\n"); 767 837 ok(written == readden, "write file len\n"); 768 838 769 839 /* finish this connection, wait for next one */ 770 840 ok(FlushFileBuffers(hnp), "FlushFileBuffers\n"); 771 - trace("Server done flushing.\n"); 841 + if (winetest_debug > 1) trace("Server done flushing.\n"); 772 842 ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n"); 773 - trace("Server done disconnecting.\n"); 843 + if (winetest_debug > 1) trace("Server done disconnecting.\n"); 774 844 } 775 845 return 0; 776 846 } ··· 802 872 803 873 user_apc_ran = FALSE; 804 874 if (i == 0 && pQueueUserAPC) { 805 - trace("Queueing an user APC\n"); /* verify the pipe is non alerable */ 875 + if (winetest_debug > 1) trace("Queueing an user APC\n"); /* verify the pipe is non alerable */ 806 876 ret = pQueueUserAPC(&user_apc, GetCurrentThread(), 0); 807 877 ok(ret, "QueueUserAPC failed: %d\n", GetLastError()); 808 878 } 809 879 810 880 /* Wait for client to connect */ 811 - trace("Server calling ConnectNamedPipe...\n"); 881 + if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n"); 812 882 ok(ConnectNamedPipe(hnp, NULL) 813 883 || GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n"); 814 - trace("ConnectNamedPipe returned.\n"); 884 + if (winetest_debug > 1) trace("ConnectNamedPipe returned.\n"); 815 885 816 886 /* Echo bytes once */ 817 887 memset(buf, 0, sizeof(buf)); 818 888 819 - trace("Server reading...\n"); 889 + if (winetest_debug > 1) trace("Server reading...\n"); 820 890 success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL); 821 - trace("Server done reading.\n"); 891 + if (winetest_debug > 1) trace("Server done reading.\n"); 822 892 ok(success, "ReadFile\n"); 823 893 824 - trace("Server writing...\n"); 894 + if (winetest_debug > 1) trace("Server writing...\n"); 825 895 ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n"); 826 - trace("Server done writing.\n"); 896 + if (winetest_debug > 1) trace("Server done writing.\n"); 827 897 ok(written == readden, "write file len\n"); 828 898 829 899 /* finish this connection, wait for next one */ ··· 859 929 int i; 860 930 HANDLE hEvent; 861 931 862 - trace("serverThreadMain3\n"); 932 + if (winetest_debug > 1) trace("serverThreadMain3\n"); 863 933 /* Set up a simple echo server */ 864 934 hnp = CreateNamedPipeA(PIPENAME "serverThreadMain3", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 865 935 PIPE_TYPE_BYTE | PIPE_WAIT, ··· 892 962 893 963 /* Wait for client to connect */ 894 964 if (i == 0) { 895 - trace("Server calling non-overlapped ConnectNamedPipe on overlapped pipe...\n"); 965 + if (winetest_debug > 1) trace("Server calling non-overlapped ConnectNamedPipe on overlapped pipe...\n"); 896 966 success = ConnectNamedPipe(hnp, NULL); 897 967 err = GetLastError(); 898 968 ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %d\n", err); 899 - trace("ConnectNamedPipe operation complete.\n"); 969 + if (winetest_debug > 1) trace("ConnectNamedPipe operation complete.\n"); 900 970 } else { 901 - trace("Server calling overlapped ConnectNamedPipe...\n"); 971 + if (winetest_debug > 1) trace("Server calling overlapped ConnectNamedPipe...\n"); 902 972 success = ConnectNamedPipe(hnp, &oOverlap); 903 973 err = GetLastError(); 904 974 ok(!success && (err == ERROR_IO_PENDING || err == ERROR_PIPE_CONNECTED), "overlapped ConnectNamedPipe\n"); 905 - trace("overlapped ConnectNamedPipe returned.\n"); 975 + if (winetest_debug > 1) trace("overlapped ConnectNamedPipe returned.\n"); 906 976 if (!success && (err == ERROR_IO_PENDING)) { 907 977 if (letWFSOEwait) 908 978 { ··· 919 989 } 920 990 } 921 991 ok(success || (err == ERROR_PIPE_CONNECTED), "GetOverlappedResult ConnectNamedPipe\n"); 922 - trace("overlapped ConnectNamedPipe operation complete.\n"); 992 + if (winetest_debug > 1) trace("overlapped ConnectNamedPipe operation complete.\n"); 923 993 } 924 994 925 995 /* Echo bytes once */ 926 996 memset(buf, 0, sizeof(buf)); 927 997 928 - trace("Server reading...\n"); 998 + if (winetest_debug > 1) trace("Server reading...\n"); 929 999 success = ReadFile(hnp, buf, sizeof(buf), &readden, &oOverlap); 930 - trace("Server ReadFile returned...\n"); 1000 + if (winetest_debug > 1) trace("Server ReadFile returned...\n"); 931 1001 err = GetLastError(); 932 1002 ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile\n"); 933 - trace("overlapped ReadFile returned.\n"); 1003 + if (winetest_debug > 1) trace("overlapped ReadFile returned.\n"); 934 1004 if (!success && (err == ERROR_IO_PENDING)) { 935 1005 if (letWFSOEwait) 936 1006 { ··· 946 1016 success = GetOverlappedResult(hnp, &oOverlap, &readden, TRUE); 947 1017 } 948 1018 } 949 - trace("Server done reading.\n"); 1019 + if (winetest_debug > 1) trace("Server done reading.\n"); 950 1020 ok(success, "overlapped ReadFile\n"); 951 1021 952 - trace("Server writing...\n"); 1022 + if (winetest_debug > 1) trace("Server writing...\n"); 953 1023 success = WriteFile(hnp, buf, readden, &written, &oOverlap); 954 - trace("Server WriteFile returned...\n"); 1024 + if (winetest_debug > 1) trace("Server WriteFile returned...\n"); 955 1025 err = GetLastError(); 956 1026 ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile\n"); 957 - trace("overlapped WriteFile returned.\n"); 1027 + if (winetest_debug > 1) trace("overlapped WriteFile returned.\n"); 958 1028 if (!success && (err == ERROR_IO_PENDING)) { 959 1029 if (letWFSOEwait) 960 1030 { ··· 970 1040 success = GetOverlappedResult(hnp, &oOverlap, &written, TRUE); 971 1041 } 972 1042 } 973 - trace("Server done writing.\n"); 1043 + if (winetest_debug > 1) trace("Server done writing.\n"); 974 1044 ok(success, "overlapped WriteFile\n"); 975 1045 ok(written == readden, "write file len\n"); 976 1046 ··· 988 1058 HANDLE hcompletion; 989 1059 BOOL ret; 990 1060 991 - trace("serverThreadMain4\n"); 1061 + if (winetest_debug > 1) trace("serverThreadMain4\n"); 992 1062 /* Set up a simple echo server */ 993 1063 hnp = CreateNamedPipeA(PIPENAME "serverThreadMain4", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 994 1064 PIPE_TYPE_BYTE | PIPE_WAIT, ··· 1020 1090 memset(&oWrite, 0, sizeof(oWrite)); 1021 1091 1022 1092 /* Wait for client to connect */ 1023 - trace("Server calling overlapped ConnectNamedPipe...\n"); 1093 + if (winetest_debug > 1) trace("Server calling overlapped ConnectNamedPipe...\n"); 1024 1094 success = ConnectNamedPipe(hnp, &oConnect); 1025 1095 err = GetLastError(); 1026 1096 ok(!success && (err == ERROR_IO_PENDING || err == ERROR_PIPE_CONNECTED), 1027 1097 "overlapped ConnectNamedPipe got %u err %u\n", success, err ); 1028 1098 if (!success && err == ERROR_IO_PENDING) { 1029 - trace("ConnectNamedPipe GetQueuedCompletionStatus\n"); 1099 + if (winetest_debug > 1) trace("ConnectNamedPipe GetQueuedCompletionStatus\n"); 1030 1100 success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 0); 1031 1101 if (!success) 1032 1102 { ··· 1041 1111 ok(oResult == &oConnect, "got overlapped pointer %p instead of %p\n", oResult, &oConnect); 1042 1112 } 1043 1113 } 1044 - trace("overlapped ConnectNamedPipe operation complete.\n"); 1114 + if (winetest_debug > 1) trace("overlapped ConnectNamedPipe operation complete.\n"); 1045 1115 1046 1116 /* Echo bytes once */ 1047 1117 memset(buf, 0, sizeof(buf)); 1048 1118 1049 - trace("Server reading...\n"); 1119 + if (winetest_debug > 1) trace("Server reading...\n"); 1050 1120 success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead); 1051 - trace("Server ReadFile returned...\n"); 1121 + if (winetest_debug > 1) trace("Server ReadFile returned...\n"); 1052 1122 err = GetLastError(); 1053 1123 ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile, err=%i\n", err); 1054 1124 success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey, ··· 1059 1129 ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey); 1060 1130 ok(oResult == &oRead, "got overlapped pointer %p instead of %p\n", oResult, &oRead); 1061 1131 } 1062 - trace("Server done reading.\n"); 1132 + if (winetest_debug > 1) trace("Server done reading.\n"); 1063 1133 1064 - trace("Server writing...\n"); 1134 + if (winetest_debug > 1) trace("Server writing...\n"); 1065 1135 success = WriteFile(hnp, buf, readden, &written, &oWrite); 1066 - trace("Server WriteFile returned...\n"); 1136 + if (winetest_debug > 1) trace("Server WriteFile returned...\n"); 1067 1137 err = GetLastError(); 1068 1138 ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile failed, err=%u\n", err); 1069 1139 success = GetQueuedCompletionStatus(hcompletion, &written, &compkey, ··· 1075 1145 ok(oResult == &oWrite, "got overlapped pointer %p instead of %p\n", oResult, &oWrite); 1076 1146 ok(written == readden, "write file len\n"); 1077 1147 } 1078 - trace("Server done writing.\n"); 1148 + if (winetest_debug > 1) trace("Server done writing.\n"); 1149 + 1150 + /* Client will finish this connection, the following ops will trigger broken pipe errors. */ 1151 + 1152 + /* Wait for the pipe to break. */ 1153 + while (PeekNamedPipe(hnp, NULL, 0, NULL, &written, &written)); 1154 + 1155 + if (winetest_debug > 1) trace("Server writing on disconnected pipe...\n"); 1156 + SetLastError(ERROR_SUCCESS); 1157 + success = WriteFile(hnp, buf, readden, &written, &oWrite); 1158 + err = GetLastError(); 1159 + todo_wine_if (!success && err == ERROR_PIPE_NOT_CONNECTED) ok(!success && err == ERROR_NO_DATA, 1160 + "overlapped WriteFile on disconnected pipe returned %u, err=%i\n", success, err); 1161 + 1162 + /* No completion status is queued on immediate error. */ 1163 + SetLastError(ERROR_SUCCESS); 1164 + oResult = (OVERLAPPED *)0xdeadbeef; 1165 + success = GetQueuedCompletionStatus(hcompletion, &written, &compkey, 1166 + &oResult, 0); 1167 + err = GetLastError(); 1168 + ok(!success && err == WAIT_TIMEOUT && !oResult, 1169 + "WriteFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n", 1170 + success, err, oResult); 1171 + 1172 + if (winetest_debug > 1) trace("Server reading from disconnected pipe...\n"); 1173 + SetLastError(ERROR_SUCCESS); 1174 + success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead); 1175 + if (winetest_debug > 1) trace("Server ReadFile from disconnected pipe returned...\n"); 1176 + err = GetLastError(); 1177 + ok(!success && err == ERROR_BROKEN_PIPE, 1178 + "overlapped ReadFile on disconnected pipe returned %u, err=%i\n", success, err); 1179 + 1180 + SetLastError(ERROR_SUCCESS); 1181 + oResult = (OVERLAPPED *)0xdeadbeef; 1182 + success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey, 1183 + &oResult, 0); 1184 + err = GetLastError(); 1185 + ok(!success && err == WAIT_TIMEOUT && !oResult, 1186 + "ReadFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n", 1187 + success, err, oResult); 1079 1188 1080 1189 /* finish this connection, wait for next one */ 1081 1190 ok(FlushFileBuffers(hnp), "FlushFileBuffers\n"); ··· 1111 1220 int i; 1112 1221 HANDLE hEvent; 1113 1222 1114 - trace("serverThreadMain5\n"); 1223 + if (winetest_debug > 1) trace("serverThreadMain5\n"); 1115 1224 /* Set up a simple echo server */ 1116 1225 hnp = CreateNamedPipeA(PIPENAME "serverThreadMain5", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 1117 1226 PIPE_TYPE_BYTE | PIPE_WAIT, ··· 1139 1248 oOverlap.hEvent = hEvent; 1140 1249 1141 1250 /* Wait for client to connect */ 1142 - trace("Server calling ConnectNamedPipe...\n"); 1251 + if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n"); 1143 1252 success = ConnectNamedPipe(hnp, NULL); 1144 1253 err = GetLastError(); 1145 1254 ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %d\n", err); 1146 - trace("ConnectNamedPipe operation complete.\n"); 1255 + if (winetest_debug > 1) trace("ConnectNamedPipe operation complete.\n"); 1147 1256 1148 1257 /* Echo bytes once */ 1149 1258 memset(buf, 0, sizeof(buf)); 1150 1259 1151 - trace("Server reading...\n"); 1260 + if (winetest_debug > 1) trace("Server reading...\n"); 1152 1261 completion_called = 0; 1153 1262 ResetEvent(hEvent); 1154 1263 success = ReadFileEx(hnp, buf, sizeof(buf), &oOverlap, completion_routine); 1155 - trace("Server ReadFileEx returned...\n"); 1264 + if (winetest_debug > 1) trace("Server ReadFileEx returned...\n"); 1156 1265 ok(success, "ReadFileEx failed, err=%i\n", GetLastError()); 1157 1266 ok(completion_called == 0, "completion routine called before ReadFileEx return\n"); 1158 - trace("ReadFileEx returned.\n"); 1267 + if (winetest_debug > 1) trace("ReadFileEx returned.\n"); 1159 1268 if (success) { 1160 1269 DWORD ret; 1161 1270 do { ··· 1168 1277 ok(completion_num_bytes != 0, "read 0 bytes\n"); 1169 1278 ok(completion_lpoverlapped == &oOverlap, "got wrong overlapped pointer %p\n", completion_lpoverlapped); 1170 1279 readden = completion_num_bytes; 1171 - trace("Server done reading.\n"); 1280 + if (winetest_debug > 1) trace("Server done reading.\n"); 1172 1281 1173 - trace("Server writing...\n"); 1282 + if (winetest_debug > 1) trace("Server writing...\n"); 1174 1283 completion_called = 0; 1175 1284 ResetEvent(hEvent); 1176 1285 success = WriteFileEx(hnp, buf, readden, &oOverlap, completion_routine); 1177 - trace("Server WriteFileEx returned...\n"); 1286 + if (winetest_debug > 1) trace("Server WriteFileEx returned...\n"); 1178 1287 ok(success, "WriteFileEx failed, err=%i\n", GetLastError()); 1179 1288 ok(completion_called == 0, "completion routine called before ReadFileEx return\n"); 1180 - trace("overlapped WriteFile returned.\n"); 1289 + if (winetest_debug > 1) trace("overlapped WriteFile returned.\n"); 1181 1290 if (success) { 1182 1291 DWORD ret; 1183 1292 do { ··· 1185 1294 } while (ret == WAIT_IO_COMPLETION); 1186 1295 ok(ret == 0, "wait WriteFileEx returned %x\n", ret); 1187 1296 } 1188 - trace("Server done writing.\n"); 1297 + if (winetest_debug > 1) trace("Server done writing.\n"); 1189 1298 ok(completion_called == 1, "completion routine called %i times\n", completion_called); 1190 1299 ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %d\n", completion_errorcode); 1191 1300 ok(completion_num_bytes == readden, "read %i bytes wrote %i\n", readden, completion_num_bytes); ··· 1202 1311 { 1203 1312 int i; 1204 1313 1205 - trace("exercizeServer starting\n"); 1314 + if (winetest_debug > 1) trace("exercizeServer starting\n"); 1206 1315 for (i = 0; i < NB_SERVER_LOOPS; i++) { 1207 1316 HANDLE hFile=INVALID_HANDLE_VALUE; 1208 1317 static const char obuf[] = "Bit Bucket"; ··· 1213 1322 1214 1323 for (loop = 0; loop < 3; loop++) { 1215 1324 DWORD err; 1216 - trace("Client connecting...\n"); 1325 + if (winetest_debug > 1) trace("Client connecting...\n"); 1217 1326 /* Connect to the server */ 1218 1327 hFile = CreateFileA(pipename, GENERIC_READ | GENERIC_WRITE, 0, 1219 1328 NULL, OPEN_EXISTING, 0, 0); ··· 1224 1333 ok(err == ERROR_PIPE_BUSY || err == ERROR_FILE_NOT_FOUND, "connecting to pipe\n"); 1225 1334 else 1226 1335 ok(err == ERROR_PIPE_BUSY, "connecting to pipe\n"); 1227 - trace("connect failed, retrying\n"); 1336 + if (winetest_debug > 1) trace("connect failed, retrying\n"); 1228 1337 Sleep(200); 1229 1338 } 1230 1339 ok(hFile != INVALID_HANDLE_VALUE, "client opening named pipe\n"); 1231 1340 1232 1341 /* Make sure it can echo */ 1233 1342 memset(ibuf, 0, sizeof(ibuf)); 1234 - trace("Client writing...\n"); 1343 + if (winetest_debug > 1) trace("Client writing...\n"); 1235 1344 ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile to client end of pipe\n"); 1236 1345 ok(written == sizeof(obuf), "write file len\n"); 1237 - trace("Client reading...\n"); 1346 + if (winetest_debug > 1) trace("Client reading...\n"); 1238 1347 ok(ReadFile(hFile, ibuf, sizeof(obuf), &readden, NULL), "ReadFile from client end of pipe\n"); 1239 1348 ok(readden == sizeof(obuf), "read file len\n"); 1240 1349 ok(memcmp(obuf, ibuf, written) == 0, "content check\n"); 1241 1350 1242 - trace("Client closing...\n"); 1351 + if (winetest_debug > 1) trace("Client closing...\n"); 1243 1352 ok(CloseHandle(hFile), "CloseHandle\n"); 1244 1353 } 1245 1354 1246 1355 ok(WaitForSingleObject(serverThread,INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject\n"); 1247 1356 CloseHandle(hnp); 1248 - trace("exercizeServer returning\n"); 1357 + if (winetest_debug > 1) trace("exercizeServer returning\n"); 1249 1358 } 1250 1359 1251 1360 static void test_NamedPipe_2(void) ··· 1299 1408 1300 1409 ok(SetEvent( alarm_event ), "SetEvent\n"); 1301 1410 CloseHandle( alarm_event ); 1302 - trace("test_NamedPipe_2 returning\n"); 1411 + if (winetest_debug > 1) trace("test_NamedPipe_2 returning\n"); 1303 1412 } 1304 1413 1305 1414 static int test_DisconnectNamedPipe(void) ··· 1349 1458 ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0 1350 1459 && GetLastError() == ERROR_PIPE_NOT_CONNECTED, 1351 1460 "ReadFile from disconnected pipe with bytes waiting\n"); 1461 + 1352 1462 ok(!DisconnectNamedPipe(hnp) && GetLastError() == ERROR_PIPE_NOT_CONNECTED, 1353 1463 "DisconnectNamedPipe worked twice\n"); 1354 1464 ret = WaitForSingleObject(hFile, 0); 1355 1465 ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %X\n", ret); 1466 + 1467 + ret = PeekNamedPipe(hFile, NULL, 0, NULL, &readden, NULL); 1468 + todo_wine 1469 + ok(!ret && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "PeekNamedPipe returned %x (%u)\n", 1470 + ret, GetLastError()); 1471 + ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL); 1472 + todo_wine 1473 + ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n", 1474 + ret, GetLastError()); 1356 1475 ok(CloseHandle(hFile), "CloseHandle\n"); 1357 1476 } 1358 1477 ··· 1464 1583 ok(numbytes == 0, "expected 0, got %u\n", numbytes); 1465 1584 1466 1585 numbytes = 0xdeadbeef; 1586 + ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL); 1587 + ok(ret, "PeekNamedPipe failed with %u\n", GetLastError()); 1588 + ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes); 1589 + 1590 + numbytes = 0xdeadbeef; 1467 1591 memset(buffer, 0, sizeof(buffer)); 1468 1592 ret = ReadFile(hfile, buffer, sizeof(buffer), &numbytes, NULL); 1469 1593 ok(ret, "ReadFile failed with %u\n", GetLastError()); ··· 1480 1604 ok(!ret, "ReadFile unexpectedly succeeded\n"); 1481 1605 ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError()); 1482 1606 1607 + numbytes = 0xdeadbeef; 1608 + ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL); 1609 + ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%u)\n", 1610 + ret, GetLastError()); 1611 + ok(numbytes == 0xdeadbeef, "numbytes = %u\n", numbytes); 1612 + 1483 1613 SetLastError(0xdeadbeef); 1484 1614 ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL); 1485 1615 ok(!ret, "WriteFile unexpectedly succeeded\n"); ··· 1563 1693 ok(numbytes == 0, "expected 0, got %u\n", numbytes); 1564 1694 1565 1695 numbytes = 0xdeadbeef; 1696 + ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL); 1697 + ok(ret, "PeekNamedPipe failed with %u\n", GetLastError()); 1698 + ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes); 1699 + 1700 + numbytes = 0xdeadbeef; 1566 1701 memset(buffer, 0, sizeof(buffer)); 1567 1702 ret = ReadFile(hpipe, buffer, sizeof(buffer), &numbytes, NULL); 1568 1703 ok(ret, "ReadFile failed with %u\n", GetLastError()); ··· 1578 1713 ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL); 1579 1714 ok(!ret, "ReadFile unexpectedly succeeded\n"); 1580 1715 ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError()); 1716 + 1717 + numbytes = 0xdeadbeef; 1718 + ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL); 1719 + ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%u)\n", 1720 + ret, GetLastError()); 1721 + ok(numbytes == 0xdeadbeef, "numbytes = %u\n", numbytes); 1581 1722 1582 1723 SetLastError(0xdeadbeef); 1583 1724 ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL); ··· 2501 2642 SetLastError(0xdeadbeef); 2502 2643 ret = ReadFile(server, read_buf, 0, &num_bytes, &overlapped); 2503 2644 ok(!ret, "ReadFile should fail\n"); 2504 - todo_wine 2505 2645 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); 2506 2646 ok(num_bytes == 0, "bytes %u\n", num_bytes); 2507 2647 ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %#lx\n", overlapped.Internal); 2508 - todo_wine 2509 2648 ok(overlapped.InternalHigh == -1, "expected -1, got %lu\n", overlapped.InternalHigh); 2510 2649 2511 2650 wait = WaitForSingleObject(event, 100); ··· 2517 2656 ok(num_bytes == 1, "bytes %u\n", num_bytes); 2518 2657 2519 2658 wait = WaitForSingleObject(event, 100); 2520 - todo_wine 2521 2659 ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", wait); 2522 2660 2523 2661 ok(num_bytes == 1, "bytes %u\n", num_bytes); 2524 - todo_wine 2525 2662 ok((NTSTATUS)overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", overlapped.Internal); 2526 2663 ok(overlapped.InternalHigh == 0, "expected 0, got %lu\n", overlapped.InternalHigh); 2527 2664 ··· 2587 2724 else 2588 2725 ok_(__FILE__,line)(res, "ReadFile failed: %u\n", GetLastError()); 2589 2726 if(partial_read) 2590 - todo_wine ok_(__FILE__,line)(!read_bytes, "read_bytes %u expected 0\n", read_bytes); 2727 + ok_(__FILE__,line)(!read_bytes, "read_bytes %u expected 0\n", read_bytes); 2591 2728 else 2592 2729 ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %u expected %u\n", read_bytes, expected_result); 2593 2730 ··· 2648 2785 overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); 2649 2786 res = WriteFile(writer, buf, size, &written_bytes, overlapped); 2650 2787 ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%u)\n", res, GetLastError()); 2651 - todo_wine ok_(__FILE__,line)(!written_bytes, "written_bytes = %u\n", written_bytes); 2788 + ok_(__FILE__,line)(!written_bytes, "written_bytes = %u\n", written_bytes); 2652 2789 2653 2790 _test_not_signaled(line, overlapped->hEvent); 2654 2791 } ··· 3048 3185 test_CreateNamedPipe(PIPE_TYPE_BYTE); 3049 3186 test_CreateNamedPipe(PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE); 3050 3187 test_CreatePipe(); 3188 + test_ReadFile(); 3051 3189 test_CloseHandle(); 3052 3190 test_impersonation(); 3053 3191 test_overlapped(); ··· 3057 3195 test_readfileex_pending(); 3058 3196 test_overlapped_transport(TRUE, FALSE); 3059 3197 test_overlapped_transport(TRUE, TRUE); 3060 - if (broken(1)) /* FIXME: Remove once Wine is ready. */ 3061 - test_overlapped_transport(FALSE, FALSE); 3198 + test_overlapped_transport(FALSE, FALSE); 3062 3199 }
+5 -4
modules/rostests/winetests/kernel32/precomp.h
··· 1 + 1 2 #ifndef _KERNEL32_WINETEST_PRECOMP_H_ 2 3 #define _KERNEL32_WINETEST_PRECOMP_H_ 3 4 4 5 #include <assert.h> 5 6 #include <stdio.h> 6 - #include <ntstatus.h> 7 7 8 + #define COBJMACROS 9 + 10 + #include <ntstatus.h> 8 11 #define WIN32_NO_STATUS 9 - #define _INC_WINDOWS 10 - #define COM_NO_WINDOWS_H 11 - #define COBJMACROS 12 12 13 + #include <windows.h> 13 14 #include <wine/test.h> 14 15 #include <wine/winternl.h> 15 16 #include <winuser.h>
+503 -3
modules/rostests/winetests/kernel32/process.c
··· 20 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 21 */ 22 22 23 - #include "precomp.h" 23 + #include <assert.h> 24 + #include <stdarg.h> 25 + #include <stdio.h> 26 + #include <stdlib.h> 27 + 28 + #include "ntstatus.h" 29 + #define WIN32_NO_STATUS 30 + #include "windef.h" 31 + #include "winbase.h" 32 + #include "winuser.h" 33 + #include "wincon.h" 34 + #include "winnls.h" 35 + #include "winternl.h" 36 + #include "tlhelp32.h" 37 + 38 + #include "wine/test.h" 39 + 40 + #include "winnt.h" 24 41 25 42 /* PROCESS_ALL_ACCESS in Vista+ PSDKs is incompatible with older Windows versions */ 26 43 #define PROCESS_ALL_ACCESS_NT4 (PROCESS_ALL_ACCESS & ~0xf000) ··· 1399 1416 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startup, &info), "CreateProcess\n"); 1400 1417 1401 1418 ok(GetExitCodeThread(info.hThread, &exit_status) && exit_status == STILL_ACTIVE, "thread still running\n"); 1402 - Sleep(8000); 1419 + Sleep(1000); 1403 1420 ok(GetExitCodeThread(info.hThread, &exit_status) && exit_status == STILL_ACTIVE, "thread still running\n"); 1404 1421 ok(ResumeThread(info.hThread) == 1, "Resuming thread\n"); 1405 1422 ··· 1668 1685 memset(buffer, 0, sizeof(buffer)); 1669 1686 ok(ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL), "Reading from child\n"); 1670 1687 ok(strcmp(buffer, msg) == 0, "Should have received '%s'\n", msg); 1688 + 1689 + /* the child may also send the final "n tests executed" string, so read it to avoid a deadlock */ 1690 + ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL); 1671 1691 1672 1692 /* wait for child to terminate */ 1673 1693 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n"); ··· 2378 2398 ok_(__FILE__, line)(ret, "CreateProcess error %u\n", GetLastError()); 2379 2399 } 2380 2400 2401 + #define test_assigned_proc(job, ...) _test_assigned_proc(__LINE__, job, __VA_ARGS__) 2402 + static void _test_assigned_proc(int line, HANDLE job, int expected_count, ...) 2403 + { 2404 + char buf[sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * 20]; 2405 + PJOBOBJECT_BASIC_PROCESS_ID_LIST pid_list = (JOBOBJECT_BASIC_PROCESS_ID_LIST *)buf; 2406 + DWORD ret_len, pid; 2407 + va_list valist; 2408 + int n; 2409 + BOOL ret; 2410 + 2411 + memset(buf, 0, sizeof(buf)); 2412 + ret = pQueryInformationJobObject(job, JobObjectBasicProcessIdList, pid_list, sizeof(buf), &ret_len); 2413 + ok_(__FILE__, line)(ret, "QueryInformationJobObject error %u\n", GetLastError()); 2414 + if (ret) 2415 + { 2416 + todo_wine_if(expected_count) 2417 + ok_(__FILE__, line)(expected_count == pid_list->NumberOfAssignedProcesses, 2418 + "Expected NumberOfAssignedProcesses to be %d (expected_count) is %d\n", 2419 + expected_count, pid_list->NumberOfAssignedProcesses); 2420 + todo_wine_if(expected_count) 2421 + ok_(__FILE__, line)(expected_count == pid_list->NumberOfProcessIdsInList, 2422 + "Expected NumberOfProcessIdsInList to be %d (expected_count) is %d\n", 2423 + expected_count, pid_list->NumberOfProcessIdsInList); 2424 + 2425 + va_start(valist, expected_count); 2426 + for (n = 0; n < min(expected_count, pid_list->NumberOfProcessIdsInList); ++n) 2427 + { 2428 + pid = va_arg(valist, DWORD); 2429 + ok_(__FILE__, line)(pid == pid_list->ProcessIdList[n], 2430 + "Expected pid_list->ProcessIdList[%d] to be %x is %lx\n", 2431 + n, pid, pid_list->ProcessIdList[n]); 2432 + } 2433 + va_end(valist); 2434 + } 2435 + } 2436 + 2437 + #define test_accounting(job, total_proc, active_proc, terminated_proc) _test_accounting(__LINE__, job, total_proc, active_proc, terminated_proc) 2438 + static void _test_accounting(int line, HANDLE job, int total_proc, int active_proc, int terminated_proc) 2439 + { 2440 + JOBOBJECT_BASIC_ACCOUNTING_INFORMATION basic_accounting; 2441 + DWORD ret_len; 2442 + BOOL ret; 2443 + 2444 + memset(&basic_accounting, 0, sizeof(basic_accounting)); 2445 + ret = pQueryInformationJobObject(job, JobObjectBasicAccountingInformation, &basic_accounting, sizeof(basic_accounting), &ret_len); 2446 + ok_(__FILE__, line)(ret, "QueryInformationJobObject error %u\n", GetLastError()); 2447 + if (ret) 2448 + { 2449 + /* Not going to check process times or page faults */ 2450 + 2451 + todo_wine_if(total_proc) 2452 + ok_(__FILE__, line)(total_proc == basic_accounting.TotalProcesses, 2453 + "Expected basic_accounting.TotalProcesses to be %d (total_proc) is %d\n", 2454 + total_proc, basic_accounting.TotalProcesses); 2455 + todo_wine_if(active_proc) 2456 + ok_(__FILE__, line)(active_proc == basic_accounting.ActiveProcesses, 2457 + "Expected basic_accounting.ActiveProcesses to be %d (active_proc) is %d\n", 2458 + active_proc, basic_accounting.ActiveProcesses); 2459 + ok_(__FILE__, line)(terminated_proc == basic_accounting.TotalTerminatedProcesses, 2460 + "Expected basic_accounting.TotalTerminatedProcesses to be %d (terminated_proc) is %d\n", 2461 + terminated_proc, basic_accounting.TotalTerminatedProcesses); 2462 + } 2463 + } 2381 2464 2382 2465 static void test_IsProcessInJob(void) 2383 2466 { ··· 2404 2487 ret = pIsProcessInJob(pi.hProcess, job, &out); 2405 2488 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2406 2489 ok(!out, "IsProcessInJob returned out=%u\n", out); 2490 + test_assigned_proc(job, 0); 2491 + test_accounting(job, 0, 0, 0); 2407 2492 2408 2493 out = TRUE; 2409 2494 ret = pIsProcessInJob(pi.hProcess, job2, &out); 2410 2495 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2411 2496 ok(!out, "IsProcessInJob returned out=%u\n", out); 2497 + test_assigned_proc(job2, 0); 2498 + test_accounting(job2, 0, 0, 0); 2412 2499 2413 2500 out = TRUE; 2414 2501 ret = pIsProcessInJob(pi.hProcess, NULL, &out); ··· 2422 2509 ret = pIsProcessInJob(pi.hProcess, job, &out); 2423 2510 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2424 2511 ok(out, "IsProcessInJob returned out=%u\n", out); 2512 + test_assigned_proc(job, 1, pi.dwProcessId); 2513 + test_accounting(job, 1, 1, 0); 2425 2514 2426 2515 out = TRUE; 2427 2516 ret = pIsProcessInJob(pi.hProcess, job2, &out); 2428 2517 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2429 2518 ok(!out, "IsProcessInJob returned out=%u\n", out); 2519 + test_assigned_proc(job2, 0); 2520 + test_accounting(job2, 0, 0, 0); 2430 2521 2431 2522 out = FALSE; 2432 2523 ret = pIsProcessInJob(pi.hProcess, NULL, &out); ··· 2442 2533 ret = pIsProcessInJob(pi.hProcess, job, &out); 2443 2534 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2444 2535 ok(out, "IsProcessInJob returned out=%u\n", out); 2536 + test_assigned_proc(job, 0); 2537 + test_accounting(job, 1, 0, 0); 2445 2538 2446 2539 CloseHandle(pi.hProcess); 2447 2540 CloseHandle(pi.hThread); ··· 2458 2551 2459 2552 job = pCreateJobObjectW(NULL, NULL); 2460 2553 ok(job != NULL, "CreateJobObject error %u\n", GetLastError()); 2554 + test_assigned_proc(job, 0); 2555 + test_accounting(job, 0, 0, 0); 2461 2556 2462 2557 create_process("wait", &pi); 2463 2558 2464 2559 ret = pAssignProcessToJobObject(job, pi.hProcess); 2465 2560 ok(ret, "AssignProcessToJobObject error %u\n", GetLastError()); 2561 + test_assigned_proc(job, 1, pi.dwProcessId); 2562 + test_accounting(job, 1, 1, 0); 2466 2563 2467 2564 ret = pTerminateJobObject(job, 123); 2468 2565 ok(ret, "TerminateJobObject error %u\n", GetLastError()); ··· 2470 2567 dwret = WaitForSingleObject(pi.hProcess, 1000); 2471 2568 ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret); 2472 2569 if (dwret == WAIT_TIMEOUT) TerminateProcess(pi.hProcess, 0); 2570 + test_assigned_proc(job, 0); 2571 + test_accounting(job, 1, 0, 0); 2473 2572 2474 2573 ret = GetExitCodeProcess(pi.hProcess, &dwret); 2475 2574 ok(ret, "GetExitCodeProcess error %u\n", GetLastError()); ··· 2489 2588 ret = pAssignProcessToJobObject(job, pi.hProcess); 2490 2589 ok(!ret, "AssignProcessToJobObject unexpectedly succeeded\n"); 2491 2590 expect_eq_d(ERROR_ACCESS_DENIED, GetLastError()); 2591 + test_assigned_proc(job, 0); 2592 + test_accounting(job, 1, 0, 0); 2492 2593 2493 2594 CloseHandle(pi.hProcess); 2494 2595 CloseHandle(pi.hThread); ··· 2675 2776 return; 2676 2777 } 2677 2778 ok(ret, "SetInformationJobObject error %u\n", GetLastError()); 2779 + test_assigned_proc(job, 0); 2780 + test_accounting(job, 0, 0, 0); 2678 2781 2679 2782 create_process("wait", &pi); 2680 2783 2681 2784 ret = pAssignProcessToJobObject(job, pi.hProcess); 2682 2785 ok(ret, "AssignProcessToJobObject error %u\n", GetLastError()); 2786 + test_assigned_proc(job, 1, pi.dwProcessId); 2787 + test_accounting(job, 1, 1, 0); 2683 2788 2684 2789 CloseHandle(job); 2685 2790 ··· 2790 2895 2791 2896 ret = pAssignProcessToJobObject(job, GetCurrentProcess()); 2792 2897 ok(ret, "AssignProcessToJobObject error %u\n", GetLastError()); 2898 + test_assigned_proc(job, 1, GetCurrentProcessId()); 2899 + test_accounting(job, 1, 1, 0); 2793 2900 2794 2901 return job; 2795 2902 } ··· 2817 2924 ret = pIsProcessInJob(pi.hProcess, job, &out); 2818 2925 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2819 2926 ok(out, "IsProcessInJob returned out=%u\n", out); 2927 + test_assigned_proc(job, 2, GetCurrentProcessId(), pi.dwProcessId); 2928 + test_accounting(job, 2, 2, 0); 2820 2929 2821 2930 dwret = WaitForSingleObject(pi.hProcess, 1000); 2822 2931 ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret); ··· 2845 2954 ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi); 2846 2955 ok(!ret, "CreateProcessA expected failure\n"); 2847 2956 expect_eq_d(ERROR_ACCESS_DENIED, GetLastError()); 2957 + test_assigned_proc(job, 1, GetCurrentProcessId()); 2958 + test_accounting(job, 2, 1, 0); 2848 2959 2849 2960 if (ret) 2850 2961 { ··· 2867 2978 ret = pIsProcessInJob(pi.hProcess, job, &out); 2868 2979 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2869 2980 ok(!out, "IsProcessInJob returned out=%u\n", out); 2981 + test_assigned_proc(job, 1, GetCurrentProcessId()); 2982 + test_accounting(job, 2, 1, 0); 2870 2983 2871 2984 dwret = WaitForSingleObject(pi.hProcess, 1000); 2872 2985 ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret); ··· 2884 2997 ret = pIsProcessInJob(pi.hProcess, job, &out); 2885 2998 ok(ret, "IsProcessInJob error %u\n", GetLastError()); 2886 2999 ok(!out, "IsProcessInJob returned out=%u\n", out); 3000 + test_assigned_proc(job, 1, GetCurrentProcessId()); 3001 + test_accounting(job, 2, 1, 0); 2887 3002 2888 3003 dwret = WaitForSingleObject(pi.hProcess, 1000); 2889 3004 ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret); ··· 2965 3080 #endif 2966 3081 } 2967 3082 3083 + #if defined(__i386__) || defined(__x86_64__) 3084 + static BOOL read_nt_header(HANDLE process_handle, MEMORY_BASIC_INFORMATION *mbi, 3085 + IMAGE_NT_HEADERS *nt_header) 3086 + { 3087 + IMAGE_DOS_HEADER dos_header; 3088 + 3089 + if (!ReadProcessMemory(process_handle, mbi->BaseAddress, &dos_header, sizeof(dos_header), NULL)) 3090 + return FALSE; 3091 + 3092 + if ((dos_header.e_magic != IMAGE_DOS_SIGNATURE) || 3093 + ((ULONG)dos_header.e_lfanew > mbi->RegionSize) || 3094 + (dos_header.e_lfanew < sizeof(dos_header))) 3095 + return FALSE; 3096 + 3097 + if (!ReadProcessMemory(process_handle, (char *)mbi->BaseAddress + dos_header.e_lfanew, 3098 + nt_header, sizeof(*nt_header), NULL)) 3099 + return FALSE; 3100 + 3101 + return (nt_header->Signature == IMAGE_NT_SIGNATURE); 3102 + } 3103 + 3104 + static PVOID get_process_exe(HANDLE process_handle, IMAGE_NT_HEADERS *nt_header) 3105 + { 3106 + PVOID exe_base, address; 3107 + MEMORY_BASIC_INFORMATION mbi; 3108 + 3109 + /* Find the EXE base in the new process */ 3110 + exe_base = NULL; 3111 + for (address = NULL ; 3112 + VirtualQueryEx(process_handle, address, &mbi, sizeof(mbi)) ; 3113 + address = (char *)mbi.BaseAddress + mbi.RegionSize) { 3114 + if ((mbi.Type == SEC_IMAGE) && 3115 + read_nt_header(process_handle, &mbi, nt_header) && 3116 + !(nt_header->FileHeader.Characteristics & IMAGE_FILE_DLL)) { 3117 + exe_base = mbi.BaseAddress; 3118 + break; 3119 + } 3120 + } 3121 + 3122 + return exe_base; 3123 + } 3124 + 3125 + static BOOL are_imports_resolved(HANDLE process_handle, PVOID module_base, IMAGE_NT_HEADERS *nt_header) 3126 + { 3127 + BOOL ret; 3128 + IMAGE_IMPORT_DESCRIPTOR iid; 3129 + ULONG_PTR orig_iat_entry_value, iat_entry_value; 3130 + 3131 + ok(nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress, "Import table VA is zero\n"); 3132 + ok(nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size, "Import table Size is zero\n"); 3133 + 3134 + if (!nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress || 3135 + !nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size) 3136 + return FALSE; 3137 + 3138 + /* Read the first IID */ 3139 + ret = ReadProcessMemory(process_handle, 3140 + (char *)module_base + nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress, 3141 + &iid, sizeof(iid), NULL); 3142 + ok(ret, "Failed to read remote module IID (%d)\n", GetLastError()); 3143 + 3144 + /* Validate the IID is present and not a bound import, and that we have 3145 + an OriginalFirstThunk to compare with */ 3146 + ok(iid.Name, "Module first IID does not have a Name\n"); 3147 + ok(iid.FirstThunk, "Module first IID does not have a FirstThunk\n"); 3148 + ok(!iid.TimeDateStamp, "Module first IID is a bound import (UNSUPPORTED for current test)\n"); 3149 + ok(iid.OriginalFirstThunk, "Module first IID does not have an OriginalFirstThunk (UNSUPPORTED for current test)\n"); 3150 + 3151 + /* Read a single IAT entry from the FirstThunk */ 3152 + ret = ReadProcessMemory(process_handle, (char *)module_base + iid.FirstThunk, 3153 + &iat_entry_value, sizeof(iat_entry_value), NULL); 3154 + ok(ret, "Failed to read IAT entry from FirstThunk (%d)\n", GetLastError()); 3155 + ok(iat_entry_value, "IAT entry in FirstThunk is NULL\n"); 3156 + 3157 + /* Read a single IAT entry from the OriginalFirstThunk */ 3158 + ret = ReadProcessMemory(process_handle, (char *)module_base + iid.OriginalFirstThunk, 3159 + &orig_iat_entry_value, sizeof(orig_iat_entry_value), NULL); 3160 + ok(ret, "Failed to read IAT entry from OriginalFirstThunk (%d)\n", GetLastError()); 3161 + ok(orig_iat_entry_value, "IAT entry in OriginalFirstThunk is NULL\n"); 3162 + 3163 + return iat_entry_value != orig_iat_entry_value; 3164 + } 3165 + 3166 + static void test_SuspendProcessNewThread(void) 3167 + { 3168 + BOOL ret; 3169 + STARTUPINFOA si = {0}; 3170 + PROCESS_INFORMATION pi = {0}; 3171 + PVOID exe_base, exit_thread_ptr; 3172 + IMAGE_NT_HEADERS nt_header; 3173 + HANDLE thread_handle = NULL; 3174 + DWORD dret, exit_code = 0; 3175 + CONTEXT ctx; 3176 + 3177 + exit_thread_ptr = GetProcAddress(hkernel32, "ExitThread"); 3178 + ok(exit_thread_ptr != NULL, "GetProcAddress ExitThread failed\n"); 3179 + 3180 + si.cb = sizeof(si); 3181 + ret = CreateProcessA(NULL, selfname, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi); 3182 + ok(ret, "Failed to create process (%d)\n", GetLastError()); 3183 + 3184 + exe_base = get_process_exe(pi.hProcess, &nt_header); 3185 + ok(exe_base != NULL, "Could not find EXE in remote process\n"); 3186 + 3187 + ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header); 3188 + ok(!ret, "IAT entry resolved prematurely\n"); 3189 + 3190 + thread_handle = CreateRemoteThread(pi.hProcess, NULL, 0, 3191 + (LPTHREAD_START_ROUTINE)exit_thread_ptr, 3192 + (PVOID)(ULONG_PTR)0x1234, CREATE_SUSPENDED, NULL); 3193 + ok(thread_handle != NULL, "Could not create remote thread (%d)\n", GetLastError()); 3194 + 3195 + ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header); 3196 + ok(!ret, "IAT entry resolved prematurely\n"); 3197 + 3198 + ctx.ContextFlags = CONTEXT_ALL; 3199 + ret = GetThreadContext( thread_handle, &ctx ); 3200 + ok( ret, "Failed retrieving remote thread context (%d)\n", GetLastError() ); 3201 + ok( ctx.ContextFlags == CONTEXT_ALL, "wrong flags %x\n", ctx.ContextFlags ); 3202 + #ifdef __x86_64__ 3203 + ok( !ctx.Rax, "rax is not zero %lx\n", ctx.Rax ); 3204 + ok( !ctx.Rbx, "rbx is not zero %lx\n", ctx.Rbx ); 3205 + ok( ctx.Rcx == (ULONG_PTR)exit_thread_ptr, "wrong rcx %lx/%p\n", ctx.Rcx, exit_thread_ptr ); 3206 + ok( ctx.Rdx == 0x1234, "wrong rdx %lx\n", ctx.Rdx ); 3207 + ok( !ctx.Rsi, "rsi is not zero %lx\n", ctx.Rsi ); 3208 + ok( !ctx.Rdi, "rdi is not zero %lx\n", ctx.Rdi ); 3209 + ok( !ctx.Rbp, "rbp is not zero %lx\n", ctx.Rbp ); 3210 + ok( !ctx.R8, "r8 is not zero %lx\n", ctx.R8 ); 3211 + ok( !ctx.R9, "r9 is not zero %lx\n", ctx.R9 ); 3212 + ok( !ctx.R10, "r10 is not zero %lx\n", ctx.R10 ); 3213 + ok( !ctx.R11, "r11 is not zero %lx\n", ctx.R11 ); 3214 + ok( !ctx.R12, "r12 is not zero %lx\n", ctx.R12 ); 3215 + ok( !ctx.R13, "r13 is not zero %lx\n", ctx.R13 ); 3216 + ok( !ctx.R14, "r14 is not zero %lx\n", ctx.R14 ); 3217 + ok( !ctx.R15, "r15 is not zero %lx\n", ctx.R15 ); 3218 + ok( !((ctx.Rsp + 0x28) & 0xfff), "rsp is not at top of stack page %lx\n", ctx.Rsp ); 3219 + ok( ctx.EFlags == 0x200, "wrong flags %08x\n", ctx.EFlags ); 3220 + ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08x\n", ctx.MxCsr ); 3221 + ok( ctx.FltSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FltSave.ControlWord ); 3222 + #else 3223 + ok( !ctx.Ebp || broken(ctx.Ebp), /* winxp */ "ebp is not zero %08x\n", ctx.Ebp ); 3224 + if (!ctx.Ebp) /* winxp is completely different */ 3225 + { 3226 + ok( !ctx.Ecx, "ecx is not zero %08x\n", ctx.Ecx ); 3227 + ok( !ctx.Edx, "edx is not zero %08x\n", ctx.Edx ); 3228 + ok( !ctx.Esi, "esi is not zero %08x\n", ctx.Esi ); 3229 + ok( !ctx.Edi, "edi is not zero %08x\n", ctx.Edi ); 3230 + } 3231 + ok( ctx.Eax == (ULONG_PTR)exit_thread_ptr, "wrong eax %08x/%p\n", ctx.Eax, exit_thread_ptr ); 3232 + ok( ctx.Ebx == 0x1234, "wrong ebx %08x\n", ctx.Ebx ); 3233 + ok( !((ctx.Esp + 0x10) & 0xfff) || broken( !((ctx.Esp + 4) & 0xfff) ), /* winxp, w2k3 */ 3234 + "esp is not at top of stack page or properly aligned: %08x\n", ctx.Esp ); 3235 + ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08x\n", ctx.EFlags ); 3236 + ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FloatSave.ControlWord ); 3237 + ok( *(WORD *)ctx.ExtendedRegisters == 0x27f, "wrong control %08x\n", *(WORD *)ctx.ExtendedRegisters ); 3238 + #endif 3239 + 3240 + ResumeThread( thread_handle ); 3241 + dret = WaitForSingleObject(thread_handle, 60000); 3242 + ok(dret == WAIT_OBJECT_0, "Waiting for remote thread failed (%d)\n", GetLastError()); 3243 + ret = GetExitCodeThread(thread_handle, &exit_code); 3244 + ok(ret, "Failed to retrieve remote thread exit code (%d)\n", GetLastError()); 3245 + ok(exit_code == 0x1234, "Invalid remote thread exit code\n"); 3246 + 3247 + ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header); 3248 + ok(ret, "EXE IAT entry not resolved\n"); 3249 + 3250 + if (thread_handle) 3251 + CloseHandle(thread_handle); 3252 + 3253 + TerminateProcess(pi.hProcess, 0); 3254 + WaitForSingleObject(pi.hProcess, 10000); 3255 + CloseHandle(pi.hProcess); 3256 + CloseHandle(pi.hThread); 3257 + } 3258 + 3259 + static void test_SuspendProcessState(void) 3260 + { 3261 + struct pipe_params 3262 + { 3263 + ULONG pipe_write_buf; 3264 + ULONG pipe_read_buf; 3265 + ULONG bytes_returned; 3266 + CHAR pipe_name[MAX_PATH]; 3267 + }; 3268 + 3269 + #ifdef __x86_64__ 3270 + struct remote_rop_chain 3271 + { 3272 + void *exit_process_ptr; 3273 + ULONG_PTR home_rcx; 3274 + ULONG_PTR home_rdx; 3275 + ULONG_PTR home_r8; 3276 + ULONG_PTR home_r9; 3277 + ULONG_PTR pipe_read_buf_size; 3278 + ULONG_PTR bytes_returned; 3279 + ULONG_PTR timeout; 3280 + }; 3281 + #else 3282 + struct remote_rop_chain 3283 + { 3284 + void *exit_process_ptr; 3285 + ULONG_PTR pipe_name; 3286 + ULONG_PTR pipe_write_buf; 3287 + ULONG_PTR pipe_write_buf_size; 3288 + ULONG_PTR pipe_read_buf; 3289 + ULONG_PTR pipe_read_buf_size; 3290 + ULONG_PTR bytes_returned; 3291 + ULONG_PTR timeout; 3292 + void *unreached_ret; 3293 + ULONG_PTR exit_code; 3294 + }; 3295 + #endif 3296 + 3297 + static const char pipe_name[] = "\\\\.\\pipe\\TestPipe"; 3298 + static const ULONG pipe_write_magic = 0x454e4957; 3299 + STARTUPINFOA si = {0}; 3300 + PROCESS_INFORMATION pi = {0}; 3301 + PVOID exe_base, remote_pipe_params, exit_process_ptr, 3302 + call_named_pipe_a; 3303 + IMAGE_NT_HEADERS nt_header; 3304 + struct pipe_params pipe_params; 3305 + struct remote_rop_chain rop_chain; 3306 + CONTEXT ctx; 3307 + HANDLE server_pipe_handle; 3308 + BOOL pipe_connected; 3309 + ULONG pipe_magic, numb; 3310 + BOOL ret; 3311 + void *entry_ptr, *peb_ptr; 3312 + PEB child_peb; 3313 + 3314 + exit_process_ptr = GetProcAddress(hkernel32, "ExitProcess"); 3315 + ok(exit_process_ptr != NULL, "GetProcAddress ExitProcess failed\n"); 3316 + 3317 + call_named_pipe_a = GetProcAddress(hkernel32, "CallNamedPipeA"); 3318 + ok(call_named_pipe_a != NULL, "GetProcAddress CallNamedPipeA failed\n"); 3319 + 3320 + si.cb = sizeof(si); 3321 + ret = CreateProcessA(NULL, selfname, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi); 3322 + ok(ret, "Failed to create process (%d)\n", GetLastError()); 3323 + 3324 + exe_base = get_process_exe(pi.hProcess, &nt_header); 3325 + /* Make sure we found the EXE in the new process */ 3326 + ok(exe_base != NULL, "Could not find EXE in remote process\n"); 3327 + 3328 + ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header); 3329 + ok(!ret, "IAT entry resolved prematurely\n"); 3330 + 3331 + server_pipe_handle = CreateNamedPipeA(pipe_name, PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH, 3332 + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1, 0x20000, 0x20000, 3333 + 0, NULL); 3334 + ok(server_pipe_handle != INVALID_HANDLE_VALUE, "Failed to create communication pipe (%d)\n", GetLastError()); 3335 + 3336 + /* Set up the remote process environment */ 3337 + ctx.ContextFlags = CONTEXT_ALL; 3338 + ret = GetThreadContext(pi.hThread, &ctx); 3339 + ok(ret, "Failed retrieving remote thread context (%d)\n", GetLastError()); 3340 + ok( ctx.ContextFlags == CONTEXT_ALL, "wrong flags %x\n", ctx.ContextFlags ); 3341 + 3342 + remote_pipe_params = VirtualAllocEx(pi.hProcess, NULL, sizeof(pipe_params), MEM_COMMIT, PAGE_READWRITE); 3343 + ok(remote_pipe_params != NULL, "Failed allocating memory in remote process (%d)\n", GetLastError()); 3344 + 3345 + pipe_params.pipe_write_buf = pipe_write_magic; 3346 + pipe_params.pipe_read_buf = 0; 3347 + pipe_params.bytes_returned = 0; 3348 + strcpy(pipe_params.pipe_name, pipe_name); 3349 + 3350 + ret = WriteProcessMemory(pi.hProcess, remote_pipe_params, 3351 + &pipe_params, sizeof(pipe_params), NULL); 3352 + ok(ret, "Failed to write to remote process memory (%d)\n", GetLastError()); 3353 + 3354 + #ifdef __x86_64__ 3355 + ok( !ctx.Rax, "rax is not zero %lx\n", ctx.Rax ); 3356 + ok( !ctx.Rbx, "rbx is not zero %lx\n", ctx.Rbx ); 3357 + ok( !ctx.Rsi, "rsi is not zero %lx\n", ctx.Rsi ); 3358 + ok( !ctx.Rdi, "rdi is not zero %lx\n", ctx.Rdi ); 3359 + ok( !ctx.Rbp, "rbp is not zero %lx\n", ctx.Rbp ); 3360 + ok( !ctx.R8, "r8 is not zero %lx\n", ctx.R8 ); 3361 + ok( !ctx.R9, "r9 is not zero %lx\n", ctx.R9 ); 3362 + ok( !ctx.R10, "r10 is not zero %lx\n", ctx.R10 ); 3363 + ok( !ctx.R11, "r11 is not zero %lx\n", ctx.R11 ); 3364 + ok( !ctx.R12, "r12 is not zero %lx\n", ctx.R12 ); 3365 + ok( !ctx.R13, "r13 is not zero %lx\n", ctx.R13 ); 3366 + ok( !ctx.R14, "r14 is not zero %lx\n", ctx.R14 ); 3367 + ok( !ctx.R15, "r15 is not zero %lx\n", ctx.R15 ); 3368 + ok( !((ctx.Rsp + 0x28) & 0xfff), "rsp is not at top of stack page %lx\n", ctx.Rsp ); 3369 + ok( ctx.EFlags == 0x200, "wrong flags %08x\n", ctx.EFlags ); 3370 + ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08x\n", ctx.MxCsr ); 3371 + ok( ctx.FltSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FltSave.ControlWord ); 3372 + entry_ptr = (void *)ctx.Rcx; 3373 + peb_ptr = (void *)ctx.Rdx; 3374 + 3375 + rop_chain.exit_process_ptr = exit_process_ptr; 3376 + ctx.Rcx = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, pipe_name); 3377 + ctx.Rdx = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, pipe_write_buf); 3378 + ctx.R8 = sizeof(pipe_params.pipe_write_buf); 3379 + ctx.R9 = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, pipe_read_buf); 3380 + rop_chain.pipe_read_buf_size = sizeof(pipe_params.pipe_read_buf); 3381 + rop_chain.bytes_returned = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, bytes_returned); 3382 + rop_chain.timeout = 10000; 3383 + 3384 + ctx.Rip = (ULONG_PTR)call_named_pipe_a; 3385 + ctx.Rsp -= sizeof(rop_chain); 3386 + ret = WriteProcessMemory(pi.hProcess, (void *)ctx.Rsp, &rop_chain, sizeof(rop_chain), NULL); 3387 + ok(ret, "Failed to write to remote process thread stack (%d)\n", GetLastError()); 3388 + #else 3389 + ok( !ctx.Ebp || broken(ctx.Ebp), /* winxp */ "ebp is not zero %08x\n", ctx.Ebp ); 3390 + if (!ctx.Ebp) /* winxp is completely different */ 3391 + { 3392 + ok( !ctx.Ecx, "ecx is not zero %08x\n", ctx.Ecx ); 3393 + ok( !ctx.Edx, "edx is not zero %08x\n", ctx.Edx ); 3394 + ok( !ctx.Esi, "esi is not zero %08x\n", ctx.Esi ); 3395 + ok( !ctx.Edi, "edi is not zero %08x\n", ctx.Edi ); 3396 + } 3397 + ok( !((ctx.Esp + 0x10) & 0xfff) || broken( !((ctx.Esp + 4) & 0xfff) ), /* winxp, w2k3 */ 3398 + "esp is not at top of stack page or properly aligned: %08x\n", ctx.Esp ); 3399 + ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08x\n", ctx.EFlags ); 3400 + ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FloatSave.ControlWord ); 3401 + ok( *(WORD *)ctx.ExtendedRegisters == 0x27f, "wrong control %08x\n", *(WORD *)ctx.ExtendedRegisters ); 3402 + entry_ptr = (void *)ctx.Eax; 3403 + peb_ptr = (void *)ctx.Ebx; 3404 + 3405 + rop_chain.exit_process_ptr = exit_process_ptr; 3406 + rop_chain.pipe_name = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, pipe_name); 3407 + rop_chain.pipe_write_buf = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, pipe_write_buf); 3408 + rop_chain.pipe_write_buf_size = sizeof(pipe_params.pipe_write_buf); 3409 + rop_chain.pipe_read_buf = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, pipe_read_buf); 3410 + rop_chain.pipe_read_buf_size = sizeof(pipe_params.pipe_read_buf); 3411 + rop_chain.bytes_returned = (ULONG_PTR)remote_pipe_params + offsetof(struct pipe_params, bytes_returned); 3412 + rop_chain.timeout = 10000; 3413 + rop_chain.exit_code = 0; 3414 + 3415 + ctx.Eip = (ULONG_PTR)call_named_pipe_a; 3416 + ctx.Esp -= sizeof(rop_chain); 3417 + ret = WriteProcessMemory(pi.hProcess, (void *)ctx.Esp, &rop_chain, sizeof(rop_chain), NULL); 3418 + ok(ret, "Failed to write to remote process thread stack (%d)\n", GetLastError()); 3419 + #endif 3420 + 3421 + ret = ReadProcessMemory( pi.hProcess, peb_ptr, &child_peb, sizeof(child_peb), NULL ); 3422 + ok( ret, "Failed to read PEB (%u)\n", GetLastError() ); 3423 + ok( child_peb.ImageBaseAddress == exe_base, "wrong base %p/%p\n", 3424 + child_peb.ImageBaseAddress, exe_base ); 3425 + ok( entry_ptr == (char *)exe_base + nt_header.OptionalHeader.AddressOfEntryPoint, 3426 + "wrong entry point %p/%p\n", entry_ptr, 3427 + (char *)exe_base + nt_header.OptionalHeader.AddressOfEntryPoint ); 3428 + 3429 + ret = SetThreadContext(pi.hThread, &ctx); 3430 + ok(ret, "Failed to set remote thread context (%d)\n", GetLastError()); 3431 + 3432 + ResumeThread(pi.hThread); 3433 + 3434 + pipe_connected = ConnectNamedPipe(server_pipe_handle, NULL) || (GetLastError() == ERROR_PIPE_CONNECTED); 3435 + ok(pipe_connected, "Pipe did not connect\n"); 3436 + 3437 + ret = ReadFile(server_pipe_handle, &pipe_magic, sizeof(pipe_magic), &numb, NULL); 3438 + ok(ret, "Failed to read buffer from pipe (%d)\n", GetLastError()); 3439 + 3440 + ok(pipe_magic == pipe_write_magic, "Did not get the correct magic from the remote process\n"); 3441 + 3442 + /* Validate the Imports, at this point the thread in the new process should have 3443 + initialized the EXE module imports and call each dll DllMain notifying it on 3444 + the new thread in the process. */ 3445 + ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header); 3446 + ok(ret, "EXE IAT is not resolved\n"); 3447 + 3448 + ret = WriteFile(server_pipe_handle, &pipe_magic, sizeof(pipe_magic), &numb, NULL); 3449 + ok(ret, "Failed to write the magic back to the pipe (%d)\n", GetLastError()); 3450 + 3451 + CloseHandle(server_pipe_handle); 3452 + TerminateProcess(pi.hProcess, 0); 3453 + WaitForSingleObject(pi.hProcess, 10000); 3454 + CloseHandle(pi.hProcess); 3455 + CloseHandle(pi.hThread); 3456 + } 3457 + #else 3458 + static void test_SuspendProcessNewThread(void) 3459 + { 3460 + } 3461 + static void test_SuspendProcessState(void) 3462 + { 3463 + } 3464 + #endif 3465 + 2968 3466 static void test_DetachStdHandles(void) 2969 3467 { 2970 3468 #ifndef _WIN64 ··· 3371 3869 ok(GetLastError() == ERROR_OBJECT_NAME_EXISTS, "got %d\n", GetLastError()); 3372 3870 3373 3871 ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR, handles, sizeof(PROCESSOR_NUMBER), NULL, NULL); 3374 - ok(ret || (!ret && GetLastError() == ERROR_NOT_SUPPORTED), "got %d gle %d\n", ret, GetLastError()); 3872 + ok(ret || GetLastError() == ERROR_NOT_SUPPORTED, "got %d gle %d\n", ret, GetLastError()); 3375 3873 3376 3874 if (ret) 3377 3875 { ··· 3484 3982 test_GetActiveProcessorCount(); 3485 3983 test_largepages(); 3486 3984 test_ProcThreadAttributeList(); 3985 + test_SuspendProcessState(); 3986 + test_SuspendProcessNewThread(); 3487 3987 3488 3988 /* things that can be tested: 3489 3989 * lookup: check the way program to be executed is searched
+44 -1
modules/rostests/winetests/kernel32/profile.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + #include <stdio.h> 23 + 24 + #include "wine/test.h" 25 + #include "windef.h" 26 + #include "winbase.h" 27 + #include "windows.h" 28 + #include "sddl.h" 22 29 23 30 #define KEY "ProfileInt" 24 31 #define SECTION "Test" ··· 524 531 } 525 532 526 533 return TRUE; 534 + } 535 + 536 + static void test_profile_directory_readonly(void) 537 + { 538 + BOOL ret; 539 + CHAR path_folder[MAX_PATH]; 540 + CHAR path_file[MAX_PATH]; 541 + const char *sddl_string_everyone_readonly = "D:PAI(A;;0x1200a9;;;WD)"; 542 + SECURITY_ATTRIBUTES attributes = {0}; 543 + char lpStruct[] = { 's', 't', 'r', 'i', 'n', 'g' }; 544 + 545 + attributes.nLength = sizeof(attributes); 546 + ret = ConvertStringSecurityDescriptorToSecurityDescriptorA(sddl_string_everyone_readonly, SDDL_REVISION_1, &attributes.lpSecurityDescriptor, NULL); 547 + ok(ret == TRUE, "ConvertStringSecurityDescriptorToSecurityDescriptor failed: %d\n", GetLastError()); 548 + 549 + GetTempPathA(MAX_PATH, path_folder); 550 + lstrcatA(path_folder, "wine-test"); 551 + 552 + strcpy(path_file, path_folder); 553 + lstrcatA(path_file, "\\tmp.ini"); 554 + 555 + ret = CreateDirectoryA(path_folder, &attributes); 556 + ok(ret == TRUE, "CreateDirectoryA failed: %d\n", GetLastError()); 557 + 558 + ret = WritePrivateProfileStringA("App", "key", "string", path_file); 559 + ok(ret == FALSE, "Expected FALSE, got %d\n", ret); 560 + 561 + ret = WritePrivateProfileSectionA("App", "key=string", path_file); 562 + ok(ret == FALSE, "Expected FALSE, got %d\n", ret); 563 + 564 + ret = WritePrivateProfileStructA("App", "key", lpStruct, sizeof(lpStruct), path_file); 565 + ok(ret == FALSE, "Expected FALSE, got %d\n", ret); 566 + 567 + ret = RemoveDirectoryA(path_folder); 568 + ok(ret == TRUE, "RemoveDirectoryA failed: %d\n", GetLastError()); 527 569 } 528 570 529 571 static void test_GetPrivateProfileString(const char *content, const char *descript) ··· 1124 1166 test_profile_existing(); 1125 1167 test_profile_delete_on_close(); 1126 1168 test_profile_refresh(); 1169 + test_profile_directory_readonly(); 1127 1170 test_GetPrivateProfileString( 1128 1171 "[section1]\r\n" 1129 1172 "name1=val1\r\n"
+4 -1
modules/rostests/winetests/kernel32/resource.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <windows.h> 22 + #include <stdio.h> 23 + 24 + #include "wine/test.h" 22 25 23 26 static const char filename[] = "test_.exe"; 24 27 static DWORD GLE;
+120 -129
modules/rostests/winetests/kernel32/sync.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #ifndef __REACTOS__ 22 + #define _WIN32_WINNT 0x500 23 + #endif 24 + #include <stdarg.h> 25 + #include <stdlib.h> 26 + #include <stdio.h> 27 + #include <windef.h> 28 + #include <winbase.h> 29 + #include <winternl.h> 22 30 31 + #include "wine/test.h" 32 + 33 + #ifdef __REACTOS__ 23 34 #define QueryDepthSList(x) RtlQueryDepthSList(x) 24 35 #define InterlockedPushEntrySList(x,y) RtlInterlockedPushEntrySList(x,y) 25 36 #define InterlockedPopEntrySList(x) RtlInterlockedPopEntrySList(x) 26 37 #define InterlockedFlushSList(x) RtlInterlockedFlushSList(x) 38 + #endif 27 39 28 40 #undef __fastcall 29 41 #define __fastcall __stdcall 30 42 31 - static BOOL (WINAPI *pChangeTimerQueueTimer)(HANDLE, HANDLE, ULONG, ULONG); 32 - static HANDLE (WINAPI *pCreateTimerQueue)(void); 33 - static BOOL (WINAPI *pCreateTimerQueueTimer)(PHANDLE, HANDLE, WAITORTIMERCALLBACK, 34 - PVOID, DWORD, DWORD, ULONG); 35 - static HANDLE (WINAPI *pCreateWaitableTimerA)(SECURITY_ATTRIBUTES*,BOOL,LPCSTR); 36 - static BOOL (WINAPI *pDeleteTimerQueueEx)(HANDLE, HANDLE); 37 - static BOOL (WINAPI *pDeleteTimerQueueTimer)(HANDLE, HANDLE, HANDLE); 38 - static HANDLE (WINAPI *pOpenWaitableTimerA)(DWORD,BOOL,LPCSTR); 39 43 static HANDLE (WINAPI *pCreateMemoryResourceNotification)(MEMORY_RESOURCE_NOTIFICATION_TYPE); 40 44 static BOOL (WINAPI *pQueryMemoryResourceNotification)(HANDLE, PBOOL); 41 45 static VOID (WINAPI *pInitOnceInitialize)(PINIT_ONCE); ··· 106 110 107 111 static void test_signalandwait(void) 108 112 { 109 - DWORD (WINAPI *pSignalObjectAndWait)(HANDLE, HANDLE, DWORD, BOOL); 110 - HMODULE kernel32; 111 113 DWORD r; 112 114 HANDLE event[2], semaphore[2], file; 113 115 int i; 114 - 115 - kernel32 = GetModuleHandleA("kernel32.dll"); 116 - pSignalObjectAndWait = (void*) GetProcAddress(kernel32, "SignalObjectAndWait"); 117 - 118 - if (!pSignalObjectAndWait) 119 - return; 120 116 121 117 /* invalid parameters */ 122 - r = pSignalObjectAndWait(NULL, NULL, 0, 0); 123 - if (r == ERROR_INVALID_FUNCTION) 124 - { 125 - win_skip("SignalObjectAndWait is not implemented\n"); 126 - return; /* Win98/ME */ 127 - } 118 + r = SignalObjectAndWait(NULL, NULL, 0, 0); 128 119 ok( r == WAIT_FAILED, "should fail\n"); 129 120 130 121 event[0] = CreateEventW(NULL, 0, 0, NULL); ··· 132 123 133 124 ok( event[0] && event[1], "failed to create event flags\n"); 134 125 135 - r = pSignalObjectAndWait(event[0], NULL, 0, FALSE); 126 + r = SignalObjectAndWait(event[0], NULL, 0, FALSE); 136 127 ok( r == WAIT_FAILED, "should fail\n"); 137 128 138 - r = pSignalObjectAndWait(NULL, event[0], 0, FALSE); 129 + r = SignalObjectAndWait(NULL, event[0], 0, FALSE); 139 130 ok( r == WAIT_FAILED, "should fail\n"); 140 131 141 132 142 133 /* valid parameters */ 143 - r = pSignalObjectAndWait(event[0], event[1], 0, FALSE); 134 + r = SignalObjectAndWait(event[0], event[1], 0, FALSE); 144 135 ok( r == WAIT_OBJECT_0, "should succeed\n"); 145 136 146 137 /* event[0] is now signalled - we repeat this test multiple times 147 138 * to ensure that the wineserver handles this situation properly. */ 148 139 for (i = 0; i < 10000; i++) 149 140 { 150 - r = pSignalObjectAndWait(event[0], event[0], 0, FALSE); 141 + r = SignalObjectAndWait(event[0], event[0], 0, FALSE); 151 142 ok(r == WAIT_OBJECT_0, "should succeed\n"); 152 143 } 153 144 ··· 155 146 r = WaitForSingleObject(event[0], 0); 156 147 ok( r == WAIT_TIMEOUT, "event was signalled\n"); 157 148 158 - r = pSignalObjectAndWait(event[0], event[0], 0, FALSE); 149 + r = SignalObjectAndWait(event[0], event[0], 0, FALSE); 159 150 ok( r == WAIT_OBJECT_0, "should succeed\n"); 160 151 161 152 /* clear event[1] and check for a timeout */ 162 153 ok(ResetEvent(event[1]), "failed to clear event[1]\n"); 163 - r = pSignalObjectAndWait(event[0], event[1], 0, FALSE); 154 + r = SignalObjectAndWait(event[0], event[1], 0, FALSE); 164 155 ok( r == WAIT_TIMEOUT, "should timeout\n"); 165 156 166 157 CloseHandle(event[0]); ··· 171 162 semaphore[1] = CreateSemaphoreW( NULL, 1, 1, NULL ); 172 163 ok( semaphore[0] && semaphore[1], "failed to create semaphore\n"); 173 164 174 - r = pSignalObjectAndWait(semaphore[0], semaphore[1], 0, FALSE); 165 + r = SignalObjectAndWait(semaphore[0], semaphore[1], 0, FALSE); 175 166 ok( r == WAIT_OBJECT_0, "should succeed\n"); 176 167 177 - r = pSignalObjectAndWait(semaphore[0], semaphore[1], 0, FALSE); 168 + r = SignalObjectAndWait(semaphore[0], semaphore[1], 0, FALSE); 178 169 ok( r == WAIT_FAILED, "should fail\n"); 179 170 180 171 r = ReleaseSemaphore(semaphore[0],1,NULL); ··· 189 180 /* try a registry key */ 190 181 file = CreateFileA("x", GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 191 182 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL); 192 - r = pSignalObjectAndWait(file, file, 0, FALSE); 183 + r = SignalObjectAndWait(file, file, 0, FALSE); 193 184 ok( r == WAIT_FAILED, "should fail\n"); 194 185 ok( ERROR_INVALID_HANDLE == GetLastError(), "should return invalid handle error\n"); 195 186 CloseHandle(file); ··· 283 274 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError()); 284 275 285 276 SetLastError(0xdeadbeef); 277 + hOpened = OpenMutexA(READ_CONTROL, FALSE, NULL); 278 + ok(!hOpened, "OpenMutex succeeded\n"); 279 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 280 + 281 + SetLastError(0xdeadbeef); 282 + hOpened = OpenMutexW(READ_CONTROL, FALSE, NULL); 283 + ok(!hOpened, "OpenMutex succeeded\n"); 284 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 285 + 286 + SetLastError(0xdeadbeef); 286 287 hOpened = CreateMutexA(NULL, FALSE, "WineTestMutex"); 287 288 ok(hOpened != NULL, "CreateMutex failed with error %d\n", GetLastError()); 288 289 ok(GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError()); ··· 535 536 ok( !handle2, "OpenEvent succeeded\n"); 536 537 ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError()); 537 538 539 + SetLastError(0xdeadbeef); 540 + handle2 = OpenEventA( EVENT_ALL_ACCESS, FALSE, NULL ); 541 + ok( !handle2, "OpenEvent succeeded\n"); 542 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 543 + 544 + SetLastError(0xdeadbeef); 545 + handle2 = OpenEventW( EVENT_ALL_ACCESS, FALSE, NULL ); 546 + ok( !handle2, "OpenEvent succeeded\n"); 547 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 548 + 538 549 CloseHandle( handle ); 539 550 540 551 /* resource notifications are events too */ ··· 604 615 ok( !handle2, "OpenSemaphore succeeded\n"); 605 616 ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError()); 606 617 618 + SetLastError(0xdeadbeef); 619 + handle2 = OpenSemaphoreA( SEMAPHORE_ALL_ACCESS, FALSE, NULL ); 620 + ok( !handle2, "OpenSemaphore succeeded\n"); 621 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 622 + 623 + SetLastError(0xdeadbeef); 624 + handle2 = OpenSemaphoreW( SEMAPHORE_ALL_ACCESS, FALSE, NULL ); 625 + ok( !handle2, "OpenSemaphore succeeded\n"); 626 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 627 + 607 628 CloseHandle( handle ); 608 629 } 609 630 ··· 611 632 { 612 633 HANDLE handle, handle2; 613 634 614 - if (!pCreateWaitableTimerA || !pOpenWaitableTimerA) 615 - { 616 - win_skip("{Create,Open}WaitableTimerA() is not available\n"); 617 - return; 618 - } 619 - 620 635 /* test case sensitivity */ 621 636 622 637 SetLastError(0xdeadbeef); 623 - handle = pCreateWaitableTimerA(NULL, FALSE, __FILE__ ": Test WaitableTimer"); 638 + handle = CreateWaitableTimerA(NULL, FALSE, __FILE__ ": Test WaitableTimer"); 624 639 ok(handle != NULL, "CreateWaitableTimer failed with error %u\n", GetLastError()); 625 640 ok(GetLastError() == 0, "wrong error %u\n", GetLastError()); 626 641 627 642 SetLastError(0xdeadbeef); 628 - handle2 = pCreateWaitableTimerA(NULL, FALSE, __FILE__ ": Test WaitableTimer"); 643 + handle2 = CreateWaitableTimerA(NULL, FALSE, __FILE__ ": Test WaitableTimer"); 629 644 ok( handle2 != NULL, "CreateWaitableTimer failed with error %d\n", GetLastError()); 630 645 ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError()); 631 646 CloseHandle( handle2 ); 632 647 633 648 SetLastError(0xdeadbeef); 634 - handle2 = pCreateWaitableTimerA(NULL, FALSE, __FILE__ ": TEST WAITABLETIMER"); 649 + handle2 = CreateWaitableTimerA(NULL, FALSE, __FILE__ ": TEST WAITABLETIMER"); 635 650 ok( handle2 != NULL, "CreateWaitableTimer failed with error %d\n", GetLastError()); 636 651 ok( GetLastError() == 0, "wrong error %u\n", GetLastError()); 637 652 CloseHandle( handle2 ); 638 653 639 654 SetLastError(0xdeadbeef); 640 - handle2 = pOpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, __FILE__ ": Test WaitableTimer"); 655 + handle2 = OpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, __FILE__ ": Test WaitableTimer"); 641 656 ok( handle2 != NULL, "OpenWaitableTimer failed with error %d\n", GetLastError()); 642 657 CloseHandle( handle2 ); 643 658 644 659 SetLastError(0xdeadbeef); 645 - handle2 = pOpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, __FILE__ ": TEST WAITABLETIMER"); 660 + handle2 = OpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, __FILE__ ": TEST WAITABLETIMER"); 646 661 ok( !handle2, "OpenWaitableTimer succeeded\n"); 647 - ok( GetLastError() == ERROR_FILE_NOT_FOUND || 648 - GetLastError() == ERROR_INVALID_NAME, /* win98 */ 649 - "wrong error %u\n", GetLastError()); 662 + ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError()); 663 + 664 + SetLastError(0xdeadbeef); 665 + handle2 = OpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, NULL ); 666 + ok( !handle2, "OpenWaitableTimer failed with error %d\n", GetLastError()); 667 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 668 + 669 + SetLastError(0xdeadbeef); 670 + handle2 = OpenWaitableTimerW( TIMER_ALL_ACCESS, FALSE, NULL ); 671 + ok( !handle2, "OpenWaitableTimer failed with error %d\n", GetLastError()); 672 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); 650 673 651 674 CloseHandle( handle ); 652 675 } ··· 776 799 SetLastError(0xdeadbeef); 777 800 /* Note, XP SP2 does *not* do any deadlock checking, so passing 778 801 INVALID_HANDLE_VALUE here will just hang. */ 779 - ret = pDeleteTimerQueueTimer(d->q, d->t, NULL); 802 + ret = DeleteTimerQueueTimer(d->q, d->t, NULL); 780 803 ok(!ret, "DeleteTimerQueueTimer\n"); 781 804 ok(GetLastError() == ERROR_IO_PENDING, "DeleteTimerQueueTimer\n"); 782 805 } ··· 790 813 { 791 814 /* Basically kill the timer since it won't have time to run 792 815 again. */ 793 - BOOL ret = pChangeTimerQueueTimer(d->q, d->t, 10000, 0); 816 + BOOL ret = ChangeTimerQueueTimer(d->q, d->t, 10000, 0); 794 817 ok(ret, "ChangeTimerQueueTimer\n"); 795 818 } 796 819 } ··· 806 829 period of zero (run once), then ChangeTimerQueueTimer will 807 830 fail if the timer is already flagged. Hence we really run 808 831 only once. Otherwise we will run multiple times. */ 809 - BOOL ret = pChangeTimerQueueTimer(d->q, d->t, 50, 50); 832 + BOOL ret = ChangeTimerQueueTimer(d->q, d->t, 50, 50); 810 833 ok(ret, "ChangeTimerQueueTimer\n"); 811 834 ++d->num_calls; 812 835 } ··· 838 861 839 862 /* The delete will pend while we are in this callback. */ 840 863 SetLastError(0xdeadbeef); 841 - ret = pDeleteTimerQueueTimer(d->q, d->t, NULL); 864 + ret = DeleteTimerQueueTimer(d->q, d->t, NULL); 842 865 ok(!ret, "DeleteTimerQueueTimer\n"); 843 866 ok(GetLastError() == ERROR_IO_PENDING, "DeleteTimerQueueTimer\n"); 844 867 845 - ret = pCreateTimerQueueTimer(&t, d->q, timer_queue_cb1, NULL, 100, 0, 0); 868 + ret = CreateTimerQueueTimer(&t, d->q, timer_queue_cb1, NULL, 100, 0, 0); 846 869 ok(ret, "CreateTimerQueueTimer\n"); 847 870 ok(t != NULL, "CreateTimerQueueTimer\n"); 848 871 849 - ret = pDeleteTimerQueueTimer(d->q, t, INVALID_HANDLE_VALUE); 872 + ret = DeleteTimerQueueTimer(d->q, t, INVALID_HANDLE_VALUE); 850 873 ok(ret, "DeleteTimerQueueTimer\n"); 851 874 852 875 /* Now we stay alive by hanging around in the callback. */ ··· 862 885 HANDLE e, et1, et2; 863 886 BOOL ret, ret0; 864 887 865 - if (!pChangeTimerQueueTimer || !pCreateTimerQueue || !pCreateTimerQueueTimer 866 - || !pDeleteTimerQueueEx || !pDeleteTimerQueueTimer) 867 - { 868 - win_skip("TimerQueue API not present\n"); 869 - return; 870 - } 871 - 872 888 /* Test asynchronous deletion of the queue. */ 873 - q = pCreateTimerQueue(); 889 + q = CreateTimerQueue(); 874 890 ok(q != NULL, "CreateTimerQueue\n"); 875 891 876 892 SetLastError(0xdeadbeef); 877 - ret = pDeleteTimerQueueEx(q, NULL); 893 + ret = DeleteTimerQueueEx(q, NULL); 878 894 ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING, 879 895 "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n", 880 896 GetLastError()); 881 897 882 898 /* Test synchronous deletion of the queue and running timers. */ 883 - q = pCreateTimerQueue(); 899 + q = CreateTimerQueue(); 884 900 ok(q != NULL, "CreateTimerQueue\n"); 885 901 886 902 /* Not called. */ 887 903 t0 = NULL; 888 904 n0 = 0; 889 - ret = pCreateTimerQueueTimer(&t0, q, timer_queue_cb1, &n0, 0, 890 - 300, 0); 905 + ret = CreateTimerQueueTimer(&t0, q, timer_queue_cb1, &n0, 0, 300, 0); 891 906 ok(ret, "CreateTimerQueueTimer\n"); 892 907 ok(t0 != NULL, "CreateTimerQueueTimer\n"); 893 - ret0 = pDeleteTimerQueueTimer(q, t0, NULL); 908 + ret0 = DeleteTimerQueueTimer(q, t0, NULL); 894 909 ok((!ret0 && GetLastError() == ERROR_IO_PENDING) || 895 910 broken(ret0), /* Win 2000 & XP & 2003 */ 896 911 "DeleteTimerQueueTimer ret=%d le=%u\n", ret0, GetLastError()); ··· 898 913 /* Called once. */ 899 914 t1 = NULL; 900 915 n1 = 0; 901 - ret = pCreateTimerQueueTimer(&t1, q, timer_queue_cb1, &n1, 0, 902 - 0, 0); 916 + ret = CreateTimerQueueTimer(&t1, q, timer_queue_cb1, &n1, 0, 0, 0); 903 917 ok(ret, "CreateTimerQueueTimer\n"); 904 918 ok(t1 != NULL, "CreateTimerQueueTimer\n"); 905 919 906 920 /* A slow one. */ 907 921 t2 = NULL; 908 922 n2 = 0; 909 - ret = pCreateTimerQueueTimer(&t2, q, timer_queue_cb1, &n2, 0, 910 - 100, 0); 923 + ret = CreateTimerQueueTimer(&t2, q, timer_queue_cb1, &n2, 0, 100, 0); 911 924 ok(ret, "CreateTimerQueueTimer\n"); 912 925 ok(t2 != NULL, "CreateTimerQueueTimer\n"); 913 926 914 927 /* A fast one. */ 915 928 t3 = NULL; 916 929 n3 = 0; 917 - ret = pCreateTimerQueueTimer(&t3, q, timer_queue_cb1, &n3, 0, 918 - 10, 0); 930 + ret = CreateTimerQueueTimer(&t3, q, timer_queue_cb1, &n3, 0, 10, 0); 919 931 ok(ret, "CreateTimerQueueTimer\n"); 920 932 ok(t3 != NULL, "CreateTimerQueueTimer\n"); 921 933 922 934 /* Start really late (it won't start). */ 923 935 t4 = NULL; 924 936 n4 = 0; 925 - ret = pCreateTimerQueueTimer(&t4, q, timer_queue_cb1, &n4, 10000, 926 - 10, 0); 937 + ret = CreateTimerQueueTimer(&t4, q, timer_queue_cb1, &n4, 10000, 10, 0); 927 938 ok(ret, "CreateTimerQueueTimer\n"); 928 939 ok(t4 != NULL, "CreateTimerQueueTimer\n"); 929 940 930 941 /* Start soon, but delay so long it won't run again. */ 931 942 t5 = NULL; 932 943 n5 = 0; 933 - ret = pCreateTimerQueueTimer(&t5, q, timer_queue_cb1, &n5, 0, 934 - 10000, 0); 944 + ret = CreateTimerQueueTimer(&t5, q, timer_queue_cb1, &n5, 0, 10000, 0); 935 945 ok(ret, "CreateTimerQueueTimer\n"); 936 946 ok(t5 != NULL, "CreateTimerQueueTimer\n"); 937 947 ··· 939 949 Sleep(500); 940 950 941 951 /* Test deleting a once-only timer. */ 942 - ret = pDeleteTimerQueueTimer(q, t1, INVALID_HANDLE_VALUE); 952 + ret = DeleteTimerQueueTimer(q, t1, INVALID_HANDLE_VALUE); 943 953 ok(ret, "DeleteTimerQueueTimer\n"); 944 954 945 955 /* A periodic timer. */ 946 - ret = pDeleteTimerQueueTimer(q, t2, INVALID_HANDLE_VALUE); 956 + ret = DeleteTimerQueueTimer(q, t2, INVALID_HANDLE_VALUE); 947 957 ok(ret, "DeleteTimerQueueTimer\n"); 948 958 949 - ret = pDeleteTimerQueueEx(q, INVALID_HANDLE_VALUE); 959 + ret = DeleteTimerQueueEx(q, INVALID_HANDLE_VALUE); 950 960 ok(ret, "DeleteTimerQueueEx\n"); 951 961 todo_wine 952 962 ok(n0 == 1 || broken(ret0 && n0 == 0), "Timer callback 0 expected 1 got %d\n", n0); ··· 965 975 return; 966 976 } 967 977 968 - q = pCreateTimerQueue(); 978 + q = CreateTimerQueue(); 969 979 ok(q != NULL, "CreateTimerQueue\n"); 970 980 971 981 /* Run once and finish quickly (should be done when we delete it). */ 972 982 t1 = NULL; 973 - ret = pCreateTimerQueueTimer(&t1, q, timer_queue_cb5, NULL, 0, 0, 0); 983 + ret = CreateTimerQueueTimer(&t1, q, timer_queue_cb5, NULL, 0, 0, 0); 974 984 ok(ret, "CreateTimerQueueTimer\n"); 975 985 ok(t1 != NULL, "CreateTimerQueueTimer\n"); 976 986 977 987 /* Run once and finish slowly (shouldn't be done when we delete it). */ 978 988 t2 = NULL; 979 - ret = pCreateTimerQueueTimer(&t2, q, timer_queue_cb5, (PVOID) 1000, 0, 980 - 0, 0); 989 + ret = CreateTimerQueueTimer(&t2, q, timer_queue_cb5, (PVOID) 1000, 0, 0, 0); 981 990 ok(ret, "CreateTimerQueueTimer\n"); 982 991 ok(t2 != NULL, "CreateTimerQueueTimer\n"); 983 992 984 993 /* Run once and finish quickly (should be done when we delete it). */ 985 994 t3 = NULL; 986 - ret = pCreateTimerQueueTimer(&t3, q, timer_queue_cb5, NULL, 0, 0, 0); 995 + ret = CreateTimerQueueTimer(&t3, q, timer_queue_cb5, NULL, 0, 0, 0); 987 996 ok(ret, "CreateTimerQueueTimer\n"); 988 997 ok(t3 != NULL, "CreateTimerQueueTimer\n"); 989 998 990 999 /* Run once and finish slowly (shouldn't be done when we delete it). */ 991 1000 t4 = NULL; 992 - ret = pCreateTimerQueueTimer(&t4, q, timer_queue_cb5, (PVOID) 1000, 0, 993 - 0, 0); 1001 + ret = CreateTimerQueueTimer(&t4, q, timer_queue_cb5, (PVOID) 1000, 0, 0, 0); 994 1002 ok(ret, "CreateTimerQueueTimer\n"); 995 1003 ok(t4 != NULL, "CreateTimerQueueTimer\n"); 996 1004 ··· 1000 1008 /* DeleteTimerQueueTimer always returns PENDING with a NULL event, 1001 1009 even if the timer is finished. */ 1002 1010 SetLastError(0xdeadbeef); 1003 - ret = pDeleteTimerQueueTimer(q, t1, NULL); 1011 + ret = DeleteTimerQueueTimer(q, t1, NULL); 1004 1012 ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING, 1005 1013 "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %d\n", 1006 1014 GetLastError()); 1007 1015 1008 1016 SetLastError(0xdeadbeef); 1009 - ret = pDeleteTimerQueueTimer(q, t2, NULL); 1017 + ret = DeleteTimerQueueTimer(q, t2, NULL); 1010 1018 ok(!ret, "DeleteTimerQueueTimer call was expected to fail\n"); 1011 1019 ok(GetLastError() == ERROR_IO_PENDING, 1012 1020 "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %d\n", 1013 1021 GetLastError()); 1014 1022 1015 1023 SetLastError(0xdeadbeef); 1016 - ret = pDeleteTimerQueueTimer(q, t3, et1); 1024 + ret = DeleteTimerQueueTimer(q, t3, et1); 1017 1025 ok(ret, "DeleteTimerQueueTimer call was expected to fail\n"); 1018 1026 ok(GetLastError() == 0xdeadbeef, 1019 1027 "DeleteTimerQueueTimer, GetLastError: expected 0xdeadbeef, got %d\n", ··· 1022 1030 "Timer destruction event not triggered\n"); 1023 1031 1024 1032 SetLastError(0xdeadbeef); 1025 - ret = pDeleteTimerQueueTimer(q, t4, et2); 1033 + ret = DeleteTimerQueueTimer(q, t4, et2); 1026 1034 ok(!ret, "DeleteTimerQueueTimer call was expected to fail\n"); 1027 1035 ok(GetLastError() == ERROR_IO_PENDING, 1028 1036 "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %d\n", ··· 1031 1039 "Timer destruction event not triggered\n"); 1032 1040 1033 1041 SetLastError(0xdeadbeef); 1034 - ret = pDeleteTimerQueueEx(q, e); 1042 + ret = DeleteTimerQueueEx(q, e); 1035 1043 ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING, 1036 1044 "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n", 1037 1045 GetLastError()); ··· 1040 1048 CloseHandle(e); 1041 1049 1042 1050 /* Test deleting/changing a timer in execution. */ 1043 - q = pCreateTimerQueue(); 1051 + q = CreateTimerQueue(); 1044 1052 ok(q != NULL, "CreateTimerQueue\n"); 1045 1053 1046 1054 /* Test changing a once-only timer before it fires (this is allowed, 1047 1055 whereas after it fires you cannot). */ 1048 1056 n1 = 0; 1049 - ret = pCreateTimerQueueTimer(&t1, q, timer_queue_cb1, &n1, 10000, 1050 - 0, 0); 1057 + ret = CreateTimerQueueTimer(&t1, q, timer_queue_cb1, &n1, 10000, 0, 0); 1051 1058 ok(ret, "CreateTimerQueueTimer\n"); 1052 1059 ok(t1 != NULL, "CreateTimerQueueTimer\n"); 1053 - ret = pChangeTimerQueueTimer(q, t1, 0, 0); 1060 + ret = ChangeTimerQueueTimer(q, t1, 0, 0); 1054 1061 ok(ret, "ChangeTimerQueueTimer\n"); 1055 1062 1056 1063 d2.t = t2 = NULL; 1057 1064 d2.num_calls = 0; 1058 1065 d2.max_calls = 3; 1059 1066 d2.q = q; 1060 - ret = pCreateTimerQueueTimer(&t2, q, timer_queue_cb2, &d2, 10, 1061 - 10, 0); 1067 + ret = CreateTimerQueueTimer(&t2, q, timer_queue_cb2, &d2, 10, 10, 0); 1062 1068 d2.t = t2; 1063 1069 ok(ret, "CreateTimerQueueTimer\n"); 1064 1070 ok(t2 != NULL, "CreateTimerQueueTimer\n"); ··· 1067 1073 d3.num_calls = 0; 1068 1074 d3.max_calls = 4; 1069 1075 d3.q = q; 1070 - ret = pCreateTimerQueueTimer(&t3, q, timer_queue_cb3, &d3, 10, 1071 - 10, 0); 1076 + ret = CreateTimerQueueTimer(&t3, q, timer_queue_cb3, &d3, 10, 10, 0); 1072 1077 d3.t = t3; 1073 1078 ok(ret, "CreateTimerQueueTimer\n"); 1074 1079 ok(t3 != NULL, "CreateTimerQueueTimer\n"); ··· 1076 1081 d4.t = t4 = NULL; 1077 1082 d4.num_calls = 0; 1078 1083 d4.q = q; 1079 - ret = pCreateTimerQueueTimer(&t4, q, timer_queue_cb4, &d4, 10, 1080 - 0, 0); 1084 + ret = CreateTimerQueueTimer(&t4, q, timer_queue_cb4, &d4, 10, 0, 0); 1081 1085 d4.t = t4; 1082 1086 ok(ret, "CreateTimerQueueTimer\n"); 1083 1087 ok(t4 != NULL, "CreateTimerQueueTimer\n"); 1084 1088 1085 1089 Sleep(500); 1086 1090 1087 - ret = pDeleteTimerQueueEx(q, INVALID_HANDLE_VALUE); 1091 + ret = DeleteTimerQueueEx(q, INVALID_HANDLE_VALUE); 1088 1092 ok(ret, "DeleteTimerQueueEx\n"); 1089 1093 ok(n1 == 1, "ChangeTimerQueueTimer\n"); 1090 1094 ok(d2.num_calls == d2.max_calls, "DeleteTimerQueueTimer\n"); ··· 1092 1096 ok(d4.num_calls == 1, "Timer flagged for deletion incorrectly\n"); 1093 1097 1094 1098 /* Test an obscure bug that was in the original implementation. */ 1095 - q = pCreateTimerQueue(); 1099 + q = CreateTimerQueue(); 1096 1100 ok(q != NULL, "CreateTimerQueue\n"); 1097 1101 1098 1102 /* All the work is done in the callback. */ 1099 1103 d1.t = t1 = NULL; 1100 1104 d1.num_calls = 0; 1101 1105 d1.q = q; 1102 - ret = pCreateTimerQueueTimer(&t1, q, timer_queue_cb6, &d1, 100, 1103 - 100, WT_EXECUTELONGFUNCTION); 1106 + ret = CreateTimerQueueTimer(&t1, q, timer_queue_cb6, &d1, 100, 100, WT_EXECUTELONGFUNCTION); 1104 1107 d1.t = t1; 1105 1108 ok(ret, "CreateTimerQueueTimer\n"); 1106 1109 ok(t1 != NULL, "CreateTimerQueueTimer\n"); ··· 1108 1111 Sleep(750); 1109 1112 1110 1113 SetLastError(0xdeadbeef); 1111 - ret = pDeleteTimerQueueEx(q, NULL); 1114 + ret = DeleteTimerQueueEx(q, NULL); 1112 1115 ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING, 1113 1116 "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n", 1114 1117 GetLastError()); ··· 1117 1120 /* Test functions on the default timer queue. */ 1118 1121 t1 = NULL; 1119 1122 n1 = 0; 1120 - ret = pCreateTimerQueueTimer(&t1, NULL, timer_queue_cb1, &n1, 1000, 1121 - 1000, 0); 1123 + ret = CreateTimerQueueTimer(&t1, NULL, timer_queue_cb1, &n1, 1000, 1000, 0); 1122 1124 ok(ret, "CreateTimerQueueTimer, default queue\n"); 1123 1125 ok(t1 != NULL, "CreateTimerQueueTimer, default queue\n"); 1124 1126 1125 - ret = pChangeTimerQueueTimer(NULL, t1, 2000, 2000); 1127 + ret = ChangeTimerQueueTimer(NULL, t1, 2000, 2000); 1126 1128 ok(ret, "ChangeTimerQueueTimer, default queue\n"); 1127 1129 1128 - ret = pDeleteTimerQueueTimer(NULL, t1, INVALID_HANDLE_VALUE); 1130 + ret = DeleteTimerQueueTimer(NULL, t1, INVALID_HANDLE_VALUE); 1129 1131 ok(ret, "DeleteTimerQueueTimer, default queue\n"); 1130 1132 1131 1133 /* Try mixing default and non-default queues. Apparently this works. */ 1132 - q = pCreateTimerQueue(); 1134 + q = CreateTimerQueue(); 1133 1135 ok(q != NULL, "CreateTimerQueue\n"); 1134 1136 1135 1137 t1 = NULL; 1136 1138 n1 = 0; 1137 - ret = pCreateTimerQueueTimer(&t1, q, timer_queue_cb1, &n1, 1000, 1138 - 1000, 0); 1139 + ret = CreateTimerQueueTimer(&t1, q, timer_queue_cb1, &n1, 1000, 1000, 0); 1139 1140 ok(ret, "CreateTimerQueueTimer\n"); 1140 1141 ok(t1 != NULL, "CreateTimerQueueTimer\n"); 1141 1142 1142 1143 t2 = NULL; 1143 1144 n2 = 0; 1144 - ret = pCreateTimerQueueTimer(&t2, NULL, timer_queue_cb1, &n2, 1000, 1145 - 1000, 0); 1145 + ret = CreateTimerQueueTimer(&t2, NULL, timer_queue_cb1, &n2, 1000, 1000, 0); 1146 1146 ok(ret, "CreateTimerQueueTimer\n"); 1147 1147 ok(t2 != NULL, "CreateTimerQueueTimer\n"); 1148 1148 1149 - ret = pChangeTimerQueueTimer(NULL, t1, 2000, 2000); 1149 + ret = ChangeTimerQueueTimer(NULL, t1, 2000, 2000); 1150 1150 ok(ret, "ChangeTimerQueueTimer\n"); 1151 1151 1152 - ret = pChangeTimerQueueTimer(q, t2, 2000, 2000); 1152 + ret = ChangeTimerQueueTimer(q, t2, 2000, 2000); 1153 1153 ok(ret, "ChangeTimerQueueTimer\n"); 1154 1154 1155 - ret = pDeleteTimerQueueTimer(NULL, t1, INVALID_HANDLE_VALUE); 1155 + ret = DeleteTimerQueueTimer(NULL, t1, INVALID_HANDLE_VALUE); 1156 1156 ok(ret, "DeleteTimerQueueTimer\n"); 1157 1157 1158 - ret = pDeleteTimerQueueTimer(q, t2, INVALID_HANDLE_VALUE); 1158 + ret = DeleteTimerQueueTimer(q, t2, INVALID_HANDLE_VALUE); 1159 1159 ok(ret, "DeleteTimerQueueTimer\n"); 1160 1160 1161 1161 /* Try to delete the default queue? In any case: not allowed. */ 1162 1162 SetLastError(0xdeadbeef); 1163 - ret = pDeleteTimerQueueEx(NULL, NULL); 1163 + ret = DeleteTimerQueueEx(NULL, NULL); 1164 1164 ok(!ret, "DeleteTimerQueueEx call was expected to fail\n"); 1165 1165 ok(GetLastError() == ERROR_INVALID_HANDLE, 1166 1166 "DeleteTimerQueueEx, GetLastError: expected ERROR_INVALID_HANDLE, got %d\n", 1167 1167 GetLastError()); 1168 1168 1169 1169 SetLastError(0xdeadbeef); 1170 - ret = pDeleteTimerQueueEx(q, NULL); 1170 + ret = DeleteTimerQueueEx(q, NULL); 1171 1171 ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING, 1172 1172 "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n", 1173 1173 GetLastError()); ··· 2645 2645 HMODULE hdll = GetModuleHandleA("kernel32.dll"); 2646 2646 HMODULE hntdll = GetModuleHandleA("ntdll.dll"); 2647 2647 2648 - pChangeTimerQueueTimer = (void*)GetProcAddress(hdll, "ChangeTimerQueueTimer"); 2649 - pCreateTimerQueue = (void*)GetProcAddress(hdll, "CreateTimerQueue"); 2650 - pCreateTimerQueueTimer = (void*)GetProcAddress(hdll, "CreateTimerQueueTimer"); 2651 - pCreateWaitableTimerA = (void*)GetProcAddress(hdll, "CreateWaitableTimerA"); 2652 - pDeleteTimerQueueEx = (void*)GetProcAddress(hdll, "DeleteTimerQueueEx"); 2653 - pDeleteTimerQueueTimer = (void*)GetProcAddress(hdll, "DeleteTimerQueueTimer"); 2654 - pOpenWaitableTimerA = (void*)GetProcAddress(hdll, "OpenWaitableTimerA"); 2655 - pCreateMemoryResourceNotification = (void *)GetProcAddress(hdll, "CreateMemoryResourceNotification"); 2656 - pQueryMemoryResourceNotification = (void *)GetProcAddress(hdll, "QueryMemoryResourceNotification"); 2657 2648 pInitOnceInitialize = (void *)GetProcAddress(hdll, "InitOnceInitialize"); 2658 2649 pInitOnceExecuteOnce = (void *)GetProcAddress(hdll, "InitOnceExecuteOnce"); 2659 2650 pInitOnceBeginInitialize = (void *)GetProcAddress(hdll, "InitOnceBeginInitialize");
-1
modules/rostests/winetests/kernel32/testlist.c
··· 9 9 extern void func_codepage(void); 10 10 extern void func_comm(void); 11 11 extern void func_console(void); 12 - extern void func_cpu(void); 13 12 extern void func_debugger(void); 14 13 extern void func_directory(void); 15 14 extern void func_drive(void);
+28 -1
modules/rostests/winetests/kernel32/thread.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + /* Define _WIN32_WINNT to get SetThreadIdealProcessor on Windows */ 22 + #ifndef __REACTOS__ 23 + #define _WIN32_WINNT 0x0600 24 + #endif 25 + 26 + #include <assert.h> 27 + #include <stdarg.h> 28 + #include <stdio.h> 29 + 30 + /* the tests intentionally pass invalid pointers and need an exception handler */ 31 + #define WINE_NO_INLINE_STRING 32 + 33 + #include <ntstatus.h> 34 + #define WIN32_NO_STATUS 35 + #include <windef.h> 36 + #include <winbase.h> 37 + #include <winnt.h> 38 + #include <winerror.h> 39 + #include <winnls.h> 40 + #include <winternl.h> 41 + #include "wine/test.h" 22 42 23 43 /* THREAD_ALL_ACCESS in Vista+ PSDKs is incompatible with older Windows versions */ 24 44 #define THREAD_ALL_ACCESS_NT4 (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3ff) ··· 1380 1400 ok(LS_index0 != LS_index1, "%s failed\n", LS_AllocFuncName); 1381 1401 1382 1402 /* Both slots should be initialized to NULL */ 1403 + SetLastError(0xdeadbeef); 1383 1404 val = LS_GetValueFunc(LS_index0); 1384 1405 ok(GetLastError() == ERROR_SUCCESS, "%s failed\n", LS_GetValueFuncName); 1385 1406 ok(val == NULL, "Slot not initialized correctly\n"); 1386 1407 1408 + SetLastError(0xdeadbeef); 1387 1409 val = LS_GetValueFunc(LS_index1); 1388 1410 ok(GetLastError() == ERROR_SUCCESS, "%s failed\n", LS_GetValueFuncName); 1389 1411 ok(val == NULL, "Slot not initialized correctly\n"); ··· 1392 1414 1393 1415 if (sync_threads_and_run_one(0, id)) 1394 1416 { 1417 + SetLastError(0xdeadbeef); 1395 1418 val = LS_GetValueFunc(LS_index0); 1396 1419 ok(GetLastError() == ERROR_SUCCESS, "%s failed\n", LS_GetValueFuncName); 1397 1420 ok(val == NULL, "Slot not initialized correctly\n"); 1398 1421 1422 + SetLastError(0xdeadbeef); 1399 1423 val = LS_GetValueFunc(LS_index1); 1400 1424 ok(GetLastError() == ERROR_SUCCESS, "%s failed\n", LS_GetValueFuncName); 1401 1425 ok(val == NULL, "Slot not initialized correctly\n"); ··· 1406 1430 ret = LS_SetValueFunc(LS_index1, (LPVOID) 2); 1407 1431 ok(ret, "%s failed\n", LS_SetValueFuncName); 1408 1432 1433 + SetLastError(0xdeadbeef); 1409 1434 val = LS_GetValueFunc(LS_index0); 1410 1435 ok(GetLastError() == ERROR_SUCCESS, "%s failed\n", LS_GetValueFuncName); 1411 1436 ok(val == (LPVOID) 1, "Slot not initialized correctly\n"); 1412 1437 1438 + SetLastError(0xdeadbeef); 1413 1439 val = LS_GetValueFunc(LS_index1); 1414 1440 ok(GetLastError() == ERROR_SUCCESS, "%s failed\n", LS_GetValueFuncName); 1415 1441 ok(val == (LPVOID) 2, "Slot not initialized correctly\n"); ··· 1702 1728 res = CloseHandle(ctx.finished); 1703 1729 ok(!!res, "Failed to close event handle, last error %#x.\n", GetLastError()); 1704 1730 1731 + CloseHandle(thread); 1705 1732 return ctx.cw; 1706 1733 } 1707 1734
+4 -1
modules/rostests/winetests/kernel32/time.c
··· 19 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 20 */ 21 21 22 - #include "precomp.h" 22 + #include "wine/test.h" 23 + #include "winbase.h" 24 + #include "winnls.h" 25 + #include "winternl.h" 23 26 24 27 static BOOL (WINAPI *pTzSpecificLocalTimeToSystemTime)(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME); 25 28 static BOOL (WINAPI *pSystemTimeToTzSpecificLocalTime)(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
+7 -1
modules/rostests/winetests/kernel32/timer.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #ifndef __REACTOS__ 22 + #define _WIN32_WINNT 0x0501 23 + #endif 24 + 25 + #include "wine/test.h" 26 + #include "winbase.h" 27 + 22 28 23 29 static void test_timer(void) 24 30 {
+9 -1
modules/rostests/winetests/kernel32/toolhelp.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + #include <stdarg.h> 22 + #include <stdlib.h> 23 + #include <stdio.h> 24 + 25 + #include "windef.h" 26 + #include "winbase.h" 27 + #include "tlhelp32.h" 28 + #include "wine/test.h" 29 + #include "winuser.h" 22 30 23 31 static char selfname[MAX_PATH]; 24 32
+474 -466
modules/rostests/winetests/kernel32/version.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 21 + /* Needed for PRODUCT_* defines and GetProductInfo() */ 22 + #ifndef __REACTOS__ 23 + #define _WIN32_WINNT 0x0600 24 + #endif 25 + 26 + #include "wine/test.h" 27 + #include "winbase.h" 28 + #include "winternl.h" 22 29 23 30 static BOOL (WINAPI * pGetProductInfo)(DWORD, DWORD, DWORD, DWORD, DWORD *); 24 - static BOOL (WINAPI * pVerifyVersionInfoA)(LPOSVERSIONINFOEXA, DWORD, DWORDLONG); 25 - static ULONGLONG (WINAPI * pVerSetConditionMask)(ULONGLONG, DWORD, BYTE); 26 31 static NTSTATUS (WINAPI * pRtlGetVersion)(RTL_OSVERSIONINFOEXW *); 27 32 28 33 #define GET_PROC(func) \ ··· 35 40 hmod = GetModuleHandleA("kernel32.dll"); 36 41 37 42 GET_PROC(GetProductInfo); 38 - GET_PROC(VerifyVersionInfoA); 39 - GET_PROC(VerSetConditionMask); 40 43 41 44 hmod = GetModuleHandleA("ntdll.dll"); 42 45 ··· 82 85 res = pGetProductInfo(entry[0], entry[1], entry[2], entry[3], &product); 83 86 84 87 if (entry[0] >= 6) 85 - ok(res && (product > PRODUCT_UNDEFINED) && (product <= PRODUCT_PROFESSIONAL_WMC), 88 + ok(res && (product > PRODUCT_UNDEFINED) && (product <= PRODUCT_ENTERPRISE_S_N_EVALUATION), 86 89 "got %d and 0x%x (expected TRUE and a valid PRODUCT_* value)\n", res, product); 87 90 else 88 91 ok(!res && !product && (GetLastError() == 0xdeadbeef), ··· 148 151 SetLastError(0xdeadbeef); 149 152 infoExA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 150 153 ret = GetVersionExA((OSVERSIONINFOA *)&infoExA); 151 - ok(ret || 152 - broken(ret == 0), /* win95 */ 153 - "Expected GetVersionExA to succeed\n"); 154 + ok(ret, "GetVersionExA failed.\n"); 154 155 155 156 if (!infoExA.wServicePackMajor && !infoExA.wServicePackMinor) 156 157 ok(!infoExA.szCSDVersion[0], "got '%s'\n", infoExA.szCSDVersion); ··· 158 159 159 160 static void test_VerifyVersionInfo(void) 160 161 { 161 - OSVERSIONINFOEXA info; 162 - BOOL ret; 163 - DWORD servicepack, error; 162 + enum srcversion_mode 163 + { 164 + SRCVERSION_ZERO = 0, 165 + SRCVERSION_CURRENT = 1, 166 + SRCVERSION_INC_MINOR = 2, 167 + SRCVERSION_INC_SP_MINOR = 3, 168 + SRCVERSION_INC_SP_MAJOR = 4, 169 + SRCVERSION_DEC_SP_MAJOR = 5, 170 + SRCVERSION_DEC_MAJOR = 6, 171 + SRCVERSION_INC_BUILD = 7, 172 + SRCVERSION_REQUIRES_SP = 0x1000, 173 + }; 164 174 165 - if(!pVerifyVersionInfoA || !pVerSetConditionMask) 175 + struct verify_version_test 166 176 { 167 - win_skip("Needed functions not available\n"); 168 - return; 169 - } 177 + DWORD verifymask; /* Type mask for VerifyVersionInfo() */ 178 + DWORD srcinfo; /* The way current version info is modified. */ 179 + DWORD err; /* Error code on failure, 0 on success. */ 170 180 171 - /* Before we start doing some tests we should check what the version of 172 - * the ServicePack is. Tests on a box with no ServicePack will fail otherwise. 173 - */ 174 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 175 - GetVersionExA((OSVERSIONINFOA *)&info); 176 - servicepack = info.wServicePackMajor; 181 + DWORD typemask1; 182 + DWORD condition1; 183 + DWORD typemask2; 184 + DWORD condition2; 185 + DWORD typemask3; 186 + DWORD condition3; 187 + DWORD typemask4; 188 + DWORD condition4; 177 189 178 - /* Win8.1+ returns Win8 version in GetVersionEx when there's no app manifest targeting 8.1 */ 179 - if (info.dwMajorVersion == 6 && info.dwMinorVersion == 2) 190 + BOOL todo; 191 + } verify_version_tests[] = 180 192 { 181 - RTL_OSVERSIONINFOEXW rtlinfo; 182 - rtlinfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); 183 - ok(SUCCEEDED(pRtlGetVersion(&rtlinfo)), "RtlGetVersion failed\n"); 193 + { 194 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 195 + SRCVERSION_INC_MINOR, 196 + 0, 184 197 185 - if (rtlinfo.dwMajorVersion != 6 || rtlinfo.dwMinorVersion != 2) 198 + VER_MAJORVERSION, VER_EQUAL, 199 + VER_MINORVERSION, VER_LESS, 200 + }, 186 201 { 187 - win_skip("GetVersionEx and VerifyVersionInfo are faking values\n"); 188 - return; 189 - } 190 - } 202 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 203 + SRCVERSION_INC_MINOR, 204 + ERROR_OLD_WIN_VERSION, 191 205 192 - memset(&info, 0, sizeof(info)); 206 + VER_MAJORVERSION, VER_GREATER_EQUAL, 207 + VER_MINORVERSION, VER_LESS, 208 + }, 209 + { 210 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 211 + SRCVERSION_CURRENT, 212 + 0, 193 213 194 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION, 195 - pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); 196 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 214 + VER_MAJORVERSION, VER_GREATER_EQUAL, 215 + VER_MINORVERSION, VER_LESS, 216 + }, 217 + { 218 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 219 + SRCVERSION_CURRENT, 220 + 0, 197 221 198 - SetLastError(0xdeadbeef); 199 - ret = pVerifyVersionInfoA(&info, VER_BUILDNUMBER | VER_MAJORVERSION | 200 - VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR | 201 - VER_SERVICEPACKMINOR | VER_SUITENAME | VER_PRODUCT_TYPE */, 202 - pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); 203 - error = GetLastError(); 204 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 205 - ok(error == ERROR_OLD_WIN_VERSION, 206 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 222 + VER_MAJORVERSION, VER_GREATER_EQUAL, 223 + VER_MINORVERSION, VER_AND, 224 + }, 225 + { 226 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 227 + SRCVERSION_INC_MINOR, 228 + 0, 207 229 208 - /* tests special handling of VER_SUITENAME */ 230 + VER_MAJORVERSION, VER_LESS_EQUAL, 231 + VER_MINORVERSION, VER_LESS, 232 + }, 233 + { 234 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 235 + SRCVERSION_INC_MINOR, 236 + ERROR_OLD_WIN_VERSION, 209 237 210 - ret = pVerifyVersionInfoA(&info, VER_SUITENAME, 211 - pVerSetConditionMask(0, VER_SUITENAME, VER_AND)); 212 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 238 + VER_MAJORVERSION, VER_AND, 239 + VER_MINORVERSION, VER_LESS, 240 + }, 241 + { 242 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 243 + SRCVERSION_INC_MINOR, 244 + ERROR_OLD_WIN_VERSION, 213 245 214 - ret = pVerifyVersionInfoA(&info, VER_SUITENAME, 215 - pVerSetConditionMask(0, VER_SUITENAME, VER_OR)); 216 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 246 + VER_MAJORVERSION, VER_OR, 247 + VER_MINORVERSION, VER_LESS, 248 + }, 249 + { 250 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 251 + SRCVERSION_INC_SP_MINOR, 252 + ERROR_OLD_WIN_VERSION, 217 253 218 - /* test handling of version numbers */ 219 - 220 - /* v3.10 is always less than v4.x even 221 - * if the minor version is tested */ 222 - info.dwMajorVersion = 3; 223 - info.dwMinorVersion = 10; 224 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 225 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), 226 - VER_MAJORVERSION, VER_GREATER_EQUAL)); 227 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 254 + VER_MINORVERSION, VER_EQUAL, 255 + VER_SERVICEPACKMINOR, VER_LESS, 256 + }, 257 + { 258 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 259 + SRCVERSION_INC_SP_MINOR, 260 + ERROR_OLD_WIN_VERSION, 228 261 229 - info.dwMinorVersion = 0; 230 - info.wServicePackMajor = 10; 231 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 232 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), 233 - VER_MAJORVERSION, VER_GREATER_EQUAL)); 234 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 262 + VER_MAJORVERSION, VER_EQUAL, 263 + VER_SERVICEPACKMINOR, VER_LESS, 264 + }, 265 + { 266 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 267 + SRCVERSION_INC_SP_MAJOR, 268 + ERROR_OLD_WIN_VERSION, 235 269 236 - info.wServicePackMajor = 0; 237 - info.wServicePackMinor = 10; 238 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 239 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), 240 - VER_MAJORVERSION, VER_GREATER_EQUAL)); 241 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 270 + VER_MAJORVERSION, VER_EQUAL, 271 + VER_SERVICEPACKMAJOR, VER_EQUAL, 272 + }, 273 + { 274 + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 275 + SRCVERSION_INC_SP_MINOR, 276 + 0, 242 277 243 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 244 - GetVersionExA((OSVERSIONINFOA *)&info); 245 - info.wServicePackMinor++; 246 - SetLastError(0xdeadbeef); 247 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 248 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 249 - error = GetLastError(); 250 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 251 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some wink2 */, 252 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 278 + VER_SERVICEPACKMAJOR, VER_EQUAL, 279 + VER_SERVICEPACKMINOR, VER_LESS, 280 + }, 281 + { 282 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 283 + SRCVERSION_INC_SP_MINOR, 284 + ERROR_OLD_WIN_VERSION, 253 285 254 - if (servicepack == 0) 255 - { 256 - skip("There is no ServicePack on this system\n"); 257 - } 258 - else 259 - { 260 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 261 - GetVersionExA((OSVERSIONINFOA *)&info); 262 - info.wServicePackMajor--; 263 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 264 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER)); 265 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 286 + VER_SERVICEPACKMAJOR, VER_EQUAL, 287 + VER_SERVICEPACKMINOR, VER_LESS, 288 + }, 289 + { 290 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 291 + SRCVERSION_INC_SP_MINOR, 292 + 0, 266 293 267 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 268 - GetVersionExA((OSVERSIONINFOA *)&info); 269 - info.wServicePackMajor--; 270 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 271 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 272 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 273 - } 294 + VER_MINORVERSION, VER_EQUAL, 295 + VER_SERVICEPACKMAJOR, VER_EQUAL, 296 + VER_SERVICEPACKMINOR, VER_LESS, 297 + }, 298 + { 299 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 300 + SRCVERSION_INC_SP_MINOR, 301 + ERROR_OLD_WIN_VERSION, 274 302 275 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 276 - GetVersionExA((OSVERSIONINFOA *)&info); 277 - info.wServicePackMajor++; 278 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 279 - pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS)); 280 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 303 + VER_MINORVERSION, VER_EQUAL, 304 + VER_SERVICEPACKMAJOR, VER_EQUAL, 305 + VER_SERVICEPACKMINOR, VER_LESS, 306 + }, 307 + { 308 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 309 + SRCVERSION_INC_SP_MINOR, 310 + 0, 281 311 282 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 283 - GetVersionExA((OSVERSIONINFOA *)&info); 284 - info.wServicePackMajor++; 285 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 286 - pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS_EQUAL)); 287 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 312 + VER_MAJORVERSION, VER_EQUAL, 313 + VER_MINORVERSION, VER_EQUAL, 314 + VER_SERVICEPACKMAJOR, VER_EQUAL, 315 + VER_SERVICEPACKMINOR, VER_LESS, 316 + }, 317 + { 318 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 319 + SRCVERSION_INC_SP_MINOR, 320 + ERROR_OLD_WIN_VERSION, 288 321 289 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 290 - GetVersionExA((OSVERSIONINFOA *)&info); 291 - info.wServicePackMajor--; 292 - SetLastError(0xdeadbeef); 293 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 294 - pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL)); 295 - error = GetLastError(); 296 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 297 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 298 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 322 + VER_MAJORVERSION, VER_EQUAL, 323 + VER_MINORVERSION, VER_GREATER_EQUAL, 324 + VER_SERVICEPACKMAJOR, VER_EQUAL, 325 + VER_SERVICEPACKMINOR, VER_LESS, 326 + }, 327 + { 328 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 329 + SRCVERSION_INC_SP_MAJOR, 330 + 0, 299 331 300 - /* test the failure hierarchy for the four version fields */ 332 + VER_MAJORVERSION, VER_LESS_EQUAL, 333 + VER_SERVICEPACKMAJOR, VER_GREATER, 334 + }, 335 + { 336 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 337 + SRCVERSION_INC_SP_MAJOR, 338 + ERROR_OLD_WIN_VERSION, 301 339 302 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 303 - GetVersionExA((OSVERSIONINFOA *)&info); 304 - info.wServicePackMajor++; 305 - SetLastError(0xdeadbeef); 306 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 307 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 308 - error = GetLastError(); 309 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 310 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 311 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 340 + VER_MAJORVERSION, VER_EQUAL, 341 + VER_SERVICEPACKMAJOR, VER_LESS, 342 + }, 343 + { 344 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 345 + SRCVERSION_INC_SP_MAJOR, 346 + ERROR_OLD_WIN_VERSION, 312 347 313 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 314 - GetVersionExA((OSVERSIONINFOA *)&info); 315 - info.dwMinorVersion++; 316 - SetLastError(0xdeadbeef); 317 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 318 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 319 - error = GetLastError(); 320 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 321 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 322 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 348 + VER_MINORVERSION, VER_EQUAL, 349 + VER_SERVICEPACKMAJOR, VER_LESS, 350 + }, 351 + { 352 + VER_MAJORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 353 + SRCVERSION_INC_SP_MAJOR, 354 + 0, 323 355 324 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 325 - GetVersionExA((OSVERSIONINFOA *)&info); 326 - info.dwMajorVersion++; 327 - SetLastError(0xdeadbeef); 328 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 329 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 330 - error = GetLastError(); 331 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 332 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 333 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 356 + VER_MAJORVERSION, VER_EQUAL, 357 + VER_SERVICEPACKMAJOR, VER_LESS, 358 + }, 359 + { 360 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 361 + SRCVERSION_INC_SP_MAJOR, 362 + ERROR_OLD_WIN_VERSION, 334 363 335 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 336 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 337 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 364 + VER_MAJORVERSION, VER_EQUAL, 365 + VER_SERVICEPACKMAJOR, VER_LESS, 366 + }, 367 + { 368 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 369 + SRCVERSION_INC_SP_MAJOR, 370 + 0, 338 371 339 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 340 - GetVersionExA((OSVERSIONINFOA *)&info); 341 - info.dwBuildNumber++; 342 - SetLastError(0xdeadbeef); 343 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 344 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 345 - error = GetLastError(); 346 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 347 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 348 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 372 + VER_MAJORVERSION, VER_EQUAL, 373 + VER_MINORVERSION, VER_EQUAL, 374 + VER_SERVICEPACKMAJOR, VER_LESS, 375 + }, 376 + { 377 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 378 + SRCVERSION_INC_SP_MAJOR, 379 + ERROR_OLD_WIN_VERSION, 349 380 350 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 351 - pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); 352 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 381 + VER_MAJORVERSION, VER_GREATER_EQUAL, 382 + VER_SERVICEPACKMAJOR, VER_LESS, 383 + }, 384 + { 385 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 386 + SRCVERSION_DEC_MAJOR, 387 + 0, 353 388 354 - /* systematically test behaviour of condition mask (tests sorted by condition mask value) */ 389 + VER_MAJORVERSION, VER_GREATER_EQUAL, 390 + VER_SERVICEPACKMAJOR, VER_LESS, 391 + }, 392 + { 393 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 394 + SRCVERSION_CURRENT, 395 + 0, 355 396 356 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 357 - GetVersionExA((OSVERSIONINFOA *)&info); 358 - info.dwMinorVersion++; 359 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 360 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), VER_MINORVERSION, VER_LESS)); 361 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 397 + VER_MAJORVERSION, VER_GREATER_EQUAL, 398 + VER_SERVICEPACKMAJOR, VER_LESS, 399 + }, 400 + { 401 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 402 + SRCVERSION_INC_SP_MAJOR, 403 + ERROR_OLD_WIN_VERSION, 362 404 363 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 364 - GetVersionExA((OSVERSIONINFOA *)&info); 365 - info.dwMinorVersion++; 366 - SetLastError(0xdeadbeef); 367 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 368 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_MINORVERSION, VER_LESS)); 369 - error = GetLastError(); 370 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 371 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 372 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 405 + VER_MAJORVERSION, VER_GREATER_EQUAL, 406 + VER_MINORVERSION, VER_EQUAL, 407 + VER_SERVICEPACKMAJOR, VER_LESS, 408 + }, 409 + { 410 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 411 + SRCVERSION_INC_SP_MAJOR, 412 + ERROR_OLD_WIN_VERSION, 373 413 374 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 375 - GetVersionExA((OSVERSIONINFOA *)&info); 376 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 377 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_MINORVERSION, VER_LESS)); 378 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 414 + VER_MAJORVERSION, VER_GREATER_EQUAL, 415 + VER_MINORVERSION, VER_GREATER_EQUAL, 416 + VER_SERVICEPACKMAJOR, VER_LESS_EQUAL, 417 + }, 418 + { 419 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 420 + SRCVERSION_INC_SP_MAJOR, 421 + ERROR_OLD_WIN_VERSION, 379 422 380 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 381 - GetVersionExA((OSVERSIONINFOA *)&info); 382 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 383 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_MINORVERSION, VER_AND)); 384 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 423 + VER_MAJORVERSION, VER_GREATER_EQUAL, 424 + VER_SERVICEPACKMAJOR, VER_AND, 425 + }, 426 + { 427 + VER_MAJORVERSION | VER_MINORVERSION, 428 + SRCVERSION_ZERO, 429 + 0, 385 430 386 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 387 - GetVersionExA((OSVERSIONINFOA *)&info); 388 - info.dwMinorVersion++; 389 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 390 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_LESS_EQUAL), VER_MINORVERSION, VER_LESS)); 391 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 431 + VER_MAJORVERSION, VER_GREATER_EQUAL, 432 + }, 433 + { 434 + VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, 435 + SRCVERSION_ZERO, 436 + ERROR_OLD_WIN_VERSION, 392 437 393 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 394 - GetVersionExA((OSVERSIONINFOA *)&info); 395 - info.dwMinorVersion++; 396 - SetLastError(0xdeadbeef); 397 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 398 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_AND), VER_MINORVERSION, VER_LESS)); 399 - error = GetLastError(); 400 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 401 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 402 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 438 + VER_MAJORVERSION, VER_GREATER_EQUAL, 439 + }, 440 + { 441 + VER_SUITENAME, 442 + SRCVERSION_ZERO, 443 + 0, 403 444 404 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 405 - GetVersionExA((OSVERSIONINFOA *)&info); 406 - info.dwMinorVersion++; 407 - SetLastError(0xdeadbeef); 408 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 409 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_OR), VER_MINORVERSION, VER_LESS)); 410 - error = GetLastError(); 411 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 412 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 413 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 445 + VER_SUITENAME, VER_AND, 446 + }, 447 + { 448 + VER_SUITENAME, 449 + SRCVERSION_ZERO, 450 + 0, 414 451 415 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 416 - GetVersionExA((OSVERSIONINFOA *)&info); 417 - info.wServicePackMinor++; 418 - SetLastError(0xdeadbeef); 419 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 420 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 421 - error = GetLastError(); 422 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 423 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 424 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 452 + VER_SUITENAME, VER_OR, 453 + }, 454 + { 455 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 456 + SRCVERSION_INC_SP_MINOR, 457 + ERROR_OLD_WIN_VERSION, 425 458 426 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 427 - GetVersionExA((OSVERSIONINFOA *)&info); 428 - info.wServicePackMinor++; 429 - SetLastError(0xdeadbeef); 430 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 431 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 432 - error = GetLastError(); 433 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 434 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 435 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 459 + VER_MINORVERSION, VER_GREATER_EQUAL, 460 + }, 461 + { 462 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 463 + SRCVERSION_INC_SP_MAJOR, 464 + 0, 436 465 437 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 438 - GetVersionExA((OSVERSIONINFOA *)&info); 439 - info.wServicePackMajor++; 440 - SetLastError(0xdeadbeef); 441 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 442 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_EQUAL)); 443 - error = GetLastError(); 444 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 445 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 446 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 466 + VER_MINORVERSION, VER_LESS, 467 + }, 468 + { 469 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 470 + SRCVERSION_INC_SP_MAJOR, 471 + 0, 447 472 448 - if (servicepack) 449 - { 450 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 451 - GetVersionExA((OSVERSIONINFOA *)&info); 452 - info.dwMajorVersion++; 453 - info.wServicePackMajor--; 454 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 455 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_LESS), VER_SERVICEPACKMAJOR, VER_EQUAL)); 456 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 457 - } 473 + VER_MINORVERSION, VER_LESS_EQUAL, 474 + }, 475 + { 476 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 477 + SRCVERSION_INC_SP_MAJOR, 478 + ERROR_OLD_WIN_VERSION, 458 479 459 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 460 - GetVersionExA((OSVERSIONINFOA *)&info); 461 - info.wServicePackMinor++; 462 - ret = pVerifyVersionInfoA(&info, VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 463 - pVerSetConditionMask(pVerSetConditionMask(0, VER_SERVICEPACKMAJOR, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 464 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 480 + VER_MINORVERSION, VER_EQUAL, 481 + }, 482 + { 483 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 484 + SRCVERSION_INC_SP_MAJOR, 485 + ERROR_OLD_WIN_VERSION, 465 486 466 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 467 - GetVersionExA((OSVERSIONINFOA *)&info); 468 - info.wServicePackMinor++; 469 - SetLastError(0xdeadbeef); 470 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 471 - pVerSetConditionMask(pVerSetConditionMask(0, VER_SERVICEPACKMAJOR, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 472 - error = GetLastError(); 473 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 474 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 475 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 487 + VER_MINORVERSION, VER_GREATER_EQUAL, 488 + }, 489 + { 490 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 491 + SRCVERSION_INC_MINOR, 492 + ERROR_OLD_WIN_VERSION, 476 493 477 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 478 - GetVersionExA((OSVERSIONINFOA *)&info); 479 - info.wServicePackMinor++; 480 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 481 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL), 482 - VER_SERVICEPACKMAJOR, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 483 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 494 + VER_MINORVERSION, VER_GREATER_EQUAL, 495 + }, 496 + { 497 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 498 + SRCVERSION_INC_MINOR, 499 + ERROR_OLD_WIN_VERSION, 484 500 485 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 486 - GetVersionExA((OSVERSIONINFOA *)&info); 487 - info.wServicePackMinor++; 488 - SetLastError(0xdeadbeef); 489 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 490 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL), 491 - VER_SERVICEPACKMAJOR, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 492 - error = GetLastError(); 493 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 494 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 495 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 501 + VER_MINORVERSION, VER_GREATER_EQUAL, 502 + }, 503 + { 504 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 505 + SRCVERSION_CURRENT, 506 + 0, 496 507 497 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 498 - GetVersionExA((OSVERSIONINFOA *)&info); 499 - info.wServicePackMinor++; 500 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 501 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), 502 - VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 503 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 508 + VER_MINORVERSION, VER_GREATER_EQUAL, 509 + }, 510 + { 511 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 512 + SRCVERSION_INC_BUILD, 513 + ERROR_OLD_WIN_VERSION, 504 514 505 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 506 - GetVersionExA((OSVERSIONINFOA *)&info); 507 - info.wServicePackMinor++; 508 - SetLastError(0xdeadbeef); 509 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 510 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), 511 - VER_MINORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_EQUAL), VER_SERVICEPACKMINOR, VER_LESS)); 512 - error = GetLastError(); 513 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 514 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 515 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 515 + VER_MINORVERSION, VER_GREATER_EQUAL, 516 + }, 517 + { 518 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 519 + SRCVERSION_INC_BUILD, 520 + 0, 516 521 517 - if (servicepack) 518 - { 519 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 520 - GetVersionExA((OSVERSIONINFOA *)&info); 521 - info.wServicePackMajor--; 522 - SetLastError(0xdeadbeef); 523 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 524 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_GREATER)); 525 - error = GetLastError(); 526 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 527 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 528 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 522 + VER_MINORVERSION, VER_GREATER_EQUAL, 523 + }, 524 + { 525 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 526 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 527 + 0, 529 528 530 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 531 - GetVersionExA((OSVERSIONINFOA *)&info); 532 - info.wServicePackMajor--; 533 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 534 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), 535 - VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_GREATER)); 536 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 529 + VER_MINORVERSION, VER_GREATER, 530 + }, 531 + { 532 + VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 533 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 534 + 0, 537 535 538 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 539 - GetVersionExA((OSVERSIONINFOA *)&info); 540 - info.wServicePackMajor--; 541 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 542 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), 543 - VER_MINORVERSION, VER_LESS_EQUAL), VER_SERVICEPACKMAJOR, VER_GREATER)); 544 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 536 + VER_MINORVERSION, VER_GREATER_EQUAL, 537 + }, 538 + { 539 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 540 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 541 + ERROR_OLD_WIN_VERSION, 545 542 546 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 547 - GetVersionExA((OSVERSIONINFOA *)&info); 548 - info.wServicePackMajor--; 549 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 550 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), 551 - VER_MINORVERSION, VER_AND), VER_SERVICEPACKMAJOR, VER_GREATER)); 552 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 553 - } 543 + VER_MAJORVERSION, VER_EQUAL, 544 + VER_SERVICEPACKMAJOR, VER_GREATER, 545 + }, 546 + { 547 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 548 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 549 + 0, 554 550 551 + VER_MAJORVERSION, VER_GREATER_EQUAL, 552 + VER_MINORVERSION, VER_EQUAL, 553 + VER_SERVICEPACKMAJOR, VER_GREATER, 554 + }, 555 + { 556 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 557 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 558 + 0, 559 + 560 + VER_MAJORVERSION, VER_GREATER_EQUAL, 561 + VER_MINORVERSION, VER_LESS_EQUAL, 562 + VER_SERVICEPACKMAJOR, VER_GREATER, 563 + }, 564 + { 565 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 566 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 567 + 0, 568 + 569 + VER_MAJORVERSION, VER_GREATER_EQUAL, 570 + VER_MINORVERSION, VER_AND, 571 + VER_SERVICEPACKMAJOR, VER_GREATER, 572 + }, 573 + { 574 + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 575 + SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP, 576 + ERROR_OLD_WIN_VERSION, 577 + 578 + VER_SERVICEPACKMAJOR, VER_GREATER, 579 + VER_SERVICEPACKMINOR, VER_EQUAL, 580 + }, 581 + }; 582 + 583 + OSVERSIONINFOEXA info; 584 + DWORD servicepack; 585 + unsigned int i; 586 + BOOL ret; 587 + 588 + /* Before we start doing some tests we should check what the version of 589 + * the ServicePack is. Tests on a box with no ServicePack will fail otherwise. 590 + */ 555 591 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 556 592 GetVersionExA((OSVERSIONINFOA *)&info); 557 - info.wServicePackMajor++; 558 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 559 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_LESS_EQUAL), VER_SERVICEPACKMAJOR, VER_GREATER)); 560 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 593 + servicepack = info.wServicePackMajor; 594 + if (servicepack == 0) 595 + skip("There is no ServicePack on this system. Some tests will be skipped.\n"); 561 596 562 - if (servicepack) 597 + /* Win8.1+ returns Win8 version in GetVersionEx when there's no app manifest targeting 8.1 */ 598 + if (info.dwMajorVersion == 6 && info.dwMinorVersion == 2) 563 599 { 564 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 565 - GetVersionExA((OSVERSIONINFOA *)&info); 566 - info.wServicePackMajor--; 567 - SetLastError(0xdeadbeef); 568 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 569 - pVerSetConditionMask(pVerSetConditionMask(0, VER_SERVICEPACKMAJOR, VER_GREATER), VER_SERVICEPACKMINOR, VER_EQUAL)); 570 - error = GetLastError(); 571 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 572 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 573 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 600 + RTL_OSVERSIONINFOEXW rtlinfo; 601 + rtlinfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); 602 + ok(!pRtlGetVersion(&rtlinfo), "RtlGetVersion failed\n"); 603 + 604 + if (rtlinfo.dwMajorVersion != 6 || rtlinfo.dwMinorVersion != 2) 605 + { 606 + win_skip("GetVersionEx and VerifyVersionInfo are faking values\n"); 607 + return; 608 + } 574 609 } 575 610 576 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 577 - GetVersionExA((OSVERSIONINFOA *)&info); 578 - info.wServicePackMajor++; 579 - ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 580 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 581 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 611 + for (i = 0; i < sizeof(verify_version_tests)/sizeof(verify_version_tests[0]); i++) 612 + { 613 + struct verify_version_test *test = &verify_version_tests[i]; 614 + DWORD srcinfo = test->srcinfo; 615 + ULONGLONG mask; 582 616 583 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 584 - GetVersionExA((OSVERSIONINFOA *)&info); 585 - info.wServicePackMajor++; 586 - SetLastError(0xdeadbeef); 587 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 588 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 589 - error = GetLastError(); 590 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 591 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 592 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 617 + if (servicepack == 0 && srcinfo & SRCVERSION_REQUIRES_SP) 618 + continue; 619 + srcinfo &= ~SRCVERSION_REQUIRES_SP; 593 620 594 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 595 - GetVersionExA((OSVERSIONINFOA *)&info); 596 - info.wServicePackMajor++; 597 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 598 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 599 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 621 + info.dwOSVersionInfoSize = sizeof(info); 622 + GetVersionExA((OSVERSIONINFOA *)&info); 600 623 601 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 602 - GetVersionExA((OSVERSIONINFOA *)&info); 603 - info.wServicePackMajor++; 604 - SetLastError(0xdeadbeef); 605 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 606 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 607 - error = GetLastError(); 608 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 609 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 610 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 624 + switch (srcinfo) 625 + { 626 + case SRCVERSION_ZERO: 627 + memset(&info, 0, sizeof(info)); 628 + break; 629 + case SRCVERSION_INC_MINOR: 630 + info.dwMinorVersion++; 631 + break; 632 + case SRCVERSION_INC_SP_MINOR: 633 + info.wServicePackMinor++; 634 + break; 635 + case SRCVERSION_INC_SP_MAJOR: 636 + info.wServicePackMajor++; 637 + break; 638 + case SRCVERSION_DEC_SP_MAJOR: 639 + info.wServicePackMajor--; 640 + break; 641 + case SRCVERSION_DEC_MAJOR: 642 + info.dwMajorVersion--; 643 + break; 644 + case SRCVERSION_INC_BUILD: 645 + info.dwBuildNumber++; 646 + break; 647 + default: 648 + ; 649 + } 611 650 612 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 613 - GetVersionExA((OSVERSIONINFOA *)&info); 614 - info.wServicePackMajor++; 615 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 616 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL), 617 - VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 618 - ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 651 + mask = VerSetConditionMask(0, test->typemask1, test->condition1); 652 + if (test->typemask2) 653 + mask = VerSetConditionMask(mask, test->typemask2, test->condition2); 654 + if (test->typemask3) 655 + mask = VerSetConditionMask(mask, test->typemask3, test->condition3); 656 + if (test->typemask4) 657 + mask = VerSetConditionMask(mask, test->typemask4, test->condition4); 619 658 620 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 621 - GetVersionExA((OSVERSIONINFOA *)&info); 622 - info.wServicePackMajor++; 623 - SetLastError(0xdeadbeef); 624 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 625 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 626 - error = GetLastError(); 627 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 628 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 629 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 659 + SetLastError(0xdeadbeef); 660 + ret = VerifyVersionInfoA(&info, test->verifymask, mask); 661 + todo_wine_if(test->todo) 662 + { 663 + ok(test->err ? !ret : ret, "%u: unexpected return value %d.\n", i, ret); 664 + if (!ret) 665 + ok(GetLastError() == test->err, "%u: unexpected error code %d, expected %d.\n", i, GetLastError(), test->err); 666 + } 667 + } 630 668 631 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 632 - GetVersionExA((OSVERSIONINFOA *)&info); 633 - info.dwMajorVersion--; 634 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 635 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 669 + /* test handling of version numbers */ 670 + /* v3.10 is always less than v4.x even 671 + * if the minor version is tested */ 672 + info.dwMajorVersion = 3; 673 + info.dwMinorVersion = 10; 674 + ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 675 + VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), 676 + VER_MAJORVERSION, VER_GREATER_EQUAL)); 636 677 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 637 678 638 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 639 - GetVersionExA((OSVERSIONINFOA *)&info); 640 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 641 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 679 + info.dwMinorVersion = 0; 680 + info.wServicePackMajor = 10; 681 + ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 682 + VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), 683 + VER_MAJORVERSION, VER_GREATER_EQUAL)); 642 684 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 643 685 644 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 645 - GetVersionExA((OSVERSIONINFOA *)&info); 646 - info.wServicePackMajor++; 647 - SetLastError(0xdeadbeef); 648 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 649 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 650 - error = GetLastError(); 651 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 652 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 653 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 654 - 655 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 656 - GetVersionExA((OSVERSIONINFOA *)&info); 657 - info.wServicePackMajor++; 658 - SetLastError(0xdeadbeef); 659 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 660 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), 661 - VER_MINORVERSION, VER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS)); 662 - error = GetLastError(); 663 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 664 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 665 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 666 - 667 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 668 - GetVersionExA((OSVERSIONINFOA *)&info); 669 - info.wServicePackMajor++; 670 - SetLastError(0xdeadbeef); 671 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 672 - pVerSetConditionMask(pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), 673 - VER_MINORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_LESS_EQUAL)); 674 - error = GetLastError(); 675 - ok(!ret, "VerifyVersionInfoA succeeded\n"); 676 - ok(error == ERROR_OLD_WIN_VERSION || broken(error == ERROR_BAD_ARGUMENTS) /* some win2k */, 677 - "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", error); 678 - 679 - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 680 - GetVersionExA((OSVERSIONINFOA *)&info); 681 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 682 - pVerSetConditionMask(pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_AND)); 686 + info.wServicePackMajor = 0; 687 + info.wServicePackMinor = 10; 688 + ret = VerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 689 + VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), 690 + VER_MAJORVERSION, VER_GREATER_EQUAL)); 683 691 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 684 692 685 693 /* test bad dwOSVersionInfoSize */ 686 694 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 687 695 GetVersionExA((OSVERSIONINFOA *)&info); 688 696 info.dwOSVersionInfoSize = 0; 689 - ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 690 - pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); 691 - ok(ret || broken(!ret) /* some win2k */, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 697 + ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, 698 + VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); 699 + ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError()); 692 700 } 693 701 694 702 START_TEST(version)
+6 -4
modules/rostests/winetests/kernel32/volume.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "precomp.h" 22 - 23 - #include <wine/ddk/ntddcdvd.h> 21 + #include "wine/test.h" 22 + #include "winbase.h" 23 + #include "winioctl.h" 24 + #include <stdio.h> 25 + #include "wine/ddk/ntddcdvd.h" 24 26 25 27 #include <pshpack1.h> 26 28 struct COMPLETE_DVD_LAYER_DESCRIPTOR ··· 258 260 } 259 261 260 262 ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0); 261 - ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n"); 263 + ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n"); 262 264 ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE || 263 265 GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */ 264 266 "wrong error, last=%d\n", GetLastError());