• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TMemoryStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TMemoryStream

//---------------------------------------------------------------------------
int __fastcall TTrdCot_Rm::Request(TRequest Request,TAnswer **Answer,int &AnsCount)
{
	TAnswer answer;
	int     retVal     = 0;
	Request.Head.Version = 2010;

	try
	{
		TMemoryStream* dest = new TMemoryStream();
		int orgsize = sizeof(Request) ;
		dest->Write(&orgsize,sizeof(int));
		TCompressionStream * cs = new TCompressionStream(Zlib::clDefault,dest);
		TMemoryStream *source = new TMemoryStream();
		TDecompressionStream *ds = new TDecompressionStream(source);

		FCS->Enter();
		try
		{
			memset(&answer,0,sizeof(TAnswer));
			if( Request.Head.FuncType == ftInit)
			{
				this->Connect();
				if( FTcpClt->Connected() == false )
				  return ERR_TRDSVR_SEND_FAILED;
				FTcpClt->Socket->UseNagle = false;
			}
			cs->Write(&Request,sizeof(Request));
			delete cs;
			cs = NULL;

			if( FTcpClt == NULL ) return -1000;
			// 发送请求
			try
			{
				FTcpClt->IOHandler->LargeStream = false;
				FTcpClt->IOHandler->Write(dest,0x000000000,true);
			}
			catch(...)
			{
				retVal = ERR_TRDSVR_SEND_FAILED;
				FTcpClt->Disconnect();
				return retVal;
			}
			delete dest;
			dest = NULL;


			// 接收响应

			try
			{
				int size = FTcpClt->IOHandler->ReadInteger(false);
				if( size >0 )
				{
					orgsize = FTcpClt->IOHandler->ReadInteger(false);
					FTcpClt->IOHandler->ReadStream(source,size-sizeof(int),false);
					if( sizeof(TAnswer) != ds->Read(&answer,sizeof(TAnswer)) )
					{
						throw "";
					}
				}
				else
				{
					throw "";
				}
			}
			catch(...)
			{
				retVal = ERR_TRDSVR_RECV_FAILED;
				FTcpClt->Disconnect();
				return retVal;
			}

			retVal   = answer.Head.RetVal;

			if(retVal==0)
			{
				AnsCount = answer.Head.AnsCount;

				if(AnsCount>0)
				{
					*Answer  = new TAnswer[AnsCount];
					try
					{
						memcpy(&(*Answer)[0],&answer,sizeof(TAnswer));
						int len = sizeof(TAnswer)*(AnsCount-1);
						if( len!= ds->Read(&(*Answer)[1],len))
						{
							throw "";
						}
					}
					catch(...)
					{
						delete []  (*Answer);
						retVal= ERR_TRDSVR_RECV_FAILED;
						FTcpClt->Disconnect();
						return  retVal;
					}
				}
//.........这里部分代码省略.........
开发者ID:code4hunter,项目名称:oldpts,代码行数:101,代码来源:UTrdCot_Rm.cpp


示例17: ZeroMemory

//===========================================================================
// スレッド実行
//===========================================================================
void __fastcall TAttacheCaseFileEncrypt::Execute()
{

int i, c;
int res;

float ProgressPercentNumF;  //進捗パーセンテージ(浮動小数点)

z_stream z;                 // zlibライブラリとやりとりするための構造体
int flush, status;          // zlib

//出力する暗号化ファイルのタイムスタンプを元ファイルに合わせる
HANDLE hFile;
//_WIN32_FIND_DATAW first_fd;
ZeroMemory(&first_fd, sizeof(_WIN32_FIND_DATAW));

int len, pos;
int FileIndex;
String FilePath;

int HeaderSize;                          //ヘッダデータサイズ
__int64 CurrentDriveFreeSpaceSize = -1;  //保存するドライブの空き容量

//実行可能形式出力ファイルのデータサイズ
__int64 ExeAllSize = 0;
__int64 ExeSize    = 0;

//全体のファイルサイズ
AllTotalSize = 0;
__int64 TotalSize = 0;

//バッファ
char source_buffer[BUF_SIZE];
char read_buffer[BUF_SIZE];
char out_buffer[BUF_SIZE];
char chain_buffer[BUF_SIZE]; // IVなどを格納するチェインバッファ
char margin_buffer[BUF_SIZE];

//ファイルストリーム
TFileStream *fsIn;
TFileStream *fsOut;
TFileStream *fsExe;

//オープン中か
bool fOpenIn;
bool fOpenOut;
//メモリストリーム
TMemoryStream *pms = new TMemoryStream;

// マージンバッファサイズ
int MarginBufSize = MARGIN_BUF_SIZE;

// PKCS #7 Pading num.
unsigned char paddingNum = 0;

//---------------------------------------
// 同名ファイルがあるのでダイアログ表示
//---------------------------------------
if ( fConfirmOverwirte == true && fOverwirteYesToAll == false ) {

	if (FileExists(OutFilePath) == true) {
		//同名ファイルの上書き確認メッセージダイアログ
		MsgText = LoadResourceString(&Msgencrypt::_MSG_CONFIRM_OVER_WRITE_SAME_FILE)+"\n"+OutFilePath;
		Synchronize(&PostConfirmOverwriteMessageForm);
		if ( MsgReturnVal == mrYes ) {
			//上書きOKなのでFilePathはそのまま
		}
		else if ( MsgReturnVal == mrNo ) {
			//別名保存でFilePath文字列が書き換えられてきている
			OutFilePath = MsgReturnPath;
		}
		else if ( MsgReturnVal == mrYesToAll ) {
			//すべて上書き(YesToAll)
			fOverwirteYesToAll = true;
		}
		else if ( MsgReturnVal == mrCancel ) {
			//キャンセル
			delete pms;
			goto LabelStop;
		}
	}

}

//---------------------------------------
// ヘッダ情報の生成&ファイル総サイズ取得
//---------------------------------------

//'暗号化するファイルリストの生成中...'
ProgressStatusText = LoadResourceString(&Msgencrypt::_LABEL_STATUS_TITLE_LISTING);

if ( CreateHeaderData( pms, InputFileList, FilePathList, AllTotalSize) == false ){
	if (Terminated == true) {
		//ユーザーキャンセルで抜けてきた
		delete pms;
		goto LabelStop;
	}
//.........这里部分代码省略.........
开发者ID:OnTheMagellanVoyage,项目名称:AttacheCase,代码行数:101,代码来源:TAttacheCaseFileEncrypt.cpp


示例18: extractItem

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

	if( !( mrf.isOpen() ) )
	{
		printf("ERROR: Could not open file (%s)\n", strMrf );
		return false;
	}

	// Format the output filename
	std::string fname( fsRename( strMrf, strName ) );
	
#ifdef VERBOSE
	printf("Using filename: %s\n", fname.c_str());
#endif

	// UNFORCED EXTRACTION
	// If file already exists, ignore it
	if( TFileSize( fname.c_str() ) == info.size )
	{
		mrf.Close();
		return true;
	}

	unsigned char *buf( new unsigned char[ info.zsize ] );

#ifdef VERBOSE
	printf("Allocated %u bytes\n", info.zsize);
#endif

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

#ifdef VERBOSE
	printf("Read %u bytes at %u\n", info.zsize, info.offset );
#endif

	// Copy into TStream
	TMemoryStream fdata;
	fdata.LoadFromBuffer( buf, info.zsize );
	delete buf;

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

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

	switch( method )
	{
		// Compressed, most files
		case FILEINDEX_ENTRY_COMPRESSED :
		{
			fsXor( info, fdata );
		#ifdef VERBOSE
			printf("Complete XOR routine\n");
		#endif

			TMemoryStream fdata_raw;
			if( fsRle( fdata, fdata_raw ) )
			{
			#ifdef VERBOSE
				printf("Completed RLE routine\n");
			#endif
			
				if( user_opt_allow_extraction )
					fdata_raw.SaveToFile( fname.c_str() );

				printf("done!\n");
			}
		
			// 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( z3CurrentKey, fdata, fdata_dec );
			fdata.Close();

			// Now same as FILEINDEX_ENTRY_COMPRESSED

			fsXor( info, fdata_dec );

			TMemoryStream fdata_raw;
			if( fsRle( fdata_dec, fdata_raw ) )
			{
				if( user_opt_allow_extraction )
					fdata_raw.SaveToFile( fname.c_str() );
//.........这里部分代码省略.........
开发者ID:iKlui,项目名称:z3ResEx,代码行数:101,代码来源:main.cpp


示例19: main

int main( int argc, char **argv )
{
	printf
	(
		"z3ResEx" \
		"\nResearched and coded by x1nixmzeng\n\n"
	);
		
	// Check arguments
	if( argc > 1 )
	{
		if( SetCurrentDirectory( argv[1] ) == 0 )
		{
			printf("ERROR: Failed to set the client path (%s)\n", argv[1] );
			return 0;
		}

		if( argc > 2 )
		{
			// For all other arguments, check against known flags

			if( argv[2][0] == '-' )
			{
				// -v		Verbose
				// todo

				// -l		List all files
				if( argv[2][1] == 'l' )
				{
					user_opt_list_files = true;
				}
				else
				
				// -x		No extraction
				if( argv[2][1] == 'x' )
				{
					user_opt_allow_extraction = false;
				}

				// -f		Extract only (filter)
				// todo
			}

		}
	}

	// Check the fileindex exists
	if( TFileSize( msfName ) == 0 )
	{
		printf("ERROR: Unable to open file (%s)\n", msfName);
	}
	else
	{
		unsigned int keyIndex( 0 );
		TMemoryStream msf;

		// Brute-force the key
		while( ( keyIndex < Z3_KEY_LIST_LENGTH ) && ( msf.Size() == 0 ) )
		{
			if( fsReadMSF( msf, Z3_KEY_LIST[ keyIndex ] ) )
			{
				z3CurrentKey = Z3_KEY_LIST[ keyIndex ];
				
				// todo: verbose? - show key
			}

			++keyIndex;
		}

		if( !( z3CurrentKey == nullptr ) )
		{
			// Run main extraction loop
			if( !( user_opt_allow_extraction ) )
				printf("NOTE:  Opted NOT to save data\n");

			extractionMain( msf );
		}
		else
		{
			// No key found or incompatiable file (not checked)
			printf("ERROR: This file is using an updated key or unsupported method\n");
		}

		msf.Close();
	}

	return 0;
}
开发者ID:iKlui,项目名称:z3ResEx,代码行数:88,代码来源:main.cpp


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TMinuit类代码示例发布时间:2022-05-31
下一篇:
C++ TMem类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap