<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.9.1"/> <title>Crashpad: util/win/get_function.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { init_search(); }); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Crashpad </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.9.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_23ec12649285f9fabf3a6b7380226c28.html">util</a></li><li class="navelem"><a class="el" href="dir_04861af0646e74845232399e73d584d9.html">win</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#namespaces">Namespaces</a> | <a href="#define-members">Macros</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">get_function.h File Reference</div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><code>#include <windows.h></code><br /> </div><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a> Namespaces</h2></td></tr> <tr class="memitem:namespacecrashpad"><td class="memItemLeft" align="right" valign="top">  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespacecrashpad.html">crashpad</a></td></tr> <tr class="memdesc:namespacecrashpad"><td class="mdescLeft"> </td><td class="mdescRight">The main namespace. <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:namespacecrashpad_1_1internal"><td class="memItemLeft" align="right" valign="top">  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespacecrashpad_1_1internal.html">crashpad::internal</a></td></tr> <tr class="memdesc:namespacecrashpad_1_1internal"><td class="mdescLeft"> </td><td class="mdescRight">The internal namespace, not for public use. <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> Macros</h2></td></tr> <tr class="memitem:a0997574e7522725516242d78632ed686"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="get__function_8h.html#a0997574e7522725516242d78632ed686">GET_FUNCTION</a>(library, function)</td></tr> <tr class="memdesc:a0997574e7522725516242d78632ed686"><td class="mdescLeft"> </td><td class="mdescRight">Returns a function pointer to a named function in a library without requiring that it be found. <a href="#a0997574e7522725516242d78632ed686">More...</a><br /></td></tr> <tr class="separator:a0997574e7522725516242d78632ed686"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae87bc4c8800c7e6f35c06bf48cb636f3"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="get__function_8h.html#ae87bc4c8800c7e6f35c06bf48cb636f3">GET_FUNCTION_REQUIRED</a>(library, function)</td></tr> <tr class="memdesc:ae87bc4c8800c7e6f35c06bf48cb636f3"><td class="mdescLeft"> </td><td class="mdescRight">Returns a function pointer to a named function in a library, requiring that it be found. <a href="#ae87bc4c8800c7e6f35c06bf48cb636f3">More...</a><br /></td></tr> <tr class="separator:ae87bc4c8800c7e6f35c06bf48cb636f3"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:aa982a8cad0e72cddf1989d135db3c338"><td class="memItemLeft" align="right" valign="top">FARPROC </td><td class="memItemRight" valign="bottom"><a class="el" href="namespacecrashpad_1_1internal.html#aa982a8cad0e72cddf1989d135db3c338">crashpad::internal::GetFunctionInternal</a> (const wchar_t *library, const char *function, bool required)</td></tr> <tr class="memdesc:aa982a8cad0e72cddf1989d135db3c338"><td class="mdescLeft"> </td><td class="mdescRight">Returns a function pointer to a named function in a library. <a href="#aa982a8cad0e72cddf1989d135db3c338">More...</a><br /></td></tr> <tr class="separator:aa982a8cad0e72cddf1989d135db3c338"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a334a660002ce6e6f06432ccf7d3cc50f"><td class="memTemplParams" colspan="2">template<typename FunctionType > </td></tr> <tr class="memitem:a334a660002ce6e6f06432ccf7d3cc50f"><td class="memTemplItemLeft" align="right" valign="top">FunctionType * </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespacecrashpad_1_1internal.html#a334a660002ce6e6f06432ccf7d3cc50f">crashpad::internal::GetFunction</a> (const wchar_t *library, const char *function, bool required)</td></tr> <tr class="memdesc:a334a660002ce6e6f06432ccf7d3cc50f"><td class="mdescLeft"> </td><td class="mdescRight">Returns a function pointer to a named function in a library. <a href="#a334a660002ce6e6f06432ccf7d3cc50f">More...</a><br /></td></tr> <tr class="separator:a334a660002ce6e6f06432ccf7d3cc50f"><td class="memSeparator" colspan="2"> </td></tr> </table> <h2 class="groupheader">Macro Definition Documentation</h2> <a class="anchor" id="a0997574e7522725516242d78632ed686"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define GET_FUNCTION</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname">library, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"> </td> <td class="paramname">function </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <b>Value:</b><div class="fragment"><div class="line">crashpad::internal::GetFunction<decltype(function)>( \</div> <div class="line"> library, #<span class="keyword">function</span>, <span class="keyword">false</span>)</div> </div><!-- fragment --> <p>Returns a function pointer to a named function in a library without requiring that it be found. </p> <p>If the library or function cannot be found, this will return <code>nullptr</code>. This macro is intended to be used to access functions that may not be available at runtime.</p> <p>This macro returns a properly-typed function pointer. It is expected to be used in this way: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> static const auto get_named_pipe_client_process_id =</div> <div class="line"><a name="l00002"></a><span class="lineno"> 2</span>  GET_FUNCTION(L"kernel32.dll", ::GetNamedPipeClientProcessId);</div> <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> if (get_named_pipe_client_process_id) {</div> <div class="line"><a name="l00004"></a><span class="lineno"> 4</span>  BOOL rv = get_named_pipe_client_process_id(pipe, &client_process_id);</div> <div class="line"><a name="l00005"></a><span class="lineno"> 5</span> }</div> </div><!-- fragment --><p>This accesses <em>library</em> by calling <code>LoadLibrary()</code> and is subject to the same restrictions as that function. Notably, it can’t be used from a <code>DllMain()</code> entry point.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramdir">[in]</td><td class="paramname">library</td><td>The library to search in. </td></tr> <tr><td class="paramdir">[in]</td><td class="paramname">function</td><td>The function to search for. A leading <code>::</code> is recommended when a wrapper function of the same name is present.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>A pointer to the requested function on success, or <code>nullptr</code> on failure.</dd></dl> <dl class="section see"><dt>See also</dt><dd><a class="el" href="get__function_8h.html#ae87bc4c8800c7e6f35c06bf48cb636f3" title="Returns a function pointer to a named function in a library, requiring that it be found...">GET_FUNCTION_REQUIRED</a> </dd></dl> </div> </div> <a class="anchor" id="ae87bc4c8800c7e6f35c06bf48cb636f3"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define GET_FUNCTION_REQUIRED</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname">library, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"> </td> <td class="paramname">function </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <b>Value:</b><div class="fragment"><div class="line">crashpad::internal::GetFunction<decltype(function)>( \</div> <div class="line"> library, #<span class="keyword">function</span>, <span class="keyword">true</span>)</div> </div><!-- fragment --> <p>Returns a function pointer to a named function in a library, requiring that it be found. </p> <p>If the library or function cannot be found, this will trigger a <code>DCHECK</code> 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.</p> <p>This macro returns a properly-typed function pointer. It is expected to be used in this way: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> static const auto nt_query_object =</div> <div class="line"><a name="l00002"></a><span class="lineno"> 2</span>  GET_FUNCTION_REQUIRED(L"ntdll.dll", ::NtQueryObject);</div> <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> NTSTATUS status =</div> <div class="line"><a name="l00004"></a><span class="lineno"> 4</span>  nt_query_object(handle, type, &info, info_length, &return_length);</div> </div><!-- fragment --><p>This accesses <em>library</em> by calling <code>LoadLibrary()</code> and is subject to the same restrictions as that function. Notably, it can’t be used from a <code>DllMain()</code> entry point.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramdir">[in]</td><td class="paramname">library</td><td>The library to search in. </td></tr> <tr><td class="paramdir">[in]</td><td class="paramname">function</td><td>The function to search for. A leading <code>::</code> is recommended when a wrapper function of the same name is present.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>A pointer to the requested function.</dd></dl> <dl class="section see"><dt>See also</dt><dd><a class="el" href="get__function_8h.html#a0997574e7522725516242d78632ed686" title="Returns a function pointer to a named function in a library without requiring that it be found...">GET_FUNCTION</a> </dd></dl> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.9.1 </small></address> </body> </html>