ReactOS  0.4.14-dev-98-gb0d4763
module.c File Reference
#include "wine/test.h"
#include <windows.h>
#include <stdio.h>
#include <psapi.h>
Include dependency graph for module.c:

Go to the source code of this file.

Macros

#define MAKEFUNC(f)   (p##f = (void*)GetProcAddress(hKernel32, #f))
 

Functions

static DWORD (WINAPI *pGetDllDirectoryA)(DWORD
 
static BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR)
 
static DLL_DIRECTORY_COOKIE (WINAPI *pAddDllDirectory)(const WCHAR *)
 
static BOOL cmpStrAW (const char *a, const WCHAR *b, DWORD lenA, DWORD lenB)
 
static void create_test_dll (const char *name)
 
static void testGetModuleFileName (const char *name)
 
static void testGetModuleFileName_Wrong (void)
 
static void testLoadLibraryA (void)
 
static void testNestedLoadLibraryA (void)
 
static void testLoadLibraryA_Wrong (void)
 
static void testGetProcAddress_Wrong (void)
 
static void testLoadLibraryEx (void)
 
static void test_LoadLibraryEx_search_flags (void)
 
static void testGetDllDirectory (void)
 
static void init_pointers (void)
 
static void testGetModuleHandleEx (void)
 
static void testK32GetModuleInformation (void)
 
static void test_AddDllDirectory (void)
 
static void test_SetDefaultDllDirectories (void)
 
 START_TEST (module)
 

Variables

static LPSTR
 
static LPWSTR
 
static HMODULE module
 
static HMODULE MODULEINFOmodinfo
 
static HMODULE MODULEINFO DWORD cb
 
static BOOL is_unicode_enabled = TRUE
 
struct {
   IMAGE_DOS_HEADER   dos
 
   IMAGE_NT_HEADERS   nt
 
   IMAGE_SECTION_HEADER   section
 
dll_image
 

Macro Definition Documentation

◆ MAKEFUNC

#define MAKEFUNC (   f)    (p##f = (void*)GetProcAddress(hKernel32, #f))

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pSetDllDirectoryA)
static

◆ cmpStrAW()

static BOOL cmpStrAW ( const char a,
const WCHAR b,
DWORD  lenA,
DWORD  lenB 
)
static

Definition at line 37 of file module.c.

38 {
39  WCHAR aw[1024];
40 
42  a, lenA, aw, sizeof(aw) / sizeof(aw[0]) );
43  if (len != lenB) return FALSE;
44  return memcmp(aw, b, len * sizeof(WCHAR)) == 0;
45 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define CP_ACP
Definition: compat.h:99
BOOL WINAPI AreFileApisANSI(VOID)
Definition: utils.c:864
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define CP_OEMCP
Definition: winnls.h:228

Referenced by testGetDllDirectory(), and testGetModuleFileName().

◆ create_test_dll()

static void create_test_dll ( const char name)
static

Definition at line 118 of file module.c.

119 {
120  DWORD dummy;
122 
123  ok( handle != INVALID_HANDLE_VALUE, "failed to create file err %u\n", GetLastError() );
124  WriteFile( handle, &dll_image, sizeof(dll_image), &dummy, NULL );
125  SetFilePointer( handle, dll_image.nt.OptionalHeader.SizeOfImage, NULL, FILE_BEGIN );
126  SetEndOfFile( handle );
127  CloseHandle( handle );
128 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_READ
Definition: compat.h:125
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_BEGIN
Definition: winbase.h:112
static const struct @1607 dll_image
unsigned char dummy
Definition: maze.c:118
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399

Referenced by test_LoadLibraryEx_search_flags().

◆ DLL_DIRECTORY_COOKIE()

static DLL_DIRECTORY_COOKIE ( WINAPI pAddDllDirectory) const
static

◆ DWORD()

static DWORD ( WINAPI pGetDllDirectoryA)
static

◆ init_pointers()

static void init_pointers ( void  )
static

Definition at line 688 of file module.c.

689 {
690  HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
691 
692 #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f))
699  MAKEFUNC(K32GetModuleInformation);
700 #undef MAKEFUNC
701 
702  /* before Windows 7 this was not exported in kernel32 */
703  if (!pK32GetModuleInformation)
704  {
705  HMODULE hPsapi = LoadLibraryA("psapi.dll");
706  pK32GetModuleInformation = (void *)GetProcAddress(hPsapi, "GetModuleInformation");
707  }
708 }
WINBASEAPI BOOL WINAPI SetDefaultDllDirectories(DWORD)
#define MAKEFUNC(f)
DWORD WINAPI GetDllDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:914
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
BOOL WINAPI SetDllDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:837
WINBASEAPI BOOL WINAPI RemoveDllDirectory(DLL_DIRECTORY_COOKIE)
static HMODULE hPsapi
Definition: integrity.c:31
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
DWORD WINAPI GetDllDirectoryW(IN DWORD nBufferLength, OUT LPWSTR lpBuffer)
Definition: path.c:886
#define GetProcAddress(x, y)
Definition: compat.h:410
WINBASEAPI DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory(const WCHAR *)

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( module  )

Definition at line 1017 of file module.c.

1018 {
1020 
1021  /* Test if we can use GetModuleFileNameW */
1022 
1023  SetLastError(0xdeadbeef);
1026  {
1027  win_skip("GetModuleFileNameW not existing on this platform, skipping W-calls\n");
1029  }
1030 
1031  init_pointers();
1032 
1034  testGetModuleFileName("kernel32.dll");
1036 
1038 
1039  testLoadLibraryA();
1049 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
static void test_SetDefaultDllDirectories(void)
Definition: module.c:950
static void testK32GetModuleInformation(void)
Definition: module.c:883
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void testGetProcAddress_Wrong(void)
Definition: module.c:291
static const WCHAR filenameW[]
Definition: amstream.c:41
static void testLoadLibraryA_Wrong(void)
Definition: module.c:277
static void testLoadLibraryA(void)
Definition: module.c:203
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
static void init_pointers(void)
Definition: module.c:688
static void testGetModuleFileName_Wrong(void)
Definition: module.c:185
static void testGetModuleHandleEx(void)
Definition: module.c:710
static BOOL is_unicode_enabled
Definition: module.c:35
static void testGetDllDirectory(void)
Definition: module.c:588
static void test_LoadLibraryEx_search_flags(void)
Definition: module.c:462
static void testLoadLibraryEx(void)
Definition: module.c:306
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
static void testNestedLoadLibraryA(void)
Definition: module.c:226
static void testGetModuleFileName(const char *name)
Definition: module.c:130
#define win_skip
Definition: test.h:141
static void test_AddDllDirectory(void)
Definition: module.c:904

◆ test_AddDllDirectory()

static void test_AddDllDirectory ( void  )
static

Definition at line 904 of file module.c.

905 {
906  static const WCHAR tmpW[] = {'t','m','p',0};
907  static const WCHAR dotW[] = {'.','\\','.',0};
908  static const WCHAR rootW[] = {'\\',0};
910  DLL_DIRECTORY_COOKIE cookie;
911  BOOL ret;
912 
913  if (!pAddDllDirectory || !pRemoveDllDirectory)
914  {
915  win_skip( "AddDllDirectory not available\n" );
916  return;
917  }
918 
919  buf[0] = '\0';
920  GetTempPathW( sizeof(path)/sizeof(path[0]), path );
921  ret = GetTempFileNameW( path, tmpW, 0, buf );
922  ok( ret, "GetTempFileName failed err %u\n", GetLastError() );
923  SetLastError( 0xdeadbeef );
924  cookie = pAddDllDirectory( buf );
925  ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
926  SetLastError( 0xdeadbeef );
927  ret = pRemoveDllDirectory( cookie );
928  ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
929 
930  DeleteFileW( buf );
931  SetLastError( 0xdeadbeef );
932  cookie = pAddDllDirectory( buf );
933  ok( !cookie, "AddDllDirectory succeeded\n" );
934  ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError() );
935  cookie = pAddDllDirectory( dotW );
936  ok( !cookie, "AddDllDirectory succeeded\n" );
937  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
938  cookie = pAddDllDirectory( rootW );
939  ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
940  SetLastError( 0xdeadbeef );
941  ret = pRemoveDllDirectory( cookie );
942  ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
944  lstrcpyW( buf + 2, tmpW );
945  cookie = pAddDllDirectory( buf );
946  ok( !cookie, "AddDllDirectory succeeded\n" );
947  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
948 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const WCHAR rootW[]
Definition: chain.c:69
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
#define SetLastError(x)
Definition: compat.h:409
int ret
#define lstrcpyW
Definition: compat.h:406
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define win_skip
Definition: test.h:141
static const WCHAR dotW[]
Definition: directory.c:80

Referenced by START_TEST().

◆ test_LoadLibraryEx_search_flags()

static void test_LoadLibraryEx_search_flags ( void  )
static

Definition at line 462 of file module.c.

463 {
464  static const struct
465  {
466  int add_dirs[4];
467  int dll_dir;
468  int expect;
469  } tests[] =
470  {
471  { { 1, 2, 3 }, 4, 3 }, /* 0 */
472  { { 1, 3, 2 }, 4, 2 },
473  { { 3, 1 }, 4, 1 },
474  { { 5, 6 }, 4, 4 },
475  { { 5, 2 }, 4, 2 },
476  { { 0 }, 4, 4 }, /* 5 */
477  { { 0 }, 0, 0 },
478  { { 6, 5 }, 5, 0 },
479  { { 1, 1, 2 }, 0, 2 },
480  };
481  char *p, path[MAX_PATH], buf[MAX_PATH];
482  WCHAR bufW[MAX_PATH];
484  unsigned int i, j, k;
485  BOOL ret;
486  HMODULE mod;
487 
488  if (!pAddDllDirectory || !pSetDllDirectoryA) return;
489 
490  GetTempPathA( sizeof(path), path );
491  GetTempFileNameA( path, "tmp", 0, buf );
492  DeleteFileA( buf );
494  ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
495  p = buf + strlen( buf );
496  for (i = 1; i <= 6; i++)
497  {
498  sprintf( p, "\\%u", i );
500  ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
501  if (i >= 5) continue; /* dirs 5 and 6 are left empty */
502  sprintf( p, "\\%u\\winetestdll.dll", i );
503  create_test_dll( buf );
504  }
505  SetLastError( 0xdeadbeef );
506  mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
507  ok( !mod, "LoadLibrary succeeded\n" );
508  ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
509 
510  SetLastError( 0xdeadbeef );
511  mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
512  ok( !mod, "LoadLibrary succeeded\n" );
514  "wrong error %u\n", GetLastError() );
515 
516  SetLastError( 0xdeadbeef );
517  mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
518  ok( !mod, "LoadLibrary succeeded\n" );
519  ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
520 
521  SetLastError( 0xdeadbeef );
522  mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
523  ok( !mod, "LoadLibrary succeeded\n" );
524  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
525 
526  SetLastError( 0xdeadbeef );
528  ok( !mod, "LoadLibrary succeeded\n" );
529  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
530 
531  SetLastError( 0xdeadbeef );
532  mod = LoadLibraryExA( "foo\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
533  ok( !mod, "LoadLibrary succeeded\n" );
534  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
535 
536  SetLastError( 0xdeadbeef );
537  mod = LoadLibraryExA( "\\windows\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
538  ok( !mod, "LoadLibrary succeeded\n" );
539  ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
540 
541  for (j = 0; j < sizeof(tests) / sizeof(tests[0]); j++)
542  {
543  for (k = 0; tests[j].add_dirs[k]; k++)
544  {
545  sprintf( p, "\\%u", tests[j].add_dirs[k] );
546  MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, MAX_PATH );
547  cookies[k] = pAddDllDirectory( bufW );
548  ok( cookies[k] != NULL, "failed to add %s\n", buf );
549  }
550  if (tests[j].dll_dir)
551  {
552  sprintf( p, "\\%u", tests[j].dll_dir );
553  pSetDllDirectoryA( buf );
554  }
555  else pSetDllDirectoryA( NULL );
556 
557  SetLastError( 0xdeadbeef );
558  mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
559  if (tests[j].expect)
560  {
561  ok( mod != NULL, "%u: LoadLibrary failed err %u\n", j, GetLastError() );
563  sprintf( p, "\\%u\\winetestdll.dll", tests[j].expect );
564  ok( !lstrcmpiA( path, buf ), "%u: wrong module %s expected %s\n", j, path, buf );
565  }
566  else
567  {
568  ok( !mod, "%u: LoadLibrary succeeded\n", j );
570  "%u: wrong error %u\n", j, GetLastError() );
571  }
572  FreeLibrary( mod );
573 
574  for (k = 0; tests[j].add_dirs[k]; k++) pRemoveDllDirectory( cookies[k] );
575  }
576 
577  for (i = 1; i <= 6; i++)
578  {
579  sprintf( p, "\\%u\\winetestdll.dll", i );
580  DeleteFileA( buf );
581  sprintf( p, "\\%u", i );
583  }
584  *p = 0;
586 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct param_test tests[]
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
static void create_test_dll(const char *name)
Definition: module.c:118
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define CP_ACP
Definition: compat.h:99
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define LOAD_LIBRARY_SEARCH_SYSTEM32
Definition: winbase.h:346
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
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
Definition: glfuncs.h:250
#define FreeLibrary(x)
Definition: compat.h:405
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
int ret
static CookieInternal * cookies
Definition: msctf.c:67
#define broken(x)
Definition: _sntprintf.h:21
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define LOAD_LIBRARY_SEARCH_USER_DIRS
Definition: winbase.h:345
#define ok(value,...)
Definition: atltest.h:57
#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR
Definition: winbase.h:344
Definition: services.c:325
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
#define expect(expected, got)
Definition: combo.c:36
#define MultiByteToWideChar
Definition: compat.h:100
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
Definition: winbase.h:343
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
GLfloat GLfloat p
Definition: glext.h:8902
int k
Definition: mpi.c:3369
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
static int mod
Definition: i386-dis.c:1273

Referenced by START_TEST().

◆ test_SetDefaultDllDirectories()

static void test_SetDefaultDllDirectories ( void  )
static

Definition at line 950 of file module.c.

951 {
952  HMODULE mod;
953  BOOL ret;
954 
955  if (!pSetDefaultDllDirectories)
956  {
957  win_skip( "SetDefaultDllDirectories not available\n" );
958  return;
959  }
960 
961  mod = LoadLibraryA( "authz.dll" );
962  ok( mod != NULL, "loading authz failed\n" );
963  FreeLibrary( mod );
964  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_USER_DIRS );
965  ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
966  mod = LoadLibraryA( "authz.dll" );
967  todo_wine ok( !mod, "loading authz succeeded\n" );
968  FreeLibrary( mod );
969  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
970  ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
971  mod = LoadLibraryA( "authz.dll" );
972  ok( mod != NULL, "loading authz failed\n" );
973  FreeLibrary( mod );
975  todo_wine ok( !mod, "loading authz succeeded\n" );
976  FreeLibrary( mod );
977  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
978  ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
979  mod = LoadLibraryA( "authz.dll" );
980  todo_wine ok( !mod, "loading authz succeeded\n" );
981  FreeLibrary( mod );
982  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
983  ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
984  mod = LoadLibraryA( "authz.dll" );
985  ok( mod != NULL, "loading authz failed\n" );
986  FreeLibrary( mod );
987 
988  SetLastError( 0xdeadbeef );
989  ret = pSetDefaultDllDirectories( 0 );
990  ok( !ret, "SetDefaultDllDirectories succeeded\n" );
991  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
992 
993  SetLastError( 0xdeadbeef );
994  ret = pSetDefaultDllDirectories( 3 );
995  ok( !ret, "SetDefaultDllDirectories succeeded\n" );
996  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
997 
998  SetLastError( 0xdeadbeef );
999  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 0x8000 );
1000  ok( !ret, "SetDefaultDllDirectories succeeded\n" );
1001  ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1002 
1003  SetLastError( 0xdeadbeef );
1004  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
1005  ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
1006  if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1007 
1008  SetLastError( 0xdeadbeef );
1009  ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_USER_DIRS );
1010  ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
1011  if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1012 
1013  /* restore some sane defaults */
1014  pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
1015 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define LOAD_LIBRARY_SEARCH_SYSTEM32
Definition: winbase.h:346
#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
Definition: winbase.h:347
unsigned int BOOL
Definition: ntddk_ex.h:94
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405
#define SetLastError(x)
Definition: compat.h:409
int ret
#define todo_wine
Definition: test.h:154
#define broken(x)
Definition: _sntprintf.h:21
#define LOAD_LIBRARY_SEARCH_USER_DIRS
Definition: winbase.h:345
#define ok(value,...)
Definition: atltest.h:57
#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR
Definition: winbase.h:344
#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
Definition: winbase.h:343
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
#define win_skip
Definition: test.h:141
static int mod
Definition: i386-dis.c:1273

Referenced by START_TEST().

◆ testGetDllDirectory()

static void testGetDllDirectory ( void  )
static

Definition at line 588 of file module.c.

589 {
590  CHAR bufferA[MAX_PATH];
591  WCHAR bufferW[MAX_PATH];
592  DWORD length, ret;
593  int i;
594  static const char *dll_directories[] =
595  {
596  "",
597  "C:\\Some\\Path",
598  "C:\\Some\\Path\\",
599  "Q:\\A\\Long\\Path with spaces that\\probably\\doesn't exist!",
600  };
601  const int test_count = sizeof(dll_directories) / sizeof(dll_directories[0]);
602 
603  if (!pGetDllDirectoryA || !pGetDllDirectoryW)
604  {
605  win_skip("GetDllDirectory not available\n");
606  return;
607  }
608  if (!pSetDllDirectoryA)
609  {
610  win_skip("SetDllDirectoryA not available\n");
611  return;
612  }
613 
614  for (i = 0; i < test_count; i++)
615  {
616  length = strlen(dll_directories[i]);
617  if (!pSetDllDirectoryA(dll_directories[i]))
618  {
619  skip("i=%d, SetDllDirectoryA failed\n", i);
620  continue;
621  }
622 
623  /* no buffer, determine length */
624  ret = pGetDllDirectoryA(0, NULL);
625  ok(ret == length + 1, "Expected %u, got %u\n", length + 1, ret);
626 
627  ret = pGetDllDirectoryW(0, NULL);
628  ok(ret == length + 1, "Expected %u, got %u\n", length + 1, ret);
629 
630  /* buffer of exactly the right size */
631  bufferA[length] = 'A';
632  bufferA[length + 1] = 'A';
633  ret = pGetDllDirectoryA(length + 1, bufferA);
634  ok(ret == length || broken(ret + 1 == length) /* win8 */,
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);
638 
639  bufferW[length] = 'A';
640  bufferW[length + 1] = 'A';
641  ret = pGetDllDirectoryW(length + 1, bufferW);
642  ok(ret == length, "i=%d, Expected %u, got %u\n", i, length, ret);
643  ok(bufferW[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
644  ok(cmpStrAW(dll_directories[i], bufferW, length, length),
645  "i=%d, Wrong path returned: %s\n", i, wine_dbgstr_w(bufferW));
646 
647  /* Zero size buffer. The buffer may or may not be terminated depending
648  * on the Windows version and whether the A or W API is called. */
649  bufferA[0] = 'A';
650  ret = pGetDllDirectoryA(0, bufferA);
651  ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
652 
653  bufferW[0] = 'A';
654  ret = pGetDllDirectoryW(0, bufferW);
655  ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
656  ok(bufferW[0] == 0 || /* XP, 2003 */
657  broken(bufferW[0] == 'A'), "i=%d, Buffer overflow\n", i);
658 
659  /* buffer just one too short */
660  bufferA[0] = 'A';
661  ret = pGetDllDirectoryA(length, bufferA);
662  ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
663  if (length != 0)
664  ok(bufferA[0] == 0, "i=%d, Buffer not null terminated\n", i);
665 
666  bufferW[0] = 'A';
667  ret = pGetDllDirectoryW(length, bufferW);
668  ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
669  ok(bufferW[0] == 0 || /* XP, 2003 */
670  broken(bufferW[0] == 'A'), "i=%d, Buffer overflow\n", i);
671 
672  if (0)
673  {
674  /* crashes on win8 */
675  /* no buffer, but too short length */
676  ret = pGetDllDirectoryA(length, NULL);
677  ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
678 
679  ret = pGetDllDirectoryW(length, NULL);
680  ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
681  }
682  }
683 
684  /* unset whatever we did so following tests won't be affected */
685  pSetDllDirectoryA(NULL);
686 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
char CHAR
Definition: xmlstorage.h:175
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
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static BOOL cmpStrAW(const char *a, const WCHAR *b, DWORD lenA, DWORD lenB)
Definition: module.c:37
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
static void test_count(void)
Definition: eventlog.c:192
#define skip(...)
Definition: atltest.h:64
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ testGetModuleFileName()

static void testGetModuleFileName ( const char name)
static

Definition at line 130 of file module.c.

131 {
132  HMODULE hMod;
133  char bufA[MAX_PATH];
134  WCHAR bufW[MAX_PATH];
135  DWORD len1A, len1W = 0, len2A, len2W = 0;
136 
137  hMod = (name) ? GetModuleHandleA(name) : NULL;
138 
139  /* first test, with enough space in buffer */
140  memset(bufA, '-', sizeof(bufA));
141  SetLastError(0xdeadbeef);
142  len1A = GetModuleFileNameA(hMod, bufA, sizeof(bufA));
144  broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
145  "LastError was not reset: %u\n", GetLastError());
146  ok(len1A > 0, "Getting module filename for handle %p\n", hMod);
147 
148  if (is_unicode_enabled)
149  {
150  memset(bufW, '-', sizeof(bufW));
151  SetLastError(0xdeadbeef);
152  len1W = GetModuleFileNameW(hMod, bufW, sizeof(bufW) / sizeof(WCHAR));
154  broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
155  "LastError was not reset: %u\n", GetLastError());
156  ok(len1W > 0, "Getting module filename for handle %p\n", hMod);
157  }
158 
159  ok(len1A == strlen(bufA), "Unexpected length of GetModuleFilenameA (%d/%d)\n", len1A, lstrlenA(bufA));
160 
161  if (is_unicode_enabled)
162  {
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");
165  }
166 
167  /* second test with a buffer too small */
168  memset(bufA, '-', sizeof(bufA));
169  len2A = GetModuleFileNameA(hMod, bufA, len1A / 2);
170  ok(len2A > 0, "Getting module filename for handle %p\n", hMod);
171 
172  if (is_unicode_enabled)
173  {
174  memset(bufW, '-', sizeof(bufW));
175  len2W = GetModuleFileNameW(hMod, bufW, len1W / 2);
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);
179  }
180 
181  ok(len1A / 2 == len2A,
182  "Correct length in GetModuleFilenameA with buffer too small (%d/%d)\n", len1A / 2, len2A);
183 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define lstrlenW
Definition: compat.h:407
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static BOOL cmpStrAW(const char *a, const WCHAR *b, DWORD lenA, DWORD lenB)
Definition: module.c:37
static BOOL is_unicode_enabled
Definition: module.c:35
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define broken(x)
Definition: _sntprintf.h:21
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
#define memset(x, y, z)
Definition: compat.h:39
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by START_TEST().

◆ testGetModuleFileName_Wrong()

static void testGetModuleFileName_Wrong ( void  )
static

Definition at line 185 of file module.c.

186 {
187  char bufA[MAX_PATH];
188  WCHAR bufW[MAX_PATH];
189 
190  /* test wrong handle */
191  if (is_unicode_enabled)
192  {
193  bufW[0] = '*';
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");
196  }
197 
198  bufA[0] = '*';
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");
201 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static BOOL is_unicode_enabled
Definition: module.c:35
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ testGetModuleHandleEx()

static void testGetModuleHandleEx ( void  )
static

Definition at line 710 of file module.c.

711 {
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};
714  BOOL ret;
715  DWORD error;
716  HMODULE mod, mod_kernel32;
717 
718  SetLastError( 0xdeadbeef );
719  ret = GetModuleHandleExA( 0, NULL, NULL );
720  error = GetLastError();
721  ok( !ret, "unexpected success\n" );
722  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
723 
724  SetLastError( 0xdeadbeef );
725  ret = GetModuleHandleExA( 0, "kernel32", NULL );
726  error = GetLastError();
727  ok( !ret, "unexpected success\n" );
728  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
729 
730  SetLastError( 0xdeadbeef );
731  mod = (HMODULE)0xdeadbeef;
732  ret = GetModuleHandleExA( 0, "kernel32", &mod );
733  ok( ret, "unexpected failure %u\n", GetLastError() );
734  ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
735  FreeLibrary( mod );
736 
737  SetLastError( 0xdeadbeef );
738  mod = (HMODULE)0xdeadbeef;
739  ret = GetModuleHandleExA( 0, "nosuchmod", &mod );
740  error = GetLastError();
741  ok( !ret, "unexpected success\n" );
742  ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
743  ok( mod == NULL, "got %p\n", mod );
744 
745  SetLastError( 0xdeadbeef );
746  ret = GetModuleHandleExW( 0, NULL, NULL );
747  error = GetLastError();
748  ok( !ret, "unexpected success\n" );
749  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
750 
751  SetLastError( 0xdeadbeef );
752  ret = GetModuleHandleExW( 0, kernel32W, NULL );
753  error = GetLastError();
754  ok( !ret, "unexpected success\n" );
755  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
756 
757  SetLastError( 0xdeadbeef );
758  mod = (HMODULE)0xdeadbeef;
759  ret = GetModuleHandleExW( 0, kernel32W, &mod );
760  ok( ret, "unexpected failure %u\n", GetLastError() );
761  ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
762  FreeLibrary( mod );
763 
764  SetLastError( 0xdeadbeef );
765  mod = (HMODULE)0xdeadbeef;
766  ret = GetModuleHandleExW( 0, nosuchmodW, &mod );
767  error = GetLastError();
768  ok( !ret, "unexpected success\n" );
769  ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
770  ok( mod == NULL, "got %p\n", mod );
771 
772  SetLastError( 0xdeadbeef );
773  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
774  error = GetLastError();
775  ok( !ret, "unexpected success\n" );
776  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
777 
778  SetLastError( 0xdeadbeef );
779  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", NULL );
780  error = GetLastError();
781  ok( !ret, "unexpected success\n" );
782  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
783 
784  SetLastError( 0xdeadbeef );
785  mod = (HMODULE)0xdeadbeef;
786  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", &mod );
787  ok( ret, "unexpected failure %u\n", GetLastError() );
788  ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
789 
790  SetLastError( 0xdeadbeef );
791  mod = (HMODULE)0xdeadbeef;
792  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "nosuchmod", &mod );
793  error = GetLastError();
794  ok( !ret, "unexpected success\n" );
795  ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
796  ok( mod == NULL, "got %p\n", mod );
797 
798  SetLastError( 0xdeadbeef );
799  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
800  error = GetLastError();
801  ok( !ret, "unexpected success\n" );
802  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
803 
804  SetLastError( 0xdeadbeef );
805  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, NULL );
806  error = GetLastError();
807  ok( !ret, "unexpected success\n" );
808  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
809 
810  SetLastError( 0xdeadbeef );
811  mod = (HMODULE)0xdeadbeef;
812  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, &mod );
813  ok( ret, "unexpected failure %u\n", GetLastError() );
814  ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
815 
816  SetLastError( 0xdeadbeef );
817  mod = (HMODULE)0xdeadbeef;
818  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, nosuchmodW, &mod );
819  error = GetLastError();
820  ok( !ret, "unexpected success\n" );
821  ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
822  ok( mod == NULL, "got %p\n", mod );
823 
824  mod_kernel32 = LoadLibraryA( "kernel32" );
825 
826  SetLastError( 0xdeadbeef );
827  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
828  error = GetLastError();
829  ok( !ret, "unexpected success\n" );
830  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
831 
832  SetLastError( 0xdeadbeef );
833  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, NULL );
834  error = GetLastError();
835  ok( !ret, "unexpected success\n" );
836  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
837 
838  SetLastError( 0xdeadbeef );
839  mod = (HMODULE)0xdeadbeef;
840  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, &mod );
841  ok( ret, "unexpected failure %u\n", GetLastError() );
842  ok( mod == mod_kernel32, "got %p\n", mod );
843  FreeLibrary( mod );
844 
845  SetLastError( 0xdeadbeef );
846  mod = (HMODULE)0xdeadbeef;
847  ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)0xbeefdead, &mod );
848  error = GetLastError();
849  ok( !ret, "unexpected success\n" );
850  ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
851  ok( mod == NULL, "got %p\n", mod );
852 
853  SetLastError( 0xdeadbeef );
854  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
855  error = GetLastError();
856  ok( !ret, "unexpected success\n" );
857  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
858 
859  SetLastError( 0xdeadbeef );
860  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, NULL );
861  error = GetLastError();
862  ok( !ret, "unexpected success\n" );
863  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
864 
865  SetLastError( 0xdeadbeef );
866  mod = (HMODULE)0xdeadbeef;
867  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, &mod );
868  ok( ret, "unexpected failure %u\n", GetLastError() );
869  ok( mod == mod_kernel32, "got %p\n", mod );
870  FreeLibrary( mod );
871 
872  SetLastError( 0xdeadbeef );
873  mod = (HMODULE)0xdeadbeef;
874  ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)0xbeefdead, &mod );
875  error = GetLastError();
876  ok( !ret, "unexpected success\n" );
877  ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
878  ok( mod == NULL, "got %p\n", mod );
879 
880  FreeLibrary( mod_kernel32 );
881 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define error(str)
Definition: mkdosfs.c:1605
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define FreeLibrary(x)
Definition: compat.h:405
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:905
HANDLE HMODULE
Definition: typedefs.h:75
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:875
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
static int mod
Definition: i386-dis.c:1273

Referenced by START_TEST().

◆ testGetProcAddress_Wrong()

static void testGetProcAddress_Wrong ( void  )
static

Definition at line 291 of file module.c.

292 {
293  FARPROC fp;
294 
295  SetLastError(0xdeadbeef);
296  fp = GetProcAddress(NULL, "non_ex_call");
297  ok( !fp, "non_ex_call should not be found\n");
298  ok( GetLastError() == ERROR_PROC_NOT_FOUND, "Expected ERROR_PROC_NOT_FOUND, got %d\n", GetLastError() );
299 
300  SetLastError(0xdeadbeef);
301  fp = GetProcAddress((HMODULE)0xdeadbeef, "non_ex_call");
302  ok( !fp, "non_ex_call should not be found\n");
303  ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() );
304 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
#define GetProcAddress(x, y)
Definition: compat.h:410
int(* FARPROC)()
Definition: compat.h:28

Referenced by START_TEST().

◆ testK32GetModuleInformation()

static void testK32GetModuleInformation ( void  )
static

Definition at line 883 of file module.c.

884 {
886  HMODULE mod;
887  BOOL ret;
888 
890  memset(&info, 0xAA, sizeof(info));
891  ret = pK32GetModuleInformation(GetCurrentProcess(), mod, &info, sizeof(info));
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");
895 
896  mod = GetModuleHandleA("kernel32.dll");
897  memset(&info, 0xAA, sizeof(info));
898  ret = pK32GetModuleInformation(GetCurrentProcess(), mod, &info, sizeof(info));
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");
902 }
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define ok(value,...)
Definition: atltest.h:57
#define memset(x, y, z)
Definition: compat.h:39
static int mod
Definition: i386-dis.c:1273

Referenced by START_TEST().

◆ testLoadLibraryA()

static void testLoadLibraryA ( void  )
static

Definition at line 203 of file module.c.

204 {
205  HMODULE hModule, hModule1;
206  FARPROC fp;
207 
208  SetLastError(0xdeadbeef);
209  hModule = LoadLibraryA("kernel32.dll");
210  ok( hModule != NULL, "kernel32.dll should be loadable\n");
211  ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError());
212 
213  fp = GetProcAddress(hModule, "CreateFileA");
214  ok( fp != NULL, "CreateFileA should be there\n");
215  ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError());
216 
217  SetLastError(0xdeadbeef);
218  hModule1 = LoadLibraryA("kernel32 ");
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);
224 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405
#define SetLastError(x)
Definition: compat.h:409
#define ok(value,...)
Definition: atltest.h:57
#define GetProcAddress(x, y)
Definition: compat.h:410
int(* FARPROC)()
Definition: compat.h:28
HMODULE hModule
Definition: animate.c:44

Referenced by START_TEST().

◆ testLoadLibraryA_Wrong()

static void testLoadLibraryA_Wrong ( void  )
static

Definition at line 277 of file module.c.

278 {
280 
281  /* Try to load a nonexistent dll */
282  SetLastError(0xdeadbeef);
283  hModule = LoadLibraryA("non_ex_pv.dll");
284  ok( !hModule, "non_ex_pv.dll should be not loadable\n");
285  ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() );
286 
287  /* Just in case */
289 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FreeLibrary(x)
Definition: compat.h:405
#define SetLastError(x)
Definition: compat.h:409
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
HMODULE hModule
Definition: animate.c:44

Referenced by START_TEST().

◆ testLoadLibraryEx()

static void testLoadLibraryEx ( void  )
static

Definition at line 306 of file module.c.

307 {
308  CHAR path[MAX_PATH];
310  HANDLE hfile;
311  BOOL ret;
312 
313  hfile = CreateFileA("testfile.dll", GENERIC_READ | GENERIC_WRITE,
316  ok(hfile != INVALID_HANDLE_VALUE, "Expected a valid file handle\n");
317 
318  /* NULL lpFileName */
319  SetLastError(0xdeadbeef);
321  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
324  "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
325 
326  /* empty lpFileName */
327  SetLastError(0xdeadbeef);
328  hmodule = LoadLibraryExA("", NULL, 0);
329  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
331  GetLastError() == ERROR_INVALID_PARAMETER /* win8 */,
332  "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %d\n", GetLastError());
333 
334  /* hFile is non-NULL */
335  SetLastError(0xdeadbeef);
336  hmodule = LoadLibraryExA("testfile.dll", hfile, 0);
337  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
338  todo_wine
339  {
341  GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
342  "Unexpected last error, got %d\n", GetLastError());
343  }
344 
345  SetLastError(0xdeadbeef);
346  hmodule = LoadLibraryExA("testfile.dll", (HANDLE)0xdeadbeef, 0);
347  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
348  todo_wine
349  {
351  GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
352  "Unexpected last error, got %d\n", GetLastError());
353  }
354 
355  /* try to open a file that is locked */
356  SetLastError(0xdeadbeef);
357  hmodule = LoadLibraryExA("testfile.dll", NULL, 0);
358  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
359  todo_wine
360  {
362  "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
363  }
364 
365  /* lpFileName does not matter */
366  if (is_unicode_enabled)
367  {
368  SetLastError(0xdeadbeef);
369  hmodule = LoadLibraryExA(NULL, hfile, 0);
370  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
372  GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
373  "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
374  }
375 
376  CloseHandle(hfile);
377 
378  /* load empty file */
379  SetLastError(0xdeadbeef);
381  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
382  todo_wine
383  {
385  "Expected ERROR_FILE_INVALID, got %d\n", GetLastError());
386  }
387 
388  DeleteFileA("testfile.dll");
389 
391  if (path[lstrlenA(path) - 1] != '\\')
392  lstrcatA(path, "\\");
393  lstrcatA(path, "kernel32.dll");
394 
395  /* load kernel32.dll with an absolute path */
396  SetLastError(0xdeadbeef);
398  ok(hmodule != 0, "Expected valid module handle\n");
399  ok(GetLastError() == 0xdeadbeef ||
401  "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n", GetLastError());
402 
403  /* try invalid file handle */
404  SetLastError(0xdeadbeef);
405  hmodule = LoadLibraryExA(path, (HANDLE)0xdeadbeef, 0);
406  if (!hmodule) /* succeeds on xp and older */
407  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
408 
410 
411  /* load kernel32.dll with no path */
412  SetLastError(0xdeadbeef);
414  ok(hmodule != 0, "Expected valid module handle\n");
415  ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
416 
418 
420  if (path[lstrlenA(path) - 1] != '\\')
421  lstrcatA(path, "\\");
422  lstrcatA(path, "kernel32.dll");
423 
424  /* load kernel32.dll with an absolute path that does not exist */
425  SetLastError(0xdeadbeef);
427  todo_wine
428  {
429  ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
430  }
432  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
433 
434  /* Free the loaded dll when it's the first time this dll is loaded
435  in process - First time should pass, second fail */
436  SetLastError(0xdeadbeef);
438  ok(hmodule != 0, "Expected valid module handle\n");
439 
440  SetLastError(0xdeadbeef);
442  ok(ret, "Expected to be able to free the module, failed with %d\n", GetLastError());
443  SetLastError(0xdeadbeef);
445  ok(!ret, "Unexpected ability to free the module, failed with %d\n", GetLastError());
446 
447  /* load with full path, name without extension */
449  if (path[lstrlenA(path) - 1] != '\\')
450  lstrcatA(path, "\\");
451  lstrcatA(path, "kernel32");
453  ok(hmodule != NULL, "got %p\n", hmodule);
455 
456  /* same with alterate search path */
458  ok(hmodule != NULL, "got %p\n", hmodule);
460 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:339
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
static HMODULE hmodule
Definition: rasapi.c:29
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define FreeLibrary(x)
Definition: compat.h:405
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define todo_wine
Definition: test.h:154
static BOOL is_unicode_enabled
Definition: module.c:35
#define GENERIC_READ
Definition: compat.h:124
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define CREATE_ALWAYS
Definition: disk.h:72
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
Definition: services.c:325
#define ERROR_FILE_INVALID
Definition: winerror.h:585
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399

Referenced by START_TEST().

◆ testNestedLoadLibraryA()

static void testNestedLoadLibraryA ( void  )
static

Definition at line 226 of file module.c.

227 {
228  static const char dllname[] = "shell32.dll";
229  char path1[MAX_PATH], path2[MAX_PATH];
230  HMODULE hModule1, hModule2, hModule3;
231 
232  /* This is not really a Windows conformance test, but more a Wine
233  * regression test. Wine's builtin dlls can be loaded from multiple paths,
234  * and this test tries to make sure that Wine does not get confused and
235  * really unloads the Unix .so file at the right time. Failure to do so
236  * will result in the dll being unloadable.
237  * This test must be done with a dll that can be unloaded, which means:
238  * - it must not already be loaded
239  * - it must not have a 16-bit counterpart
240  */
241  GetWindowsDirectoryA(path1, sizeof(path1));
242  strcat(path1, "\\system\\");
243  strcat(path1, dllname);
244  hModule1 = LoadLibraryA(path1);
245  if (!hModule1)
246  {
247  /* We must be on Windows, so we cannot test */
248  return;
249  }
250 
251  GetWindowsDirectoryA(path2, sizeof(path2));
252  strcat(path2, "\\system32\\");
253  strcat(path2, dllname);
254  hModule2 = LoadLibraryA(path2);
255  ok(hModule2 != NULL, "LoadLibrary(%s) failed\n", path2);
256 
257  /* The first LoadLibrary() call may have registered the dll under the
258  * system32 path. So load it, again, under the '...\system\...' path so
259  * Wine does not immediately notice that it is already loaded.
260  */
261  hModule3 = LoadLibraryA(path1);
262  ok(hModule3 != NULL, "LoadLibrary(%s) failed\n", path1);
263 
264  /* Now fully unload the dll */
265  ok(FreeLibrary(hModule3), "FreeLibrary() failed\n");
266  ok(FreeLibrary(hModule2), "FreeLibrary() failed\n");
267  ok(FreeLibrary(hModule1), "FreeLibrary() failed\n");
268  ok(GetModuleHandleA(dllname) == NULL, "%s was not fully unloaded\n", dllname);
269 
270  /* Try to load the dll again, if refcounting is ok, this should work */
271  hModule1 = LoadLibraryA(path1);
272  ok(hModule1 != NULL, "LoadLibrary(%s) failed\n", path1);
273  if (hModule1 != NULL)
274  ok(FreeLibrary(hModule1), "FreeLibrary() failed\n");
275 }
static const WCHAR path2[]
Definition: path.c:29
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR path1[]
Definition: path.c:28
#define FreeLibrary(x)
Definition: compat.h:405
#define MAX_PATH
Definition: compat.h:26
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define ok(value,...)
Definition: atltest.h:57
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336

Referenced by START_TEST().

Variable Documentation

◆ cb

Definition at line 32 of file module.c.

◆ dll_image

const { ... } dll_image

Referenced by create_test_dll().

◆ dos

◆ is_unicode_enabled

BOOL is_unicode_enabled = TRUE
static

◆ LPSTR

Definition at line 26 of file module.c.

◆ LPWSTR

Definition at line 27 of file module.c.

◆ modinfo

HMODULE MODULEINFO* modinfo

Definition at line 32 of file module.c.

Referenced by test_pe_checksum().

◆ module

◆ nt

◆ section

Definition at line 51 of file module.c.