예제 #1
0
	bool SetLowLabel(HANDLE p_Object, SE_OBJECT_TYPE p_seObjType)
	{
		if ( !IsVista() )
		{
			return true;
		}

		DWORD dwErr = ERROR_INVALID_FUNCTION;
		PSECURITY_DESCRIPTOR pSD = NULL;    

		PACL pSacl = NULL; // not allocated
		BOOL fSaclPresent = FALSE;
		BOOL fSaclDefaulted = FALSE;

		if ( ::ConvertStringSecurityDescriptorToSecurityDescriptorW(LOW_INTEGRITY_SDDL_SACL, SDDL_REVISION_1, &pSD, NULL) )
		{
			if ( ::GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted) )
			{
				dwErr = ::SetSecurityInfo(p_Object,	p_seObjType, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl);
			}
			::LocalFree(pSD);
		}

		return (dwErr == ERROR_SUCCESS);
	}
예제 #2
0
파일: Misc.cpp 프로젝트: CyberShadow/Ditto
bool IsRunningLimited()
{
	LPCTSTR pszSubKey = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
	LPCTSTR pszValue = _T("EnableLUA");
	DWORD dwType = 0;
	DWORD dwValue = 0;
	DWORD dwValueSize = sizeof(DWORD);

	if(ERROR_SUCCESS != SHGetValue(HKEY_LOCAL_MACHINE, pszSubKey, pszValue, &dwType, &dwValue, &dwValueSize))
	{
		//failed to read the reg key, either it's not there or we don't have access to the registry
		//If we are vista then assume we don't have access and we are running as a limited app
		//otherwise we are xp and the reg key probably doesn't exist and we are not a limited running app
		if(IsVista())
		{
			OutputDebugString(_T("Ditto - Failed to read registry entry finding UAC, Running as limited application"));
			return true;
		}
	}

	if(dwValue == 1)
	{
		OutputDebugString(_T("Ditto - UAC ENABLED, Running as limited application"));
		return true;
	}

	OutputDebugString(_T("Ditto - Running as standard application"));	
	return false;
}
예제 #3
0
파일: Utils.cpp 프로젝트: N2oBeef/vc_scan
CString CUtils::GetOsName( void )
{
	static CString szOsName;
	if (szOsName.IsEmpty())
	{
		if (IsXP())
		{
			szOsName = L"windowsxp";
		}
		if (IsVista())
		{
			szOsName = L"windowsvista";
		}
		if (IsWin7())
		{
			szOsName = L"windows7";
		}
		if (IsWin8())
		{
			szOsName = L"windows8";
		}
		if (IsWin8_1())
		{
			szOsName = L"windows81";
		}
		if (IsWin10())
		{
			szOsName = L"windows10";
		}
	}

	return szOsName;
}
//=============================================================================
// Set the list view to desired mode.
BOOL CXFileOpenListView::SetViewMode(int cmd)
//=============================================================================
{
	TRACE(_T("in CXFileOpenListView::SetViewMode:  0x%X\n"), cmd);

	if (IsWindow(m_hWnd)) 
	{
		// SHELLDLL_DefView window found: send it the command.
		if (cmd == 0)
		{
			if (IsXP())	
				cmd = XLVM_XP_LIST;
			else if (IsVista())
				cmd = XLVM_VISTA_LIST;
		}

		SendMessage(WM_COMMAND, cmd);

		// Send parent dialog a Refresh command (F5) to force repaint.
		// The command ID value was obtained by inspection using Spy++.
		const UINT CMD_REFRESH = 40966;
		GetParent()->SendMessage(WM_COMMAND, CMD_REFRESH);

		return TRUE;
	}
	else
	{
		TRACE(_T("ERROR - no m_hWnd\n"));
	}
	return FALSE;
}
//=============================================================================
// Get current list view mode in the form of WM_COMMAND code that can be
// passed to SetViewMode.
int CXFileOpenListView::GetViewMode()
//=============================================================================
{
	TRACE(_T("in CXFileOpenListView::GetViewMode\n"));

	int nViewMode = 0;

	if (IsWindow(m_hWnd))
	{
		// Get the child list view window.
		HWND hlc = ::FindWindowEx(m_hWnd, NULL, _T("SysListView32"), NULL);
		if (hlc)
		{
			CListCtrl* plc = (CListCtrl*)CWnd::FromHandle(hlc);
			if (plc)
			{
				long lView = (long)plc->SendMessage(LVM_GETVIEW);

				TRACE(_T("lView=%X\n"), lView);

				if (IsXP())	
					nViewMode = GetXpViewMode(lView, plc);
				else if (IsVista())
					nViewMode = GetVistaViewMode(lView, plc);
			}
		}
	}

	return nViewMode;
}
예제 #6
0
	bool SetLowLabelDir(const wchar_t *p_szName)
	{
		if ( !IsVista() )
		{
			return true;
		}

		static WIN32_FIND_DATAW fdata;//allow re-enter
		struct _stat st;
		if ( 0 != _wstat(p_szName, &st) )
		{
			return false;
		}

		if ( st.st_mode & _S_IFDIR )
		{
			wchar_t *pBuf = (wchar_t *)malloc(sizeof(wchar_t) * MAX_PATH);
			if ( NULL == pBuf )
			{
				return false;
			}

			wcscpy_s(pBuf, MAX_PATH, p_szName);
			wcscat_s(pBuf, MAX_PATH, L"\\*.*");
			HANDLE hFind = ::FindFirstFileW(pBuf, &fdata);
			if ( INVALID_HANDLE_VALUE != hFind )
			{
				do
				{
					if ( !wcscmp(fdata.cFileName, L".") || !wcscmp(fdata.cFileName, L"..") )
					{
						continue;
					}
					wcscpy_s(pBuf, MAX_PATH, p_szName);
					wcscat_s(pBuf, MAX_PATH, L"\\");
					wcscat_s(pBuf, MAX_PATH, fdata.cFileName);
					SetLowLabel(pBuf, SE_FILE_OBJECT);
				}
				while (::FindNextFileW(hFind, &fdata));
				::FindClose(hFind);
			}
			free(pBuf);
		}

		SetLowLabel(p_szName, SE_FILE_OBJECT);
		return true;
	}
예제 #7
0
    CSize GetBorderSize(HWND hWnd, bool dwmEnabled)
    {
        // Check for Caption
        DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
        bool caption = (dwStyle & WS_CAPTION) != 0;
        DWORD dwExStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE);

        // Get BorderMultiplierFactor
        int bmfactor = 0;
        ::SystemParametersInfo(SPI_GETBORDER, 0, &bmfactor, 0);
        int factor = bmfactor - 1;

        CSize border;
        if ((dwExStyle & WS_EX_CLIENTEDGE) != 0)
        {
            // Fixed3D
            border = GetFixedFrameBorderSize() + GetBorder3DSize();
        }
        else if ((dwStyle & WS_THICKFRAME) != 0)
        {
            // Dialog
            if ((dwExStyle & WS_EX_DLGMODALFRAME) != 0)
            {
                // Dialog with WS_EX_DLGMODALFRAME has double border
                int cx = ::GetSystemMetrics(SM_CXDLGFRAME);
                int cy = ::GetSystemMetrics(SM_CYDLGFRAME);
                border.SetSize(cx + cx, cy + cy);
            }
            // Sizable or SizableToolWindow
            else if (IsVista())
                border = GetFrameBorderSize();
            else
                border = GetFixedFrameBorderSize() +
                            (caption ? GetBorderSize() + CSize(factor, factor)
                                : CSize(factor, factor));
        }
        else
        {
            if (dwmEnabled)
                border = GetFrameBorderSize();
            else
                border = GetFixedFrameBorderSize();
        }

        return border;
    }
예제 #8
0
/*++

Routine Name:

    CWICToBMFormatScan::Initialize

Routine Description:

    Initializes the WIC to BMFORMAT transform data from the WICToBMFORMAT structure

Arguments:

    WICToBM - Structure containing WIC pixel format to BMFORMAT conversion information

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CWICToBMFormatScan::Initialize(
    __in CONST WICToBMFORMAT& WICToBM
    )
{
    HRESULT hr = S_OK;

    m_convData = WICToBM;

    if (m_convData.m_pixFormTarget <= kWICPixelFormatMin ||
        m_convData.m_pixFormTarget >= kWICPixelFormatMax ||
        m_convData.m_bmFormTarget  <  kICMPixelFormatMin ||
        m_convData.m_bmFormTarget  >= kICMPixelFormatMax)
    {
        hr = E_INVALIDARG;
    }

    if (SUCCEEDED(hr) &&
        !IsVista())
    {
        //
        // When processing color data down-level from Vista, we cannot use fixed or float
        // BMFORMAT types. In these circumstances we need to convert to a 16 bpc equivalent,
        // then back again.
        //
        if (m_convData.m_bmFormTarget == kBM_32b_scRGB ||
            m_convData.m_bmFormTarget == kBM_32b_scARGB ||
            m_convData.m_bmFormTarget == kBM_S2DOT13FIXED_scRGB ||
            m_convData.m_bmFormTarget == kBM_S2DOT13FIXED_scARGB)
        {
            m_convData.m_bNeedsScanBuffer = TRUE;
            m_convData.m_bmFormTarget = kBM_16b_RGB;
        }
    }

    if (SUCCEEDED(hr))
    {
        m_bInitialized = TRUE;
    }

    ERR_ON_HR(hr);
    return hr;
}
예제 #9
0
LRESULT CUpdateDlg::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	if (!m_bUpdateFinished)
	{
		// Begin Update Process
		CString pid = IntToStr(GetCurrentProcessId());

		BOOL elev = false;
		bool isVista = IsVista();
		if (isVista)
			IsElevated(&elev);
		bool CanWrite = IsDirectory(WinUtils::GetAppFolder() + _T("Data"));

		bool NeedElevation = m_UpdateManager.AreCoreUpdates() && isVista && !elev && !CmdLine.IsOption(_T("update"));
		NeedElevation |= isVista && !elev && !CanWrite;
		//	&& !CanWriteToFolder(IU_GetDataFolder());
		if (NeedElevation)
		{
			IU_RunElevated(CString(_T("/update ")) + _T("/waitforpid=") + pid);
			m_bClose = 2;

			return 0;
		}
		Start();
	}
	else
	{
		// Closing and reexecuting image uploader
		CString pid = IntToStr(GetCurrentProcessId());
		if (!CmdLine.IsOption(_T("update")))
			IULaunchCopy(_T("/afterupdate /waitforpid=") + pid);  // executing new IU copy with the same command line params
		else
			IULaunchCopy(_T("/afterupdate /waitforpid=") + pid, CAtlArray<CString>());

		m_bClose = 2;
		return 0;
	}

	return 0;
}
예제 #10
0
	bool SetLowLabel(const wchar_t *p_szName, SE_OBJECT_TYPE p_seObjType)
	{
		if( !p_szName )
		{
			return false;
		}

		if ( !IsVista() )
		{
			return true;
		}

		if ( p_seObjType == SE_FILE_OBJECT )
		{
			const wchar_t *pEnd = wcsrchr(p_szName, L'.');
			if( pEnd && _wcsicmp(pEnd, L".exe") == 0 )
			{
				return true;
			}
		}

		DWORD dwErr = ERROR_INVALID_FUNCTION;
		PSECURITY_DESCRIPTOR pSD = NULL;    

		PACL pSacl = NULL; // not allocated
		BOOL fSaclPresent = FALSE;
		BOOL fSaclDefaulted = FALSE;

		if ( ::ConvertStringSecurityDescriptorToSecurityDescriptorW(LOW_INTEGRITY_SDDL_SACL, SDDL_REVISION_1, &pSD, NULL) )
		{
			if ( ::GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted) )
			{
				dwErr = ::SetNamedSecurityInfoW((LPWSTR)p_szName,	p_seObjType, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl);
			}
			::LocalFree(pSD);
		}     

		return (dwErr == ERROR_SUCCESS);
	}
예제 #11
0
void CSettings::Uninstall() {
	BOOL b;
	if (IsVista() && IsElevated(&b) != S_OK) {
		RunIuElevated("/uninstall");
		return;
	}
	AutoStartup = false;
	SendToContextMenu  = false;
	RegisterShellExtension(false);
	EnableAutostartup(false);
	CRegistry Reg;
	Reg.SetRootKey(HKEY_CURRENT_USER);
	Reg.DeleteWithSubkeys("Software\\Zenden.ws\\Image Uploader\\ContextMenuItems");
	Reg.DeleteKey( "Software\\Zenden.ws\\Image Uploader" );
	Reg.DeleteKey( "Software\\Zenden.ws" ); // Will not delete if contains subkeys
	Reg.SetRootKey( HKEY_LOCAL_MACHINE );
	Reg.DeleteKey( "Software\\Zenden.ws\\Image Uploader" );
	Reg.DeleteKey( "Software\\Zenden.ws" ); // Will not delete if contains subkeys
	WinUtils::RemoveBrowserKey();

	CString ShortcutName = GetSendToPath() + _T("\\Image Uploader.lnk");
	DeleteFile(ShortcutName);
}
예제 #12
0
void RegisterShellExtension(bool Register) {
	CString moduleName = Settings.getShellExtensionFileName();
	if ( !FileExists( moduleName ) ) {
		return;
	}

	CRegistry Reg;
	Reg.SetRootKey( HKEY_LOCAL_MACHINE );

	bool canCreateRegistryKey = Register;
	
	if ( Reg.SetKey( "Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) {
		Reg.WriteBool( "ExplorerContextMenu", Register );
	}

	SHELLEXECUTEINFO TempInfo = {0};
	CString s = WinUtils::GetAppFolder();
	TempInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
	TempInfo.fMask  = SEE_MASK_NOCLOSEPROCESS;
	TempInfo.hwnd   = NULL;
	BOOL b = FALSE;
	IsElevated( &b );
	if ( IsVista() && !b ) {
		TempInfo.lpVerb = _T("runas");
	} else {
		TempInfo.lpVerb = _T("open");
	}
	TempInfo.lpFile       = _T("regsvr32");
	TempInfo.lpParameters = CString((Register ? _T("") : _T("/u "))) + _T("/s \"") + moduleName + _T("\"");
	TempInfo.lpDirectory  = s;
	TempInfo.nShow        = SW_NORMAL;
	//MessageBox(0,TempInfo.lpParameters,0,0);
	::ShellExecuteEx(&TempInfo);
	WaitForSingleObject( TempInfo.hProcess, INFINITE );
	CloseHandle( TempInfo.hProcess );
}
LRESULT CScreenshotSettingsPagePage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	TRC(IDC_GROUPPARAMS, "Дополнительно");
	TRC(IDC_QUALITYLABEL, "Качество:");
	TRC(IDC_DELAYLABEL, "Задержка:");
	TRC(IDC_FORMATLABEL, "Формат:");
	TRC(IDC_SECLABEL, "сек");
	TRC(IDC_MSECLABEL, "мс");
	TRC(IDC_SCREENSHOTSFOLDERSELECT, "Обзор");
	TRC(IDC_SCREENSHOTFOLDERLABEL, "Папка для сохранения скриншотов:");
	TRC(IDC_SCREENSHOTFILENAMELABEL, "Формат имени файла");
	TRC(IDC_DELAYLABEL2, "Задержка при скрытии окон:");
	TRC(IDC_ALWAYSCOPYTOCLIPBOARD, "Всегда копировать в буфер обмена");
	TRC(IDC_SCREENSHOTSAVINGPARAMS, "Параметры сохранения снимков");
	TRC(IDC_FOREGROUNDWHENSHOOTING, "Выводить окно на передний план при выборе мышью");
	TRC(IDC_PARAMETERSHINTLABEL, "%y - год, %m - месяц, %d - день\n%h - час, %n - минута, %s - секунда\n %i - порядковый номер,\n%width% - ширина,  %height% - высота изображения");
	TRC(IDC_ADDSHADOW, "Добавлять тень окна");
	CString removeCornersText = TR("Удалять уголки у окна")+CString(_T(" (Windows Vista/7)"));
	SetDlgItemText(IDC_REMOVECORNERS, removeCornersText);
	TRC(IDC_REMOVEBACKGROUND, "Удалять фон окна");
	TRC(IDC_SHORTENURLFROMTRAYCHECKBOX, "Сокращать ссылки при быстрой загрузке (по горячей клавише)");
	TRC(IDC_AEROONLY, "Только для Aero (Windows Vista и новее)");
	TRC(IDC_USEOLDREGIONSCREENSHOTMETHOD, "Использовать старый способ выбора области экрана");
	
	SetDlgItemText(IDC_SCREENSHOTFILENAMEEDIT, Settings.ScreenshotSettings.FilenameTemplate);

	SetDlgItemText(IDC_SCREENSHOTFOLDEREDIT, Settings.ScreenshotSettings.Folder);
	SendDlgItemMessage(IDC_DELAYSPIN, UDM_SETRANGE, 0, (LPARAM) MAKELONG((short)30, (short)0) );
	SendDlgItemMessage(IDC_QUALITYSPIN, UDM_SETRANGE, 0, (LPARAM) MAKELONG((short)100, (short)1) );
	
	SendDlgItemMessage(IDC_FORMATLIST, CB_ADDSTRING, 0, (LPARAM)_T("JPEG"));
	SendDlgItemMessage(IDC_FORMATLIST, CB_ADDSTRING, 0, (LPARAM)_T("PNG"));
	SendDlgItemMessage(IDC_FOREGROUNDWHENSHOOTING, BM_SETCHECK,Settings.ScreenshotSettings.ShowForeground);
	SendDlgItemMessage(IDC_ALWAYSCOPYTOCLIPBOARD, BM_SETCHECK, Settings.ScreenshotSettings.CopyToClipboard);

	SendDlgItemMessage(IDC_REMOVECORNERS, BM_SETCHECK, Settings.ScreenshotSettings.RemoveCorners);
	SendDlgItemMessage(IDC_ADDSHADOW, BM_SETCHECK, Settings.ScreenshotSettings.AddShadow);
	SendDlgItemMessage(IDC_REMOVEBACKGROUND, BM_SETCHECK, Settings.ScreenshotSettings.RemoveBackground);

	GuiTools::SetCheck(m_hWnd, IDC_SHORTENURLFROMTRAYCHECKBOX, Settings.TrayIconSettings.ShortenLinks);
	GuiTools::SetCheck(m_hWnd, IDC_USEOLDREGIONSCREENSHOTMETHOD, Settings.ScreenshotSettings.UseOldRegionScreenshotMethod);

	int Quality, Delay, Format;
	Quality = Settings.ScreenshotSettings.Quality;
	Format = Settings.ScreenshotSettings.Format;
	Delay = Settings.ScreenshotSettings.Delay;

	if( Format < 0) Format = 0;
	if( Quality < 0) Quality = 85;
	if( Delay < 0 || Delay > 30) Delay = 2;

	SetDlgItemInt(IDC_QUALITYEDIT, Quality);
	SetDlgItemInt(IDC_DELAYEDIT, Delay);
	SetDlgItemInt(IDC_WINDOWHIDINGDELAY, Settings.ScreenshotSettings.WindowHidingDelay);
	SendDlgItemMessage(IDC_FORMATLIST, CB_SETCURSEL, Format, 0);

	bool isVista = IsVista();
	::EnableWindow(GetDlgItem(IDC_AEROONLY), isVista);
	::EnableWindow(GetDlgItem(IDC_REMOVECORNERS), isVista);
	::EnableWindow(GetDlgItem(IDC_ADDSHADOW), isVista);
	::EnableWindow(GetDlgItem(IDC_REMOVEBACKGROUND), isVista);
	return 1;  // Let the system set the focus
}
예제 #14
0
	bool CSettings::SaveSettings()
	{
		SimpleXml xml;
		mgr_.saveToXmlNode(xml.getRoot("ImageUploader").GetChild("Settings"));
#if !defined(IU_SERVERLISTTOOL) && !defined  (IU_CLI) && !defined(IU_SHELLEXT)
		SaveConvertProfiles(xml.getRoot("ImageUploader").GetChild("Settings").GetChild("Image").GetChild("Profiles"));
		SaveServerProfiles( xml.getRoot("ImageUploader").GetChild("Settings").GetChild("Uploading").GetChild("ServerProfiles") );
#endif
		SaveAccounts(xml.getRoot("ImageUploader").GetChild("Settings").GetChild("ServersParams"));
		//std::cerr << "Saving setting to "<< IuCoreUtils::WstringToUtf8((LPCTSTR)fileName_);
		xml.SaveToFile(fileName_);

#if !defined(IU_SERVERLISTTOOL) && !defined(IU_CLI)
		CRegistry Reg;
		Reg.SetRootKey(HKEY_CURRENT_USER);
		// if(ExplorerContextMenu)
		{
			bool canCreateRegistryKey = ( ExplorerContextMenu );
			if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) {
				if ( ExplorerContextMenu ) {
					Reg.WriteBool( "ExplorerCascadedMenu", ExplorerCascadedMenu );
					Reg.WriteBool("ExplorerContextMenu", ExplorerContextMenu);
					Reg.WriteBool( "ExplorerVideoContextMenu", ExplorerVideoContextMenu );
					Reg.WriteString( "Language", Language );
				} else {
					Reg.DeleteValue("ExplorerCascadedMenu");
					Reg.DeleteValue("ExplorerContextMenu");
					Reg.DeleteValue("ExplorerVideoContextMenu");
					Reg.DeleteValue("Language");
				}
			}
		}
		/*else
		{
		   //Reg.DeleteKey("Software\\Zenden.ws\\Image Uploader");
		}*/
		EnableAutostartup(AutoStartup);

		if (SendToContextMenu_changed   || ExplorerContextMenu_changed) {
			AutoStartup_changed = false;
			BOOL b;
			if ( IsVista() && IsElevated(&b) != S_OK ) {
				// Start new elevated process 
				ApplyRegistrySettings();
			} else {
				// Process has already admin rights
				ApplyRegSettingsRightNow();
			}
		}

		ExplorerContextMenu_changed = false;
		SendToContextMenu_changed = false;

		if (ShowTrayIcon_changed)
		{
			ShowTrayIcon_changed = false;
			if (ShowTrayIcon)
			{
				if (!IsRunningFloatingWnd())
				{
					CmdLine.AddParam(_T("/tray"));
					floatWnd.CreateTrayIcon();
				}
			}
			else
			{
				HWND TrayWnd = FindWindow(0, _T("ImageUploader_TrayWnd"));
				if (TrayWnd) {
					::SendMessage( TrayWnd, WM_CLOSETRAYWND, 0, 0 );
				}
			}
		}
		else if (ShowTrayIcon)
		{
			HWND TrayWnd = FindWindow(0, _T("ImageUploader_TrayWnd"));
			if (TrayWnd)
				SendMessage(TrayWnd, WM_RELOADSETTINGS,  (floatWnd.m_hWnd) ? 1 : 0, (Settings.Hotkeys_changed) ? 0 : 1);
		}

		Settings.Hotkeys_changed  = false;
#endif
		return true;
	}
예제 #15
0
int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int nPCIVendor, LARGE_INTEGER VideoDriverVersion)
{
	H264Context*	pContext	= (H264Context*) pAVCtx->priv_data;
	SPS*			cur_sps;
	PPS*			cur_pps;

	int supportLevel51 = 0;

	if (pBuffer != NULL)
		av_h264_decode_frame (pAVCtx, pBuffer, nSize);

	cur_sps		= pContext->sps_buffers[0];
	cur_pps		= pContext->pps_buffers[0];

	if (cur_sps != NULL)
	{
		
		if (nPCIVendor == 4318) {
			// nVidia cards support level 5.1 since drivers v6.14.11.7800 for XP and drivers v7.15.11.7800 for Vista
			// vA.B.C.D
			int A, B, C, D;
			if (IsVista()) {
				A = 7; B = 15; C = 11; D = 7800;
			} else {
				A = 6; B = 14; C = 11; D = 7800;
			}

			if (HIWORD(VideoDriverVersion.HighPart) > A) {
				supportLevel51 = 1;
			} else if (HIWORD(VideoDriverVersion.HighPart) == A) {
				if (LOWORD(VideoDriverVersion.HighPart) > B) {
					supportLevel51 = 1;
				} else if (LOWORD(VideoDriverVersion.HighPart) == B) {
					if (HIWORD(VideoDriverVersion.LowPart) > C) {
						supportLevel51 = 1;
					} else if (HIWORD(VideoDriverVersion.LowPart) == C) {
						if (LOWORD(VideoDriverVersion.LowPart) >= D) {
							supportLevel51 = 1;
						}
					}
				}
			}
		}

		// Check max num reference frame according to the level
		#define MAX_DPB_41 12288 // DPB value for level 4.1

		if (supportLevel51 == 1) {
			// 11 refs as absolute max, but for Nvidia - 16
			if (cur_sps->ref_frame_count > 16/*11*/)
				return 2;	// Too much ref frames
		} else {
			// level 4.1 with 11 refs as absolute max
			if (cur_sps->ref_frame_count > min(11, (1024*MAX_DPB_41/(nWidth*nHeight*1.5))))
				return 2;	// Too much ref frames
		}
	
	}
		
	return 0;
}
예제 #16
0
int main ()
{
	int argc;
	//TCHAR charBuf[BUFFERSIZE];
    LPTSTR KeePassRPCSource;
	LPTSTR KeePassRPCDest;
	LPWSTR commandLine = GetCommandLineW();
	int bufSize = lstrlen(commandLine); //TODO2: a bit too cautious
	TCHAR charBuf[4096];// = L"";
	for (int j=0; j<4096; j++)
		charBuf[j] = '\0';
	LPTSTR cmdParams = (LPTSTR) charBuf;
//	SecureZeroMemory(&cmdParams, 4096);

	// extract the command line parameters and check there is the right quantity
	LPTSTR *argv = ::CommandLineToArgvW(commandLine,&argc);
	if (argc <= 1)
	{
		LocalFree(argv);
//		printf("a");
		return 1;
	}

	for (int i=2; i<argc; i++)
	{
		if (FAILED(StringCchCat(cmdParams,lstrlen(cmdParams)+lstrlen(argv[i])+1,argv[i])))
		{
			LocalFree(argv);
//			printf("b");
			return 1;
		}
	}

int result = 0;

	if (IsVista())
		result = MyShellExec( NULL, L"runas", argv[1], cmdParams,L"", TRUE );
	else
		result = MyShellExec( NULL, L"open", argv[1], cmdParams,L"", TRUE );
//printf("c");
		LocalFree(argv);
	return result;

	//// define 1KB buffers for each file path (should be more than enough
	////for any path length for forseeable future and is already longer
	////than current MAX_PATH windows constant)
 //   KeePassRPCSource = (LPTSTR) charBuf;
	//KeePassRPCDest = (LPTSTR) charBuf+(INDIVIDUALBUFFERSIZE);

	//// populate the string buffers with the directory path to each file we're interested in
 //   if (FAILED(StringCchCopy(
	//	KeePassRPCSource,
	//	INDIVIDUALBUFFERSIZE-(sizeof(TCHAR)*lstrlen(L"\\KeePassRPC.plgx")),
	//	argv[1])))
 //   {
 //       LocalFree(argv);
 //       return 1;
 //   }

	//if (FAILED(StringCchCopy(
	//	KeePassRPCDest,
	//	INDIVIDUALBUFFERSIZE-(sizeof(TCHAR)*lstrlen(L"\\KeePassRPC.plgx")),
	//	argv[2])))
 //   {
 //       LocalFree(argv);
 //       return 1;
 //   }

	//// create the plugins directory if required
	//if (!fileExists(argv[2]))
	//	CreateDirectoryW(argv[2],NULL);
	//	
	//LocalFree(argv);

	//// append the name of each file so we end up with full paths to the files we need
	//if (FAILED(StringCchCat(KeePassRPCSource,INDIVIDUALBUFFERSIZE,L"\\KeePassRPC.plgx")))
	//	return 1;
	//if (FAILED(StringCchCat(KeePassRPCDest,INDIVIDUALBUFFERSIZE,L"\\KeePassRPC.plgx")))
	//	return 1;

	//// copy the file to its new home
	//if (::CopyFileW (KeePassRPCSource, KeePassRPCDest, false))
	//	return 0; // everything worked

 //   return 1;	// files couldn't be copied (most likely = permission
	//			// denied but we can't be certain about that)
}