コード例 #1
2
STDMETHODIMP C[!output Safe_root]PropPage::Apply(void)
{
    WCHAR   wszStr[MAXSTRING] = { 0 };
    double  fScaleFactor = 1.0;

    GetDlgItemText(IDC_SCALEFACTOR, wszStr, sizeof(wszStr) / sizeof(wszStr[0]));
    swscanf_s(wszStr, L"%lf", &fScaleFactor);    

    // make sure scale factor is valid
    if ((fScaleFactor < 0.0) ||
        (fScaleFactor > 1.0))
    {
        if (::LoadString(_Module.GetResourceInstance(), IDS_SCALERANGEERROR, wszStr, sizeof(wszStr) / sizeof(wszStr[0])))
        {
            MessageBox(wszStr);
        }

        return E_FAIL;
    }

    // update the registry
    CRegKey key;
    LONG    lResult;

    lResult = key.Create(HKEY_CURRENT_USER, kwszPrefsRegKey);
    if (ERROR_SUCCESS == lResult)
    {
[!if VSNET]
        DWORD dwValue = (DWORD) (fScaleFactor * 65536);
        lResult = key.SetValue(kwszPrefsScaleFactor, REG_DWORD, &dwValue, sizeof(dwValue));
[!else]
        lResult = key.SetValue((DWORD) (fScaleFactor * 65536), kwszPrefsScaleFactor );
[!endif]
    }
コード例 #2
0
void loadOptions()
{
	FILE* optionsFile = getOptionsFile(L"r");

	if (optionsFile)
	{
		WCHAR option[256], value[256];
		while (fwscanf_s(optionsFile, L"%[^,],%[^\r\n] ", option, 256, value, 256) == 2)
		{
			if (wcsncmp(option, reqFSOptionName, 256) == 0)
			{
				unsigned char fullscreen;
				swscanf_s(value, L"%hhu", &fullscreen);
				reqFullscreen = fullscreen;
			}
			else if (wcsncmp(option, soundOptionName, 256) == 0)
			{
				swscanf_s(value, L"%i", &soundOption);
			}
		}

		fclose(optionsFile);
	}

	updateRequireFullScreen();
	updateSoundOption();
}
コード例 #3
0
ファイル: GoToDlg.cpp プロジェクト: Armada651/mpc-hc
void CGoToDlg::OnParseTimeCode()
{
    UpdateData();

    AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GOTO_LAST_USED, TYPE_TIME);

    // The hh and mm are declared volatile to work around a compiler bug with ICL 13.
    // It prevents the compiler to optimize out those variables from the computation.
    volatile unsigned int hh = 0;
    volatile unsigned int mm = 0;
    float ss = 0.0f;
    wchar_t c[2]; // unnecessary character

    if (((swscanf_s(m_timestr, L"%f%1s", &ss, c, _countof(c)) == 1) // ss[.ms]
            || (swscanf_s(m_timestr, L"%u:%f%1s", &mm, &ss, c, _countof(c)) == 2 && ss < 60.0f) // mm:ss[.ms]
            || (swscanf_s(m_timestr, L"%u:%u:%f%1s", &hh, &mm, &ss, c, _countof(c)) == 3 && mm < 60  && ss < 60.0f)) // hh:mm:ss[.ms]
            && ss >= 0.0f) {

        int time = (int)(1000.0f * ((hh * 60 + mm) * 60 + ss) + 0.5f);
        m_time = time * 10000i64;

        OnOK();
    } else {
        AfxMessageBox(IDS_GOTO_ERROR_PARSING_TIME, MB_ICONEXCLAMATION | MB_OK, 0);
    }
}
コード例 #4
0
ファイル: GoToDlg.cpp プロジェクト: Tphive/mpc-be
void CGoToDlg::OnBnClickedOk1()
{
    UpdateData();

    AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GOTO_LAST_USED, TYPE_TIME);

    unsigned int hh = 0;
    unsigned int mm = 0;
    float ss = 0.0;
    wchar_t c1 = L':'; // delimiter character
    wchar_t c2 = L':'; // delimiter character
    wchar_t c3[2]; // unnecessary character

    if (((swscanf_s(m_timestr, L"%f%1s", &ss, &c3, _countof(c3)) == 1 || // sss[.ms]
            swscanf_s(m_timestr, L"%u%c%f%1s", &mm, &c2, sizeof(wchar_t), &ss, &c3, _countof(c3)) == 3 && ss < 60 || // mmm:ss[.ms]
            (swscanf_s(m_timestr, L"%u%c%u%c%f%1s", &hh, &c1, sizeof(wchar_t), &mm, &c2, sizeof(wchar_t), &ss, &c3, _countof(c3)) == 5 && mm < 60  && ss < 60)) && // hhh:mm:ss[.ms]
            c1 == L':' && c2 == L':' && ss >= 0)) {

        int time = (int)(1000*((hh*60+mm)*60+ss)+0.5);
        m_time = time * 10000i64;

        OnOK();
    } else {
        AfxMessageBox(ResStr(IDS_GOTO_ERROR_PARSING_TIME), MB_ICONEXCLAMATION | MB_OK);
    }
}
コード例 #5
0
ファイル: serviceControl.cpp プロジェクト: BillyONeal/pevFind
int serviceControl::main(int argc, wchar_t* argv[])
{
    if (argc < 3) throw std::runtime_error("At least 3 arguments are required for SC!");
    if (boost::algorithm::iequals(argv[1], L"create"))
    {
        if (argc < 6) return 1;
        DWORD serviceType;
        if (swscanf_s(argv[4], L"%u", &serviceType) != 1) return 1;
        DWORD startType;
        if (swscanf_s(argv[5], L"%u", &startType) != 1) return 1;
        SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE | SC_MANAGER_CONNECT | STANDARD_RIGHTS_EXECUTE);
        SC_HANDLE createdService = ::CreateServiceW(
                                       hSCM,
                                       argv[2],
                                       argc >= 6 ? argv[6] : NULL,
                                       SC_MANAGER_ALL_ACCESS,
                                       serviceType,
                                       startType,
                                       SERVICE_ERROR_IGNORE,
                                       argv[3],
                                       NULL,
                                       NULL,
                                       NULL,
                                       NULL,
                                       NULL);
        CloseServiceHandle(createdService);
        CloseServiceHandle(hSCM);
        return 0;
    } else if (boost::algorithm::iequals(argv[1], L"delete"))
    {
        SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | STANDARD_RIGHTS_EXECUTE);
        SC_HANDLE openedService = OpenService(hSCM, argv[2], DELETE | SERVICE_CHANGE_CONFIG);
        DeleteService(openedService);
        CloseServiceHandle(openedService);
        CloseServiceHandle(hSCM);
    } else if (boost::algorithm::iequals(argv[1], L"stop"))
    {
        SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | STANDARD_RIGHTS_EXECUTE);
        SC_HANDLE openedService = OpenService(hSCM, argv[2], SERVICE_STOP);
        SERVICE_STATUS crap;
        ControlService(openedService, SERVICE_CONTROL_STOP, &crap);
        CloseServiceHandle(openedService);
        CloseServiceHandle(hSCM);
    } else if (boost::algorithm::iequals(argv[1], L"start"))
    {
        SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | STANDARD_RIGHTS_EXECUTE);
        SC_HANDLE openedService = OpenService(hSCM, argv[2], SERVICE_START);
        StartService(openedService, NULL, NULL);
        CloseServiceHandle(openedService);
        CloseServiceHandle(hSCM);
    }
    return 0;
}
コード例 #6
0
ファイル: SettingDlg.cpp プロジェクト: ardy30/YUVPlayer
BOOL CSettingDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    CString strTemp;

    // default
    if (!ExistRegistration())
    {
        SetRegistration(m_strAddedSize, m_nWidth,m_nHeight, m_nFpsIndex, m_nYuvFormat, m_fLoop);
    }
    // read
    GetRegistration(m_strAddedSize, m_nWidth, m_nHeight, m_nFpsIndex, m_nYuvFormat, m_fLoop);

    int pos = 0;  
    strTemp = m_strAddedSize.Tokenize(_T(";"), pos);
    m_strArrAddedSize.Add(strTemp);
    while (strTemp != _T(""))
    {
        strTemp = m_strAddedSize.Tokenize(_T(";"), pos);
        m_strArrAddedSize.Add(strTemp);
    }

    // 不知为何,最后一个是空的,这里删除,否则后面再添加时会多一个空字符串
    m_strArrAddedSize.RemoveAt(m_strArrAddedSize.GetCount()-1);

    int nResolutionIdx = -1;
    for (int i = 0; i < m_strArrAddedSize.GetCount(); i++)
    {
        m_cbResolution.AddString(m_strArrAddedSize[i]);
        int width = 0;
        int height = 0;
        swscanf_s(m_strArrAddedSize[i].GetBuffer(), _T("%dx%d"), &width, &height);
        if (width == m_nWidth && height == m_nHeight)
            nResolutionIdx = i;
    }

    m_cbYuvFormat.SetCurSel(m_nYuvFormat);
    m_cbFps.SetCurSel(m_nFpsIndex);
    m_cbResolution.SetCurSel(nResolutionIdx);
    m_nYuvFormat = m_cbYuvFormat.GetCurSel();
    m_cbFps.GetWindowText(strTemp);
    swscanf_s(strTemp.GetBuffer(), _T("%d"), &m_nFps);

    GetDlgItem(IDC_APPLY)->EnableWindow(FALSE);

    UpdateData(FALSE);
    return TRUE;  // return TRUE unless you set the focus to a control
}
コード例 #7
0
ファイル: PPageVideo.cpp プロジェクト: Tphive/mpc-be
BOOL CPPageVideo::OnApply()
{
	UpdateData();

	AppSettings& s = AfxGetAppSettings();

	CRenderersSettings& renderersSettings                   = s.m_RenderersSettings;
	s.iDSVideoRendererType		                            = m_iDSVideoRendererType = m_iDSVideoRendererType_store = m_iDSVideoRendererTypeCtrl.GetItemData(m_iDSVideoRendererTypeCtrl.GetCurSel());
	s.iRMVideoRendererType		                            = m_iRMVideoRendererType;
	s.iQTVideoRendererType		                            = m_iQTVideoRendererType;
	renderersSettings.iAPSurfaceUsage	                    = m_iAPSurfaceUsage;
	renderersSettings.iDX9Resizer		                    = m_iDX9Resizer;
	renderersSettings.fVMRMixerMode							= !!m_fVMRMixerMode;
	renderersSettings.fVMRMixerYUV		                    = !!m_fVMRMixerYUV;

	renderersSettings.m_AdvRendSets.fVMR9AlterativeVSync	= m_fVMR9AlterativeVSync != 0;
	s.fD3DFullscreen			                            = m_fD3DFullscreen ? true : false;

	renderersSettings.fResetDevice = !!m_fResetDevice;

	if (!m_iEvrBuffers.IsEmpty()) {
		int Temp = 5;
		swscanf_s(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
		renderersSettings.iEvrBuffers = Temp;
	} else {
		renderersSettings.iEvrBuffers = 5;
	}

	renderersSettings.D3D9RenderDevice = m_fD3D9RenderDevice ? m_D3D9GUIDNames[m_iD3D9RenderDevice] : L"";

	return __super::OnApply();
}
コード例 #8
0
ファイル: Utils.cpp プロジェクト: 453483289/x360ce
void StringToGUID(GUID* id, const std::wstring& szBuf)
{
	const wchar_t* p = szBuf.c_str();
	if (wcschr(p, L'{')) p++;

	u32 d1;
	s32 d2, d3;
	s32 b[8];

	if (swscanf_s(p, L"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
		&d1, &d2, &d3, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7]) != 11)
	{
		*id = GUID_NULL;
		return;
	}

	id->Data1 = d1;
	id->Data2 = (u16)d2;
	id->Data3 = (u16)d3;

	for (int i = 0; i < 8; ++i)
		id->Data4[i] = (u8)b[i];

	return;
}
コード例 #9
0
bool CLR_RT_ParseOptions::Parameter_Boolean::Parse( LPCWSTR arg )
{
    int num;

    if(!_wcsicmp( arg, L"true" ) ||
       !_wcsicmp( arg, L"on"   )  )
    {
        *m_dataPtr = true;
        return true;
    }

    if(!_wcsicmp( arg, L"false" ) ||
       !_wcsicmp( arg, L"off"   )  )
    {
        *m_dataPtr = false;
        return true;
    }

    if(swscanf_s( arg, L"%d", &num ) == 0)
    {
        wprintf( L"Expecting a boolean for parameter '%s': %s\n\n", m_szName, arg );
        return false;
    }

    *m_dataPtr = (num != 0);
    return true;
}
コード例 #10
0
void IRCMsgThread::SetUserColor(std::wstring User,std::wstring Color){ //already lowercase
	//std::map<std::wstring,unsigned int> UserColorMap
	unsigned int iColor;
	std::wregex color_pattern(L"^#[0-9a-fA-F]{6}$");
	//std::wsmatch base_match;
	if(std::regex_match(Color, color_pattern)){
		int iErrno=swscanf_s(Color.substr(1).c_str(),L"%x",&iColor);
	}
	else {
		iColor=1<<24;
		if(Color.compare(L"red")==0)				iColor=0x00FF0000;
		else if(Color.compare(L"blue")==0)			iColor=0x000000FF;
		else if(Color.compare(L"green")==0)			iColor=0x00008000;
		else if(Color.compare(L"firebrick")==0)		iColor=0x00B22222;
		else if(Color.compare(L"coral")==0)			iColor=0x00FF7F50;
		else if(Color.compare(L"yellowgreen")==0)	iColor=0x009ACD32;
		else if(Color.compare(L"orangered")==0)		iColor=0x00FF4500;
		else if(Color.compare(L"seagreen")==0)		iColor=0x002E8B57;
		else if(Color.compare(L"goldenrod")==0)		iColor=0x00D2691E;
		else if(Color.compare(L"cadetblue")==0)		iColor=0x005F9EA0;
		else if(Color.compare(L"dodgerblue")==0)	iColor=0x001E90FF;
		else if(Color.compare(L"hotpink")==0)		iColor=0x00FF69B4;
		else if(Color.compare(L"blueviolet")==0)	iColor=0x008A2BE2;
		else if(Color.compare(L"springgreen")==0)	iColor=0x0000FF7F;
		else if(Color.compare(L"black")==0)			iColor=0x00000000;
		else if(Color.compare(L"gray")==0)			iColor=0x00808080;
		else if(Color.compare(L"darkred")==0)		iColor=0x008B0000;
		else if(Color.compare(L"midnightblue")==0)	iColor=0x00191970;
		else if(Color.compare(L"deeppink")==0)		iColor=0x00FF1493;
	}
	//onDebugMsg(L"SetUserColor: %ls, %ls, 0X%08X\n",User.c_str(),Color.c_str(),iColor);
		std::pair<std::map<std::wstring,unsigned int>::iterator,bool> ret=UserColorMap.insert( std::pair<std::wstring,unsigned int>(User,iColor|0xFF000000) );
		if (ret.second==false) ret.first->second=iColor|0xFF000000;
}
コード例 #11
0
ファイル: product.cpp プロジェクト: firegiant/wix4
HRESULT ProductValidateVersion(
    __in_z LPCWSTR wzVersion
    )
{
    HRESULT hr = S_OK;

    DWORD dw1 = 0;
    DWORD dw2 = 0;
    DWORD dw3 = 0;
    DWORD dw4 = 0;
    DWORD dwResult = 0;
    WCHAR wcExtra;

    dwResult = swscanf_s(wzVersion, L"%u.%u.%u.%u%lc", &dw1, &dw2, &dw3, &dw4, &wcExtra);

    // Must have 4 components to the version
    if (4 != dwResult)
    {
        hr = HRESULT_FROM_WIN32(ERROR_CLUSTER_INVALID_STRING_FORMAT);
        ExitOnFailure(hr, "Version \"%ls\" wasn't in a valid format - expected version like: 1.0.0.0", wzVersion);
    }

    // TODO: Any additional validation here? Is "0.*" accepted? What about a version component > 65535?

LExit:
    return hr;
}
コード例 #12
0
BOOL CALLBACK OpenFileDialogProc(HWND hDlg, UINT message,
                                 WPARAM wParam, LPARAM lParam)
{
   _TCHAR achText[260];

   switch (message)
   {
      case WM_INITDIALOG:
         return TRUE;

      case WM_COMMAND:
         switch (LOWORD(wParam))
         {
            case IDOK:
               GetDlgItemText(hDlg, IDC_FILENAME, achText, sizeof(achText));
               swscanf_s(achText, TEXT("%s"), achFileName, 260);
               EndDialog(hDlg, 1);
               return TRUE;

            case IDCANCEL:
               EndDialog(hDlg, 0);
               return FALSE;
         }
         break;
   }
   return FALSE;
}
コード例 #13
0
void ConfigurationRemoteXmlParser::ParseBlockCompatibility(XmlNode node)
{
	if (node.GetName().compare(L"version")==0)
	{
		m_configuration.SetCompatibility(node.GetText());
	}

	if (node.GetName().compare(L"date")==0)
	{		
		wstring sdate = node.GetText();
		wchar_t* date = (wchar_t *) sdate.c_str();
		int params;
		SYSTEMTIME stime = { 0 };
		FILETIME ftime = { 0 };

		params = swscanf_s(date, L"%04d-%02d-%02dT%02d:%02d:%02d",
			&stime.wYear, &stime.wMonth,  &stime.wDay,
			&stime.wHour, &stime.wMinute, &stime.wSecond);

		if (params == NUMBER_OF_PARMS)
		{
			_LARGE_INTEGER ulong;

			SystemTimeToFileTime(&stime, &ftime);		

			ulong.LowPart = ftime.dwLowDateTime;
			ulong.HighPart = ftime.dwHighDateTime;
			m_configuration.SetDateTime(ulong);
		}
	}
}
コード例 #14
0
ファイル: GoToDlg.cpp プロジェクト: Tphive/mpc-be
void CGoToDlg::OnBnClickedOk2()
{
    UpdateData();

    AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GOTO_LAST_USED, TYPE_FRAME);

    unsigned int frame;
    float fps;
    wchar_t c1[2]; // delimiter character
    wchar_t c2[2]; // unnecessary character

    int result = swscanf_s(m_framestr, L"%u%1s%f%1s", &frame, &c1, _countof(c1), &fps, &c2, _countof(c2));

    if (result == 1) {
        m_time = (REFERENCE_TIME)ceil(10000000.0*frame/m_fps);
        OnOK();
    } else if (result == 3 && c1[0] == L',') {
        m_time = (REFERENCE_TIME)ceil(10000000.0*frame/fps);
        OnOK();
    } else if (result == 0 || c1[0] != L',') {
        AfxMessageBox(ResStr(IDS_GOTO_ERROR_PARSING_TEXT), MB_ICONEXCLAMATION | MB_OK);
    } else {
        AfxMessageBox(ResStr(IDS_GOTO_ERROR_PARSING_FPS), MB_ICONEXCLAMATION | MB_OK);
    }
}
コード例 #15
0
wstring formatDate(StringBuffer& date) {
    
    wstring dd(TEXT(""));
    wchar_t* wdate = toWideChar(date);
    if (wdate == NULL) {
        return dd;
    }
    wchar_t data[80];
    wchar_t formatDate[80];
    int found = 0;
    SYSTEMTIME timeDest;
    swscanf_s(wdate, L"%4d%2d%2d", &timeDest.wYear, &timeDest.wMonth, &timeDest.wDay);
    
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, data, 80);

    dd = data;            
    if ((found = dd.find(TEXT("dddd, "))) != wstring::npos) {
        dd.replace(found, 6, TEXT(""));
    } else if ((found = dd.find(TEXT("dddd,"))) != wstring::npos) {
        dd.replace(found, 5, TEXT(""));
    }else if ((found = dd.find(TEXT("dddd"))) != wstring::npos) {
        dd.replace(found, 4, TEXT(""));
    }

    trim(dd);            
    GetDateFormat(LOCALE_USER_DEFAULT, NULL, &timeDest, dd.c_str(), formatDate, 80); 
    dd = formatDate;
    return dd;
}
コード例 #16
0
static bool
ParseChannelMappingItem(std::wstring s, ChannelMappingItem &item_return)
{
    std::wstring::size_type found = s.find(L'>');
    if (found == std::wstring::npos || s.length()-1 <= found) {
        return false;
    }

    s[found] = 0;
    const wchar_t *sc = s.c_str();

    swscanf_s(&sc[0],       L"%u", &item_return.fromCh);
    swscanf_s(&sc[found+1], L"%u", &item_return.toCh);

    return true;
}
コード例 #17
0
ファイル: filter.cpp プロジェクト: timepp/tplog
bool logcontent_filter::load(component_creator* /*cc*/, serializer* s)
{
	m_matcher = s->get_property(L"matcher");
	int tmp = 0;
	swscanf_s(s->get_property(L"ignorecase").c_str(), L"%d", &tmp);
	m_ignore_case = (tmp == 1);
	tmp = 0;
	swscanf_s(s->get_property(L"useregex").c_str(), L"%d", &tmp);
	m_use_regex = (tmp == 1);

	if (m_use_regex)
	{
		m_regexp.Parse(m_matcher.c_str(), m_ignore_case);
	}

	return true;
}
コード例 #18
0
ファイル: SettingDlg.cpp プロジェクト: ardy30/YUVPlayer
void CSettingDlg::OnSelchangeCbFps()
{
    CString strTemp;
    m_nFpsIndex = m_cbFps.GetCurSel();
    m_cbFps.GetLBText(m_cbFps.GetCurSel(), strTemp);
    swscanf_s(strTemp.GetBuffer(), _T("%d"), &m_nFps);
    GetDlgItem(IDC_APPLY)->EnableWindow(TRUE);
}
コード例 #19
0
ファイル: IniFile.cpp プロジェクト: SHIYUENING/topace
float GetIniFloat2(wchar_t * lpAppName,wchar_t * lpKeyName,const wchar_t * lpFileName,const wchar_t * DefChar)
{
	wchar_t ReadIniTMP[512];
	float IniFloat=0.0f;
	GetPrivateProfileStringW(lpAppName,lpKeyName,DefChar,ReadIniTMP,512,lpFileName);
	swscanf_s(ReadIniTMP,L"%f",&IniFloat);
	return IniFloat;
}
コード例 #20
0
ファイル: SettingDlg.cpp プロジェクト: ardy30/YUVPlayer
void CSettingDlg::OnSelchangeCbSize()
{
    CString strTemp;
    m_cbResolution.GetLBText(m_cbResolution.GetCurSel(), strTemp);
    swscanf_s(strTemp.GetBuffer(), _T("%dx%d"), &m_nWidth, &m_nHeight);

    UpdateData(FALSE);
    GetDlgItem(IDC_APPLY)->EnableWindow(TRUE);
}
コード例 #21
0
void CWeekTimePicker::UpdateTimeToRect()
{
	for (int i=0; i<WEEK_LEN; ++i)
	{
		if (i >= (int)m_vecWeekTimes.size())
		{
			break;
		}
		else
		{
			if (m_vecWeekTimes[i].nWeekIndex != i)
			{
				WeekDayTime weekDaytime;
				weekDaytime.nWeekIndex = i;
				m_vecWeekTimes.insert(m_vecWeekTimes.begin()+i, weekDaytime);
			}
		}
		auto &weekDayTime = m_vecWeekTimes[i];
		auto &rcBar = m_vecWeekDayBarRect[i];
		int iHour, iMinute, iSecond;
		CString cstrTime;
		m_vecWeekDayBarSelectedRect[i].vecDayRects.clear();

		for (size_t j=0; j<weekDayTime.vecDayTimes.size(); ++j)
		{
			CRect rcBarSelect = rcBar;
			cstrTime = weekDayTime.vecDayTimes[j].cstrBeginTime;
#ifdef _UNICODE
			swscanf_s(cstrTime.GetBuffer(), L"%d:%d:%d", &iHour, &iMinute, &iSecond);
#else
			sscanf_s(cstrTime.GetBuffer(), "%d:%d:%d", &iHour, &iMinute, &iSecond);
#endif
			rcBarSelect.left = rcBar.left + iHour*HOUR_WIDTH + iMinute*HOUR_WIDTH/60;
			cstrTime = weekDayTime.vecDayTimes[j].cstrEndTime;
#ifdef _UNICODE
			swscanf_s(cstrTime.GetBuffer(), L"%d:%d:%d", &iHour, &iMinute, &iSecond);
#else
			sscanf_s(cstrTime.GetBuffer(), "%d:%d:%d", &iHour, &iMinute, &iSecond);
#endif
			rcBarSelect.right = rcBar.left + iHour*HOUR_WIDTH + iMinute*HOUR_WIDTH/60;
			m_vecWeekDayBarSelectedRect[i].vecDayRects.push_back(rcBarSelect);
		}
	}
}
コード例 #22
0
ファイル: HbgPlatform.cpp プロジェクト: plantrue/Hambugger
BOOL HbgScanHex4bit(const std::wstring& text, unsigned char& value)
{
	unsigned char tmpVal = 0;
	if (swscanf_s(text.c_str(), HbgFmtValStr_4bit, &tmpVal) > 0) {
		value = tmpVal;
		return TRUE;
	}

	return FALSE;
}
コード例 #23
0
LRESULT CLogTIDFilterEditDlg::OnOK(WORD , WORD , HWND , BOOL& )
{
	CStringW text;
	GetDlgItemText(IDC_EDIT_LOGTID, text);
	unsigned int tid;
	swscanf_s((LPCWSTR)text, L"%u", &tid);
	m_filter->setfilter(tid);
	EndDialog(IDOK);
	return 0;
}
コード例 #24
0
ファイル: HbgPlatform.cpp プロジェクト: plantrue/Hambugger
BOOL HbgScanHex2byte(const std::wstring& text, WORD& value)
{
	WORD tmpVal = 0;
	if (swscanf_s(text.c_str(), HbgFmtValStr_2byte, &tmpVal) > 0) {
		value = tmpVal;
		return TRUE;
	}

	return FALSE;
}
コード例 #25
0
bool CLR_RT_ParseOptions::Parameter_Integer::Parse( LPCWSTR arg )
{
    if(swscanf_s( arg, L"%d", m_dataPtr ) == 0)
    {
        wprintf( L"Expecting a number for parameter '%s': %s\n\n", m_szName, arg );
        return false;
    }

    return true;
}
コード例 #26
0
ファイル: LVHdrCtrl.cpp プロジェクト: soundsrc/pwsafe
BOOL CLVHdrCtrl::OnDrop(CWnd* /* pWnd */, COleDataObject* pDataObject,
                        DROPEFFECT /* dropEffect */, CPoint /* point */)
{
  // On Drop of column from Column Chooser Dialog onto Header
  if (!pDataObject->IsDataAvailable(m_ccddCPFID, NULL))
    return FALSE;

  HGLOBAL hGlobal;
  hGlobal = pDataObject->GetGlobalData(m_ccddCPFID);

  LPCWSTR pData = (LPCWSTR)GlobalLock(hGlobal);
  ASSERT(pData != NULL);

  DWORD procID;
  int iDDType, iType;

  swscanf_s(pData, L"%08x%02x%02x", &procID, &iDDType, &iType);

  // Check if it is ours?
  // - we don't accept drop from other instances of PWS
  // - we only accept drops from our ColumnChooser or our Header
  // - standard moving within the header only available if CC dialog not visible
  if ((procID != GetCurrentProcessId()) || (iDDType != FROMCC)) {
    GlobalUnlock(hGlobal);
    return FALSE;
  }

  int iAfterIndex;
  if (iType != CItemData::UUID) {
    // Get index of column we are on
    HDHITTESTINFO hdhti;
    hdhti.pt = CPoint(::GetMessagePos());
    hdhti.flags = 0;
    ScreenToClient(&hdhti.pt);
    ::SendMessage(this->GetSafeHwnd(), HDM_HITTEST, 0, (LPARAM) &hdhti);
    iAfterIndex = hdhti.iItem;
  } else
    iAfterIndex = 0;

  // Now add it but only if not trying to place to the left of the icon
  BOOL brc = TRUE;
  HDITEM hdi = {0};
  hdi.mask = HDI_LPARAM;
  GetItem(0, &hdi);
  if (hdi.lParam == CItemData::UUID && iAfterIndex == 0)
    brc = FALSE;
  else
    ::SendMessage(AfxGetApp()->m_pMainWnd->GetSafeHwnd(),
                  PWS_MSG_CCTOHDR_DD_COMPLETE, (WPARAM)iType, (LPARAM)iAfterIndex);

  GlobalUnlock(hGlobal);

  GetParent()->SetFocus();
  return brc;
}
コード例 #27
0
NTSTATUS kuhl_m_sekurlsa_msv_pth(int argc, wchar_t * argv[])
{
	BYTE ntlm[LM_NTLM_HASH_LENGTH] = {0};
	TOKEN_STATISTICS tokenStats;
	MSV1_0_PTH_DATA data = {&(tokenStats.AuthenticationId), NULL, NULL, ntlm, FALSE};
	PCWCHAR szRun, szNTLM, pFakeUserName, pFakeLogonDomain;
	DWORD i, j, dwNeededSize;
	HANDLE hToken;
	PROCESS_INFORMATION processInfos;

	if(pFakeUserName = kuhl_m_sekurlsa_msv_pth_makefakestring(argc, argv, L"user", &data.UserName))
	{
		if(pFakeLogonDomain = kuhl_m_sekurlsa_msv_pth_makefakestring(argc, argv, L"domain", &data.LogonDomain))
		{
			if(kull_m_string_args_byName(argc, argv, L"ntlm", &szNTLM, NULL))
			{
				kull_m_string_args_byName(argc, argv, L"run", &szRun, L"cmd.exe");
				if(wcslen(szNTLM) == (LM_NTLM_HASH_LENGTH * 2))
				{
					for(i = 0; i < LM_NTLM_HASH_LENGTH; i++)
					{
						swscanf_s(&szNTLM[i*2], L"%02x", &j);
						ntlm[i] = (BYTE) j;
					}
					kprintf(L"NTLM\t: "); kull_m_string_wprintf_hex(data.NtlmHash, LM_NTLM_HASH_LENGTH, 0); kprintf(L"\n");
					kprintf(L"Program\t: %s\n", szRun);
					if(kull_m_process_create(KULL_M_PROCESS_CREATE_LOGON, szRun, CREATE_SUSPENDED, NULL, LOGON_NETCREDENTIALS_ONLY, pFakeUserName, pFakeLogonDomain, L"", &processInfos, FALSE))
					{
						kprintf(
							L"  |  PID  %u\n"
							L"  |  TID  %u\n",
							processInfos.dwProcessId, processInfos.dwThreadId);
						if(OpenProcessToken(processInfos.hProcess, TOKEN_READ, &hToken))
						{
							if(GetTokenInformation(hToken, TokenStatistics, &tokenStats, sizeof(tokenStats), &dwNeededSize))
							{
								kprintf(L"  |  LUID %u ; %u (%08x:%08x)\n", tokenStats.AuthenticationId.HighPart, tokenStats.AuthenticationId.LowPart, tokenStats.AuthenticationId.HighPart, tokenStats.AuthenticationId.LowPart);
								kprintf(L"  \\_ ");
								kuhl_m_sekurlsa_enum(kuhl_m_sekurlsa_enum_callback_msv_pth, &data);
							} else PRINT_ERROR_AUTO(L"GetTokenInformation");
							CloseHandle(hToken);
						} else PRINT_ERROR_AUTO(L"OpenProcessToken");
						NtResumeProcess(processInfos.hProcess);
						CloseHandle(processInfos.hThread);
						CloseHandle(processInfos.hProcess);
					} else PRINT_ERROR_AUTO(L"CreateProcessWithLogonW");
				} else PRINT_ERROR(L"ntlm hash length must be 32 (16 bytes)\n");
			} else PRINT_ERROR(L"Missing argument : ntlm\n");
			LocalFree((HLOCAL) pFakeLogonDomain);
		}
		LocalFree((HLOCAL) pFakeUserName);
	}
	return STATUS_SUCCESS;
}
コード例 #28
0
ファイル: YString.cpp プロジェクト: SinYocto/Zee
bool YString::GetSpecifier(wchar_t* specifier, int specifierSize, const wchar_t* str)
{
	Assert(NULL != str);
	Assert(NULL != specifier);

	swscanf_s(str, L"%s", specifier, specifierSize);

	return true;
Exit:
	return false;
}
コード例 #29
0
Serializer::Serializer(const CString& hex)
{
    size_t bufLen = hex.GetLength() / 2;
    for (size_t i = 0; i < bufLen; ++i)
    {
        DWORD t;
        if (1 != swscanf_s((LPCTSTR)hex + i * 2, L"%02X", &t))
            throw std::runtime_error("invalid buffer");
        m_storage.push_back((BYTE)t);
    }
    m_buf = &m_storage[0];
    m_size = m_storage.size();
}
コード例 #30
0
ファイル: SaveManager.cpp プロジェクト: Nucleoprotein/dsfix
time_t SaveManager::getLastBackupTime()
{
	if (lastBackupTime == 0)
	{
		std::vector<std::wstring> backupFiles = getBackupFiles();
		if (!backupFiles.empty())
		{
			std::wstring fileName = getFileNameFromPath(backupFiles.front());
			swscanf_s(fileName.c_str(), L"%llu", &lastBackupTime);
		}
	}
	SDLOG(3, "SaveManager: last backup time %llu", lastBackupTime);
	return lastBackupTime;
}