42 a, lenA, aw,
sizeof(aw) /
sizeof(aw[0]) );
54 {
IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 }, 0, 0, { 0 },
61#elif defined __x86_64__
63#elif defined __powerpc__
67#elif defined __aarch64__
70# error You must specify the machine type
114 {
".rodata", { 0 }, 0x1000, 0x1000, 0, 0, 0, 0, 0,
135 DWORD len1A, len1W = 0, len2A, len2W = 0;
140 memset(bufA,
'-',
sizeof(bufA));
146 ok(len1A > 0,
"Getting module filename for handle %p\n", hMod);
150 memset(bufW,
'-',
sizeof(bufW));
156 ok(len1W > 0,
"Getting module filename for handle %p\n", hMod);
159 ok(len1A ==
strlen(bufA),
"Unexpected length of GetModuleFilenameA (%d/%d)\n", len1A,
lstrlenA(bufA));
163 ok(len1W ==
lstrlenW(bufW),
"Unexpected length of GetModuleFilenameW (%d/%d)\n", len1W,
lstrlenW(bufW));
164 ok(
cmpStrAW(bufA, bufW, len1A, len1W),
"Comparing GetModuleFilenameAW results\n");
168 memset(bufA,
'-',
sizeof(bufA));
170 ok(len2A > 0,
"Getting module filename for handle %p\n", hMod);
174 memset(bufW,
'-',
sizeof(bufW));
176 ok(len2W > 0,
"Getting module filename for handle %p\n", hMod);
177 ok(
cmpStrAW(bufA, bufW, len2A, len2W),
"Comparing GetModuleFilenameAW results with buffer too small\n" );
178 ok(len1W / 2 == len2W,
"Correct length in GetModuleFilenameW with buffer too small (%d/%d)\n", len1W / 2, len2W);
181 ok(len1A / 2 == len2A,
182 "Correct length in GetModuleFilenameA with buffer too small (%d/%d)\n", len1A / 2, len2A);
194 ok(
GetModuleFileNameW((
void*)0xffffffff, bufW,
sizeof(bufW) /
sizeof(
WCHAR)) == 0,
"Unexpected success in module handle\n");
195 ok(bufW[0] ==
'*',
"When failing, buffer shouldn't be written to\n");
199 ok(
GetModuleFileNameA((
void*)0xffffffff, bufA,
sizeof(bufA)) == 0,
"Unexpected success in module handle\n");
200 ok(bufA[0] ==
'*',
"When failing, buffer shouldn't be written to\n");
214 ok( fp !=
NULL,
"CreateFileA should be there\n");
219 ok( hModule1 !=
NULL,
"\"kernel32 \" should be loadable\n" );
221 ok(
hModule == hModule1,
"Loaded wrong module\n" );
228 static const char dllname[] =
"shell32.dll";
230 HMODULE hModule1, hModule2, hModule3;
255 ok(hModule2 !=
NULL,
"LoadLibrary(%s) failed\n",
path2);
262 ok(hModule3 !=
NULL,
"LoadLibrary(%s) failed\n",
path1);
272 ok(hModule1 !=
NULL,
"LoadLibrary(%s) failed\n",
path1);
273 if (hModule1 !=
NULL)
284 ok( !
hModule,
"non_ex_pv.dll should be not loadable\n");
297 ok( !fp,
"non_ex_call should not be found\n");
302 ok( !fp,
"non_ex_call should not be found\n");
324 "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
332 "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %d\n",
GetLastError());
362 "Expected ERROR_SHARING_VIOLATION, got %d\n",
GetLastError());
373 "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
385 "Expected ERROR_FILE_INVALID, got %d\n",
GetLastError());
398 ok(
hmodule != 0,
"Expected valid module handle\n");
401 "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n",
GetLastError());
414 ok(
hmodule != 0,
"Expected valid module handle\n");
432 "Expected ERROR_FILE_NOT_FOUND, got %d\n",
GetLastError());
438 ok(
hmodule != 0,
"Expected valid module handle\n");
442 ok(
ret,
"Expected to be able to free the module, failed with %d\n",
GetLastError());
445 ok(!
ret,
"Unexpected ability to free the module, failed with %d\n",
GetLastError());
471 { { 1, 2, 3 }, 4, 3 },
472 { { 1, 3, 2 }, 4, 2 },
479 { { 1, 1, 2 }, 0, 2 },
484 unsigned int i,
j,
k;
488 if (!pAddDllDirectory || !pSetDllDirectoryA)
return;
496 for (
i = 1;
i <= 6;
i++)
501 if (
i >= 5)
continue;
502 sprintf(
p,
"\\%u\\winetestdll.dll",
i );
507 ok( !
mod,
"LoadLibrary succeeded\n" );
512 ok( !
mod,
"LoadLibrary succeeded\n" );
518 ok( !
mod,
"LoadLibrary succeeded\n" );
523 ok( !
mod,
"LoadLibrary succeeded\n" );
528 ok( !
mod,
"LoadLibrary succeeded\n" );
533 ok( !
mod,
"LoadLibrary succeeded\n" );
538 ok( !
mod,
"LoadLibrary succeeded\n" );
547 cookies[
k] = pAddDllDirectory( bufW );
553 pSetDllDirectoryA(
buf );
555 else pSetDllDirectoryA(
NULL );
568 ok( !
mod,
"%u: LoadLibrary succeeded\n",
j );
577 for (
i = 1;
i <= 6;
i++)
579 sprintf(
p,
"\\%u\\winetestdll.dll",
i );
594 static const char *dll_directories[] =
599 "Q:\\A\\Long\\Path with spaces that\\probably\\doesn't exist!",
601 const int test_count =
sizeof(dll_directories) /
sizeof(dll_directories[0]);
603 if (!pGetDllDirectoryA || !pGetDllDirectoryW)
605 win_skip(
"GetDllDirectory not available\n");
608 if (!pSetDllDirectoryA)
610 win_skip(
"SetDllDirectoryA not available\n");
617 if (!pSetDllDirectoryA(dll_directories[
i]))
619 skip(
"i=%d, SetDllDirectoryA failed\n",
i);
624 ret = pGetDllDirectoryA(0,
NULL);
627 ret = pGetDllDirectoryW(0,
NULL);
632 bufferA[
length + 1] =
'A';
633 ret = pGetDllDirectoryA(
length + 1, bufferA);
635 "i=%d, Expected %u(+1), got %u\n",
i,
length,
ret);
636 ok(bufferA[
length + 1] ==
'A',
"i=%d, Buffer overflow\n",
i);
637 ok(
strcmp(bufferA, dll_directories[
i]) == 0,
"i=%d, Wrong path returned: '%s'\n",
i, bufferA);
640 bufferW[
length + 1] =
'A';
641 ret = pGetDllDirectoryW(
length + 1, bufferW);
643 ok(bufferW[
length + 1] ==
'A',
"i=%d, Buffer overflow\n",
i);
650 ret = pGetDllDirectoryA(0, bufferA);
654 ret = pGetDllDirectoryW(0, bufferW);
656 ok(bufferW[0] == 0 ||
657 broken(bufferW[0] ==
'A'),
"i=%d, Buffer overflow\n",
i);
661 ret = pGetDllDirectoryA(
length, bufferA);
664 ok(bufferA[0] == 0,
"i=%d, Buffer not null terminated\n",
i);
667 ret = pGetDllDirectoryW(
length, bufferW);
669 ok(bufferW[0] == 0 ||
670 broken(bufferW[0] ==
'A'),
"i=%d, Buffer overflow\n",
i);
685 pSetDllDirectoryA(
NULL);
692#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f))
703 if (!pK32GetModuleInformation)
712 static const WCHAR kernel32W[] = {
'k',
'e',
'r',
'n',
'e',
'l',
'3',
'2',0};
713 static const WCHAR nosuchmodW[] = {
'n',
'o',
's',
'u',
'c',
'h',
'm',
'o',
'd',0};
721 ok( !
ret,
"unexpected success\n" );
727 ok( !
ret,
"unexpected success\n" );
741 ok( !
ret,
"unexpected success\n" );
748 ok( !
ret,
"unexpected success\n" );
754 ok( !
ret,
"unexpected success\n" );
768 ok( !
ret,
"unexpected success\n" );
775 ok( !
ret,
"unexpected success\n" );
781 ok( !
ret,
"unexpected success\n" );
794 ok( !
ret,
"unexpected success\n" );
801 ok( !
ret,
"unexpected success\n" );
807 ok( !
ret,
"unexpected success\n" );
820 ok( !
ret,
"unexpected success\n" );
829 ok( !
ret,
"unexpected success\n" );
835 ok( !
ret,
"unexpected success\n" );
842 ok(
mod == mod_kernel32,
"got %p\n",
mod );
849 ok( !
ret,
"unexpected success\n" );
856 ok( !
ret,
"unexpected success\n" );
862 ok( !
ret,
"unexpected success\n" );
869 ok(
mod == mod_kernel32,
"got %p\n",
mod );
876 ok( !
ret,
"unexpected success\n" );
892 ok(
ret,
"K32GetModuleInformation failed for main module\n");
893 ok(
info.lpBaseOfDll ==
mod,
"Wrong info.lpBaseOfDll = %p, expected %p\n",
info.lpBaseOfDll,
mod);
894 ok(
info.EntryPoint !=
NULL,
"Expected nonzero entrypoint\n");
899 ok(
ret,
"K32GetModuleInformation failed for kernel32 module\n");
900 ok(
info.lpBaseOfDll ==
mod,
"Wrong info.lpBaseOfDll = %p, expected %p\n",
info.lpBaseOfDll,
mod);
901 ok(
info.EntryPoint !=
NULL,
"Expected nonzero entrypoint\n");
906 static const WCHAR tmpW[] = {
't',
'm',
'p',0};
907 static const WCHAR dotW[] = {
'.',
'\\',
'.',0};
913 if (!pAddDllDirectory || !pRemoveDllDirectory)
915 win_skip(
"AddDllDirectory not available\n" );
933 ok( !
cookie,
"AddDllDirectory succeeded\n" );
936 ok( !
cookie,
"AddDllDirectory succeeded\n" );
946 ok( !
cookie,
"AddDllDirectory succeeded\n" );
955 if (!pSetDefaultDllDirectories)
957 win_skip(
"SetDefaultDllDirectories not available\n" );
962 ok(
mod !=
NULL,
"loading authz failed\n" );
972 ok(
mod !=
NULL,
"loading authz failed\n" );
985 ok(
mod !=
NULL,
"loading authz failed\n" );
989 ret = pSetDefaultDllDirectories( 0 );
990 ok( !
ret,
"SetDefaultDllDirectories succeeded\n" );
994 ret = pSetDefaultDllDirectories( 3 );
995 ok( !
ret,
"SetDefaultDllDirectories succeeded\n" );
1000 ok( !
ret,
"SetDefaultDllDirectories succeeded\n" );
1005 ok( !
ret ||
broken(
ret) ,
"SetDefaultDllDirectories succeeded\n" );
1010 ok( !
ret ||
broken(
ret) ,
"SetDefaultDllDirectories succeeded\n" );
1027 win_skip(
"GetModuleFileNameW not existing on this platform, skipping W-calls\n");
std::map< E_MODULE, HMODULE > mod
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
#define ERROR_NOT_ENOUGH_MEMORY
static const WCHAR rootW[]
#define IMAGE_FILE_MACHINE_ARMNT
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
#define ERROR_MOD_NOT_FOUND
#define IMAGE_FILE_MACHINE_POWERPC
#define GetProcAddress(x, y)
#define INVALID_HANDLE_VALUE
#define CreateFileA(a, b, c, d, e, f, g)
#define GetCurrentProcess()
#define IMAGE_FILE_MACHINE_ARM64
#define FILE_ATTRIBUTE_NORMAL
#define MultiByteToWideChar
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
BOOL WINAPI SetEndOfFile(HANDLE hFile)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE *phModule)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
DWORD WINAPI GetDllDirectoryW(IN DWORD nBufferLength, OUT LPWSTR lpBuffer)
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
BOOL WINAPI SetDllDirectoryA(IN LPCSTR lpPathName)
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
DWORD WINAPI GetDllDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
struct _IMAGE_DOS_HEADER IMAGE_DOS_HEADER
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
void * DLL_DIRECTORY_COOKIE
WINBASEAPI BOOL WINAPI RemoveDllDirectory(DLL_DIRECTORY_COOKIE)
WINBASEAPI DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory(const WCHAR *)
WINBASEAPI BOOL WINAPI SetDefaultDllDirectories(DWORD)
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
int WINAPI lstrlenA(LPCSTR lpString)
#define ERROR_FILE_NOT_FOUND
static struct test_info tests[]
#define sprintf(buf, format,...)
static const WCHAR filenameW[]
IMAGE_SECTION_HEADER section
static BOOL cmpStrAW(const char *a, const WCHAR *b, DWORD lenA, DWORD lenB)
static void testGetModuleHandleEx(void)
static void testLoadLibraryA(void)
static void create_test_dll(const char *name)
static void test_LoadLibraryEx_search_flags(void)
static void testGetDllDirectory(void)
static void testGetModuleFileName_Wrong(void)
static void testGetProcAddress_Wrong(void)
static void test_AddDllDirectory(void)
static void testGetModuleFileName(const char *name)
static BOOL is_unicode_enabled
static HMODULE MODULEINFO DWORD cb
static void init_pointers(void)
static void testLoadLibraryA_Wrong(void)
static const struct @1671 dll_image
static void testLoadLibraryEx(void)
static void test_SetDefaultDllDirectories(void)
static void testNestedLoadLibraryA(void)
static void testK32GetModuleInformation(void)
static HMODULE MODULEINFO * modinfo
static const WCHAR dotW[]
static const WCHAR path1[]
static const WCHAR path2[]
static CookieInternal * cookies
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
#define IMAGE_SCN_CNT_INITIALIZED_DATA
#define IMAGE_FILE_MACHINE_AMD64
#define IMAGE_SCN_MEM_READ
#define IMAGE_NT_OPTIONAL_HDR_MAGIC
#define IMAGE_FILE_EXECUTABLE_IMAGE
#define IMAGE_FILE_MACHINE_I386
struct _IMAGE_OPTIONAL_HEADER IMAGE_OPTIONAL_HEADER
#define IMAGE_NT_SIGNATURE
#define IMAGE_DOS_SIGNATURE
#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
DWORD WINAPI GetLastError(void)
#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
#define LOAD_LIBRARY_AS_DATAFILE
#define LOAD_LIBRARY_SEARCH_SYSTEM32
BOOL WINAPI AreFileApisANSI(void)
#define LOAD_WITH_ALTERED_SEARCH_PATH
#define LOAD_LIBRARY_SEARCH_USER_DIRS
#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR
#define ERROR_SHARING_VIOLATION
#define ERROR_FILE_INVALID
#define ERROR_PROC_NOT_FOUND