Crashpad
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Loading...
Searching...
No Matches
get_function.h File Reference
#include <windows.h>

Namespaces

namespace  crashpad
 The main namespace.
 
namespace  crashpad::internal
 The internal namespace, not for public use.
 

Macros

#define GET_FUNCTION(library, function)
 Returns a function pointer to a named function in a library without requiring that it be found.
 
#define GET_FUNCTION_REQUIRED(library, function)
 Returns a function pointer to a named function in a library, requiring that it be found.
 

Functions

FARPROC crashpad::internal::GetFunctionInternal (const wchar_t *library, const char *function, bool required)
 Returns a function pointer to a named function in a library.
 
template<typename FunctionType>
FunctionType * crashpad::internal::GetFunction (const wchar_t *library, const char *function, bool required)
 Returns a function pointer to a named function in a library.
 

Macro Definition Documentation

◆ GET_FUNCTION

#define GET_FUNCTION ( library,
function )
Value:
library, #function, false)
FunctionType * GetFunction(const wchar_t *library, const char *function, bool required)
Returns a function pointer to a named function in a library.
Definition get_function.h:47

Returns a function pointer to a named function in a library without requiring that it be found.

If the library or function cannot be found, this will return nullptr. This macro is intended to be used to access functions that may not be available at runtime.

This macro returns a properly-typed function pointer. It is expected to be used in this way:

static const auto get_named_pipe_client_process_id =
GET_FUNCTION(L"kernel32.dll", ::GetNamedPipeClientProcessId);
if (get_named_pipe_client_process_id) {
BOOL rv = get_named_pipe_client_process_id(pipe, &client_process_id);
}
#define GET_FUNCTION(library, function)
Returns a function pointer to a named function in a library without requiring that it be found.
Definition get_function.h:85

This accesses library by calling LoadLibrary() and is subject to the same restrictions as that function. Notably, it can’t be used from a DllMain() entry point.

Parameters
[in]libraryThe library to search in.
[in]functionThe function to search for. A leading :: is recommended when a wrapper function of the same name is present.
Returns
A pointer to the requested function on success, or nullptr on failure.
See also
GET_FUNCTION_REQUIRED

◆ GET_FUNCTION_REQUIRED

#define GET_FUNCTION_REQUIRED ( library,
function )
Value:

Returns a function pointer to a named function in a library, requiring that it be found.

If the library or function cannot be found, this will trigger a DCHECK assertion. This macro is intended to be used to access functions that are always expected to be available at runtime but which are not present in any import library.

This macro returns a properly-typed function pointer. It is expected to be used in this way:

static const auto nt_query_object =
GET_FUNCTION_REQUIRED(L"ntdll.dll", ::NtQueryObject);
NTSTATUS status =
nt_query_object(handle, type, &info, info_length, &return_length);
#define GET_FUNCTION_REQUIRED(library, function)
Returns a function pointer to a named function in a library, requiring that it be found.
Definition get_function.h:117

This accesses library by calling LoadLibrary() and is subject to the same restrictions as that function. Notably, it can’t be used from a DllMain() entry point.

Parameters
[in]libraryThe library to search in.
[in]functionThe function to search for. A leading :: is recommended when a wrapper function of the same name is present.
Returns
A pointer to the requested function.
See also
GET_FUNCTION