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


C++ TMemoryStream类代码示例

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


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

示例1: keyStr

bool z3ResEx::z3Decrypt
(
	TMemoryStream &src,
	TMemoryStream &dst,
	unsigned char *key,
	unsigned int keylen
)
{
	StringSource keyStr( key, keylen, true );
	
	AutoSeededRandomPool rng;
	ECIES<ECP>::Decryptor ellipticalEnc( keyStr );
	
	unsigned char *tmpBuffer( new unsigned char[ src.Size() ] );

	DecodingResult dr = ellipticalEnc.Decrypt( rng, src.Data(), src.Size(), tmpBuffer );
	
	if( !( dr.isValidCoding ) || ( dr.messageLength == 0 ) )
	{
		delete tmpBuffer;
		return false;
	}

	dst.Write( tmpBuffer, dr.messageLength );

	delete tmpBuffer;

	return true;
}
开发者ID:EndScene,项目名称:z3ResEx,代码行数:29,代码来源: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: SendButtonClick

//---------------------------------------------------------------------------
void __fastcall THttpTestForm::SendButtonClick(TObject *Sender)
{
    TMemoryStream *DataIn;
    TMemoryStream *DataOut;
    AnsiString    Buf;
    BOOL          bSuccess;

    DisplayMemo->Clear();
    DataIn  = new TMemoryStream;
    DataOut = new TMemoryStream;
    bSuccess = TRUE;
    try {
        Buf     = "ID=" + UserIDEdit->Text +
                  "&REMITE=" + EMailEdit->Text +
                  "&MENSAJE=" + Encode(MessageEdit->Text);
        DataOut->Write(&Buf[1], Buf.Length());
        DataOut->Seek(0, soFromBeginning);

        HttpCli1->SendStream = DataOut;
        HttpCli1->RcvdStream = DataIn;
        HttpCli1->Proxy      = ProxyEdit->Text;
        HttpCli1->ProxyPort  = "80";
        HttpCli1->URL        = "http://www.unired.net.pe/cgi-bin/a.out";

        SendButton->Enabled  = FALSE;
        AbortButton->Enabled = TRUE;
        try {
            HttpCli1->Post();
        }
        __except (TRUE) {
            bSuccess = FALSE;
        }
        if (bSuccess) {
            DataIn->Seek(0, 0);
            DisplayMemo->Lines->LoadFromStream(DataIn);
        }
        SendButton->Enabled  = TRUE;
        AbortButton->Enabled = FALSE;
    }
    __except (TRUE) {
        bSuccess = FALSE;
    }
    if (!bSuccess)
        DisplayMemo->Lines->Add("Failed : " + HttpCli1->ReasonPhrase);

    delete DataOut;
    delete DataIn;
}
开发者ID:halaszk,项目名称:old-delphi-codes,代码行数:49,代码来源:httppg1.cpp

示例4: 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

示例5: 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

示例6: 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

示例7: SetButtonState

//---------------------------------------------------------------------------
void __fastcall THttpTestForm::PostButtonClick(TObject *Sender)
{
    TMemoryStream *DataOut;
    TFileStream   *DataIn;
    AnsiString    Buf;
    int           I;

    DisplayMemo->Clear();
    DocumentMemo->Clear();
    SetButtonState(FALSE);

    DataOut = new TMemoryStream;
    Buf     = DataEdit->Text;
    DataOut->Write(&Buf[1], Buf.Length());
    DataOut->Seek(0, soFromBeginning);

    HttpCli1->SendStream = DataOut;
    HttpCli1->Proxy      = ProxyHostEdit->Text;
    HttpCli1->ProxyPort  = ProxyPortEdit->Text;
    HttpCli1->RcvdStream = NULL;
    HttpCli1->URL        = URLEdit->Text;
    try {
        HttpCli1->Post();
    } __except (TRUE) {
        SetButtonState(TRUE);
        delete DataOut;
        DisplayMemo->Lines->Add("POST Failed !");
        DisplayMemo->Lines->Add("StatusCode   = " + IntToStr(HttpCli1->StatusCode));
        DisplayMemo->Lines->Add("ReasonPhrase = " + HttpCli1->ReasonPhrase);
        return;
    }
    delete DataOut;

    DisplayMemo->Lines->Add("StatusCode = " + IntToStr(HttpCli1->StatusCode));

    for (I = 0; I < HttpCli1->RcvdHeader->Count; I++)
        DisplayMemo->Lines->Add("hdr>" + HttpCli1->RcvdHeader->Strings[I]);

    DataIn = new TFileStream(HttpCli1->DocName, fmOpenRead);
    DocumentMemo->Lines->LoadFromStream(DataIn);
    delete DataIn;

    SetButtonState(TRUE);
}
开发者ID:KayvanGuo,项目名称:FTPRipper,代码行数:45,代码来源:OverbyteIcsHttpTst1.cpp

示例8: TMemoryStream

void __fastcall TAboutbox::setGermanText()
{
    String t = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2055{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 Arial;} "
        "{\\f1\\fswiss\\fcharset0 Arial;}} "
        "\\viewkind4\\uc1\\pard\\b\\f0\\fs28 DB-BEAD\\b0\\f1\\fs20\\par "
        "\\par "
        "Dies ist DB-BEAD, ein Programm, das Ihnen beim Entwurf von geh\\'e4kelten "
        "Perlenketten helfen soll. Die Erstellung solcher Ketten wird beispielsweise "
        "im Buch 'Geh\\'e4kelte Glasperlenketten' von Lotti Gygax beschrieben. Die Arbeit ist aufw\\'e4ndig und "
        "langwierig. Das Resultat entsch\\'e4digt aber f\\'fcr die erlittene M\\'fchsal.\\par "
        "\\par "
        "Mit DB-BEAD k\\'f6nnen Sie schon vor Beginn der Arbeit simulieren, wie Ihr "
        "Entwurf als Kette dann aussehen wird. Direkt am Bildschirm k\\'f6nnen Sie "
        "\\'c4nderungen vornehmen.\\par "
        "\\par "
        "Wenn Sie zufrieden mit dem Entwurf sind, k\\'f6nnen Sie alle notwendigen "
        "Daten ausdrucken lassen, inklusive einer 'F\\'e4delliste', die hilfreich "
        "f\\'fcr das Auff\\'e4deln der Perlen auf das H\\'e4kelgarn ist.\\par "
        "\\par "
        "DB-BEAD wurde von Damian Brunold geschrieben. Es steht unter der Lizenz "
        "GPL v3, was bedeutet, dass Sie es kostenlos verwenden, kopieren und \\'e4ndern "
        "d\\'fcrfen. Daf\\'fcr \\'fcbernimmt Damian Brunold absolut keine "
        "Haftung f\\'fcr Fehler und Sch\\'e4den durch Benutzung des Programmes. "
        "Sie m\\'fcssen selber entscheiden, ob das Programm f\\'fcr Sie n\\'fctzlich "
        "ist oder nicht.\\par "
        "\\par "
        "Weitere Informationen erhalten Sie unter http://www.brunoldsoftware.ch "
        "oder per E-Mail an [email protected] An diese Adresse k\\'f6nnen "
        "Sie auch Fehler oder Verbesserungsvorschl\\'e4ge melden.\\par "
        "\\par "
        "Viel Spass mit dem Programm\\par "
        "Damian Brunold\\par "
        "}";

    try {
        TMemoryStream* ms = new TMemoryStream();
        ms->Write (t.c_str(), t.Length());
        ms->Position = 0;
        text->Lines->LoadFromStream (ms);
        delete ms;
    } catch(...) {
    }
}
开发者ID:damianbrunold,项目名称:dbbead,代码行数:43,代码来源:aboutbox_form.cpp

示例9: works

void __fastcall TAboutbox::setEnglishText()
{
    String t = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2055{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 Arial;} "
        "{\\f1\\fswiss\\fcharset0 Arial;}} "
        "\\viewkind4\\uc1\\pard\\b\\f0\\fs28 DB-BEAD\\b0\\f1\\fs20\\par "
        "\\par "
        "This is DB-BEAD, a program designed to help you design crochet bead ropes. "
        "The creation of such ropes is describes in e.g. the book "
        "'Geh\\'e4kelte Glasperlenketten' written by Lotti Gygax. It is hard work to "
        "create such a rope, but the result is very beautiful.\\par "
        "\\par "
        "With DB-BEAD you simulate before you start working how your design will "
        "look like as a finished rope. You can make changes directly on the screen.\\par "
        "\\par "
        "After finishing the design, you can print out all relevant data "
        "including a 'list of beads', which is very useful for correctly arranging "
        "the beads onto the thread.\\par "
        "\\par "
        "DB-BEAD was written by Damian Brunold. It is freely available and licensed "
        "under the GPL v3. This means, you can use and copy it freely and you can "
        "create derivative works (if you are a programmer). Damian Brunold cannot "
        "assume any liability for bugs and damage caused by using the program. "
        "You have to decide for yourself whether the program is useful for you or not.\\par "
        "\\par "
        "More information is available at http://www.brunoldsoftware.ch or by sending "
        "e-mail to [email protected] This also is the address to direct bug "
        "reports or feature requests to.\\par "
        "\\par "
        "Have fun using DB-WEAVE\\par "
        "Damian Brunold\\par "
        "}";

    try {
        TMemoryStream* ms = new TMemoryStream();
        ms->Write (t.c_str(), t.Length());
        ms->Position = 0;
        text->Lines->LoadFromStream (ms);
        delete ms;
    } catch(...) {
    }
}
开发者ID:damianbrunold,项目名称:dbbead,代码行数:41,代码来源:aboutbox_form.cpp

示例10: keyStr

bool z3ResEx::z3Decrypt
(
	TMemoryStream &src,
	TMemoryStream &dst,
	unsigned char *key,
	unsigned int keylen
)
{
	StringSource keyStr( key, keylen, true );
	
	AutoSeededRandomPool rng;
	ECIES<ECP>::Decryptor ellipticalEnc( keyStr );
	
  vector<unsigned char> tmpBuffer(src.Size());
	DecodingResult dr = ellipticalEnc.Decrypt( rng, src.Data(), src.Size(), &tmpBuffer[0] );
	
	if( dr.isValidCoding && dr.messageLength > 0 )
	{
    dst.Write(&tmpBuffer[0], dr.messageLength);
    return true;
	}

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

示例11: tmpOffset

bool z3ResEx::fsRle( TMemoryStream &src, TMemoryStream &dst, bool isMSF )
{
	unsigned int msfSizeFlag;
	unsigned int expectedSize, len;
	unsigned char *pData( src.Data() ), *pDataEnd( pData + src.Size() );

	if( isMSF )
	{
		// Read the expected size from data
		msfSizeFlag = src.ReadUInt();
		pData += 4;
	}

	if( !( z3Rle::decodeSize( pData, expectedSize, len ) ) )
	{
		dst.Close();
		//printf("ERROR: Problems decoding RLE buffer size\n");
		return false;
	}

	if( isMSF && !( msfSizeFlag == expectedSize ) )
	{
		dst.Close();
		//printf("ERROR: Unexpected MSF buffer size\n");
		return false;
	}

	// Skip the length of the expected size
	pData += len;

	unsigned char *tmpBuffer( new unsigned char[ expectedSize ] );
	unsigned int tmpOffset( 0 );

	while( tmpOffset < expectedSize )
	{
		if( !( z3Rle::decodeInstruction( pData, len, pDataEnd, tmpBuffer, tmpOffset ) ) )
		{
			delete tmpBuffer;
			//printf("ERROR: Problems decoding RLE buffer\n");

			return false;
		}

		pData += len;
	}

	dst.Write( tmpBuffer, expectedSize );

	delete tmpBuffer;

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

示例12: mrf

bool z3ResEx::extractItem( FILEINDEX_ENTRY &info, unsigned char method, const char *strMrf, const char *strName )
{
	TFileStream mrf( strMrf );

	if( !( mrf.isOpen() ) )
	{
		setMessage( "ERROR: Unable to open file (%s)", strMrf );
		return false;
	}

	// Format the output filename
	std::string fname( fsRename( strMrf, strName ) );
	
	// UNFORCED EXTRACTION
	// If file already exists, ignore it
	if( TFileSize( fname.c_str() ) == info.size )
	{
		mrf.Close();
		return true;
	}

	vector<unsigned char> buf( info.zsize );

	// Load MRF data into buffer
	mrf.Seek( info.offset, bufo_start );
	mrf.Read( &buf[0], info.zsize );
	mrf.Close();

	// Copy into TStream
	TMemoryStream fdata;
	fdata.LoadFromBuffer( &buf[0], info.zsize );
  buf.clear();

	printf
	(	
		( m_doExtraction ? "Saving %s.. " : "Checking %s.. " ),
		fname.substr( fname.rfind('/') +1 ).c_str()
	);

	// Create path only when extraction is flagged
	if( m_doExtraction )
		fsCreatePath( fname );

	switch( method )
	{
		// Compressed, most files
		case FILEINDEX_ENTRY_COMPRESSED :
		{
			fsXor( fdata, info.xorkey );

			TMemoryStream fdata_raw;
			if( fsRle( fdata, fdata_raw ) )
			{
				if( m_doExtraction )
					fdata_raw.SaveToFile( fname.c_str() );

				puts(" ..done!");
			}
		
			// fsRle will display any errors

			fdata_raw.Close();
			break;
		}

		// Encrypted and compressed, some system data (GunZ 2)
		case FILEINDEX_ENTRY_COMPRESSED2 :
		{
			TMemoryStream fdata_dec;
			z3Decrypt( fdata, fdata_dec, m_fileindexKey, m_fileindexKeyLength );
			fdata.Close();

			// Now same as FILEINDEX_ENTRY_COMPRESSED

			fsXor( fdata_dec, info.xorkey );

			TMemoryStream fdata_raw;
			if( fsRle( fdata_dec, fdata_raw ) )
			{
				if( m_doExtraction )
					fdata_raw.SaveToFile( fname.c_str() );

				printf(" ..done!\n");
			}
		
			// fsRle will display any errors

			fdata_dec.Close();
			fdata_raw.Close();

			break;
		}

		// Large files, some FSB (GunZ 2)
		case FILEINDEX_ENTRY_UNCOMPRESSED :
		{
			if( m_doExtraction )
				fdata.SaveToFile( fname.c_str() );

			puts(" ..done!");
//.........这里部分代码省略.........
开发者ID:x1nixmzeng,项目名称:z3ResEx,代码行数:101,代码来源:z3ResEx.cpp

示例13: 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

示例14:

void z3ResEx::fsXor( TMemoryStream &src, unsigned int key ) const
{
	z3Xor::rs3Unscramble( src.Data(), src.Size(), key );
}
开发者ID:x1nixmzeng,项目名称:z3ResEx,代码行数:4,代码来源:z3ResEx.cpp

示例15: TMemoryStream

//添加数据到接收缓冲
void TFComm::SendToRecvBuf(UINT8 *pstream, UINT32 szLen)
{
	TMemoryStream *pms = new TMemoryStream();
        pms->Write(pstream, szLen);
        m_Recv->Push(pms);
}
开发者ID:vvvvcp,项目名称:PrivateDataRouter,代码行数:7,代码来源:UComm.cpp


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