[KERNEL32_WINETEST] Sync with Wine Staging 2.16. CORE-13762

This commit is contained in:
Amine Khaldi 2017-10-19 11:27:47 +01:00
parent f61627e540
commit 9a436e2dfa
6 changed files with 526 additions and 6 deletions

View file

@ -1506,6 +1506,8 @@ static void test_WaitCts(void)
args[1] = CLRRTS;
CloseHandle(hcom);
ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
CloseHandle( alarmThread );
}
/* Change the Comm Mask while a Wait is going on
@ -1588,6 +1590,8 @@ static void test_AbortWaitCts(void)
"Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
CloseHandle(hcom);
ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
CloseHandle( alarmThread );
}
/*
@ -1668,6 +1672,8 @@ static void test_WaitDsr(void)
args[1] = CLRDTR;
CloseHandle(hcom);
ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
CloseHandle( alarmThread );
}
/*
@ -1754,6 +1760,8 @@ static void test_WaitRing(void)
args[1] = CLRDTR;
CloseHandle(hcom);
ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
CloseHandle( alarmThread );
}
/*
* Wait for a change in DCD
@ -1833,6 +1841,8 @@ static void test_WaitDcd(void)
args[1] = CLRDTR;
CloseHandle(hcom);
ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
CloseHandle( alarmThread );
}
/*
@ -1914,6 +1924,8 @@ static void test_WaitBreak(void)
ok(ClearCommBreak(hcom), "ClearCommBreak failed\n");
CloseHandle(hcom);
ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
CloseHandle( alarmThread );
}
static void test_stdio(void)

View file

@ -89,6 +89,12 @@ static void test_heap(void)
HGLOBAL hsecond;
SIZE_T size, size2;
const SIZE_T max_size = 1024, init_size = 10;
/* use function pointers to avoid warnings for invalid parameter tests */
LPVOID (WINAPI *pHeapAlloc)(HANDLE,DWORD,SIZE_T);
LPVOID (WINAPI *pHeapReAlloc)(HANDLE,DWORD,LPVOID,SIZE_T);
pHeapAlloc = (void *)GetProcAddress( GetModuleHandleA("kernel32"), "HeapAlloc" );
pHeapReAlloc = (void *)GetProcAddress( GetModuleHandleA("kernel32"), "HeapReAlloc" );
/* Heap*() functions */
mem = HeapAlloc(GetProcessHeap(), 0, 0);
@ -111,12 +117,12 @@ static void test_heap(void)
/* test some border cases of HeapAlloc and HeapReAlloc */
mem = HeapAlloc(GetProcessHeap(), 0, 0);
ok(mem != NULL, "memory not allocated for size 0\n");
msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0 - 7);
msecond = pHeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0 - 7);
ok(msecond == NULL, "HeapReAlloc(~0 - 7) should have failed\n");
msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0);
msecond = pHeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0);
ok(msecond == NULL, "HeapReAlloc(~0) should have failed\n");
HeapFree(GetProcessHeap(), 0, mem);
mem = HeapAlloc(GetProcessHeap(), 0, ~(SIZE_T)0);
mem = pHeapAlloc(GetProcessHeap(), 0, ~(SIZE_T)0);
ok(mem == NULL, "memory allocated for size ~0\n");
mem = HeapAlloc(GetProcessHeap(), 0, 17);
msecond = HeapReAlloc(GetProcessHeap(), 0, mem, 0);

View file

@ -548,6 +548,7 @@ static void test_Loader(void)
};
int i;
DWORD file_size;
HANDLE h;
HMODULE hlib, hlib_as_data_file;
char temp_path[MAX_PATH];
char dll_name[MAX_PATH];
@ -730,10 +731,38 @@ static void test_Loader(void)
hlib = GetModuleHandleA(dll_name);
ok(!hlib, "GetModuleHandle should fail\n");
SetLastError(0xdeadbeef);
h = CreateFileA( dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
ok( h != INVALID_HANDLE_VALUE, "open failed err %u\n", GetLastError() );
CloseHandle( h );
SetLastError(0xdeadbeef);
ret = FreeLibrary(hlib_as_data_file);
ok(ret, "FreeLibrary error %d\n", GetLastError());
SetLastError(0xdeadbeef);
hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
if (!((ULONG_PTR)hlib_as_data_file & 1) || /* winxp */
(!hlib_as_data_file && GetLastError() == ERROR_INVALID_PARAMETER)) /* w2k3 */
{
win_skip( "LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE not supported\n" );
FreeLibrary(hlib_as_data_file);
}
else
{
ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
SetLastError(0xdeadbeef);
h = CreateFileA( dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
todo_wine ok( h == INVALID_HANDLE_VALUE, "open succeeded\n" );
todo_wine ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error %u\n", GetLastError() );
CloseHandle( h );
SetLastError(0xdeadbeef);
ret = FreeLibrary(hlib_as_data_file);
ok(ret, "FreeLibrary error %d\n", GetLastError());
}
SetLastError(0xdeadbeef);
ret = DeleteFileA(dll_name);
ok(ret, "DeleteFile error %d\n", GetLastError());
@ -869,7 +898,7 @@ static void test_Loader(void)
static void test_FakeDLL(void)
{
#ifdef __i386__
#if defined(__i386__) || defined(__x86_64__)
NTSTATUS (WINAPI *pNtSetEvent)(HANDLE, ULONG *) = NULL;
IMAGE_EXPORT_DIRECTORY *dir;
HMODULE module = GetModuleHandleA("ntdll.dll");
@ -911,8 +940,13 @@ static void test_FakeDLL(void)
dll_func = (BYTE *)GetProcAddress(module, func_name);
ok(dll_func != NULL, "%s: GetProcAddress returned NULL\n", func_name);
#if defined(__i386__)
if (dll_func[0] == 0x90 && dll_func[1] == 0x90 &&
dll_func[2] == 0x90 && dll_func[3] == 0x90)
#elif defined(__x86_64__)
if (dll_func[0] == 0x48 && dll_func[1] == 0x83 &&
dll_func[2] == 0xec && dll_func[3] == 0x08)
#endif
{
todo_wine ok(0, "%s: Export is a stub-function, skipping\n", func_name);
continue;
@ -2321,9 +2355,9 @@ static void child_process(const char *dll_name, DWORD target_offset)
}
else
{
ret = WaitForSingleObject(attached_thread[0], 1000);
ret = WaitForSingleObject(attached_thread[0], 2000);
ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
ret = WaitForSingleObject(attached_thread[1], 1000);
ret = WaitForSingleObject(attached_thread[1], 2000);
ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
}

View file

@ -20,11 +20,15 @@
#include "wine/test.h"
#include <windows.h>
#include <stdio.h>
#include <psapi.h>
static DWORD (WINAPI *pGetDllDirectoryA)(DWORD,LPSTR);
static DWORD (WINAPI *pGetDllDirectoryW)(DWORD,LPWSTR);
static BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR);
static DLL_DIRECTORY_COOKIE (WINAPI *pAddDllDirectory)(const WCHAR*);
static BOOL (WINAPI *pRemoveDllDirectory)(DLL_DIRECTORY_COOKIE);
static BOOL (WINAPI *pSetDefaultDllDirectories)(DWORD);
static BOOL (WINAPI *pGetModuleHandleExA)(DWORD,LPCSTR,HMODULE*);
static BOOL (WINAPI *pGetModuleHandleExW)(DWORD,LPCWSTR,HMODULE*);
static BOOL (WINAPI *pK32GetModuleInformation)(HANDLE process, HMODULE module,
@ -42,6 +46,89 @@ static BOOL cmpStrAW(const char* a, const WCHAR* b, DWORD lenA, DWORD lenB)
return memcmp(aw, b, len * sizeof(WCHAR)) == 0;
}
static const struct
{
IMAGE_DOS_HEADER dos;
IMAGE_NT_HEADERS nt;
IMAGE_SECTION_HEADER section;
} dll_image =
{
{ IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 }, 0, 0, { 0 },
sizeof(IMAGE_DOS_HEADER) },
{
IMAGE_NT_SIGNATURE, /* Signature */
{
#if defined __i386__
IMAGE_FILE_MACHINE_I386, /* Machine */
#elif defined __x86_64__
IMAGE_FILE_MACHINE_AMD64, /* Machine */
#elif defined __powerpc__
IMAGE_FILE_MACHINE_POWERPC, /* Machine */
#elif defined __arm__
IMAGE_FILE_MACHINE_ARMNT, /* Machine */
#elif defined __aarch64__
IMAGE_FILE_MACHINE_ARM64, /* Machine */
#else
# error You must specify the machine type
#endif
1, /* NumberOfSections */
0, /* TimeDateStamp */
0, /* PointerToSymbolTable */
0, /* NumberOfSymbols */
sizeof(IMAGE_OPTIONAL_HEADER), /* SizeOfOptionalHeader */
IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL /* Characteristics */
},
{ IMAGE_NT_OPTIONAL_HDR_MAGIC, /* Magic */
1, /* MajorLinkerVersion */
0, /* MinorLinkerVersion */
0, /* SizeOfCode */
0, /* SizeOfInitializedData */
0, /* SizeOfUninitializedData */
0, /* AddressOfEntryPoint */
0x1000, /* BaseOfCode */
#ifndef _WIN64
0, /* BaseOfData */
#endif
0x10000000, /* ImageBase */
0x1000, /* SectionAlignment */
0x1000, /* FileAlignment */
4, /* MajorOperatingSystemVersion */
0, /* MinorOperatingSystemVersion */
1, /* MajorImageVersion */
0, /* MinorImageVersion */
4, /* MajorSubsystemVersion */
0, /* MinorSubsystemVersion */
0, /* Win32VersionValue */
0x2000, /* SizeOfImage */
sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS), /* SizeOfHeaders */
0, /* CheckSum */
IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
0, /* DllCharacteristics */
0, /* SizeOfStackReserve */
0, /* SizeOfStackCommit */
0, /* SizeOfHeapReserve */
0, /* SizeOfHeapCommit */
0, /* LoaderFlags */
0, /* NumberOfRvaAndSizes */
{ { 0 } } /* DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] */
}
},
{ ".rodata", { 0 }, 0x1000, 0x1000, 0, 0, 0, 0, 0,
IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ }
};
static void create_test_dll( const char *name )
{
DWORD dummy;
HANDLE handle = CreateFileA( name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0 );
ok( handle != INVALID_HANDLE_VALUE, "failed to create file err %u\n", GetLastError() );
WriteFile( handle, &dll_image, sizeof(dll_image), &dummy, NULL );
SetFilePointer( handle, dll_image.nt.OptionalHeader.SizeOfImage, NULL, FILE_BEGIN );
SetEndOfFile( handle );
CloseHandle( handle );
}
static void testGetModuleFileName(const char* name)
{
HMODULE hMod;
@ -407,6 +494,132 @@ static void testLoadLibraryEx(void)
FreeLibrary(hmodule);
}
static void test_LoadLibraryEx_search_flags(void)
{
static const struct
{
int add_dirs[4];
int dll_dir;
int expect;
} tests[] =
{
{ { 1, 2, 3 }, 4, 3 }, /* 0 */
{ { 1, 3, 2 }, 4, 2 },
{ { 3, 1 }, 4, 1 },
{ { 5, 6 }, 4, 4 },
{ { 5, 2 }, 4, 2 },
{ { 0 }, 4, 4 }, /* 5 */
{ { 0 }, 0, 0 },
{ { 6, 5 }, 5, 0 },
{ { 1, 1, 2 }, 0, 2 },
};
char *p, path[MAX_PATH], buf[MAX_PATH];
WCHAR bufW[MAX_PATH];
DLL_DIRECTORY_COOKIE cookies[4];
unsigned int i, j, k;
BOOL ret;
HMODULE mod;
if (!pAddDllDirectory || !pSetDllDirectoryA) return;
GetTempPathA( sizeof(path), path );
GetTempFileNameA( path, "tmp", 0, buf );
DeleteFileA( buf );
ret = CreateDirectoryA( buf, NULL );
ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
p = buf + strlen( buf );
for (i = 1; i <= 6; i++)
{
sprintf( p, "\\%u", i );
ret = CreateDirectoryA( buf, NULL );
ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
if (i >= 5) continue; /* dirs 5 and 6 are left empty */
sprintf( p, "\\%u\\winetestdll.dll", i );
create_test_dll( buf );
}
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_MOD_NOT_FOUND || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
"wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "foo\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "\\windows\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
for (j = 0; j < sizeof(tests) / sizeof(tests[0]); j++)
{
for (k = 0; tests[j].add_dirs[k]; k++)
{
sprintf( p, "\\%u", tests[j].add_dirs[k] );
MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, MAX_PATH );
cookies[k] = pAddDllDirectory( bufW );
ok( cookies[k] != NULL, "failed to add %s\n", buf );
}
if (tests[j].dll_dir)
{
sprintf( p, "\\%u", tests[j].dll_dir );
pSetDllDirectoryA( buf );
}
else pSetDllDirectoryA( NULL );
SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
if (tests[j].expect)
{
ok( mod != NULL, "%u: LoadLibrary failed err %u\n", j, GetLastError() );
GetModuleFileNameA( mod, path, MAX_PATH );
sprintf( p, "\\%u\\winetestdll.dll", tests[j].expect );
ok( !lstrcmpiA( path, buf ), "%u: wrong module %s expected %s\n", j, path, buf );
}
else
{
ok( !mod, "%u: LoadLibrary succeeded\n", j );
ok( GetLastError() == ERROR_MOD_NOT_FOUND || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
"%u: wrong error %u\n", j, GetLastError() );
}
FreeLibrary( mod );
for (k = 0; tests[j].add_dirs[k]; k++) pRemoveDllDirectory( cookies[k] );
}
for (i = 1; i <= 6; i++)
{
sprintf( p, "\\%u\\winetestdll.dll", i );
DeleteFileA( buf );
sprintf( p, "\\%u", i );
RemoveDirectoryA( buf );
}
*p = 0;
RemoveDirectoryA( buf );
}
static void testGetDllDirectory(void)
{
CHAR bufferA[MAX_PATH];
@ -515,6 +728,9 @@ static void init_pointers(void)
MAKEFUNC(GetDllDirectoryA);
MAKEFUNC(GetDllDirectoryW);
MAKEFUNC(SetDllDirectoryA);
MAKEFUNC(AddDllDirectory);
MAKEFUNC(RemoveDllDirectory);
MAKEFUNC(SetDefaultDllDirectories);
MAKEFUNC(GetModuleHandleExA);
MAKEFUNC(GetModuleHandleExW);
MAKEFUNC(K32GetModuleInformation);
@ -739,6 +955,118 @@ static void testK32GetModuleInformation(void)
ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n");
}
static void test_AddDllDirectory(void)
{
static const WCHAR tmpW[] = {'t','m','p',0};
static const WCHAR dotW[] = {'.','\\','.',0};
static const WCHAR rootW[] = {'\\',0};
WCHAR path[MAX_PATH], buf[MAX_PATH];
DLL_DIRECTORY_COOKIE cookie;
BOOL ret;
if (!pAddDllDirectory || !pRemoveDllDirectory)
{
win_skip( "AddDllDirectory not available\n" );
return;
}
buf[0] = '\0';
GetTempPathW( sizeof(path)/sizeof(path[0]), path );
GetTempFileNameW( path, tmpW, 0, buf );
SetLastError( 0xdeadbeef );
cookie = pAddDllDirectory( buf );
ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pRemoveDllDirectory( cookie );
ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
DeleteFileW( buf );
SetLastError( 0xdeadbeef );
cookie = pAddDllDirectory( buf );
ok( !cookie, "AddDllDirectory succeeded\n" );
ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError() );
cookie = pAddDllDirectory( dotW );
ok( !cookie, "AddDllDirectory succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
cookie = pAddDllDirectory( rootW );
ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pRemoveDllDirectory( cookie );
ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
GetWindowsDirectoryW( buf, MAX_PATH );
lstrcpyW( buf + 2, tmpW );
cookie = pAddDllDirectory( buf );
ok( !cookie, "AddDllDirectory succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
}
static void test_SetDefaultDllDirectories(void)
{
HMODULE mod;
BOOL ret;
if (!pSetDefaultDllDirectories)
{
win_skip( "SetDefaultDllDirectories not available\n" );
return;
}
mod = LoadLibraryA( "authz.dll" );
ok( mod != NULL, "loading authz failed\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_USER_DIRS );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
todo_wine ok( !mod, "loading authz succeeded\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
ok( mod != NULL, "loading authz failed\n" );
FreeLibrary( mod );
mod = LoadLibraryExA( "authz.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
todo_wine ok( !mod, "loading authz succeeded\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
todo_wine ok( !mod, "loading authz succeeded\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
ok( mod != NULL, "loading authz failed\n" );
FreeLibrary( mod );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( 0 );
ok( !ret, "SetDefaultDllDirectories succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( 3 );
ok( !ret, "SetDefaultDllDirectories succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 0x8000 );
ok( !ret, "SetDefaultDllDirectories succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_USER_DIRS );
ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
/* restore some sane defaults */
pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
}
START_TEST(module)
{
WCHAR filenameW[MAX_PATH];
@ -766,6 +1094,9 @@ START_TEST(module)
testLoadLibraryA_Wrong();
testGetProcAddress_Wrong();
testLoadLibraryEx();
test_LoadLibraryEx_search_flags();
testGetModuleHandleEx();
testK32GetModuleInformation();
test_AddDllDirectory();
test_SetDefaultDllDirectories();
}

View file

@ -72,6 +72,7 @@ static BOOL (WINAPI *pNeedCurrentDirectoryForExePathW)(LPCWSTR);
static DWORD (WINAPI *pSearchPathA)(LPCSTR,LPCSTR,LPCSTR,DWORD,LPSTR,LPSTR*);
static DWORD (WINAPI *pSearchPathW)(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,LPWSTR,LPWSTR*);
static BOOL (WINAPI *pSetSearchPathMode)(DWORD);
static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
@ -2158,6 +2159,7 @@ static void init_pointers(void)
MAKEFUNC(NeedCurrentDirectoryForExePathW);
MAKEFUNC(SearchPathA);
MAKEFUNC(SearchPathW);
MAKEFUNC(SetSearchPathMode);
MAKEFUNC(ActivateActCtx);
MAKEFUNC(CreateActCtxW);
MAKEFUNC(DeactivateActCtx);
@ -2315,6 +2317,112 @@ static void test_CheckNameLegalDOS8Dot3(void)
}
}
static void test_SetSearchPathMode(void)
{
BOOL ret;
char orig[MAX_PATH], buf[MAX_PATH], dir[MAX_PATH], expect[MAX_PATH];
HANDLE handle;
if (!pSetSearchPathMode)
{
win_skip( "SetSearchPathMode isn't available\n" );
return;
}
GetCurrentDirectoryA( MAX_PATH, orig );
GetTempPathA( MAX_PATH, buf );
GetTempFileNameA( buf, "path", 0, dir );
DeleteFileA( dir );
CreateDirectoryA( dir, NULL );
ret = SetCurrentDirectoryA( dir );
ok( ret, "failed to switch to %s\n", dir );
if (!ret)
{
RemoveDirectoryA( dir );
return;
}
handle = CreateFileA( "kernel32.dll", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
CloseHandle( handle );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( 0 );
ok( !ret, "SetSearchPathMode succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( 0x80 );
ok( !ret, "SetSearchPathMode succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_PERMANENT );
ok( !ret, "SetSearchPathMode succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
ok( ret, "SearchPathA failed err %u\n", GetLastError() );
GetCurrentDirectoryA( MAX_PATH, expect );
strcat( expect, "\\kernel32.dll" );
ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE );
ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
ok( ret, "SearchPathA failed err %u\n", GetLastError() );
GetSystemDirectoryA( expect, MAX_PATH );
strcat( expect, "\\kernel32.dll" );
ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE );
ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
ok( ret, "SearchPathA failed err %u\n", GetLastError() );
GetCurrentDirectoryA( MAX_PATH, expect );
strcat( expect, "\\kernel32.dll" );
ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
ok( !ret, "SetSearchPathMode succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE );
ok( !ret, "SetSearchPathMode succeeded\n" );
ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE );
ok( !ret, "SetSearchPathMode succeeded\n" );
ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
ok( ret, "SearchPathA failed err %u\n", GetLastError() );
GetSystemDirectoryA( expect, MAX_PATH );
strcat( expect, "\\kernel32.dll" );
ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
DeleteFileA( "kernel32.dll" );
SetCurrentDirectoryA( orig );
RemoveDirectoryA( dir );
}
START_TEST(path)
{
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
@ -2348,4 +2456,5 @@ START_TEST(path)
test_GetFullPathNameA();
test_GetFullPathNameW();
test_CheckNameLegalDOS8Dot3();
test_SetSearchPathMode();
}

View file

@ -403,6 +403,23 @@ static void test_VirtualAlloc(void)
ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status);
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
/* 21 zero bits is valid */
size = 0x1000;
addr2 = NULL;
status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY,
"NtAllocateVirtualMemory returned %08x\n", status);
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
/* 22 zero bits is invalid */
size = 0x1000;
addr2 = NULL;
status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status);
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
/* AT_ROUND_TO_PAGE flag is not supported for VirtualAlloc */
SetLastError(0xdeadbeef);
addr2 = VirtualAlloc(addr1, 0x1000, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE);
@ -1163,6 +1180,17 @@ static void test_NtMapViewOfSection(void)
ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
}
/* 22 zero bits isn't acceptable */
ptr2 = NULL;
size = 0;
status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE );
ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status );
if (status == STATUS_SUCCESS)
{
status = pNtUnmapViewOfSection( hProcess, ptr2 );
ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
}
/* mapping at the same page conflicts */
ptr2 = ptr;
size = 0;