void CSynapseServer::EnumerateInterfaces( Str &soname ) { CSynapseClientSlot slot; slot.mpDLL = LoadLibrary( soname.GetBuffer() ); if ( !slot.mpDLL ) { Syn_Printf( "LoadLibrary '%s' failed\n", soname.GetBuffer() ); Syn_Printf( " GetLastError: %s", FormatGetLastError() ); return; } slot.mpEnumerate = (PFN_SYNAPSE_ENUMERATEINTERFACES)GetProcAddress( slot.mpDLL, NAME_SYNAPSE_ENUMERATEINTERFACES ); if ( !slot.mpEnumerate ) { Syn_Printf( "GetProcAddress('%s') failed\n", NAME_SYNAPSE_ENUMERATEINTERFACES ); Syn_Printf( " GetLastError: %s", FormatGetLastError() ); return; } Syn_Printf( "Enumerate interfaces on '%s'\n", soname.GetBuffer() ); slot.mpClient = slot.mpEnumerate( SYNAPSE_VERSION, this ); if ( !slot.mpClient ) { Syn_Printf( "Enumerate interfaces on '%s' returned NULL, unloading.\n", soname.GetBuffer() ); if ( !FreeLibrary( slot.mpDLL ) ) { Syn_Printf( " FreeLibrary failed: GetLastError: '%s'\n", CSynapseServer::FormatGetLastError() ); } return; } slot.mFileName = soname; mClients.push_front( slot ); }
void write_symbol(PSYMBOL_INFO pSym, STACKFRAME& sf, TextOutputStream& outputStream, std::size_t& count) { if ( pSym->Flags & SYMFLAG_PARAMETER ) { #if 0 DWORD basicType; if ( SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, pSym->TypeIndex, TI_GET_BASETYPE, &basicType ) ) { int bleh = 0; } else { DWORD typeId; if(SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, pSym->TypeIndex, TI_GET_TYPEID, &typeId )) { if ( SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, pSym->TypeIndex, TI_GET_BASETYPE, &basicType ) ) { int bleh = 0; } else { const char* FormatGetLastError(); const char* error = FormatGetLastError(); int bleh = 0; WCHAR* name; if(SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, typeId, TI_GET_SYMNAME, &name )) { outputStream << name << " "; LocalFree(name); int bleh = 0; } else { const char* FormatGetLastError(); const char* error = FormatGetLastError(); int bleh = 0; } } } else { const char* FormatGetLastError(); const char* error = FormatGetLastError(); int bleh = 0; } } #endif if(count != 0) { outputStream << ", "; } outputStream << pSym->Name; ++count; } }
DynamicLibrary( const char* filename ){ m_library = LoadLibrary( filename ); if ( m_library == 0 ) { globalErrorStream() << "LoadLibrary failed: '" << filename << "'\n"; globalErrorStream() << "GetLastError: " << FormatGetLastError(); } }
FunctionPointer findSymbol( const char* symbol ){ FunctionPointer address = (FunctionPointer) GetProcAddress( m_library, symbol ); if ( address == 0 ) { globalErrorStream() << "GetProcAddress failed: '" << symbol << "'\n"; globalErrorStream() << "GetLastError: " << FormatGetLastError(); } return address; }
DynamicLibrary::DynamicLibrary(const std::string& filename) : _name(filename), _library(LoadLibrary(_name.c_str())) { if (_library == 0) { std::cerr << "LoadLibrary failed: '" << filename << "'" << std::endl; std::cerr << "GetLastError: " << FormatGetLastError(); } }
DynamicLibrary::FunctionPointer DynamicLibrary::findSymbol(const std::string& symbol) { // Try to lookup the symbol address FunctionPointer address = GetProcAddress(_library, symbol.c_str()); // Emit a warning if the lookup failed if (address == 0) { std::cerr << "GetProcAddress failed: '" << symbol << "'" << std::endl; std::cerr << "GetLastError: " << FormatGetLastError(); } return address; }
/* ===================== idModelExport::LoadMayaDll Checks to see if we can load the Maya export dll ===================== */ void idModelExport::LoadMayaDll( void ) { exporterDLLEntry_t dllEntry; char dllPath[ MAX_OSPATH ]; fileSystem->FindDLL( "MayaImport", dllPath, false ); if( !dllPath[ 0 ] ) { return; } importDLL = sys->DLL_Load( dllPath ); if( !importDLL ) { #ifdef WIN32 // greebo: Do another attempt in Win32 to get a better error message idStr win32DllPath( dllPath ); win32DllPath.Replace( "/", "\\" ); HMODULE dll = LoadLibrary( win32DllPath ); if( dll == 0 ) { gameLocal.Warning( "Could not load MayaImport DLL: %s ", FormatGetLastError() ); } #endif return; } // look up the dll interface functions dllEntry = ( exporterDLLEntry_t )sys->DLL_GetProcAddress( importDLL, "dllEntry" ); Maya_ConvertModel = ( exporterInterface_t )sys->DLL_GetProcAddress( importDLL, "Maya_ConvertModel" ); Maya_Shutdown = ( exporterShutdown_t )sys->DLL_GetProcAddress( importDLL, "Maya_Shutdown" ); if( !Maya_ConvertModel || !dllEntry || !Maya_Shutdown ) { Maya_ConvertModel = NULL; Maya_Shutdown = NULL; sys->DLL_Unload( importDLL ); importDLL = 0; gameLocal.Error( "Invalid interface on export DLL." ); return; } // initialize the DLL if( !dllEntry( MD5_VERSION, common, sys ) ) { // init failed Maya_ConvertModel = NULL; Maya_Shutdown = NULL; sys->DLL_Unload( importDLL ); importDLL = 0; gameLocal.Error( "Export DLL init failed." ); return; } }
void WindowWnd::RegisterSuperClass() { //!!目前还不知道有什么用 //功能是如下 // Get the class information from an existing // window so we can subclass it later on... //为什么是ControlProc不明白 WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); if( !::GetClassInfoEx( NULL, GetSuperClassName() , &wc) ) { /* if( !::GetClassInfoEx(PaintManagerUI::GetInstance(),GetSuperClassName(),&wc)) { THROW_EXCEPTION(YYUIException()<< UIErrorStr(_T("找不到Register Class Name"))); }*/ } m_OldWndProc = wc.lpfnWndProc; wc.lpfnWndProc = WindowWnd::ControlProc; wc.hInstance = SystemInfo::GetInstance()->GetProcessInstance();; wc.lpszClassName = GetWindowClassName(); ATOM hr = ::RegisterClassEx(&wc); assert( hr !=0 || hr == ERROR_CLASS_ALREADY_EXISTS ); if( hr == 0 && hr != ERROR_CLASS_ALREADY_EXISTS) { THROW_EXCEPTION(YYUIException()<<UIErrorStr(_T("Call RegisterClassEx Failed! :")+FormatGetLastError(hr))); } }
void WindowWnd::RegisterWindowClass() { WNDCLASS wc; ZeroMemory(&wc,sizeof(wc)); wc.style = GetClassStyle(); wc.lpfnWndProc =WindowManger::WndProc; //用自己的WndProc wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = SystemInfo::GetInstance()->GetProcessInstance(); wc.hIcon = NULL; wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = GetWindowClassName(); ATOM ret = ::RegisterClass( &wc ); DWORD err = ::GetLastError(); assert( ret !=0 || err == ERROR_CLASS_ALREADY_EXISTS ); if( ret == 0 && err != ERROR_CLASS_ALREADY_EXISTS) { THROW_EXCEPTION(YYUIException()<<UIErrorStr(_T("Call RegisterClassEx Failed! :")+FormatGetLastError(err))); } }