예제 #1
0
BOOL KCallInfocSend::_GetKInfocPath( OUT std::wstring& strInfocPath )
{
	HMODULE hModule = ::GetModuleHandle(NULL); 
	if (hModule == NULL)
		return FALSE;

	WCHAR szPath[MAX_PATH];
	DWORD dwReturn = ::GetModuleFileNameW(hModule, szPath, MAX_PATH);
	if (dwReturn == 0)
		return FALSE;

	int nLen = (int)wcslen(szPath);
	for (int i = nLen - 1; i >= 0; i--)
	{
		if (szPath[i] == '\\')
		{
			szPath[i + 1] = '\0';
			break;
		}
	}

	strInfocPath = szPath;
	strInfocPath += defUPDATANAME;

	if (_waccess_s(strInfocPath.c_str(), 0) != ENOENT)
		return TRUE;
	else
		return _CheckFileFromReg(strInfocPath);

	return FALSE;
}
예제 #2
0
static BOOL file_exists( LPCWSTR path )
{
  if( _waccess_s( path, 0 ) == 0 )
  {
    struct _stat status;
    _wstat( path, &status );
    return (status.st_mode & S_IFREG) != 0;
  }

  return FALSE;
}
예제 #3
0
//-----------------------------------------------
void SJ_Menu_Begin( char lastState )
{
	g_timeToNextKey = 0.5f;//s_keyTime*0.5f;
	
	ZeroMemory( s_availSkins, sizeof(s_availSkins) );
	s_curSkin = 0;
	// -- Retrieve all available skins
	wchar_t path[MAX_PATH];
	GetCurrentDirectory(MAX_PATH-1, path);
	_swprintf( g_txt, L"%s\\*", path );
#ifdef _WIN64
	PVOID OldValue = NULL;
	Wow64DisableWow64FsRedirection( &OldValue );
#endif
	WIN32_FIND_DATA ffdata;
	HANDLE hFind = FindFirstFile( g_txt, &ffdata );
	if ( hFind != INVALID_HANDLE_VALUE )
	{
		do
		{
			if ( ffdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
			{
				static const wchar_t* keypaths[] = { L"config.txt", L"levels", L"levels\\easy", L"levels\\medium", 
													 L"levels\\hard", L"levels\\extreme", L"sprites" };
				bool validSkin = true;
				for ( int i = 0; i < 7 && validSkin; ++i )
				{
					_swprintf( g_txt, L"%s\\%s\\%s", path, ffdata.cFileName, keypaths[i] );
					validSkin = validSkin && _waccess_s( g_txt, 0 ) == 0;
				}
				if (  validSkin && s_curSkin < MAX_AVAILSKINS )
				{
					wcscpy_s( s_availSkins[s_curSkin], ffdata.cFileName );
					if ( _wcsicmp( ffdata.cFileName, DEFAULT_SKIN ) == 0 ) 
						s_skinValue = s_curSkin;
					++s_curSkin;
				}
			}else
			{
			}
		}while ( FindNextFile(hFind,&ffdata)!=0 );
		FindClose(hFind);
	}
#ifdef _WIN64
	if ( OldValue )
		Wow64RevertWow64FsRedirection( OldValue );
#endif
	Menu_UpdateLabels();
}
예제 #4
0
BOOL KCallInfocSend::_CheckFileFromReg( OUT std::wstring& strFilePath )
{
	WCHAR szInstallPath[MAX_PATH] = {0};
	if (!_ReadOneRegKey(szInstallPath, MAX_PATH))
		return FALSE;

	wcscat_s(szInstallPath, MAX_PATH, L"\\operation\\cas\\");
	wcscat_s(szInstallPath, MAX_PATH, defUPDATANAME);

	if (_waccess_s(szInstallPath, 0) == ENOENT)
		return FALSE;

	strFilePath = szInstallPath;
	return TRUE;
}
int Directory_ExistW(
        _In_z_ const wchar_t *path)
{
#if defined(_MSC_VER)
    return _waccess_s(path, 0);
#else
    char *filePath;
    int result;

    if( !UCS2ToAscii( path, &filePath) )
        return -1;

    result = access(filePath, 0);
    PAL_Free(filePath);
    return result;
#endif        

}
예제 #6
0
	bool WINAPI Supervisor::CreateDecompressInvoke(HWND hWnd,std::wstring img, LPWSTR latter)
	{
		WCHAR _7zCmd[MAX_UNC_PATH] = { 0 };
		//HWND m_hWnd = static_cast<HWND>(hWnd);
		GetModuleFileName(GetModuleHandle(nullptr), _7zCmd, MAX_UNC_PATH);
		(wcsrchr(_7zCmd, _T('\\')))[0] = 0;
		(wcsrchr(_7zCmd, _T('\\')))[0] = 0;
		wcscat_s(_7zCmd, L"\\7-zip\\7z.exe");
		if (!_waccess_s(_7zCmd, 0) == 0)
		{
			return false;
		}
		wcscat_s(_7zCmd, L" x ");
		wcscat_s(_7zCmd, img.c_str());
		wcscat_s(_7zCmd, L" -aoa -y -o");
		wcscat_s(_7zCmd, latter);
		wcscat_s(_7zCmd, L"\\");
		//_waccess_s()
		PROCESS_INFORMATION pi;
		STARTUPINFO sInfo;
		DWORD dwExitCode;
		ZeroMemory(&sInfo, sizeof(sInfo));
		sInfo.cb = sizeof(sInfo);
		sInfo.dwFlags = STARTF_USESHOWWINDOW;
		sInfo.wShowWindow = SW_HIDE;
		ZeroMemory(&pi, sizeof(pi));

		DWORD result = CreateProcess(NULL, _7zCmd, NULL, NULL, NULL, CREATE_NO_WINDOW, NULL, NULL, &sInfo, &pi);
		if (result == TRUE)
		{
			CloseHandle(pi.hThread);
			PostMessage(hWnd, Metro::METRO_MULTITHREAD_MSG, MET_POST_PID_ADD, pi.dwProcessId);
			WaitForSingleObject(pi.hProcess, INFINITE);
			PostMessage(hWnd, Metro::METRO_MULTITHREAD_MSG, MET_POST_PID_CLEAR, 0);
			GetExitCodeProcess(pi.hProcess, &dwExitCode);
			CloseHandle(pi.hProcess);
			if (dwExitCode != 0 &&dwExitCode!=1)
			{
				return false;
			}
			return true;
		}
		return false;
	}
예제 #7
0
	bool ResolveSupervisor::FixUSBDeviceBoot(LPCWSTR DeviceLetter)
	{
		TCHAR BCDPath[MAX_UNC_PATH] = { 0 };
		PROCESS_INFORMATION pi;
		STARTUPINFO sInfo;
		DWORD dwExitCode;
		ZeroMemory(&sInfo, sizeof(sInfo));
		sInfo.cb = sizeof(sInfo);
		sInfo.dwFlags = STARTF_USESHOWWINDOW;
		sInfo.wShowWindow = SW_HIDE;
		ZeroMemory(&pi, sizeof(pi));
		GetModuleFileName(NULL, BCDPath, MAX_UNC_PATH);
		(wcsrchr(BCDPath, _T('\\')))[0] = 0;
		(wcsrchr(BCDPath, _T('\\')))[0] = 0;
		wcscat_s(BCDPath, L"\\BCDBoot\\bootsect.exe");
		if (!_waccess_s(BCDPath, 0) == 0)
		{
			return false;
		}
		wcscat_s(BCDPath, L" /NT60 ");
		wcscat_s(BCDPath, DeviceLetter);
		DWORD result = CreateProcessW(NULL, BCDPath, NULL, NULL, NULL, CREATE_NO_WINDOW, NULL, NULL, &sInfo, &pi);
		if (result == TRUE)
		{
			CloseHandle(pi.hThread);
			if (WAIT_TIMEOUT == WaitForSingleObject(pi.hProcess, INFINITE))
			{
				TerminateProcess(pi.hProcess, 11);
			}
			GetExitCodeProcess(pi.hProcess, &dwExitCode);
			CloseHandle(pi.hProcess);
			if (dwExitCode != 0)
			{
				return false;
			}
			return true;
		}
		return false;
	}
예제 #8
0
bool
fileExists(const std::string &path)
{
   auto winPath = platform::toWinApiString(path);
   return _waccess_s(winPath.c_str(), 0) == 0;
}
예제 #9
0
/////////////////////////////////////////////////////////////////////////////////////////////
////DirectUI Style MsgFun
LRESULT MetroWindow::OnDecompress()
{
	IsInvalid = true;
	m_proge.SetState(PBST_NORMAL);
	m_proge.SetPos(0);
	WCHAR szImage[MAX_UNC_PATH] = { 0 };
	int nButton;
	if (::GetWindowTextLength(::GetDlgItem(m_hWnd, IDC_EDIT_IMAGE)) < 8)
	{
		TaskDialog(m_hWnd, _Module.GetModuleInstance(),
			L"iBurnMgr Image Error", L"Image PATH Error!",
			L"No one really effective path!",
			TDCBF_OK_BUTTON,
			TD_ERROR_ICON, &nButton);
		IsInvalid = false;
		return 1;
	}
	::GetWindowText(GetDlgItem(IDC_EDIT_IMAGE), szImage, MAX_UNC_PATH);
	errno_t err = _waccess_s(szImage, 4);
	switch (err)
	{
	case 0:
		break;
	case EACCES:
		TaskDialog(m_hWnd, _Module.GetModuleInstance(),
			L"iBurnMgr Image Error", L"Image No read permission",
			szImage,
			TDCBF_OK_BUTTON,
			TD_ERROR_ICON, &nButton);
		IsInvalid = false;
		return EACCES;
	case ENOENT:
		TaskDialog(m_hWnd, _Module.GetModuleInstance(),
			L"iBurnMgr Image Error", L"The image file does not exist",
			szImage,
			TDCBF_OK_BUTTON,
			TD_ERROR_ICON, &nButton);
		IsInvalid = false;
		return ENOENT;
	case EINVAL:
		TaskDialog(m_hWnd, _Module.GetModuleInstance(),
			L"iBurnMgr Image Error", L"Invalid parameter",
			szImage,
			TDCBF_OK_BUTTON,
			TD_ERROR_ICON, &nButton);
		IsInvalid = false;
		return EINVAL;
	default:
		TaskDialog(m_hWnd, _Module.GetModuleInstance(),
			L"iBurnMgr Image Error", L"Unknown errorr",
			szImage,
			TDCBF_OK_BUTTON,
			TD_ERROR_ICON, &nButton);
		IsInvalid = false;
		return 3;
	}
	SpData.image = szImage;
	LRESULT i = SendMessage(GetDlgItem(IDC_COMBOX_DEVICE), CB_GETCURSEL, 0, 0L);
	if (0> i || i >= 26)
	{
		TaskDialog(m_hWnd, _Module.GetModuleInstance(),
			L"iBurnMgr USB Error", L"USB Error",
			L"No Select Device!",
			TDCBF_OK_BUTTON,
			TD_ERROR_ICON, &nButton);
		IsInvalid = false;
		return 1;
	}

	wcscpy_s(SpData.latter, 9, g_DriveList[i].driveLetter);
	SpData.lParam = m_hWnd;
	ProcessInfo = L"Making Rate:";
	JobStatusRate = L"Task is started";
	DWORD dwThreadID;
	HANDLE hThread = CreateThread(NULL, 0, Decompress::DecompressSupervisorThread,&SpData, 0, &dwThreadID);
	CloseHandle(hThread);
	return 0;
}