CRYPT_ARCH_ZIP 수정자가 있는 CryptDecode - 사용 방법은 무엇입니까? - 페이지 6

 
Mikalas :

표준 ZIP 파일의 압축을 풉니다!

(지금까지 아카이브에 하나의 압축 파일만 있으면 여러 파일에 대해 수행할 것입니다(필요한 경우))

고맙습니다. 필요한 것은 바로! 마이클, 당신은 훌륭합니다. 오늘 밤부터 조사를 시작하겠습니다. 그러나 MQ 주석은 여전히 필요합니다.
 
그리고 압축을 풀지 않았는데 내부 오류(4024)가 발생했습니다.
 
Mikalas :

표준 ZIP 파일의 압축을 풉니다!

(지금까지 아카이브에 하나의 압축 파일만 있으면 여러 파일에 대해 수행할 것입니다(필요한 경우))

압축을 푼 zip 파일을 첨부합니다.
 

그래서 파일 아래에?

그리고 나는 행복했다)

추신: 자신의 것이 이미 우수하더라도 의심의 여지가 없습니다.

 
sanyooooook :

그래서 파일 아래에?

그리고 나는 행복했다)

추신: 자신의 것이 이미 우수하더라도 의심의 여지가 없습니다.

오늘 해보려고 합니다
파일:
GAZR-6_15.zip  1 kb
 

바실리!

그래서 해야 하나 말아야 하나?

 
Mikalas :

바실리!

그래서 해야 하나 말아야 하나?

아직 아님. 월요일에 MQ 댓글을 봅시다. Alexander의 게시물에 따르면 문제가 zip 아카이버에 있음이 분명합니다. 기타 아카이브 귀하의 코드는 압축을 풀지 않습니다:

산요우우우우우우우우우우우우우우우우우우우 :
그리고 압축을 풀지 않았는데 내부 오류(4024)가 발생했습니다.

추신 적어도 오류는 다릅니다.

미칼라스 :

표준 ZIP 파일의 압축을 풉니다!

(지금까지 아카이브에 하나의 압축 파일만 있으면 여러 파일에 대해 수행할 것입니다(필요한 경우))

질문 하나 더. 아카이브를 만드는 데 사용된 zip 아카이브의 종류와 사용된 매개변수(압축률, 사전 크기).
 
C-4 :

아직 아님. 월요일에 MQ 댓글을 봅시다. Alexander의 게시물에 따르면 문제가 zip 아카이버에 있음이 분명합니다. 기타 아카이브 귀하의 코드는 압축을 풀지 않습니다:

추신 적어도 오류는 다릅니다.

질문 하나 더. 아카이브를 만드는 데 사용된 zip 아카이브의 종류와 사용된 매개변수(압축률, 사전 크기).

기본 설정이 있는 WinRar.

모든 아카이브의 압축을 푸는 방법을 알고 있습니다.

그러나 이를 위해서는 MQ 패커의 4바이트에 대해 약간 이해해야 합니다.

필요하다면 그렇게 하겠습니다.

MQ는 응답하지 않을 수 있습니다 :)

 

MQ 패커의 마지막 4바이트는 해시 또는 CRC입니다.

(서비스 정보)

그러나 명확하지 않거나 포장되거나 원시 데이터가 아닙니다.

MQ의 답변을 기다려야 합니다.

 

그때까지:

//+------------------------------------------------------------------+
//|                                                  Zip_decoder.mqh |
//|                                          Copyright 2015, Mikalas |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
struct ZIP_HEADER
{
  uint   sign;
  ushort a_version;
  ushort bit_flag;
  ushort comp_method;
  ushort last_mod_time;
  ushort last_mod_date;
  int    crc_32;
  uint   pack_size;
  uint   unpack_size;
  ushort fn_len;
  ushort extr_field_len;
};
//
ZIP_HEADER zip_header;
bool f_found;
//+------------------------------------------------------------------+
//| Get entryes in ZIP file                                          |
//+------------------------------------------------------------------+
uint GetEntryesZip( const string file_name, string  &f_names[] )
{
  uint a_cnt = 0;
  uchar array[];
  int handle = FileOpen( file_name, FILE_READ | FILE_BIN );
  if ( handle != INVALID_HANDLE )
  {
    ulong file_size = FileSize( handle );
    if ( file_size > 0 ) 
    {
      while ( FileTell( handle ) < file_size - 4 )
      {
        zip_header.sign = FileReadInteger( handle, 4 );
        
        if ( zip_header.sign == 0x04034b50 )
        {
          a_cnt++;  
          ArrayResize( f_names, a_cnt );
          f_names[ a_cnt - 1] = "";  
          FileSeek( handle, -4, SEEK_CUR );
          FileReadStruct( handle, zip_header ); 
          if ( zip_header.extr_field_len != 0 )
          {
            FileSeek( handle, zip_header.extr_field_len, SEEK_CUR );
          }
          ArrayResize( array, int( zip_header.fn_len ) );
          uint fn_res = FileReadArray( handle, array, 0, int( zip_header.fn_len ) );
          for ( int i = 0; i < int( fn_res ); i++ )
          {
            f_names[a_cnt - 1] += CharToString( array[i] );
          }
          FileSeek( handle, zip_header.pack_size, SEEK_CUR );
        }
      }
    }
    FileClose( handle );
  }
  return( a_cnt );
}
bool GetFile( const string src_name, const string dest_name, const int position, uchar &unp_data[] )
{
  uchar array[];
  uchar key[];
  f_found = false;
  int f_cnt = 0;
  int handle = FileOpen( src_name, FILE_READ | FILE_BIN );
  if ( handle != INVALID_HANDLE )
  {
    ulong file_size = FileSize( handle );
    if ( file_size > 0 ) 
    {
      while ( FileTell( handle ) < file_size - 4 )
      {
        zip_header.sign = FileReadInteger( handle, 4 );
        
        if ( zip_header.sign == 0x04034b50 )
        {
          f_cnt++;
          FileSeek( handle, -4, SEEK_CUR );
          FileReadStruct( handle, zip_header ); 
          if ( zip_header.extr_field_len != 0 )
          {
            FileSeek( handle, zip_header.extr_field_len, SEEK_CUR );
          }
          ArrayResize( array, int( zip_header.fn_len ) );
          
          uint fn_res = FileReadArray( handle, array, 0, int( zip_header.fn_len ) );
          
          string file_name = "";
          for ( int i = 0; i < int( fn_res ); i++ )
          {
            file_name += CharToString( array[i] );
          }  
          if ( ( file_name == dest_name ) && ( position == f_cnt - 1 ) )
          {
            f_found = true;
            ArrayResize( array, int( zip_header.pack_size ) + 6 );
            
            uint ar_res = FileReadArray( handle, array, 2, int( zip_header.pack_size ) );  
            if ( ar_res == uint( zip_header.pack_size ) ) 
            {
              array[0] = 0x78;
              array[1] = 0x5E;
              array[int( zip_header.pack_size ) + 2] = 193;  //Wait MQ !!!!!!!!!!!!!!!!!!!!!!!!!
              array[int( zip_header.pack_size ) + 3] = 12;   //Wait MQ !!!!!!!!!!!!!!!!!!!!!!!!
              array[int( zip_header.pack_size ) + 4] = 31;   //Wait MQ !!!!!!!!!!!!!!!!!!!!!!!!!
              array[int( zip_header.pack_size ) + 5] = 159;  //Wait MQ !!!!!!!!!!!!!!!!!!!!!!!!!!!
              ArrayResize( key, int( zip_header.pack_size ) + 6 );
              for ( int j = 0; j < int( zip_header.pack_size ) + 6; j++ ) key[j] = 0;
              ResetLastError();
              int dec_res = CryptDecode( CRYPT_ARCH_ZIP, array, key, unp_data );
              if ( dec_res == int( zip_header.unpack_size ) )
              {
                FileClose( handle );
                return( true );
              }
              else
              {
                Print( " Ошибка распаковки = ", GetLastError() );
                FileClose( handle );
                return( false );
              }
            } 
            break;
          }
          if ( f_found ) break;  
          FileSeek( handle, zip_header.pack_size, SEEK_CUR );
        }
      }
    }
    FileClose( handle );
  }
  return( false );
}

함수 호출:

 //+------------------------------------------------------------------+
//|                                                     Zip_test.mq5 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property version    "1.00"
//
#include "Zip_decoder.mqh" ;
//
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
//---
   string file_name = "Files.zip" ;
   string file_names[];
   uchar result[];
   uint files_tot = GetEntryesZip( file_name, file_names );
   if ( GetFile( file_name, file_names[ 1 ], 1 , result ) )
   {
     Print ( "Файл распакован. Имя файла = " , file_names[ 1 ] );
   }
//---
   return ( INIT_SUCCEEDED );
  }

아카이브에서 두 번째 파일(GAZR-6.15.dat)을 추출합니다. 아카이브는 기본 설정으로 WinRar에서 만듭니다.

GetFile() 함수에서 위치(1) 매개변수는 ZIP 아카이브에서 파일을 정확하게 식별하는 데 필요합니다.

아카이브에는 이름이 같은 파일이 포함될 수 있습니다.

 2015.03 . 29 21 : 38 : 05.553 Zip_test (GAZR- 6.15 ,M1) Файл распакован. Имя файла = GAZR- 6.15 .dat
파일:
Files.zip  1 kb
사유: