コード例 #1
0
ファイル: PathOfExile.cpp プロジェクト: dpedigo/WhaleSplash
bool CPathOfExile::Attach(bool bWriteAccess)
{
	m_dwManagerBase = 0;
	m_dwModuleAddress = 0;
	m_dwModuleSize = 0;
	m_bWriteAccess = bWriteAccess;

	const TCHAR* szProcessName = s_ProcessName;
	DWORD dwProcessId = CProcess::Find(szProcessName);
	if ( dwProcessId == 0 )
	{
		return false;
	}
	
	if ( !CProcess::GetModuleInfo(szProcessName, dwProcessId, &m_dwModuleAddress, &m_dwModuleSize) )
	{
		return false;
	}

	DWORD dwDesiredAccess = PROCESS_DEFAULT_ACCESS;
	if ( m_bWriteAccess )
	{
		dwDesiredAccess |= PROCESS_VM_WRITE | PROCESS_VM_OPERATION;
	}

	if ( Open(dwProcessId, dwDesiredAccess) )
	{
		DWORD dwAddress = FindPattern(m_dwModuleAddress, m_dwModuleSize, (BYTE*)s_BaseSignature, s_BaseMask);
		if ( dwAddress )
		{
			m_dwManagerBase = ReadDWORD(dwAddress - s_BaseOffset);
			return true;
		}
	}

	return false;
}
コード例 #2
0
ファイル: CBINFile.cpp プロジェクト: lilinfeng124/LibPrinter
bool CBinFile::ReadBinFile(const QString&  strFile,unsigned int nACount,
						   unsigned int nDCount,ChanelDataList& dataList)
{
	QFile file(strFile);
	if (!file.exists())
	{
		m_ErrorList << QString("文件%1不存在,读取出错.").arg(strFile);
		return false;
	}
	if (!file.open(QIODevice::ReadOnly))
	{
		m_ErrorList << QString("文件%1无法打开,读取出错.").arg(strFile);
		return false;
	}
	m_FileContent = file.readAll();
	if (m_FileContent.isEmpty())
	{
		m_ErrorList << QString("文件%1内容为空,读取出错.").arg(strFile);
		file.close();
		return false;
	}

	while (m_nReadPos < m_FileContent.count())
	{
		CChanelSampleData chanelData;
		//采样序号
		chanelData.m_nTick = ReadDWORD();
		//时戳
		chanelData.m_nTimeStamp = ReadDWORD();
		//A通道数据
		unsigned int nIndex=0;
		while(nIndex < nACount) //数据缺失为 0x8000
		{
			int nData = ReadWORD();
			if(nData >= 32768L)	nData = nData - 65536;
			chanelData.m_AChanelDataList << nData;
			if(nData>32767||nData<-32767)
			{
				chanelData.m_AChanelDataValidList <<false;
			}
			else
			{
				chanelData.m_AChanelDataValidList <<true;
			}
			nIndex++;
		}
		nIndex = 0;

		unsigned int nCount = (nDCount%16 == 0)? (nDCount/16):(nDCount/16 + 1);
		//D通道数据
		while(nIndex < nCount)
		{
			short nDValue = ReadWORD(); 
			unsigned int nPos = 0;
			unsigned int nBitCount = (nDCount-16*nIndex > 16)?16:(nDCount-16*nIndex);
			while (nPos < nBitCount)
			{
				short nTmp = (nDValue &(1<<nPos));
				unsigned short nValue = (nTmp != 0);
				chanelData.m_DChanelDataList.append(nValue);
				nPos++;
			}
			nIndex++;
		}
		dataList << chanelData;
	}
	
	file.close();
	return true;
}
コード例 #3
0
ファイル: registry.cpp プロジェクト: 3s3s/lavfilters
BOOL CRegistry::ReadBOOL(LPCTSTR pszKey, HRESULT &hr)
{
  DWORD dwVal = ReadDWORD(pszKey, hr);
  return dwVal ? TRUE : FALSE;
}
コード例 #4
0
ファイル: ParseEngine.cpp プロジェクト: eggxp/SuperParse
String		NormalVar::OnParse(char *lpData, int Len, int &pos, int key)
{
	String resultStr;
	if(m_Type == "int")
	{
		int result = (int)ReadDWORD(lpData, pos);
		resultStr = IntToStr(result);
	}
	else	if(m_Type == "DWORD")
	{
		if(GetParseAsHex())
		{
			DWORD	result = ReadDWORD(lpData, pos);
			resultStr = IntToHex((int)result, 8);
		}
		else
		{
			DWORD	result = (DWORD)ReadDWORD(lpData, pos);
			resultStr = IntToStr((__int64)result);
		}
	}
	else	if(m_Type == "short")
	{
		short	result = (short)ReadWORD(lpData, pos);
		resultStr = IntToStr(result);
	}
	else	if(m_Type == "WORD")
	{
		if(GetParseAsHex())
		{
			WORD	result = ReadWORD(lpData, pos);
			resultStr = IntToHex((int)result, 4);
		}
		else
		{
			WORD	result = (WORD)ReadWORD(lpData, pos);
			resultStr = IntToStr(result);
		}
	}
	else	if(m_Type == "char")
	{
		char	result = (char)ReadBYTE(lpData, pos);
		resultStr = result;
	}
	else	if(m_Type == "BYTE")
	{
		if(GetParseAsHex())
		{
			BYTE	result = ReadBYTE(lpData, pos);
			resultStr = IntToHex((int)result, 2);
		}
		else
		{
			BYTE	result = (BYTE)ReadBYTE(lpData, pos);
			resultStr = IntToStr(result);
		}
	}
	else	if(m_Type == "float")
	{
		float result = ReadFloat(lpData, pos);
		resultStr = FloatToStr(result);
	}
	else	if(m_Type == "double")
	{
		double	result = ReadDouble(lpData, pos);
		String date = "";
		try
		{
			date = DateTimeToStr(FloatToDateTime(result));
			resultStr = FormatStr("%s(%s)", FloatToStr(result), date);
		}
		catch(...)
		{
			resultStr = FormatStr("%s", FloatToStr(result));
		}
	}
	else	if(m_Type == "DateTime")
	{
		double	result = ReadDouble(lpData, pos);
		String date = DateTimeToStr(FloatToDateTime(result));
		resultStr = FormatStr("%s", date);
	}

	return	resultStr;
}