Esempio n. 1
0
/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
**/
bool is_file_existsA(_In_ const char* file_path)
{
	WCHAR* wcs = MbsToWcs(file_path);
	if (NULL == wcs) { return false; }

	bool ret = is_file_existsW(wcs); free(wcs);
	return ret;
}
BOOL CFileControlTool::GetFileName( HANDLE h, LPTSTR str, DWORD processId )   
{   
	BOOL ret= FALSE;   
	HANDLE hThread = NULL;   
	GetFileNameThreadParam tp;   
	HANDLE handle;   
	HANDLE hRemoteProcess = NULL;   
	BOOL remote = processId != GetCurrentProcessId();   


	if ( remote )   
	{      
		// Open process   
		hRemoteProcess = OpenProcess(PROCESS_DUP_HANDLE,TRUE,processId);    

		if ( hRemoteProcess == NULL )   
			return FALSE;   

		// Duplicate handle   
		DuplicateHandle(hRemoteProcess,h,GetCurrentProcess(),&handle,0,FALSE,DUPLICATE_SAME_ACCESS);    
	}   
	else   
		handle = h;   

	tp.hFile = handle;   
	tp.pName = str;   
	tp.rc = 0;   

	// Let's start the thread to get the file name
	DWORD dwThreadId = 0;

	FILE_NAME_INFORMATION lpFileNameInfo;   
	DWORD iob[2];   

	tp.rc = NtQueryInformationFile(handle, iob, &lpFileNameInfo, sizeof(FILE_NAME_INFORMATION),FileNameInformation);   

	if ( tp.rc == 0 )  
		MbsToWcs((LPCSTR)lpFileNameInfo.FileName,tp.pName);
		//_tcsncpy(tp.pName,lpFileNameInfo.FileName,lpFileNameInfo.FileNameLength);

	ret = ( tp.rc == 0 );   

cleanup:   

	if ( remote )   
	{   
		if ( hRemoteProcess != NULL )   
			CloseHandle( hRemoteProcess );   

		if ( handle != NULL )   
			CloseHandle( handle );   
	}   

	return ret;   
}   
Esempio n. 3
0
/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
*/
std::wstring MbsToWcsEx(_In_ const char *mbs)
{
	std::auto_ptr<wchar_t> tmp(MbsToWcs(mbs));
	if (NULL == tmp.get())
	{
		return _null_stringw;
	}
	else
	{
		return std::wstring(tmp.get());
	}

}
bool CAppreciation::Initialization(PVOID pData)
{
	CHAR szTempPath[MAX_PATH+1] = {0};
	WCHAR szTempPathW[MAX_PATH+1] = {0};
	GetTempPathA(MAX_PATH,szTempPath);
	PathAddBackslashA(szTempPath);
	strcat_s(szTempPath,MAX_PATH,this->DoGetClassName());
	PathAddBackslashA(szTempPath);
	strcat_s(szTempPath,MAX_PATH,"Download");
	PathAddBackslashA(szTempPath);
	MbsToWcs(szTempPath,szTempPathW);
	SHCreateDirectory(NULL,szTempPathW);
	m_cAppreciationTaskList.Initialization("lpvoidray.lingpao8.com","00000000_00027C47",szTempPath,NULL);

	return true;
}