changed support

This commit is contained in:
Pin
2021-11-02 22:42:49 -04:00
parent 7649feee82
commit cbee739c91
3 changed files with 46 additions and 24 deletions

View File

@@ -10,7 +10,7 @@
#include <pthread.h>
#include "crc_util.h"
#include "CRCLib.h"
#include "crc.h"
#include "pspng.h"
#include "compress_util.h"
//#define MAX_IDAT_SIZE 16384
@@ -74,6 +74,7 @@ static void random_window_bit_change(unsigned char *data, int width, int rounds,
size_t random_num = 0;
size_t filter_chunk_byte = 0;
size_t change_num = 0;
long prior_chuck_check = 0;
for (int i = 0; i < rounds; i++) {
random_num = 0;
do {
@@ -109,7 +110,15 @@ static void random_window_bit_change(unsigned char *data, int width, int rounds,
data[random_num]++;
}
} else if(data[filter_chunk_byte] == 3) {
printf("3\n");
// Average Filter Type Change
//printf("HEE: %d\n", data[(filter_chunk_byte - (width * color_range))-1]);
prior_chuck_check = filter_chunk_byte;
do {
//printf("C: %d\n", data[prior_chuck_check]);
prior_chuck_check = (prior_chuck_check - (width * color_range)-1);
//printf("CH: %ld\n", prior_chuck_check);
} while(prior_chuck_check >= 0);
if(data[random_num] == 255) {
data[random_num]--;
} else {
@@ -487,8 +496,9 @@ int main(int argc, char **argv) {
};
const char* usage =
"Usage: crc [options]\n"
"Usage: pspng [options]\n\n"
" -c --compress Compress Message\n"
" -u --uncompress Currently used for debugging\n"
" -h, --help Shows help message\n"
" -f, --file Denotes input file\n"
" -o, --outfile Denotes output file\n"
@@ -559,29 +569,37 @@ int main(int argc, char **argv) {
if(uncompress_call == 1) {
size_t idat_byte_length = 0;
unsigned long cur_idat_len = 0;
//unsigned char message_data[8192];
unsigned char* idat_data = populate_idat_array(file_data, offset, &idat_byte_length);
for(int i = 0; i < idat_byte_length; i++) {
//for(int i = 0; i < idat_byte_length; i++) {
//printf("%02X ", idat_data[i]);
}
//}
printf("\nDecompressed Data:\n\n");
// Decompressing data
unsigned char *uncom_data_buff = NULL;
size_t uncom_data_size = 0;
zlib_decompress_data(idat_data, idat_byte_length, &uncom_data_buff, &uncom_data_size);
for(int i = 0; i < uncom_data_size; i++) {
printf("%02X ", uncom_data_buff[i]);
}
printf("\n");
//for(int k=0;k<20;k++) {
// printf("%d: %d\n", (0+k), uncom_data_buff[0+k]);
//unsigned char *uncom_data_buff = NULL;
//size_t uncom_data_size = 0;
//zlib_decompress_data(idat_data, idat_byte_length, &uncom_data_buff, &uncom_data_size);
//for(int i = 0; i < uncom_data_size; i++) {
// printf("%02X ", uncom_data_buff[i]);
//}
//printf("\n");
//printf("\n");
//for(int k=0;k<20;k++) {
// printf("%d: %d\n", (24000+k), uncom_data_buff[24000+k]);
//}
printf("\n");
do {
for(int j = 0; j < 64; j++) {
cur_idat_len = 0;
for(int i = 0; i < 4; i++) {
cur_idat_len += (file_data[offset+i] << (24-(8*i)));
}
//printf("%c", file_data[offset+cur_idat_len+8]);
if((j % 4) == 0) {
printf("%c", file_data[offset+cur_idat_len+8]);
}
// Offset Plus idat length + 3 bytes
offset += cur_idat_len + 12;
}
} while(offset < idat_byte_length);
free(idat_data);
free(file_data);