bool Module::LoadLibrary() { string path = config[CONF_APPLICATION_LIBRARY]; libHandler = LOAD_LIBRARY(STR(path), LOAD_LIBRARY_FLAGS); if (libHandler == NULL) { string strError = OPEN_LIBRARY_ERROR; FATAL("Unable to open library %s. Error was: %s", STR(path), STR(strError)); return false; } string functionName = (string) config[CONF_APPLICATION_INIT_APPLICATION_FUNCTION]; getApplication = (GetApplicationFunction_t) GET_PROC_ADDRESS(libHandler, STR(functionName)); if (getApplication == NULL) { string strError = OPEN_LIBRARY_ERROR; FATAL("Unable to find %s function. Error was: %s", STR(functionName), STR(strError)); return false; } functionName = (string) config[CONF_APPLICATION_INIT_FACTORY_FUNCTION]; getFactory = (GetFactoryFunction_t) GET_PROC_ADDRESS(libHandler, STR(functionName)); INFO("Module %s loaded", STR(path)); return true; }
int main( int argc, char ** argv ) { int nLibIndex = ParseArgs( argc, argv ); if( nLibIndex == 0 ) return -1; if( g_fDiag ) Diags( argc, argv ); Logger logger; GetLinuxPwd(); for( ; nLibIndex < argc; nLibIndex++ ) { StringList files = GetFileList( argv[nLibIndex] ); for( StringList::const_iterator it=files.begin(); it!=files.end(); ++it ) { std::string library = *it; std::cout << "Loading Library: " << library << std::endl; DllHandle hModule = LOAD_LIBRARY( library.c_str() ); DLERROR_CHECK; if( !hModule ) { std::cout<<"ERROR: Failed to load "<< *it << std::endl; std::cout.flush(); continue; } RunAllFn pRunAll = (RunAllFn)GET_PROC_ADDRESS( hModule, "RunAll" ); if( pRunAll == NULL ) { std::cerr << std::endl << "Function RunAll() not found in library " << library << "!" << std::endl; FREE_LIBRARY( hModule ); continue; } pRunAll( &logger, g_configFileName.c_str() ); FREE_LIBRARY( hModule ); } // next library } // next arg if( g_fCSV ) { try { std::ofstream log(g_logPath.c_str()); GenerateReportCSV( logger, log, g_fNoHeader ); } catch(...) { std::cerr << "Error writing log file " << g_logPath << "!" << std::endl; } } std::cout << std::endl; }
static void __cdecl __scrt_initialize_thread_safe_statics_platform_specific() throw() { InitializeCriticalSectionAndSpinCount(&_Tss_mutex, 4000); // CONDITION_VARIABLE is available via this APISet starting on Windows 8. HMODULE kernel_dll = GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll"); if (kernel_dll == nullptr) { kernel_dll = GetModuleHandleW(L"kernel32.dll"); } if (kernel_dll == nullptr) { __scrt_fastfail(FAST_FAIL_FATAL_APP_EXIT); } #define GET_PROC_ADDRESS(m, f) reinterpret_cast<decltype(f)*>(GetProcAddress(m, _CRT_STRINGIZE(f))) auto const initialize_condition_variable = GET_PROC_ADDRESS(kernel_dll, InitializeConditionVariable); auto const sleep_condition_variable_cs = GET_PROC_ADDRESS(kernel_dll, SleepConditionVariableCS); auto const wake_all_condition_variable = GET_PROC_ADDRESS(kernel_dll, WakeAllConditionVariable); #undef GET_PROC_ADDRESS if (initialize_condition_variable && sleep_condition_variable_cs && wake_all_condition_variable) { _Tss_event = nullptr; initialize_condition_variable(&_Tss_cv); encoded_sleep_condition_variable_cs = __crt_fast_encode_pointer(sleep_condition_variable_cs); encoded_wake_all_condition_variable = __crt_fast_encode_pointer(wake_all_condition_variable); } else { _Tss_event = CreateEventW(NULL, TRUE, FALSE, NULL); if (_Tss_event == nullptr) { __scrt_fastfail(FAST_FAIL_FATAL_APP_EXIT); } } }
void __CGsampler_state::initExtensionFuncs() { # if defined(__APPLE__) || defined(__ADM__) // No "GetProcAddress" required. #else static int funcsInited = 0; if (funcsInited) { // Already called return; } glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) GET_PROC_ADDRESS("glActiveTexture"); if (0 == glActiveTexture) { glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) GET_PROC_ADDRESS("glActiveTextureARB"); } glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) GET_PROC_ADDRESS("glGetBufferSubData"); if (0 == glGetBufferSubData) { glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) GET_PROC_ADDRESS("glGetBufferSubDataARB"); } glBindBuffer = (PFNGLBINDBUFFERPROC) GET_PROC_ADDRESS("glBindBuffer"); if (0 == glBindBuffer) { glBindBuffer = (PFNGLBINDBUFFERPROC) GET_PROC_ADDRESS("glBindBufferARB"); } funcsInited = 1; #endif }
// these extensions may not be listed the normal way so we don't check the extension string for them static int opengl_get_extensions_special() { int i, num_found = 0; ogl_function *func = NULL; for (i = 0; i < NUM_OGL_EXT_SPECIAL; i++) { func = &GL_EXT_Special[i]; Assert( func->function_name != NULL ); func->function_ptr = (ptr_u)GET_PROC_ADDRESS(func->function_name); if (func->function_ptr) { mprintf((" Found special extension function \"%s\".\n", func->function_name)); num_found++; } } return num_found; }
//finds OGL extension functions //returns number found int opengl_get_extensions() { int i, j, k, num_found = 0; ogl_extension *ext = NULL; ogl_function *func = NULL; OGL_extension_string = (char*)glGetString(GL_EXTENSIONS); for (i = 0; i < NUM_OGL_EXTENSIONS; i++) { ext = &GL_Extensions[i]; k = 0; while ( !ext->enabled && (k < ext->num_extensions) ) { if ( opengl_find_extension(ext->extension_name[k]) ) { // some extensions do not have functions if (!ext->num_functions) { mprintf((" Using extension \"%s\".\n", ext->extension_name[k])); ext->enabled = 1; num_found++; goto Next; } // we do have functions so check any/all of them for (j = 0; j < ext->num_functions; j++) { func = get_ogl_function( ext->function_names[j] ); if (func == NULL) break; if ( !func->function_ptr ) func->function_ptr = (ptr_u)GET_PROC_ADDRESS(func->function_name); if ( !func->function_ptr ) break; } if ( j != ext->num_functions ) { mprintf((" Found extension \"%s\", but can't find the required function \"%s()\". Extension will be disabled!\n", ext->extension_name[k], ext->function_names[j])); if (ext->required_to_run) Error( LOCATION, "The required OpenGL extension '%s' is not fully supported by your current driver version or graphics card.\n", ext->extension_name[k] ); } else { mprintf((" Using extension \"%s\".\n", ext->extension_name[k])); ext->enabled = 1; num_found++; } } else { // only report if unable to find when we have checked all available extension name variants if ( k+1 >= ext->num_extensions ) { mprintf((" Unable to find extension \"%s\".\n", ext->extension_name[k])); if (ext->required_to_run) Error( LOCATION, "The required OpenGL extension '%s' is not supported by your current driver version or graphics card.\n", ext->extension_name[k] ); } } // now move the the next extension name Next: k++; } } num_found += opengl_get_extensions_special(); mprintf(( "\n" )); return num_found; }
HRESULT CCamMicro::Init(__in PTSTR ptszMicroDriverName, MCAM_DEVICE_INFO **ppDeviceInfo) { DBG_FN("CCamMicro::CCamMicro"); HRESULT hr = S_OK; // // Load the camera microdriver // m_hModule = LoadLibrary(ptszMicroDriverName); REQUIRE_FILEHANDLE(m_hModule, hr, "CCamMicro::CCamMicro", "LoadLibrary failed"); GET_PROC_ADDRESS(Init); GET_PROC_ADDRESS(UnInit); GET_PROC_ADDRESS(Open); GET_PROC_ADDRESS(Close); GET_PROC_ADDRESS(GetDeviceInfo); GET_PROC_ADDRESS(ReadEvent); GET_PROC_ADDRESS(StopEvents); GET_PROC_ADDRESS(GetItemInfo); GET_PROC_ADDRESS(FreeItemInfo); GET_PROC_ADDRESS(GetThumbnail); GET_PROC_ADDRESS(GetItemData); GET_PROC_ADDRESS(DeleteItem); GET_PROC_ADDRESS(SetItemProt); GET_PROC_ADDRESS(TakePicture); GET_PROC_ADDRESS(Status); GET_PROC_ADDRESS(Reset); if (m_pInit) { hr = m_pInit(ppDeviceInfo); } else { wiauDbgError("CCamMicro::Init", "m_pInit not initialized"); hr = E_FAIL; } Cleanup: return hr; }
void GetGLFunctions() { glVertexAttribPointer= ( PFNGLVERTEXATTRIBPOINTERPROC ) GET_PROC_ADDRESS( glVertexAttribPointer ); glGenBuffers= (PFNGLGENBUFFERSPROC) GET_PROC_ADDRESS( glGenBuffers ); glBindBuffer= (PFNGLBINDBUFFERPROC) GET_PROC_ADDRESS( glBindBuffer ); glBufferData= (PFNGLBUFFERDATAPROC) GET_PROC_ADDRESS( glBufferData ); glBufferSubData= (PFNGLBUFFERSUBDATAPROC) GET_PROC_ADDRESS( glBufferSubData ); glUniform1i= (PFNGLUNIFORM1IPROC) GET_PROC_ADDRESS(glUniform1i); glUniformMatrix4fv= (PFNGLUNIFORMMATRIX4FVPROC) GET_PROC_ADDRESS(glUniformMatrix4fv); glUniformMatrix3fv= (PFNGLUNIFORMMATRIX3FVPROC) GET_PROC_ADDRESS(glUniformMatrix3fv); glUniform3f= (PFNGLUNIFORM3FPROC) GET_PROC_ADDRESS(glUniform3f); glUniform1f= (PFNGLUNIFORM1FPROC) GET_PROC_ADDRESS(glUniform1f); glGetUniformLocation= (PFNGLGETUNIFORMLOCATIONPROC) GET_PROC_ADDRESS(glGetUniformLocation); glBindAttribLocation= (PFNGLBINDATTRIBLOCATIONPROC) GET_PROC_ADDRESS(glBindAttribLocation); glCreateProgram= (PFNGLCREATEPROGRAMPROC) GET_PROC_ADDRESS(glCreateProgram); glAttachShader= (PFNGLATTACHSHADERPROC) GET_PROC_ADDRESS(glAttachShader); glLinkProgram= (PFNGLLINKPROGRAMPROC)GET_PROC_ADDRESS(glLinkProgram); glUseProgram= (PFNGLUSEPROGRAMPROC) GET_PROC_ADDRESS(glUseProgram); glGetProgramiv= (PFNGLGETPROGRAMIVPROC) GET_PROC_ADDRESS(glGetProgramiv); glGetProgramInfoLog= (PFNGLGETPROGRAMINFOLOGPROC) GET_PROC_ADDRESS(glGetProgramInfoLog); glCreateShader= (PFNGLCREATESHADERPROC)GET_PROC_ADDRESS(glCreateShader); glShaderSource= (PFNGLSHADERSOURCEPROC) GET_PROC_ADDRESS(glShaderSource); glCompileShader= (PFNGLCOMPILESHADERPROC)GET_PROC_ADDRESS(glCompileShader); glGetShaderiv= (PFNGLGETSHADERIVPROC) GET_PROC_ADDRESS(glGetShaderiv); glGetShaderInfoLog= (PFNGLGETSHADERINFOLOGPROC) GET_PROC_ADDRESS(glGetShaderInfoLog); glEnableVertexAttribArray= (PFNGLENABLEVERTEXATTRIBARRAYPROC) GET_PROC_ADDRESS(glEnableVertexAttribArray); glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC) GET_PROC_ADDRESS(glDisableVertexAttribArray); }