Modify the 7ZMAIN.C.
Our goal is to write a function extract7z, receive parameters are 7z file path, output file path, you can perform all decompression.
Main calling Function:
Execution effect, can decompress correctly.
Such decompression can only be used for simple decompression, does not support encryption, parameter 2 of the output file path of all folders must exist, compressed folder does not need to exist, uncompressed will be automatically created.
The folder in the compressed package cannot be Chinese, otherwise garbled.
#include <string.h>/* for memcpy () */#include <stdio.h> #include "md5.h" #ifndef highfirst #define
Bytereverse (buf, len)/* Nothing/#else void Bytereverse (unsigned char *buf, unsigned longs);
#ifndef ASM_MD5/* note:this code is harmless on Little-endian machines.
*/void Bytereverse (unsigned char *buf, unsigned longs) {UInt32 T;
do {t = (UInt32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
* (UInt32 *) buf = t;
BUF + 4;
}while (--longs);
#endif #endif static void Putu32 (UInt32 data, unsigned char *addr) {addr[0] = (unsigned char) data;
ADDR[1] = (unsigned char) (data >> 8);
ADDR[2] = (unsigned char) (data >> 16);
ADDR[3] = (unsigned char) (data >> 24); } * * Start MD5 accumulation.
Set bit count to 0 and buffer to mysterious * initialization constants. */void Md5init (struct md5context *ctx) {ctx->buf[0] = 0x67452301;
CTX->BUF[1] = 0xefcdab89;
CTX->BUF[2] = 0x98badcfe;
CTX->BUF[3] = 0x10325476;
Ctx->bits[0] = 0;
Ctx->bits[1] = 0;
} * * Update context to reflect the concatenation of another buffer full * of bytes.
*/void Md5update (struct md5context *ctx, unsigned char const *BUF, unsigned len) {UInt32 T;
/* Update Bitcount */t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32) Len << 3)) < T) ctx->bits[1]++;
/* Carry from low to High */ctx->bits[1] + = len >> 29; t = (t >> 3) & 0x3f; /* Bytes already in Shsinfo->data/* Handle any leading odd-sized chunks */if (t) {unsigned char *p
= (unsigned char *) Ctx->in + t;
t = 64-t;
if (Len < T) {memcpy (P, buf, Len);
Return
} memcpy (P, buf, T);
Bytereverse (Ctx->in, 16);
Md5transform (Ctx->buf, (UInt32 *) ctx->in);
BUF + = t;
Len-= t;
} /* Process data in 64-byte chunks */while (len >=) {memcpy (ctx->in, buf, 64);
Bytereverse (Ctx->in, 16);
Md5transform (Ctx->buf, (UInt32 *) ctx->in);
BUF + 64;
Len-= 64; }/* Handle any remaining bytes of data.
* * memcpy (ctx->in, buf, Len); } * * Final Wrapup-pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, msb-firs
T) */void md5final (unsigned char digest[16], struct md5context *ctx) {unsigned count;
unsigned char *p;
/* Compute number of bytes MoD/count = (Ctx->bits[0] >> 3) & 0x3F; /* Set the padding to 0x80.
This is safe since there are always at least one byte/p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make Bytes * * count = 64-1-count; /* Pad out to the MoD/if (count < 8) {/* Two lots of padding:pad the ' IMset (p, 0, Count);
Bytereverse (Ctx->in, 16);
Md5transform (Ctx->buf, (UInt32 *) ctx->in);
/* Now fill the next blocks with bytes * * memset (ctx->in, 0, 56);
else {/* Pad blocks to bytes * * memset (p, 0, count-8);
} bytereverse (Ctx->in, 14);
/* Append length in bits and transform *///((UInt32 *) ctx->in) [+] = ctx->bits[0];
((UInt32 *) ctx->in) = ctx->bits[1];
Putu32 (Ctx->bits[0], ctx->in + 56);
Putu32 (Ctx->bits[1], ctx->in + 60);
Md5transform (Ctx->buf, (UInt32 *) ctx->in);
Bytereverse ((unsigned char *) CTX->BUF, 4);
memcpy (Digest, Ctx->buf, 16); memset (CTX, 0, sizeof (*CTX)); /* In case it ' s sensitive/} #ifndef ASM_MD5/* The four core functions-f1 is optimized somewhat/* #defi
Ne F1 (x, Y, Z) (X & y | ~x & z) */#define F1 (x, Y, z) (z ^ (x & (y ^ z)) #define F2 (x, Y, z) F1 (z, x, y) #define F3 (x, Y, z) (x ^ y ^ z) #defineF4 (x, Y, z) (y ^ (x | ~z))/* This is the MD5 algorithm. * * #define MD5STEP (F, W, X, Y, Z, data, s) \ (w + f (x, Y, z) + data, W = W<<s | w>> (32-s), w = = x)/ * The core of the MD5 algorithm, this alters a existing MD5 hash to * reflect the addition of longwords of new D Ata.
Md5update blocks * The data and converts bytes into longwords for this routine.
* * void Md5transform (UInt32 buf[4], UInt32 const IN[16]) {Register UInt32 A, B, C, D;
A = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
Md5step (F1, A, B, C, D, in[0] + 0xd76aa478, 7);
Md5step (F1, D, a, B, C, in[1] + 0xe8c7b756, 12);
Md5step (F1, C, D, a, B, in[2] + 0x242070db, 17);
Md5step (F1, B, C, D, a, in[3] + 0xc1bdceee, 22);
Md5step (F1, A, B, C, D, in[4] + 0XF57C0FAF, 7);
Md5step (F1, D, a, B, C, in[5] + 0x4787c62a, 12);
Md5step (F1, C, D, a, B, in[6] + 0xa8304613, 17);
Md5step (F1, B, C, D, a, in[7] + 0xfd469501, 22); Md5step (F1, A,b, C, D, In[8] + 0x698098d8, 7);
Md5step (F1, D, a, B, C, in[9] + 0X8B44F7AF, 12);
Md5step (F1, C, D, a, B, in[10] + 0XFFFF5BB1, 17);
Md5step (F1, B, C, D, a, in[11] + 0x895cd7be, 22);
Md5step (F1, A, B, C, D, in[12] + 0x6b901122, 7);
Md5step (F1, D, a, B, C, in[13] + 0xfd987193, 12);
Md5step (F1, C, D, a, B, in[14] + 0xa679438e, 17);
Md5step (F1, B, C, D, a, in[15] + 0x49b40821, 22);
Md5step (F2, A, B, C, D, in[1] + 0xf61e2562, 5);
Md5step (F2, D, a, B, C, in[6] + 0xc040b340, 9);
Md5step (F2, C, D, a, B, in[11] + 0x265e5a51, 14);
Md5step (F2, B, C, D, a, in[0] + 0XE9B6C7AA, 20);
Md5step (F2, A, B, C, D, in[5] + 0xd62f105d, 5);
Md5step (F2, D, a, B, C, in[10] + 0x02441453, 9);
Md5step (F2, C, D, a, B, in[15] + 0xd8a1e681, 14);
Md5step (F2, B, C, D, a, in[4] + 0xe7d3fbc8, 20);
Md5step (F2, A, B, C, D, in[9] + 0x21e1cde6, 5);
Md5step (F2, D, a, B, C, in[14] + 0xc33707d6, 9);
Md5step (F2, C, D, a, B, in[3] + 0xf4d50d87, 14); Md5step (F2, B, C, D, a, IN[8] + 0x455a14ed, 20);
Md5step (F2, A, B, C, D, in[13] + 0xa9e3e905, 5);
Md5step (F2, D, a, B, C, in[2] + 0xfcefa3f8, 9);
Md5step (F2, C, D, a, B, in[7] + 0x676f02d9, 14);
Md5step (F2, B, C, D, a, in[12] + 0x8d2a4c8a, 20);
Md5step (F3, A, B, C, D, in[5] + 0xfffa3942, 4);
Md5step (F3, D, a, B, C, in[8] + 0x8771f681, 11);
Md5step (F3, C, D, a, B, in[11] + 0x6d9d6122, 16);
Md5step (F3, B, C, D, a, in[14] + 0xfde5380c, 23);
Md5step (F3, A, B, C, D, in[1] + 0xa4beea44, 4);
Md5step (F3, D, a, B, C, in[4] + 0x4bdecfa9, 11);
Md5step (F3, C, D, a, B, in[7] + 0xf6bb4b60, 16);
Md5step (F3, B, C, D, a, in[10] + 0xbebfbc70, 23);
Md5step (F3, A, B, C, D, in[13] + 0x289b7ec6, 4);
Md5step (F3, D, a, B, C, in[0] + 0XEAA127FA, 11);
Md5step (F3, C, D, a, B, in[3] + 0xd4ef3085, 16);
Md5step (F3, B, C, D, a, in[6] + 0x04881d05, 23);
Md5step (F3, A, B, C, D, in[9] + 0xd9d4d039, 4);
Md5step (F3, D, a, B, C, in[12] + 0xe6db99e5, 11); Md5step (F3, C, D, a, B, in[15] + 0x1fa27cf8, 16);
Md5step (F3, B, C, D, a, in[2] + 0xc4ac5665, 23);
Md5step (F4, A, B, C, D, in[0] + 0xf4292244, 6);
Md5step (F4, D, a, B, C, in[7] + 0x432aff97, 10);
Md5step (F4, C, D, a, B, in[14] + 0xab9423a7, 15);
Md5step (F4, B, C, D, a, in[5] + 0xfc93a039, 21);
Md5step (F4, A, B, C, D, in[12] + 0x655b59c3, 6);
Md5step (F4, D, a, B, C, in[3] + 0x8f0ccc92, 10);
Md5step (F4, C, D, a, B, in[10] + 0xffeff47d, 15);
Md5step (F4, B, C, D, a, in[1] + 0x85845dd1, 21);
Md5step (F4, A, B, C, D, In[8] + 0x6fa87e4f, 6);
Md5step (F4, D, a, B, C, in[15] + 0xfe2ce6e0, 10);
Md5step (F4, C, D, a, B, in[6] + 0xa3014314, 15);
Md5step (F4, B, C, D, a, in[13] + 0X4E0811A1, 21);
Md5step (F4, A, B, C, D, in[4] + 0xf7537e82, 6);
Md5step (F4, D, a, B, C, in[11] + 0xbd3af235, 10);
Md5step (F4, C, D, a, B, in[2] + 0X2AD7D2BB, 15);
Md5step (F4, B, C, D, a, in[9] + 0xeb86d391, 21);
Buf[0] + = A;
BUF[1] + b;
BUF[2] + = C;
BUF[3] + = D; } * * Get MD5 of A byTE buffer */int getBytesMD5 (const unsigned char* src, unsigned int length, char* md5) {unsigned char i = 0;
unsigned char md5bytes[16] = {0};
Md5_ctx context;
if (src = null | | md5 = NULL) {return-1;
} md5init (&context);
Md5update (&context, src, length);
Md5final (Md5bytes, &context);
for (i = 0; i < i++) {sprintf (MD5, "%02x", Md5bytes[i]);
MD5 + 2;
} *md5 = ' I ';
return 0; }/* Get MD5 for a string */int getStringMD5 (const char* SRC, char* MD5) {return getBytesMD5 (unsigned char
*) SRC, strlen ((char*) src), MD5);
/** * Get MD5 of a file */int getFileMD5 (const char* path, char* MD5) {file* fp = NULL;
unsigned char Buffer[md5_file_buffer_len] = {0};
int count = 0;
Md5_ctx context;
unsigned char md5bytes[16] = {0};
int i;
if (path = = NULL | | md5 = NULL) {return-1;
fp = fopen (path, "RB");
if (fp = = NULL) {return-1; } md5iNIT (&context);
while (count = fread (buffer, 1, Md5_file_buffer_len, FP)) > 0) {md5update (&context, buffer, count);
} md5final (Md5bytes, &context);
for (i = 0; i < i++) {sprintf (MD5, "%02x", Md5bytes[i]);
MD5 + 2;
} *md5 = ' I ';
return 0;
} #endif