MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / CTL_APICALL ctlInit

Function CTL_APICALL ctlInit

IntelPresentMon/ControlLib/cApiWrapper.cpp:99–155  ·  view source on GitHub ↗

* @brief Control Api Init * * @details * - Control Api Init * * @returns * - CTL_RESULT_SUCCESS * - CTL_RESULT_ERROR_UNINITIALIZED * - CTL_RESULT_ERROR_DEVICE_LOST * - CTL_RESULT_ERROR_INVALID_NULL_POINTER * + `nullptr == pInitDesc` * + `nullptr == phAPIHandle` * - ::CTL_RESULT_ERROR_UNSUPPORTED_VERSION - "Unsupported version" */

Source from the content-addressed store, hash-verified

97* - ::CTL_RESULT_ERROR_UNSUPPORTED_VERSION - "Unsupported version"
98*/
99ctl_result_t CTL_APICALL
100ctlInit(
101 ctl_init_args_t* pInitDesc, ///< [in][out] App's control API version
102 ctl_api_handle_t* phAPIHandle ///< [in][out][release] Control API handle
103 )
104{
105 ctl_result_t result = CTL_RESULT_ERROR_NOT_INITIALIZED;
106
107 // special code - only for ctlInit()
108 if (NULL == hinstLib)
109 {
110 std::vector<wchar_t> strDLLPath;
111 try
112 {
113 strDLLPath.resize(CTL_DLL_PATH_LEN);
114 }
115 catch (std::bad_alloc&)
116 {
117 return CTL_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
118 }
119
120 result = GetControlAPIDLLPath(pInitDesc, strDLLPath.data());
121 if (result == CTL_RESULT_SUCCESS)
122 {
123#ifdef WINDOWS_UWP
124 hinstLib = LoadPackagedLibrary(strDLLPath.data(), 0);
125#else
126 DWORD dwFlags = LOAD_LIBRARY_SEARCH_SYSTEM32;
127#ifdef _DEBUG
128 dwFlags = dwFlags | LOAD_LIBRARY_SEARCH_APPLICATION_DIR;
129#endif
130 hinstLib = LoadLibraryExW(strDLLPath.data(), NULL, dwFlags);
131#endif
132 if (NULL == hinstLib)
133 {
134 result = CTL_RESULT_ERROR_LOAD;
135 }
136 else if (pRuntimeArgs)
137 {
138 ctlSetRuntimePath(pRuntimeArgs);
139 }
140 }
141 }
142
143 HINSTANCE hinstLibPtr = GetLoaderHandle();
144
145 if (NULL != hinstLibPtr)
146 {
147 ctl_pfnInit_t pfnInit = (ctl_pfnInit_t)GetProcAddress(hinstLibPtr, "ctlInit");
148 if (pfnInit)
149 {
150 result = pfnInit(pInitDesc, phAPIHandle);
151 }
152 }
153
154 return result;
155}
156

Callers

nothing calls this directly

Calls 2

GetControlAPIDLLPathFunction · 0.85
GetLoaderHandleFunction · 0.85

Tested by

no test coverage detected