网站首页  词典首页

请输入您要查询的函数:

 

术语 loadlibraryex
释义 LoadLibraryEx
语法:
C++
HMODULE WINAPI LoadLibraryEx(
__in LPCTSTR lpFileName,
__reserved HANDLE hFile,
__in DWORD dwFlags
);
LoadLibraryEx函数
加载到调用进程的地址空间指定的模块。指定的模块可能导致其他模块被加载。
参数
lpFileName [in]
该模块的名称。这可以是一个库模块(。dll文件)或可执行模块(。exe文件)。此名称是该模块的文件名,它是不相关的名称库中存储模块本身,如在模块定义关键字指定库(。def)文件。
如果该字符串指定完整的路径,该函数只搜索的模块路径。
如果字符串没有指定路径或相对路径的模块名称,该函数使用标准的检索策略,来寻找模块有更多信息,请参见备注。
如果该函数找不到模块,功能失败。当指定的路径,一定要使用反斜杠(\\),而不是正斜杠(/)。欲了解更多有关路径的信息,请参见命名文件或目录。
如果该字符串指定的路径没有一个模块的名称和文件扩展名被省略,函数附加默认库推广的。dll的模块名称。为了防止附加功能。dll文件的模块名称,包括一个尾随(。)模块中的名称字符串点字符。
如果加载到地址空间中指定的模块会导致系统加载其他相关的模块,功能可以使用标准的搜索策略或候补检索策略,来找到这些模块。更多信息见备注。
如果指定的模块。exe文件,静态导入不加载,而是模块被加载,如果DONT_RESOLVE_DLL_REFERENCES指定。更多信息见dwFlags参数。
hFile
这个参数是保留供将来使用。它必须为NULL。
dwFlags [in]
该采取的行动时加载的模块。如果没有指定标志,这个函数的行为是完全相同的LoadLibrary函数。此参数可以是下列值之一。
ValueMeaning
DONT_RESOLVE_DLL_REFERENCES
0x00000001If此值时,和可执行模块是一个DLL,系统并没有要求进程和线程初始化和终止的DllMain。此外,这个制度不加载额外的由指定的模块引用的可执行模块。
注意不要使用此值,只是为了向下兼容。如果您计划访问数据或只在DLL资源,使用LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE或LOAD_LIBRARY_AS_IMAGE_RESOURCE或两者兼而有之。否则,作为加载DLL或可执行模块使用LoadLibrary函数库。
LOAD_IGNORE_CODE_AUTHZ_LEVEL
0x00000010If使用此值,系统不检查AppLocker规则或申请DLL的软件限制策略。这个动作只适用于该DLL被加载,而不是其家属。此值建议在安装程序必须运行在安装过程中提取的DLL使用。
Server 2008中,Windows Vista中的Windows Server 2003和Windows XP:AppLocker已在Windows 7和Windows Server 2008 R2的推出Windows。
Windows 2000中:此值,直到Windows XP的支持。
LOAD_LIBRARY_AS_DATAFILE
0x00000002If使用此值,系统映射到调用进程的虚拟地址空间的文件,好像它是一个数据文件。不采取任何行动来执行或准备执行的映射文件。因此,您不能使用此DLL调用等GetModuleFileName,GetModuleHandle或调用GetProcAddress函数。使用此值会导致写入只读存储器,以提高访问冲突。 Use this flag when you want to load a DLL only to extract messages or resources from it.
此值可用于LOAD_LIBRARY_AS_IMAGE_RESOURCE。有关更多信息,请参见备注。
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
0x00000040Similar的LOAD_LIBRARY_AS_DATAFILE,但该DLL文件在磁盘上开放供独占写访问。因此,其他进程不能打开该DLL文件进行写访问,而它是在使用。然而,该DLL仍然可以打开其他进程。
此值可用于LOAD_LIBRARY_AS_IMAGE_RESOURCE。有关更多信息,请参见备注。
Windows Server 2003和Windows XP/2000操作系统:此值不支持,直到Windows Vista的。
LOAD_LIBRARY_AS_IMAGE_RESOURCE
0x00000020If使用此值,系统映射到进程的虚拟地址空间作为图像文件的文件。不过,加载程序不加载静态import 或执行其他通常的初始化步骤。使用此标志时,您希望加载DLL只从中提取的信息或资源。
除非该应用程序在图像上的布局而定,此值应使用或者LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE或LOAD_LIBRARY_AS_DATAFILE。有关详细信息,请参见备注部分。
Windows Server 2003和Windows XP/2000操作系统:此值不支持,直到Windows Vista的。
LOAD_WITH_ALTERED_SEARCH_PATH
0x00000008If此值是使用和lpFileName指定的绝对路径,系统将使用备用文件搜索策略在备注一节中讨论寻找相关的指定模块的原因是加载可执行模块。如果此值是使用和lpFileName指定一个相对路径,则行为是不确定的。
如果此值不使用,或者如果lpFileName没有指定路径,系统将使用标准的搜索战略的备注部分讨论,以找到相关的指定模块的原因是加载可执行模块。
返回值
如果函数成功,返回值是一个句柄加载的模块。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
如果lpFileName不包括道路,有多个具有相同的基本名称和扩展加载的模块,该函数返回的句柄这是先加载模块。
调用进程可以使用的处理这个函数返回鉴别的调用GetProcAddress,FindResource电话模块,和LoadResource功能。
要启用或禁用错误DLL加载过程中加载显示的消息,请使用SetErrorMode功能。
该LoadLibraryEx函数非常相似LoadLibrary函数。差异包括一个可选的行为的一套LoadLibraryEx提供。首先,LoadLibraryEx可以加载不调用DLL的DllMain函数的DLL模块。二,LoadLibraryEx可以使用两种文件的检索策略可以发现与指定的模块相关模块。第三,LoadLibraryEx可以加载在一个是为在该模块将永远不会被执行的情况最优化的方式模块,加载的模块,它是一个数据文件。由您选择dwFlags参数设置这些可选的行为,如果dwFlags是零,LoadLibraryEx行为相同调用LoadLibrary。
该LOAD_LIBRARY_AS_DATAFILE,LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE和LOAD_LIBRARY_AS_IMAGE_RESOURCE价值观影响每个进程的引用计数,并指定模块加载。如果这些值的任何指定的dwFlags参数,该模块是否已被作为可执行进程加载的DLL加载程序检查。如果是这样,这意味着该模块已映射到调用进程的虚拟地址空间。在这种情况下,LoadLibraryEx返回的句柄DLL和增量该DLL的引用计数。如果DLL模块尚未加载一个DLL时,系统映射作为数据或图像文件和DLL中没有一个可执行模块。在这种情况下,LoadLibraryEx返回的句柄加载的数据或图像文件,但不增加的模块的引用计数。
如果LoadLibraryEx调用两次与LOAD_LIBRARY_AS_DATAFILE,LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE,同一文件或LOAD_LIBRARY_AS_IMAGE_RESOURCE的dwFlags参数指定的,两个单独的映射创建该文件。
当LOAD_LIBRARY_AS_IMAGE_RESOURCE值时,该模块被加载一个使用移植可执行(PE)的一段路扩建形象。相对(RvA)的虚拟地址没有被映射到磁盘地址,因此资源可以更快地从模块检索。指定LOAD_LIBRARY_AS_IMAGE_RESOURCE阻止修改,而这是其他进程加载的模块。
除非一个应用程序映射的具体形象特征,取决于LOAD_LIBRARY_AS_IMAGE_RESOURCE值应使用或者LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE或LOAD_LIBRARY_AS_DATAFILE。这使得装载机选择是否要加载图像资源或数据文件中选择两个选项,该模块使系统能更有效地共享网页。如FindResource资源的功能可以使用映射。
要确定如何模块被加载,下列宏使用一个测试处理LoadLibraryEx返回。
#define LDR_IS_DATAFILE(handle) (((ULONG_PTR)(handle)) & (ULONG_PTR)1)
#define LDR_IS_IMAGEMAPPING(handle) (((ULONG_PTR)(handle)) & (ULONG_PTR)2)
#define LDR_IS_RESOURCE(handle) (LDR_IS_IMAGEMAPPING(x) || LDR_IS_DATAFILE(x))
下表描述了这些宏。
MacroDescription
LDR_IS_DATAFILE(处理如果此宏返回TRUE),该模块是与LOAD_LIBRARY_AS_DATAFILE或LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE加载。
LDR_IS_IMAGEMAPPING(处理如果此宏返回TRUE),该模块是与LOAD_LIBRARY_AS_IMAGE_RESOURCE加载。
LDR_IS_RESOURCE(处理如果此宏返回TRUE),该模块是与LOAD_LIBRARY_AS_IMAGE_RESOURCE,要么LOAD_LIBRARY_AS_DATAFILE或LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE加载。
FreeLibrary函数应当用于自由加载模块,不论是否加载模块造成的引用计数递增。如果模块是作为数据或图像文件中加载,映射被破坏,但没有引用计数递减。否则,该DLL引用计数减1。因此,它是安全的调用任何处理LoadLibraryEx返回FreeLibrary。
这是不安全的调用DllMain中LoadLibraryEx。有关详细信息,请参阅在DllMain备注部分。
该LoadLibraryEx函数执行一个标准的搜索模块的文件名,如果没有指定路径和文件名的基础不匹配的加载模块的基本文件名,或者有一个指定的路径,但LOAD_WITH_ALTERED_SEARCH_PATH没有使用。
如果使用相对路径,整个相对路径追加到每个DLL的搜索路径列表标记。要加载的相对路径没有任何其他路径搜索模块,使用GetFullPathName获得nonrelative的道路,并要求与nonrelative路径LoadLibraryEx。如果模块被加载为一个数据文件的相对路径与开始。\\或.. \\,相对路径是绝对路径的待遇。
如果路径指定的dwFlags设置为LOAD_WITH_ALTERED_SEARCH_PATH的LoadLibraryEx函数使用一个备用文件检索策略。指定的路径必须是绝对路径。 LOAD_WITH_ALTERED_SEARCH_PATH无法使用相对路径。如需更多关于替代的搜索战略的信息,请参见动态链接库搜索顺序。
搜索路径可以改变使用SetDllDirectory功能。这个解决方案是建议,而不是使用SetCurrentDirectory或硬编码的完整路径的DLL。
如果指定的路径有一个重定向与应用程序关联的文件,为应用程序目录模块LoadLibraryEx函数搜索。如果模块在应用程序目录中,LoadLibraryEx忽略路径规范并加载的应用程序目录模块。如果模块中不存在应用程序目录,函数加载从指定的目录模块。有关更多信息,请参见动态链接库重定向。
如果您调用的程序集名称LoadLibraryEx没有路径规范和大会在系统兼容清单中列出的通话会被自动重定向到边并排组装。
的Visual C + +:的Visual C + +编译器支持的语法,使您可以声明线程局部变量:_declspec(线程)。如果您使用的DLL此语法,您将无法加载DLL明确使用的Windows版本LoadLibraryEx前到Windows Vista。如果您的DLL会被载入明确,您必须使用线程,而不是_declspec(线程本地存储功能)。有关示例,请参阅使用的动态链接库线程本地存储。
安全备注
LOAD_LIBRARY_AS_DATAFILE不会阻止修改,而这是其他进程加载的模块。因为这可以使您的应用程序更不安全,您应该使用LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE而不是LOAD_LIBRARY_AS_DATAFILE时加载的模块的数据文件,除非您特别需要使用LOAD_LIBRARY_AS_DATAFILE。指定LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE阻止修改,而这是其他进程加载的模块。不要指定LOAD_LIBRARY_AS_DATAFILE在同一调用LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE。
不要使用SearchPath函数来检索随后LoadLibraryEx调用DLL的路径。该SearchPath函数使用一个不同的搜寻比LoadLibraryEx秩序,它不使用安全搜索模式的过程,这是明确的,除非通过调用BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE SetSearchPathMode启用。因此,SearchPath可能是第一次搜索用户的当前工作目录指定的DLL。如果一个攻击者复制到当前的工作目录中的恶意DLL的版本,由SearchPath检索路径将指向恶意DLL,它LoadLibraryEx然后加载。
不要对一个调用LoadLibrary为基础的作业系统版本的假设搜索一个DLL。如果应用程序是在一个环境中运行该DLL在合法不存在,而是恶意的DLL版本的搜索路径,DLL的恶意版本可能会加载。相反,使用获取系统版本所描述的推荐技术。
实例
有关示例,请参见期望,错误代码数字的文本。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesLoadLibraryExW(Unicode)和LoadLibraryExA(ANSI)的
参见
的DllMain
动态链接库函数
FindResource
FreeLibrary
调用GetProcAddress
GetSystemDirectory
GetWindowsDirectory
调用LoadLibrary
LoadResource
OpenFile
运行时动态链接
SearchPath
SetDllDirectory
SetErrorMode
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==LoadLibraryEx Function
Loads the specified module into the address space of the calling process. The specified module may cause other modules to be loaded.
Syntax
C++
HMODULE WINAPI LoadLibraryEx(
__in LPCTSTR lpFileName,
__reserved HANDLE hFile,
__in DWORD dwFlags
);
Parameters
lpFileName [in]
The name of the module. This can be a library module (a .dll file) or an executable module (an .exe file). This name is the file name of the module; it is not related to the name stored in a library module itself, as specified by the LIBRARY keyword in the module-definition (.def) file.
If the string specifies a full path, the function searches only that path for the module.
If the string specifies module name without a path or with a relative path, the function uses a standard search strategy to find the module; for more information, see Remarks.
If the function cannot find the module, the function fails. When specifying a path, be sure to use backslashes (\\), not forward slashes (/). For more information about paths, see Naming a File or Directory .
If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name string.
If loading the specified module into the address space causes the system to load other associated modules, the function can use either the standard search strategy or an alternate search strategy to find those modules. See the Remarks for more information.
If the specified module is an .exe file, static imports are not loaded; instead, the module is loaded as if DONT_RESOLVE_DLL_REFERENCES was specified. See the dwFlags parameter for more information.
hFile
This parameter is reserved for future use. It must be NULL.
dwFlags [in]
The action to be taken when loading the module. If no flags are specified, the behavior of this function is identical to that of the LoadLibrary function. This parameter can be one of the following values.
ValueMeaning
DONT_RESOLVE_DLL_REFERENCES
0x00000001If this value is used, and the executable module is a DLL, the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module.
Note Do not use this value; it is provided only for backwards compatibility. If you are planning to access only data or resources in the DLL, use LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_IMAGE_RESOURCE or both. Otherwise, load the library as a DLL or executable module using the LoadLibrary function.
LOAD_IGNORE_CODE_AUTHZ_LEVEL
0x00000010If this value is used, the system does not check AppLocker rules or apply Software Restriction Policies for the DLL. This action applies only to the DLL being loaded and not to its dependents. This value is recommended for use in setup programs that must run extracted DLLs during installation.
Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: AppLocker was introduced in Windows 7 and Windows Server 2008 R2.
Windows 2000: This value is not supported until Windows XP.
LOAD_LIBRARY_AS_DATAFILE
0x00000002If this value is used, the system maps the file into the calling process's virtual address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file. Therefore, you cannot call functions like GetModuleFileName , GetModuleHandle or GetProcAddress with this DLL. Using this value causes writes to read-only memory to raise an access violation. Use this flag when you want to load a DLL only to extract messages or resources from it.
This value can be used with LOAD_LIBRARY_AS_IMAGE_RESOURCE. For more information, see Remarks.
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
0x00000040Similar to LOAD_LIBRARY_AS_DATAFILE, except that the DLL file on the disk is opened for exclusive write access. Therefore, other processes cannot open the DLL file for write access while it is in use. However, the DLL can still be opened by other processes.
This value can be used with LOAD_LIBRARY_AS_IMAGE_RESOURCE. For more information, see Remarks.
Windows Server 2003 and Windows XP/2000: This value is not supported until Windows Vista.
LOAD_LIBRARY_AS_IMAGE_RESOURCE
0x00000020If this value is used, the system maps the file into the process's virtual address space as an image file. However, the loader does not load the static imports or perform the other usual initialization steps. Use this flag when you want to load a DLL only to extract messages or resources from it.
Unless the application depends on the image layout, this value should be used with either LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_DATAFILE. For more information, see the Remarks section.
Windows Server 2003 and Windows XP/2000: This value is not supported until Windows Vista.
LOAD_WITH_ALTERED_SEARCH_PATH
0x00000008If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. If this value is used and lpFileName specifies a relative path, the behavior is undefined.
If this value is not used, or if lpFileName does not specify a path, the system uses the standard search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded.

Return Value
If the function succeeds, the return value is a handle to the loaded module.
If the function fails, the return value is NULL. To get extended error information, call GetLastError .
Remarks
If lpFileName does not include a path and there is more than one loaded module with the same base name and extension, the function returns a handle to the module that was loaded first.
The calling process can use the handle returned by this function to identify the module in calls to the GetProcAddress , FindResource , and LoadResource functions.
To enable or disable error messages displayed by the loader during DLL loads, use the SetErrorMode function.
The LoadLibraryEx function is very similar to the LoadLibrary function. The differences consist of a set of optional behaviors that LoadLibraryEx provides. First, LoadLibraryEx can load a DLL module without calling the DllMain function of the DLL. Second, LoadLibraryEx can use either of two file search strategies to find modules that are associated with the specified module. Third, LoadLibraryEx can load a module in a way that is optimized for the case where the module will never be executed, loading the module as if it were a data file. You select these optional behaviors by setting the dwFlags parameter; if dwFlags is zero, LoadLibraryEx behaves identically to LoadLibrary.
The LOAD_LIBRARY_AS_DATAFILE, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE, and LOAD_LIBRARY_AS_IMAGE_RESOURCE values affect the per-process reference count and the loading of the specified module. If any of these values is specified for the dwFlags parameter, the loader checks whether the module was already loaded by the process as an executable DLL. If so, this means that the module is already mapped into the virtual address space of the calling process. In this case, LoadLibraryEx returns a handle to the DLL and increments the DLL reference count. If the DLL module was not already loaded as a DLL, the system maps the module as a data or image file and not as a executable DLL. In this case, LoadLibraryEx returns a handle to the loaded data or image file but does not increment the reference count for the module.
If LoadLibraryEx is called twice for the same file with LOAD_LIBRARY_AS_DATAFILE, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE, or LOAD_LIBRARY_AS_IMAGE_RESOURCE specified for the dwFlags parameter, two separate mappings are created for the file.
When the LOAD_LIBRARY_AS_IMAGE_RESOURCE value is used, the module is loaded as an image using portable executable (PE) section alignment expansion. Relative virtual addresses (RVA) do not have to be mapped to disk addresses, so resources can be more quickly retrieved from the module. Specifying LOAD_LIBRARY_AS_IMAGE_RESOURCE prevents other processes from modifying the module while it is loaded.
Unless an application depends on specific image mapping characteristics, the LOAD_LIBRARY_AS_IMAGE_RESOURCE value should be used with either LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_DATAFILE. This allows the loader to choose whether to load the module as an image resource or a data file, selecting whichever option enables the system to share pages more effectively. Resource functions such as FindResource can use either mapping.
To determine how a module was loaded, use one of the following macros to test the handle returned by LoadLibraryEx.
#define LDR_IS_DATAFILE(handle) (((ULONG_PTR)(handle)) & (ULONG_PTR)1)
#define LDR_IS_IMAGEMAPPING(handle) (((ULONG_PTR)(handle)) & (ULONG_PTR)2)
#define LDR_IS_RESOURCE(handle) (LDR_IS_IMAGEMAPPING(x) || LDR_IS_DATAFILE(x))
The following table describes these macros.
MacroDescription
LDR_IS_DATAFILE(handle)If this macro returns TRUE, the module was loaded with LOAD_LIBRARY_AS_DATAFILE or LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE.
LDR_IS_IMAGEMAPPING(handle)If this macro returns TRUE, the module was loaded with LOAD_LIBRARY_AS_IMAGE_RESOURCE.
LDR_IS_RESOURCE(handle)If this macro returns TRUE, the module was loaded with LOAD_LIBRARY_AS_IMAGE_RESOURCE and either LOAD_LIBRARY_AS_DATAFILE or LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE.

The FreeLibrary function should be used to free a loaded module, whether or not loading the module caused its reference count to be incremented. If the module was loaded as a data or image file, the mapping is destroyed but the reference count is not decremented. Otherwise, the DLL reference count is decremented. Therefore, it is safe to call FreeLibrary with any handle returned by LoadLibraryEx.
It is not safe to call LoadLibraryEx from DllMain. For more information, see the Remarks section in DllMain.
The LoadLibraryEx function performs a standard search for modules if the file name is specified without a path and the base file name does not match the base file name of a loaded module, or there is a path specified but LOAD_WITH_ALTERED_SEARCH_PATH is not used.
If a relative path is used, the entire relative path is appended to every token in the DLL search path list. To load a module from a relative path without searching any other path, use GetFullPathName to get a nonrelative path and call LoadLibraryEx with the nonrelative path. If the module is being loaded as a datafile and the relative path that starts with .\\ or ..\\, the relative path is treated as an absolute path.
If a path is specified and dwFlags is set to LOAD_WITH_ALTERED_SEARCH_PATH, the LoadLibraryEx function uses an alternate file search strategy. The specified path must be an absolute path. LOAD_WITH_ALTERED_SEARCH_PATH does not work with relative paths. For more information about alternate search strategies, see Dynamic-Link Library Search Order .
The search path can be altered using the SetDllDirectory function. This solution is recommended instead of using SetCurrentDirectory or hard-coding the full path to the DLL.
If a path is specified and there is a redirection file associated with the application, the LoadLibraryEx function searches for the module in the application directory. If the module exists in the application directory, LoadLibraryEx ignores the path specification and loads the module from the application directory. If the module does not exist in the application directory, the function loads the module from the specified directory. For more information, see Dynamic Link Library Redirection .
If you call LoadLibraryEx with the name of an assembly without a path specification and the assembly is listed in the system compatible manifest, the call is automatically redirected to the side-by-side assembly.
Visual C++: The Visual C++ compiler supports a syntax that enables you to declare thread-local variables: _declspec(thread). If you use this syntax in a DLL, you will not be able to load the DLL explicitly using LoadLibraryEx on versions of Windows prior to Windows Vista. If your DLL will be loaded explicitly, you must use the thread local storage functions instead of _declspec(thread). For an example, see Using Thread Local Storage in a Dynamic Link Library .
Security Remarks
LOAD_LIBRARY_AS_DATAFILE does not prevent other processes from modifying the module while it is loaded. Because this can make your application less secure, you should use LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE instead of LOAD_LIBRARY_AS_DATAFILE when loading a module as a data file, unless you specifically need to use LOAD_LIBRARY_AS_DATAFILE. Specifying LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE prevents other processes from modifying the module while it is loaded. Do not specify LOAD_LIBRARY_AS_DATAFILE and LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE in the same call.
Do not use the SearchPath function to retrieve a path to a DLL for a subsequent LoadLibraryEx call. The SearchPath function uses a different search order than LoadLibraryEx and it does not use safe process search mode unless this is explicitly enabled by calling SetSearchPathMode with BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE. Therefore, SearchPath is likely to first search the user’s current working directory for the specified DLL. If an attacker has copied a malicious version of a DLL into the current working directory, the path retrieved by SearchPath will point to the malicious DLL, which LoadLibraryEx will then load.
Do not make assumptions about the operating system version based on a LoadLibrary call that searches for a DLL. If the application is running in an environment where the DLL is legitimately not present but a malicious version of the DLL is in the search path, the malicious version of the DLL may be loaded. Instead, use the recommended techniques described in Getting the System Version .
Examples
For an example, see Looking Up Text for Error Code Numbers .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesLoadLibraryExW (Unicode) and LoadLibraryExA (ANSI)
See Also
DllMain
Dynamic-Link Library Functions
FindResource
FreeLibrary
GetProcAddress
GetSystemDirectory
GetWindowsDirectory
LoadLibrary
LoadResource
OpenFile
Run-Time Dynamic Linking
SearchPath
SetDllDirectory
SetErrorMode
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms684179(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:25:36