当前位置: 首页>>代码示例>>C++>>正文


C++ TMemoryStream::Read方法代码示例

本文整理汇总了C++中TMemoryStream::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ TMemoryStream::Read方法的具体用法?C++ TMemoryStream::Read怎么用?C++ TMemoryStream::Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TMemoryStream的用法示例。


在下文中一共展示了TMemoryStream::Read方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: encKey

void z3ResEx::unpackStringEx( TMemoryStream &msf, vector<unsigned char>& buf, const unsigned int len ) const
{
	msf.Read( &buf[0], len );
	buf[len] = 0;

	/*
		Simple xor added to strings in later clients
			buf[0] is the xor character
			buf[1] to buf[size-1] contains the xored string
	*/
	if( m_fileindexVer == 1 )
	{
		const unsigned char encKey( buf[0] );	// First byte is the key
		unsigned int i = 1;						// Second byte starts the data

		while( i < len )
		{
			// This unscrambles the string into the same buffer
			buf[i-1] = buf[i] ^ encKey;
			++i;
		}

		buf[len-1] = 0;

		// Buffer now has 2 null characters at the end
	}
}
开发者ID:x1nixmzeng,项目名称:z3ResEx,代码行数:27,代码来源:z3ResEx.cpp

示例2: method

void z3ResEx::parseMsf( TMemoryStream &msf )
{
	switch( m_fileindexVer )
	{
		case 0 :
		{
			unsigned char method( 0 );
			FILEINDEX_ENTRY info;
			unsigned char *strMRFN( nullptr );
			unsigned char *strName( nullptr );

			unsigned int items( 0 ), errors( 0 );

			while( ( msf.Position() < msf.Size() ) && ( errors < MAX_ERRORS ) )
			{
				method = msf.ReadByte();
				msf.Read( &info, sizeof( FILEINDEX_ENTRY ) );

				unpackStringEx( msf, strMRFN, info.lenMRFN );
				unpackStringEx( msf, strName, info.lenName );

				if( m_listContents )
				{
					printf( "%s (%u bytes)\n", strName, info.size );
				}
				else
				{
					if( !( extractItem( info, method, (char *)strMRFN, (char *)strName ) ) )
						++errors;
				}

				++items;

				delete strMRFN;
				delete strName;
			}

			printf( "Processed %u items (%u issues)\n\n", items, errors );

			break;
		}
		case 1 :
		{
			parseMsfMethod2( msf );

			break;
		}		
	}
}
开发者ID:EndScene,项目名称:z3ResEx,代码行数:49,代码来源:z3ResEx.cpp

示例3: Read

//----------
//接口实现
//----------
TMemoryStream* TFComm::Read()
{
	UINT8 buf[RECV_BUFF_MAX_LEN];
        int rv;
        TMemoryStream *p;

        if (m_Recv->Count() > 0)
        {
                p = (TMemoryStream*)m_Recv->Pop();
                p->Seek(0, soFromBeginning);
                rv = p->Read(buf, RECV_BUFF_MAX_LEN);
                LogMsg("Read" + IntToStr(rv) + ": " + StreamToText(buf, rv));
                return p;
        }
        else return NULL;
}
开发者ID:vvvvcp,项目名称:PrivateDataRouter,代码行数:19,代码来源:UComm.cpp

示例4: method

void z3ResEx::parseMsf( TMemoryStream &msf )
{
	switch( m_fileindexVer )
	{
		case 0 :
		{
			unsigned char method( 0 );
			FILEINDEX_ENTRY info;

      vector<unsigned char> strMRFN(MAX_STRING_SIZE);
      vector<unsigned char> strName(MAX_STRING_SIZE);

			unsigned int items( 0 ), errors( 0 );

			while( ( msf.Position() < msf.Size() ) && ( errors < MAX_ERRORS ) )
			{
				method = msf.ReadByte();
				msf.Read( &info, sizeof( FILEINDEX_ENTRY ) );

        unpackStringEx(msf, strMRFN, info.lenMRFN);
        unpackStringEx(msf, strName, info.lenName);

				if( m_listContents )
				{
					printf( "%s (%u bytes)\n", &strName[0], info.size );
				}
				else
				{
					if( !( extractItem( info, method, reinterpret_cast<const char*>(&strMRFN[0]), reinterpret_cast<const char*>(&strName[0]) ) ) )
						++errors;
				}

				++items;
			}

			printf( "Processed %u items (%u issues)\n\n", items, errors );

			break;
		}
		case 1 :
		{
			parseMsfMethod2( msf );

			break;
		}		
	}
}
开发者ID:x1nixmzeng,项目名称:z3ResEx,代码行数:47,代码来源:z3ResEx.cpp

示例5: DateTimeToStr


//.........这里部分代码省略.........
		FileName = ExtractFileName(FileList->Strings[i]);
		ProgressMsgText = FileName;      //処理中のファイル名
		//トップディレクトリ
		GetFileInfoList(Index, DirPath, FileName, FileList->Strings[i], FilePathList, HeaderDataList);
		//その配下
		AllTotalFileSize +=
			GetFileInfoList(Index, FileList->Strings[i], "", FileList->Strings[i], FilePathList, HeaderDataList);
	}

	//ユーザーキャンセル
	if (Terminated == true) {
		delete HeaderDataList;
		return(false);
	}

}// end for;

//進捗状況表示
ProgressPercentNum = -1;
//'ヘッダデータを書き込んでいます...'
ProgressStatusText = LoadResourceString(&Msgencrypt::_LABEL_STATUS_TITLE_ENCRYPTING_LIST);
ProgressMsgText = "";

//メモリストリームへ書き込み
tpms = new TMemoryStream;

//------------------------------------------------
// 暗号化時にヘッダデータの互換性維持
//---------------------------------------------------
HeaderDataList->SaveToStream(tpms, TEncoding::GetEncoding(932));
//新バージョン(ver.2.8.0~)用(UTF-8)に保存
for (i = 0; i < HeaderDataList->Count; i++) {
	HeaderDataList->Strings[i] = StringReplace(HeaderDataList->Strings[i],"Fn_","U_",TReplaceFlags()<<rfIgnoreCase );
}
HeaderDataList->SaveToStream(tpms, TEncoding::UTF8);

delete HeaderDataList;

//-----------------------------------
//ヘッダ情報の暗号化
//-----------------------------------

//暗号化の準備
gentables();
//キー入力
gkey( 8, 8, key);

for (i = 0; i < BUF_SIZE; i++) {
	buffer[i] = 0;
}

//初期化ベクトル(IV)を生成
fillrand(chain_buffer, BUF_SIZE);
pms->Write(chain_buffer, BUF_SIZE);

//先頭にポインタを戻す
tpms->Seek((__int64)0, TSeekOrigin::soBeginning);
EncryptHeaderSize = 0;

//CBCモードで書き込む
while (tpms->Read( buffer, BUF_SIZE ) != NULL){

	EncryptHeaderSize += BUF_SIZE;

	// xor
	for ( i = 0; i < BUF_SIZE; i++ ){
		buffer[i] ^= chain_buffer[i];
	}

	// rijndael
	rijndael_encrypt(buffer);

	pms->Write(buffer, BUF_SIZE);

	//CBC&バッファの初期化
	for ( i = 0; i < BUF_SIZE; i++ ){
		chain_buffer[i] = buffer[i];
		buffer[i] = 0;
	}

	//ユーザーキャンセル
	if (Terminated == true) {
		delete tpms;
		return(false);
	}

}//loop;

delete tpms;

//暗号化部分のヘッダデータサイズ(確保しておいた場所へ改めて書き込む)
pms->Position = HeaderSizeAddress;
pms->Write(&EncryptHeaderSize, sizeof(int));
//先頭にポインタを戻す
pms->Seek((__int64)0, TSeekOrigin::soBeginning);

return(true);


}//end CreateHeaderData;
开发者ID:OnTheMagellanVoyage,项目名称:AttacheCase,代码行数:101,代码来源:TAttacheCaseFileEncrypt.cpp

示例6: strLen

void z3ResEx::parseMsfMethod2( TMemoryStream &msf )
{
	unsigned short strLen( 0 );
	unsigned short mrfIndexLen( 0 );

	// Folders are now in a table at the top of the file
	msf.Read( &mrfIndexLen, sizeof( unsigned short ) );

  if (mrfIndexLen == 0)
  {
    // There are no folders in the filesystem
    return;
  }

	// List of filenames
  vector<string> vecMsf(mrfIndexLen);

  vector<unsigned char> strBuffer(MAX_STRING_SIZE);

	// MRF filenames are now packed in a list
	for( unsigned short i( 0 ); i != mrfIndexLen; ++i )
	{
		strLen = msf.ReadUShort();
		unpackStringEx( msf, strBuffer, strLen );

		// Required to rename files
		//vecMsf[i].first.assign( (char *)strBuffer );
		// Cached file opening (and a pointer so we can call the constructor)
		//vecMsf[i].second = new TFileStream( strBuffer );

    vecMsf[i] = string(strBuffer.begin(), strBuffer.end());
	}

	// Files are now listed (similar to before)
	FILEINDEX_ENTRY2 fiItem;

	unsigned int items( 0 ), errors( 0 );

	//msf.SaveToFile("debugFilesys.dat");

	bool bMatchesCriteria = true;
	string tmpFilename;

	while( ( msf.Position() < msf.Size() ) && ( errors < MAX_ERRORS ) )
	{
		msf.Read( &fiItem, sizeof( FILEINDEX_ENTRY2 ) );

		strLen = msf.ReadUShort();
		unpackStringEx( msf, strBuffer, strLen );
		
		if( !m_folderCriteria.empty() )
		{
      tmpFilename = string(strBuffer.begin(), strBuffer.end());
			std::transform(tmpFilename.begin(), tmpFilename.end(), tmpFilename.begin(), ::toupper);
			bMatchesCriteria = !( tmpFilename.find( m_folderCriteria ) == string::npos );
		}

		if( bMatchesCriteria )
		{
			if( m_listContents )
			{
				printf( "%s (%u bytes)\n", &strBuffer[0], fiItem.size );
			}
			else
			{
				if( !( extractItem2( fiItem, vecMsf[ fiItem.mrfIndex ], reinterpret_cast<const char*>(&strBuffer[0]) ) ) )
					++errors;
			}
		}

		++items;
	}

	vecMsf.clear();

	printf( "Processed %u items (%u issues)\n\n", items, errors );
}
开发者ID:x1nixmzeng,项目名称:z3ResEx,代码行数:77,代码来源:z3ResEx.cpp

示例7: if

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
  TMemoryStream *d = new TMemoryStream();
  FormelIntr *fi = new FormelIntr();

  long double res;
  long double max = 0;
#define VARCOUNT 3
  FormIntrVar vars[VARCOUNT] = {
    { "rand" , 0 } ,
    { "t" , 0 } ,
    { "pi" , 3.141592654 }
  };
  FormIntrError error;

  int SampRate = StrToInt ( ComboBox1->Text.SubString ( 1, 5 ) );

  randomize();

  for ( long double i = 0;
        i < CSpinEdit1->Value * SampRate; i++ ) {
    vars[0].Val =
      (long double)(rand()*rand()) / ((long double)rand()+1);
    vars[1].Val = (long double)i / (long double)SampRate;
    fi->Calc ( res, Edit1->Text.c_str(), VARCOUNT, vars, error );
    if ( error.ErrNum != 0 ) res = 0.0;
    d->Write ( &res, sizeof ( res ) );
    if ( res > max ) max = res;
    else if ( res < (-max) ) max = -res;
  }

  if ( max == 0 ) {
    delete d;
    delete fi;
    OUTPUT ( "Error" );
    return;
  }

  long double scal = (long double)30000 / max;

  delete SoundBuffer;
  SoundBuffer = new TMemoryStream();
  Chart1->Series[0]->Clear();
  Chart2->Series[0]->Clear();

  WaveHeader ( SoundBuffer, SampRate, d->Size / sizeof(res) );
  d->Position = 0;

  short signed end = -1;
  short unsigned x1, x2;
  x2 = CSpinEdit2->Value;
  x1 = 0;

  while ( d->Read ( &res, sizeof(res) ) == sizeof( res ) ) {
    end = ( res * scal );
    SoundBuffer->Write ( &end, 2 );
    if ( x1 <= 0 ) {
      Chart1->Series[0]->AddY ( end, "", clTeeColor );
      Chart2->Series[0]->AddY ( end, "", clTeeColor );
      x1 = x2;
    }
    x1--;
  }

  delete d;
  delete fi;

  OUTPUT ( "Created" );
}
开发者ID:fotisp,项目名称:conqat,代码行数:69,代码来源:u_main.cpp

示例8: extractionMain

void extractionMain( TMemoryStream &msf )
{
	const unsigned int MAX_ERRORS( 50 );
	unsigned int items( 0 );

	FILEINDEX_ENTRY info;
	unsigned char method;

	char *strMRFN( nullptr ), *strName( nullptr );

	#define unpackString(buf,len) \
	{ \
		buf = new char[ len +1 ]; \
		msf.Read( buf, len ); \
		buf[ len ] = 0; \
	}

#ifdef SAVE_MSF_FILEINDEX
	msf.SaveToFile("z3debug_fileindex.msf");
#endif

	// Are we just listing files?
	if( user_opt_list_files )
	{
		std::string fname;

		printf("Listing filesystem contents\n\n");

		while( msf.Position() < msf.Size() )
		{
			method = msf.ReadByte();
			msf.Read( &info, sizeof( FILEINDEX_ENTRY ) );

			unpackString( strMRFN, info.lenMRFN );
			unpackString( strName, info.lenName );

			fname = fsRename( strMRFN, strName );
			printf("%s\n", fname.c_str());
			
			++items;

			delete strMRFN;
			delete strName;
		}

		fname.clear();
		printf("\nLocated %u files\n", items);
	}
	else
	// Run the main extraction loop
	{
		unsigned int errors( 0 );

		printf("Extracting filesystem contents\n\n");

		while( ( msf.Position() < msf.Size() ) && ( errors < MAX_ERRORS ) )
		{
			method = msf.ReadByte();
			msf.Read( &info, sizeof( FILEINDEX_ENTRY ) );

			unpackString( strMRFN, info.lenMRFN );
			unpackString( strName, info.lenName );

			if( !( extractItem( info, method, strMRFN, strName ) ) )
				++errors;

			++items;

			delete strMRFN;
			delete strName;
		}

		if( errors >= MAX_ERRORS )
			printf("ERROR: Extraction stopped as there were too many errors\n");
		else
			printf("\nExtracted %u files (%u problems)\n", items, errors);
	}
}
开发者ID:iKlui,项目名称:z3ResEx,代码行数:78,代码来源:main.cpp

示例9: strLen

void z3ResEx::parseMsfMethod2( TMemoryStream &msf )
{
	unsigned short strLen( 0 );
	unsigned char *strBuffer( nullptr );

	unsigned short mrfIndexLen( 0 );

	// Folders are now in a table at the top of the file
	msf.Read( &mrfIndexLen, sizeof( unsigned short ) );

	// List of filenames
	//typedef std::pair<string, TFileStream* > mrfItem;
	typedef vector<string > mrfItemList;

	mrfItemList vecMsf;
	vecMsf.resize( mrfIndexLen );
			
	// MRF filenames are now packed in a list
	for( unsigned short i( 0 ); i != mrfIndexLen; ++i )
	{
		strLen = msf.ReadUShort();
		unpackStringEx( msf, strBuffer, strLen );

		// Required to rename files
		//vecMsf[i].first.assign( (char *)strBuffer );
		// Cached file opening (and a pointer so we can call the constructor)
		//vecMsf[i].second = new TFileStream( strBuffer );

		vecMsf[i].assign( (char *)strBuffer );

		delete strBuffer;
	}

	// Files are now listed (similar to before)
	FILEINDEX_ENTRY2 fiItem;

	unsigned int items( 0 ), errors( 0 );

	//msf.SaveToFile("debugFilesys.dat");

	while( ( msf.Position() < msf.Size() ) && ( errors < MAX_ERRORS ) )
	{
		msf.Read( &fiItem, sizeof( FILEINDEX_ENTRY2 ) );

		strLen = msf.ReadUShort();
		unpackStringEx( msf, strBuffer, strLen );
		
		if( m_listContents )
		{
			printf( "%s (%u bytes)\n", strBuffer, fiItem.size );
		}
		else
		{
			if( !( extractItem2( fiItem, vecMsf[ fiItem.mrfIndex ], (char *)strBuffer ) ) )
				++errors;
		}

		delete strBuffer;

		++items;
	}

	vecMsf.clear();

	printf( "Processed %u items (%u issues)\n\n", items, errors );
}
开发者ID:EndScene,项目名称:z3ResEx,代码行数:66,代码来源:z3ResEx.cpp


注:本文中的TMemoryStream::Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。