Esempio n. 1
0
IPlugin* PluginManager::LoadPlugin(std::string file)
{
	std::shared_ptr<PluginInfo> dll = std::make_shared<PluginInfo>();

	Log::Instance().Write("Loading " + StripFile(file));
	file += ".plug";

#if defined(_WIN32)
	dll->mod = LoadLibrary(file.c_str());
#else
	dll->mod = dlopen(file.c_str(),RTLD_NOW);
#endif

	if(dll->mod == nullptr)
	{
		std::string error;
#ifdef _WIN32
		error = GetLastErrorAsString();
#else
		error = dlerror();
#endif
		throw error;
	}

	CREATEPLUGIN pFunct = nullptr;

#ifdef _WIN32
	pFunct = (CREATEPLUGIN)GetProcAddress((HMODULE)(dll->mod),"CreatePlugin");
#else
	pFunct = (CREATEPLUGIN)dlsym(dll->mod,"CreatePlugin");
#endif

	if(pFunct == nullptr)
	{
		throw ("Corrupted Shared Library: "  + file);
	}

	// Create the plugin
	dll->pPlugin = pFunct();

	// Get the type of the plugin
	DLLType type = dll->pPlugin->GetPluginType();
	auto iter = m_plugins.find(type); // see if the plugin is already loaded

	// If it is already loaded
	if(iter != m_plugins.end())
	{
		// replace with new
		iter->second = dll;
	}
	else
	{
		// insert plugin into map
		m_plugins.insert({ type, dll });
	}

	// return the plugin interface
	return dll->pPlugin;
}
Esempio n. 2
0
CPuzzle::CPuzzle(HWND hWindow, HPALETTE hPal)
/***********************************************************************/
{
	STRING szString; 
	HWND hItem;

	m_hWnd = hWindow;
	m_pDib = NULL;
	m_iRows = 4;
	m_iCols = 4;
	m_iSelect = -1;
	m_szDibFile[0] = '\0';
	m_bTrack = FALSE;
	m_bInRect = FALSE;
	m_hPal = hPal;
	m_idResource = GetDlgCtrlID(m_hWnd) + 1;
	m_bHintMode = FALSE;

	GetWindowText(hWindow, szString, sizeof(szString));
	m_lpSwitches = ExtractSwitches(szString);

	#ifdef UNUSED
	GetModuleFileName(GetWindowInstance(hWindow), szFileName, sizeof(szFileName));
	StripFile(szFileName);

 	if (GetStringParm(szString, 0, ',', szFile))
 	{
 		lstrcpy(m_szDibFile, szFileName);
 		lstrcat(m_szDibFile, szFile);
 	}
	if (lstrlen(m_szDibFile))
	#endif

	HWND hParent = GetParent(m_hWnd);
	hItem = GetDlgItem(hParent, m_idResource);
	if (hItem)
	{
		GetWindowText(hItem, m_szDibFile, sizeof(m_szDibFile));
	    m_pDib = CDib::LoadDibFromFile( m_szDibFile, m_hPal, FALSE, TRUE );
	}
	else
	    m_pDib = CDib::LoadDibFromResource( GetWindowInstance(m_hWnd), MAKEINTRESOURCE(m_idResource), m_hPal, FALSE, TRUE );
	if (m_pDib)
		Setup();
}
Esempio n. 3
0
//******************************************************************************
BOOL VoiceRecoInit(HWND hWnd)
//******************************************************************************
{
	if ( bInit )
		return( TRUE );

	#ifdef WIN32
	// Make voice reco registry entries under Win95
	FNAME szFileName;
	GetModuleFileName( GetApp()->GetInstance(), szFileName, sizeof(szFileName) );
	StripFile( szFileName );
	HKEY hKey;
	RegCreateKey( HKEY_LOCAL_MACHINE, "\\Software\\IBM\\ICSS", &hKey );
	RegSetValueEx( hKey, "InstallDir", NULL, REG_SZ, (CONST BYTE*)szFileName,
		(DWORD)lstrlen(szFileName)+1 );
	#endif

	if ( !ICSSMessageId )
		ICSSMessageId = RegisterWindowMessage(ICSS_USER_MSG_STRING);

	/******************************************************************************/
	/* This section starts the ICSS initialization process. Note that StartConv.  */
	/* is an asynchronous call, so results must be checked both here (for argument*/
	/* errors), and during message loop processing for processing errors.		  */
	/******************************************************************************/
	long lRetCode;
	if ( (lRetCode = ICSSStart(NULL)) != ICSS_SUCCESS )
	{
		ICSSEnd();
		Print( "Failed trying to start voice recognition. (code %ld)", lRetCode );
		return( FALSE );
	}
	if ( (lRetCode = (BOOL)ICSSStartConversation(ICSS_DEFAULT_STRING, ICSS_DEFAULT_INT,
			ICSS_DEFAULT_STRING, ICSS_DIRECT, hWnd)) != ICSS_SUCCESS )
	{
		ICSSEndConversation();
		ICSSEnd();
		Print( "Failed trying to start a voice recognition conversation. (code %ld)", lRetCode );
		return( FALSE );
	}

	return( bInit = TRUE );
}
Esempio n. 4
0
// Injects the dll specified by dllPath after creating the target process
int CInjector::InjectAuto(std::wstring dllPath, std::wstring processPath)
{
	STARTUPINFOW si;
	PROCESS_INFORMATION pi;

	ZeroMemory(&pi, sizeof(pi));
	ZeroMemory(&si, sizeof(si));

	si.cb = sizeof(si);

	try {
		std::wstring exeDirectory = StripFile(processPath);
		SetCurrentDirectoryW(exeDirectory.c_str());

		// Create the process
		if (!CreateProcessW(0,
			const_cast<LPWSTR>(processPath.c_str()),
			0,
			0,
			false,
			CREATE_SUSPENDED,
			0,
			0,
			&si,
			&pi)) throw std::exception("Could not create process");

		// Inject the dll by specific process Id
		std::wstring processName = StripPath(processPath);
		int bInjected = Inject(dllPath, processName, pi.dwProcessId);

		// Resume
		ResumeThread(pi.hThread);

		return bInjected;
	}
	catch (std::exception e) {
		TerminateProcess(pi.hProcess, 0);
		throw;
	}
}
Esempio n. 5
0
BOOL CAliasApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.
	BOOL bError = FALSE;

	if (!m_Quantize.Init())
		return(FALSE);

	Enable3dControls();
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	static char BASED_CODE szFilter[] = "Targa Files|*.tga||";

	while (!bError)
	{
		char szSceneDir[MAX_PATH];
		char szGrayDir[MAX_PATH];
		char szColorDir[MAX_PATH];
		char szCompDir[MAX_PATH];
		char szWildCard[MAX_PATH];
		char szMsg[MAX_PATH];
		WIN32_FIND_DATA FindData;

		CFileDialog bgdlg(TRUE,
				"tga",
				"*.tga",
				OFN_HIDEREADONLY,
				szFilter,
				NULL);

		//fgdlg.m_ofn.Flags &= ~OFN_EXPLORER;
		bgdlg.m_ofn.lpstrTitle = "Select Scene Background File";

		int nResponse = bgdlg.DoModal();
		if (nResponse != IDOK)
		{
			DWORD dwErr = CommDlgExtendedError();
			break;

		}
		m_statusDlg.Create(IDD_STATUS);

		CString szBackFile = bgdlg.GetPathName();
		lstrcpy(szSceneDir, szBackFile);
		StripFile(szSceneDir);

		lstrcpy(szGrayDir, szSceneDir);
		lstrcat(szGrayDir, "GRAY\\");
		lstrcpy(szColorDir, szSceneDir);
		lstrcat(szColorDir, "COLOR\\");
		lstrcpy(szCompDir, szSceneDir);
		lstrcat(szCompDir, "COMP");
#ifndef CPO
		CreateDirectory(szCompDir, NULL);
#endif
		lstrcat(szCompDir, "\\");

		lstrcpy(szWildCard, szColorDir);
		lstrcat(szWildCard, "*.*");

		m_Quantize.Reset();

		// first count the number of files to be processed
		m_nTotal = m_nFiles = 0;
		HANDLE hFind = FindFirstFile(szWildCard, &FindData);
		if (!hFind)
		{
			wsprintf(szMsg, "No subdirectories found in %s", szGrayDir);
			MessageBox(NULL, szMsg, "Error", MB_ICONSTOP|MB_OK);
			continue;
		}
		while (hFind != INVALID_HANDLE_VALUE)
		{
			if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
				FindData.cFileName[0] != '.')
			{
				char szGrayAnimDir[MAX_PATH];
				char szColorAnimDir[MAX_PATH];
				char szCompAnimDir[MAX_PATH];
				lstrcpy(szGrayAnimDir, szGrayDir);
				lstrcat(szGrayAnimDir, FindData.cFileName);
				FixPath(szGrayAnimDir);
				lstrcpy(szColorAnimDir, szColorDir);
				lstrcat(szColorAnimDir, FindData.cFileName);
				FixPath(szColorAnimDir);
				lstrcpy(szCompAnimDir, szCompDir);
				lstrcat(szCompAnimDir, FindData.cFileName);
#ifndef CPO
				CreateDirectory(szCompAnimDir, NULL);
#endif
				FixPath(szCompAnimDir);
				if (!ProcessFiles(szGrayAnimDir, szColorAnimDir, szCompAnimDir, TRUE))
				{
					FindClose(hFind);
					bError = TRUE;
					break;
				}
			}
			if (!FindNextFile(hFind, &FindData))
			{
				FindClose(hFind);
				break;
			}
		}
		// now actually process all the files
		hFind = FindFirstFile(szWildCard, &FindData);
		if (!hFind)
		{
			wsprintf(szMsg, "No subdirectories found in %s", szGrayDir);
			MessageBox(NULL, szMsg, "Error", MB_ICONSTOP|MB_OK);
			continue;
		}
		while (hFind != INVALID_HANDLE_VALUE)
		{
			if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
				FindData.cFileName[0] != '.')
			{
				char szGrayAnimDir[MAX_PATH];
				char szColorAnimDir[MAX_PATH];
				char szCompAnimDir[MAX_PATH];
				lstrcpy(szGrayAnimDir, szGrayDir);
				lstrcat(szGrayAnimDir, FindData.cFileName);
				FixPath(szGrayAnimDir);
				lstrcpy(szColorAnimDir, szColorDir);
				lstrcat(szColorAnimDir, FindData.cFileName);
				FixPath(szColorAnimDir);
				lstrcpy(szCompAnimDir, szCompDir);
				lstrcat(szCompAnimDir, FindData.cFileName);
#ifndef CPO
				CreateDirectory(szCompAnimDir, NULL);
#endif
				FixPath(szCompAnimDir);
				if (!ProcessFiles(szGrayAnimDir, szColorAnimDir, szCompAnimDir))
				{
					FindClose(hFind);
					bError = TRUE;
					break;
				}
			}
			if (!FindNextFile(hFind, &FindData))
			{
				FindClose(hFind);
				break;
			}
		}

		FNAME szPath, szFileName;
		RGBQUAD StaticMap[256];
		RGBQUAD InitialMap[256];
		RGBQUAD PaletteMap[256];

		ZeroMemory(StaticMap, sizeof(StaticMap));
		ZeroMemory(PaletteMap, sizeof(PaletteMap));
		GetModuleFileName(m_hInstance, szPath, sizeof(szPath));
		StripFile(szPath);

		lstrcpy(szFileName, szPath);
		lstrcat(szFileName, "static.pal");
		int nStaticEntries = LoadPalette(szFileName, &StaticMap[10]);

		lstrcpy(szFileName, szPath);
		lstrcat(szFileName, "initial.pal");
		int nInitialEntries = LoadPalette(szFileName, InitialMap);
		int nEntries = m_Quantize.CreatePalette(PaletteMap, 236-nStaticEntries, InitialMap, nInitialEntries);
		if (nEntries)
		{
			char szPalFile[MAX_PATH];

			#ifdef GARBAGE
		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "backgrnd.pal");
			SavePalette(szPalFile, PaletteMap, 256);
			PaletteMap[nEntries].rgbRed = m_rgbTrans.red;
			PaletteMap[nEntries].rgbGreen = m_rgbTrans.green;
			PaletteMap[nEntries].rgbBlue = m_rgbTrans.blue;
		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "foregrnd.pal");
			SavePalette(szPalFile, PaletteMap, 256);
			#endif

			for (int i = 0; i < nEntries; ++i)
				StaticMap[i+nStaticEntries+10] = PaletteMap[i];
			CreateIdentityMap(StaticMap, 256);

		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "final.pal");
			SavePalette(szPalFile, StaticMap, 256);
			nStaticEntries += 10;
			for (i = 0; i < nStaticEntries; ++i)
			{
#ifndef CPO
				if (StaticMap[i].rgbRed != m_rgbTrans.red ||
					StaticMap[i].rgbGreen != m_rgbTrans.green ||
					StaticMap[i].rgbBlue != m_rgbTrans.blue)
#endif
				{
					StaticMap[i].rgbRed =
					StaticMap[i].rgbGreen =
					StaticMap[i].rgbBlue = 0;
				}
			}
			for (i = 246; i < 256; ++i)
			{
#ifndef CPO
				if (StaticMap[i].rgbRed != m_rgbTrans.red ||
					StaticMap[i].rgbGreen != m_rgbTrans.green ||
					StaticMap[i].rgbBlue != m_rgbTrans.blue)
#endif
				{
					StaticMap[i].rgbRed =
					StaticMap[i].rgbGreen =
					StaticMap[i].rgbBlue = 0;
				}
			}
		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "premiere.pal");
			SavePalette(szPalFile, StaticMap, 256);
		}
		m_statusDlg.DestroyWindow();
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Esempio n. 6
0
CStory::CStory(HWND hWindow)
/***********************************************************************/
{
	STRING szString, szFile; 
	FNAME szFileName;
	HRSRC hResource;
	HGLOBAL hData;
	LPSHORT lpShortData;
	DWORD dwSize;
	int id;

	m_hWnd = hWindow;
	m_nRects = 0;
	m_hMCIfile = NULL;
	m_iHighlight = 0;
	m_pDib = NULL;
	m_lpWordData = NULL;
	m_fPlaying = FALSE;
	m_szStoryFile[0] = '\0';
	m_szDibFile[0] = '\0';
	m_hHotSpotCursor = LoadCursor(GetWindowInstance(hWindow), MAKEINTRESOURCE(ID_POINTER));
	m_fCursorEnabled = TRUE;
	m_fMappedToPalette = FALSE;

	GetModuleFileName(GetWindowInstance(hWindow), szFileName, sizeof(szFileName));
	StripFile(szFileName);

	GetWindowText(hWindow, szString, sizeof(szString));
	for (int i = 0; i < 2; ++i)
	{
		if (GetStringParm(szString, i, ',', szFile))
		{
			if (lstrcmpi(Extension(szFile), ".wav") == 0)
			{
				lstrcpy(m_szStoryFile, szFileName);
				lstrcat(m_szStoryFile, szFile);
			}
			else
			{
				lstrcpy(m_szDibFile, szFileName);
				lstrcat(m_szDibFile, szFile);
			}
		}
		else
			break;
	}

	id = GetDlgCtrlID(hWindow)-IDC_STORY;	
	if (id)
		wsprintf(szString, "story%d", id+1);
	else
		lstrcpy(szString, "story");
		
	id = App.GetSceneNo(GetParent(hWindow));
	if ( !(hResource = FindResource( App.GetInstance(), MAKEINTRESOURCE(id), szString )) )
		return;
	if ( !(dwSize = SizeofResource( App.GetInstance(), hResource )) )
		return;
	if ( !(hData = LoadResource( App.GetInstance(), hResource )) )
		return;
	if ( !(lpShortData = (LPSHORT)LockResource( hData )) )
		{
		FreeResource( hData );
		return;
		}
	m_nRects = (int)(dwSize / (sizeof(WORD) * 6));
	if (m_nRects)
	{
		m_lpWordData = (LPWORD_DATA)AllocX( (m_nRects * sizeof(WORD_DATA)), GMEM_ZEROINIT|GMEM_SHARE );
		if (!m_lpWordData)
			return;
		for (int i = 0; i < m_nRects; ++i)
		{
			m_lpWordData[i].dwFrom = (int)*lpShortData++;
			m_lpWordData[i].dwTo = (int)*lpShortData++;
			m_lpWordData[i].rArea.left = (int)*lpShortData++;
			m_lpWordData[i].rArea.top = (int)*lpShortData++;
			m_lpWordData[i].rArea.right = (int)*lpShortData++;
			m_lpWordData[i].rArea.bottom = (int)*lpShortData++;
		}
	}
	UnlockResource( hData );
	FreeResource( hData );
}