kernel32/tests: Fix virtual memory tests compilation with __WINESRC__ defined.

This commit is contained in:
Dmitry Timoshkov 2013-10-17 11:45:32 +09:00 committed by Alexandre Julliard
parent 6774accd02
commit 035295bb31
1 changed files with 27 additions and 27 deletions

View File

@ -49,12 +49,12 @@ static HANDLE create_target_process(const char *arg)
char cmdline[MAX_PATH]; char cmdline[MAX_PATH];
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
BOOL ret; BOOL ret;
STARTUPINFO si = { 0 }; STARTUPINFOA si = { 0 };
si.cb = sizeof(si); si.cb = sizeof(si);
winetest_get_mainargs( &argv ); winetest_get_mainargs( &argv );
sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg); sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
ret = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "error: %u\n", GetLastError()); ok(ret, "error: %u\n", GetLastError());
ret = CloseHandle(pi.hThread); ret = CloseHandle(pi.hThread);
ok(ret, "error %u\n", GetLastError()); ok(ret, "error %u\n", GetLastError());
@ -586,17 +586,17 @@ static void test_MapViewOfFile(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
name = "Local\\Foo"; name = "Local\\Foo";
file = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, name ); file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, name );
/* nt4 doesn't have Local\\ */ /* nt4 doesn't have Local\\ */
if (!file && GetLastError() == ERROR_PATH_NOT_FOUND) if (!file && GetLastError() == ERROR_PATH_NOT_FOUND)
{ {
name = "Foo"; name = "Foo";
file = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, name ); file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, name );
} }
ok( file != 0, "CreateFileMapping PAGE_READWRITE error %u\n", GetLastError() ); ok( file != 0, "CreateFileMapping PAGE_READWRITE error %u\n", GetLastError() );
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
mapping = OpenFileMapping( FILE_MAP_READ, FALSE, name ); mapping = OpenFileMappingA( FILE_MAP_READ, FALSE, name );
ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n", GetLastError() ); ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n", GetLastError() );
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 ); ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
@ -623,7 +623,7 @@ static void test_MapViewOfFile(void)
CloseHandle( mapping ); CloseHandle( mapping );
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
mapping = OpenFileMapping( FILE_MAP_WRITE, FALSE, name ); mapping = OpenFileMappingA( FILE_MAP_WRITE, FALSE, name );
ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n", GetLastError() ); ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n", GetLastError() );
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 ); ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
@ -1283,7 +1283,7 @@ static void test_write_watch(void)
"wrong error %u\n", GetLastError() ); "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
ret = pGetWriteWatch( 0, GetModuleHandle(0), size, results, &count, &pagesize ); ret = pGetWriteWatch( 0, GetModuleHandleW(NULL), size, results, &count, &pagesize );
if (ret) if (ret)
{ {
ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret ); ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
@ -1459,7 +1459,7 @@ static void test_write_watch(void)
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
ret = pResetWriteWatch( GetModuleHandle(0), size ); ret = pResetWriteWatch( GetModuleHandleW(NULL), size );
ok( ret == ~0u, "ResetWriteWatch succeeded %u\n", ret ); ok( ret == ~0u, "ResetWriteWatch succeeded %u\n", ret );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
} }
@ -1486,7 +1486,7 @@ static void test_write_watch(void)
ret = pResetWriteWatch( base, 0 ); ret = pResetWriteWatch( base, 0 );
ok( !ret, "ResetWriteWatch failed %u\n", ret ); ok( !ret, "ResetWriteWatch failed %u\n", ret );
ret = pResetWriteWatch( GetModuleHandle(0), size ); ret = pResetWriteWatch( GetModuleHandleW(NULL), size );
ok( !ret, "ResetWriteWatch failed %u\n", ret ); ok( !ret, "ResetWriteWatch failed %u\n", ret );
} }
@ -1861,11 +1861,11 @@ static void test_CreateFileMapping_protection(void)
GetSystemInfo(&si); GetSystemInfo(&si);
trace("system page size %#x\n", si.dwPageSize); trace("system page size %#x\n", si.dwPageSize);
GetTempPath(MAX_PATH, temp_path); GetTempPathA(MAX_PATH, temp_path);
GetTempFileName(temp_path, "map", 0, file_name); GetTempFileNameA(temp_path, "map", 0, file_name);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hfile = CreateFile(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL, CREATE_ALWAYS, 0, 0); hfile = CreateFileA(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL, CREATE_ALWAYS, 0, 0);
ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError()); ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError());
SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN); SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN);
SetEndOfFile(hfile); SetEndOfFile(hfile);
@ -1873,7 +1873,7 @@ static void test_CreateFileMapping_protection(void)
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmap = CreateFileMapping(hfile, NULL, td[i].prot | SEC_COMMIT, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, td[i].prot | SEC_COMMIT, 0, si.dwPageSize, NULL);
if (td[i].success) if (td[i].success)
{ {
@ -1954,7 +1954,7 @@ todo_wine
if (page_exec_supported) alloc_prot = PAGE_EXECUTE_READWRITE; if (page_exec_supported) alloc_prot = PAGE_EXECUTE_READWRITE;
else alloc_prot = PAGE_READWRITE; else alloc_prot = PAGE_READWRITE;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmap = CreateFileMapping(hfile, NULL, alloc_prot, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, alloc_prot, 0, si.dwPageSize, NULL);
ok(hmap != 0, "%d: CreateFileMapping error %d\n", i, GetLastError()); ok(hmap != 0, "%d: CreateFileMapping error %d\n", i, GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -2065,7 +2065,7 @@ todo_wine
CloseHandle(hmap); CloseHandle(hmap);
CloseHandle(hfile); CloseHandle(hfile);
DeleteFile(file_name); DeleteFileA(file_name);
} }
#define ACCESS_READ 0x01 #define ACCESS_READ 0x01
@ -2252,11 +2252,11 @@ static void test_mapping(void)
GetSystemInfo(&si); GetSystemInfo(&si);
trace("system page size %#x\n", si.dwPageSize); trace("system page size %#x\n", si.dwPageSize);
GetTempPath(MAX_PATH, temp_path); GetTempPathA(MAX_PATH, temp_path);
GetTempFileName(temp_path, "map", 0, file_name); GetTempFileNameA(temp_path, "map", 0, file_name);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hfile = CreateFile(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL, CREATE_ALWAYS, 0, 0); hfile = CreateFileA(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL, CREATE_ALWAYS, 0, 0);
ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError()); ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError());
SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN); SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN);
SetEndOfFile(hfile); SetEndOfFile(hfile);
@ -2264,7 +2264,7 @@ static void test_mapping(void)
for (i = 0; i < sizeof(page_prot)/sizeof(page_prot[0]); i++) for (i = 0; i < sizeof(page_prot)/sizeof(page_prot[0]); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmap = CreateFileMapping(hfile, NULL, page_prot[i] | SEC_COMMIT, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, page_prot[i] | SEC_COMMIT, 0, si.dwPageSize, NULL);
if (page_prot[i] == PAGE_NOACCESS) if (page_prot[i] == PAGE_NOACCESS)
{ {
@ -2275,7 +2275,7 @@ static void test_mapping(void)
/* A trick to create a not accessible mapping */ /* A trick to create a not accessible mapping */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmap = CreateFileMapping(hfile, NULL, PAGE_READWRITE | SEC_COMMIT, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, PAGE_READWRITE | SEC_COMMIT, 0, si.dwPageSize, NULL);
ok(hmap != 0, "CreateFileMapping(PAGE_READWRITE) error %d\n", GetLastError()); ok(hmap != 0, "CreateFileMapping(PAGE_READWRITE) error %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = DuplicateHandle(GetCurrentProcess(), hmap, GetCurrentProcess(), &hmap2, 0, FALSE, 0); ret = DuplicateHandle(GetCurrentProcess(), hmap, GetCurrentProcess(), &hmap2, 0, FALSE, 0);
@ -2442,7 +2442,7 @@ todo_wine
} }
CloseHandle(hfile); CloseHandle(hfile);
DeleteFile(file_name); DeleteFileA(file_name);
} }
static void test_shared_memory(int is_child) static void test_shared_memory(int is_child)
@ -2451,7 +2451,7 @@ static void test_shared_memory(int is_child)
LONG *p; LONG *p;
SetLastError(0xdeadbef); SetLastError(0xdeadbef);
mapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_virtual.c"); mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_virtual.c");
ok(mapping != 0, "CreateFileMapping error %d\n", GetLastError()); ok(mapping != 0, "CreateFileMapping error %d\n", GetLastError());
if (is_child) if (is_child)
ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %d\n", GetLastError()); ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %d\n", GetLastError());
@ -2469,14 +2469,14 @@ static void test_shared_memory(int is_child)
char **argv; char **argv;
char cmdline[MAX_PATH]; char cmdline[MAX_PATH];
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFO si = { sizeof(si) }; STARTUPINFOA si = { sizeof(si) };
DWORD ret; DWORD ret;
*p = 0x1a2b3c4d; *p = 0x1a2b3c4d;
winetest_get_mainargs(&argv); winetest_get_mainargs(&argv);
sprintf(cmdline, "\"%s\" virtual sharedmem", argv[0]); sprintf(cmdline, "\"%s\" virtual sharedmem", argv[0]);
ret = CreateProcess(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError()); ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
winetest_wait_child_process(pi.hProcess); winetest_wait_child_process(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -2525,10 +2525,10 @@ START_TEST(virtual)
pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx"); pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch"); pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch");
pResetWriteWatch = (void *) GetProcAddress(hkernel32, "ResetWriteWatch"); pResetWriteWatch = (void *) GetProcAddress(hkernel32, "ResetWriteWatch");
pNtAreMappedFilesTheSame = (void *)GetProcAddress( GetModuleHandle("ntdll.dll"), pNtAreMappedFilesTheSame = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"),
"NtAreMappedFilesTheSame" ); "NtAreMappedFilesTheSame" );
pNtMapViewOfSection = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtMapViewOfSection"); pNtMapViewOfSection = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtMapViewOfSection");
pNtUnmapViewOfSection = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtUnmapViewOfSection"); pNtUnmapViewOfSection = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtUnmapViewOfSection");
test_shared_memory(0); test_shared_memory(0);
test_mapping(); test_mapping();