mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-11-09 23:12:21 +05:30
63 lines
1.1 KiB
C
63 lines
1.1 KiB
C
#ifndef _CORRUPTER_H
|
|
#define _CORRUPTER_H
|
|
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <inttypes.h>
|
|
#include <limits.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "MTPRNG.h"
|
|
#include "file_boundaries.h"
|
|
#include "file_type.h"
|
|
|
|
/* structures */
|
|
struct _corrupter_result {
|
|
bool error;
|
|
size_t hit_counter,
|
|
file_size,
|
|
damaged_bytes;
|
|
};
|
|
|
|
struct _corrupter_param {
|
|
FILE* file;
|
|
uint16_t probability;
|
|
uint8_t threshold;
|
|
size_t passes;
|
|
uint8_t config;
|
|
uint32_t* seed;
|
|
file_type_t type;
|
|
};
|
|
|
|
/* typedefs */
|
|
typedef struct _corrupter_param Corrupter_Param;
|
|
typedef struct _corrupter_result Corrupter_Result;
|
|
typedef unsigned char byte;
|
|
|
|
/* macros: procedures */
|
|
#ifdef DEBUG
|
|
# define DBG_EXPECT(text, condition) do { \
|
|
if (!(condition)) \
|
|
die("[debug] Fail: %s", text); \
|
|
} while (0)
|
|
#else
|
|
# define DBG_EXPECT(text, condition) do { \
|
|
if (!(condition)) \
|
|
abort(); \
|
|
} while (0)
|
|
#endif
|
|
|
|
/* macros: lambdas */
|
|
#define FLIP_BIT(x, n) ((x) ^ (1 << (n)))
|
|
|
|
/* functions definitions */
|
|
Corrupter_Result* corrupt_file(Corrupter_Param* param);
|
|
|
|
#endif /* _CORRUPTER_H */
|