コード例 #1
0
ファイル: BoxeeAuthenticator.cpp プロジェクト: Kr0nZ/boxee
BoxeeAuthenticator::~BoxeeAuthenticator()
{
  if (m_DllHandle)
  {
    UnloadDll();
  }
}
コード例 #2
0
ファイル: DllLoader.cpp プロジェクト: mlbrock/MlbDev
// ////////////////////////////////////////////////////////////////////////////
DllLoader::~DllLoader()
{
	if (dll_load_flags_ & UnloadOnDestruction) {
		try {
			UnloadDll();
		}
		catch (const std::exception &) {
		}
	}
}
コード例 #3
0
ActivationContextLoader::~ActivationContextLoader(void)
{
	try
	{
		if (m_bShouldLoadActivationContext)
		{
			UnloadAC();
			UnloadDll();
		}
	}
	catch (std::exception & e)
	{
		CStdString sError = CA2T(e.what());
		LOG_WS_ERROR(sError); 
	}
}
コード例 #4
0
ファイル: dll.cpp プロジェクト: paulvortex/BloodPill
bool LoadDll (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts, bool verbose)
{
#ifdef SUPPORTDLL
	const dllfunction_t *func;
	dllhandle_t dllhandle = 0;
	char dllpath[MAX_OSPATH];
	unsigned int i;

	if (handle == NULL)
		return false;

#ifndef WIN32
#ifdef PREFER_PRELOAD
	dllhandle = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
	if(LoadDllFunctions(dllhandle, fcts, false, false))
	{
		Verbose ("All of %s's functions were already linked in! Not loading dynamically...\n", dllnames[0]);
		*handle = dllhandle;
		return true;
	}
	else
		UnloadDll(&dllhandle);
notfound:
#endif
#endif

	// Initializations
	for (func = fcts; func && func->name != NULL; func++)
		*func->funcvariable = NULL;

	// Try every possible name
	if (verbose)
		Verbose ("Trying to load library...");
	for (i = 0; dllnames[i] != NULL; i++)
	{
		if (verbose)
			Verbose (" \"%s\"", dllnames[i]);
		sprintf(dllpath, "%s%s", progpath, dllnames[i]);
#ifdef WIN32
# ifdef _WIN64
		SetDllDirectory("bin64");
# endif
		dllhandle = LoadLibrary(dllpath);
# ifdef _WIN64
		SetDllDirectory(NULL);
# endif
#else
		dllhandle = dlopen (dllpath, RTLD_LAZY | RTLD_GLOBAL);
#endif
		if (LoadDllFunctions(dllhandle, fcts, verbose, (dllnames[i+1] != NULL) /* vortex: broke || (strrchr(com_argv[0], '/'))*/))
			break;
		else
			UnloadDll (&dllhandle);
	}

	// No DLL found
	if (!dllhandle)
	{
		if (verbose)
			Verbose(" - failed.\n");
		return false;
	}

	if (verbose)
		Verbose(" - loaded.\n");

	*handle = dllhandle;
	return true;
#else
	return false;
#endif
}
コード例 #5
0
ファイル: Vcc.c プロジェクト: vcc6809/VCC
/*--------------------------------------------------------------------------*/
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	MSG  Msg;

	EmuState.WindowInstance = hInstance;
	char temp1[MAX_PATH]="";
	char temp2[MAX_PATH]=" Running on ";
	unsigned threadID;
	HANDLE hEvent,

//	SetPriorityClass(GetCurrentProcess(),ABOVE_NORMAL_PRIORITY_CLASS );
//	SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
//	CoInitializeEx(NULL,COINIT_MULTITHREADED);
//	CoInitialize(NULL);
//	InitializeCriticalSection();
	OleInitialize(NULL); //Work around fixs app crashing in "Open file" system dialogs (related to Adobe acrobat 7+
	LoadString(hInstance, IDS_APP_TITLE,g_szAppName, MAX_LOADSTRING);

	if ( strlen(lpCmdLine) !=0)
	{
		strcpy(QuickLoadFile,lpCmdLine);
		strcpy(temp1,lpCmdLine);
		PathStripPath(temp1);
		strlwr(temp1);
		temp1[0]=toupper(temp1[0]);
		strcat (temp1,temp2);
		strcat(temp1,g_szAppName);
		strcpy(g_szAppName,temp1);
	}
	EmuState.WindowSize.x=640;
	EmuState.WindowSize.y=480;
	InitInstance (hInstance, nCmdShow);
	if (!CreateDDWindow(&EmuState))
	{
		MessageBox(0,"Can't create primary Window","Error",0);
		exit(0);
	}
	
	Cls(0,&EmuState);
	DynamicMenuCallback( "",0, 0);
	DynamicMenuCallback( "",1, 0);

	LoadConfig(&EmuState);			//Loads the default config file Vcc.ini from the exec directory
	EmuState.ResetPending=2;
	SetClockSpeed(1);	//Default clock speed .89 MHZ	
	BinaryRunning = true;
	EmuState.EmulationRunning=AutoStart;
	if (strlen(lpCmdLine)!=0)
	{
		Qflag=255;
		EmuState.EmulationRunning=1;
	}

	hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ) ;
	if (hEvent==NULL)
	{
		MessageBox(0,"Can't create Thread!!","Error",0);
		return(0);
	}
	hEMUThread = (HANDLE)_beginthreadex( NULL, 0, &EmuLoop, hEvent, 0, &threadID );
	if (hEMUThread==NULL)
	{
		MessageBox(0,"Can't Start main Emulation Thread!","Ok",0);
		return(0);
	}
	
	WaitForSingleObject( hEvent, INFINITE );
	SetThreadPriority(hEMUThread,THREAD_PRIORITY_NORMAL);

//	InitializeCriticalSection(&FrameRender);

while (BinaryRunning) 
	{
		if (FlagEmuStop==TH_WAITING)		//Need to stop the EMU thread for screen mode change
			{								//As it holds the Secondary screen buffer open while running
				FullScreenToggle();
				FlagEmuStop=TH_RUNNING;
			}
			GetMessage(&Msg,NULL,0,0);		//Seems if the main loop stops polling for Messages the child threads stall
			TranslateMessage(&Msg);
			DispatchMessage(&Msg) ;
	} 

	CloseHandle( hEvent ) ;	
	CloseHandle( hEMUThread ) ;
	timeEndPeriod(1);
	UnloadDll();
	SoundDeInit();
	WriteIniFile(); //Save Any changes to ini File
	return Msg.wParam;
}
コード例 #6
0
ファイル: BoxeeAuthenticator.cpp プロジェクト: Kr0nZ/boxee
bool BoxeeAuthenticator::Init()
{
  CStdString serverUrlPrefix = BOXEE::BXConfiguration::GetInstance().GetURLParam("Boxee.Server","http://app.boxee.tv");
  CStdString version = g_infoManager.GetVersion();
  CStdString platform;
#if defined(_LINUX) && !defined(__APPLE__)
  platform = "linux";
#elif defined(__APPLE__)
  if(CSysInfo::IsAppleTV())
  {
    platform = "atv";
  }
  else
  {
    platform = "mac";
  }
#elif defined(_WIN32)
  platform = "win";
#endif
  CStdString pathToCookieJar = BOXEE::BXCurl::GetCookieJar();
  CStdString pathToAppsDir = _P("special://home/apps/");
  
  CStdString strUrl = serverUrlPrefix;
  strUrl += "/ping?bxlibauth_ver=";
  
  if (LoadDll())
  {    
    const char* currentVersion = _AuthVersion();
    CLog::Log(LOGDEBUG, "Checking for new authenticator version. current: %s", currentVersion);
    
    strUrl += currentVersion;

    UnloadDll();
  }
  else
  {
    CLog::Log(LOGDEBUG, "No authenticator dll found. downloading");
    strUrl += "0";
  }

  BOXEE::BXCurl curl;
  if (!curl.HttpHEAD(strUrl))
  {
    return false;
  }
  
  if (curl.GetLastRetCode() == 200)
  {
    CLog::Log(LOGDEBUG, "Downloading authenticator dll");
    
    // Download the file
    CStdString TempFileName = "special://temp/AuthenticatorDll.bin";
    TempFileName = _P(TempFileName);
    
    if (!curl.HttpDownloadFile(strUrl, TempFileName, ""))
    {
      CLog::Log(LOGERROR, "Unable to download authenticator dll");
      XFILE::CFile::Delete(TempFileName);
      return false;
    }
    
    // Rename the downloaded file
    CStdString DllFileName = GetDllFilename();
    XFILE::CFile::Delete(DllFileName);
    XFILE::CFile::Rename(TempFileName, DllFileName);
  }
  
  if (LoadDll())
  {
    const char* currentVersion = _AuthVersion();
    CLog::Log(LOGDEBUG, "Using authenticator version %s", currentVersion);

    _AuthInit(platform.c_str(), version.c_str(), pathToCookieJar.c_str(), pathToAppsDir.c_str(), serverUrlPrefix.c_str());
    
    return true;
  }
  else
  {
    CLog::Log(LOGWARNING, "Cannot load authenticator dll");
    
    return false;
  }
}
コード例 #7
0
ファイル: BoxeeAuthenticator.cpp プロジェクト: Kr0nZ/boxee
bool BoxeeAuthenticator::LoadDll()
{
  if (m_DllHandle)
  {
    UnloadDll();
  }

  CStdString dllFileName = GetDllFilename();
  CLog::Log(LOGDEBUG,"BoxeeAuthenticator::LoadDll - dllFileName was set [%s] (ba)",dllFileName.c_str());

#ifdef _LINUX
  m_DllHandle = dlopen(dllFileName.c_str(), RTLD_LAZY);
  if (!m_DllHandle)
  {
    CLog::Log(LOGWARNING,"BoxeeAuthenticator::LoadDll - FAILED to open [dllFileName=%s] (ba). Boxee authenticator disabled.",dllFileName.c_str());
    return false;
  }
#else
  m_DllHandle = LoadLibrary(dllFileName.c_str());
  if (!m_DllHandle)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - FAILED to LoadLibrary [dllFileName=%s] (ba)",dllFileName.c_str());
    return false;
  }
#endif
  _AuthVersion = (BXAuthVersionType) FW_LOAD_PROC(m_DllHandle, "BXVersion"); 
  if (_AuthVersion == NULL)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - Error loading func BXVersion. [dllFileName=%s] (ba)",dllFileName.c_str());
    UnloadDll();
    return false;
  }
    
  if (atoi(_AuthVersion()) < AUTH_MIN_VALID_VERSION)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - Error - bxauth version is too old, not loading authenticator [dllFileName=%s, ver: %s] (ba)",dllFileName.c_str(), _AuthVersion());
    UnloadDll();
    return false;
  }

  _AuthInit = (BXAuthInitType) FW_LOAD_PROC(m_DllHandle, "BXAuthInit"); 
  if (_AuthInit == NULL)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - Error loading func BXAuthInit. [dllFileName=%s] (ba)",dllFileName.c_str());
    UnloadDll();
    return false;
  }
  
  _AuthApp = (BXAuthAppType) FW_LOAD_PROC(m_DllHandle, "BXAuthApp"); 
  if (_AuthApp == NULL)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - Error loading func BXAuthApp. [dllFileName=%s] (ba)",dllFileName.c_str());
    UnloadDll();
    return false;
  }

  _AuthMain = (BXAuthMainType) FW_LOAD_PROC(m_DllHandle, "BXAuthMain"); 
  if (_AuthMain == NULL)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - Error loading func BXAuthMain. [dllFileName=%s] (ba)",dllFileName.c_str());
    UnloadDll();
    return false;
  }
  
  _AuthFree = (BXAuthFreeType) FW_LOAD_PROC(m_DllHandle, "BXFree"); 
  if (_AuthFree == NULL)
  {
    CLog::Log(LOGERROR,"BoxeeAuthenticator::LoadDll - Error loading func BXFree. [dllFileName=%s] (ba)",dllFileName.c_str());
    UnloadDll();
    return false;
  }  

  return true;
}