-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCorruptor.h
44 lines (38 loc) · 1.28 KB
/
Corruptor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef CORRUPTOR_H
#define CORRUPTOR_H
#include "Settings.h"
#include <QString>
#include <QFile>
#include <QByteArray>
#include <QWidget>
const static int MAX_BUFFER_SIZE = 33554432; //32MB
class Corruptor
{
public:
Corruptor(QWidget *parent, Settings *settings, const QString &inFileLocation, const QString &outFileLocation);
~Corruptor();
int Run();
bool Show_Message(int errorCode);
private:
bool Use_NES_CPU_Jam_Protection(QFile *file);
bool Is_NES_ROM(QByteArray *buffer);
bool Is_Famicom_ROM(QByteArray *buffer);
void Fix_Byte(unsigned char &byte);
bool Is_Byte_Protected(QByteArray *buffer, qint64 pos);
bool Is_First_Byte_Protected(unsigned char byte);
bool Is_Second_Byte_Protected(unsigned char byte);
bool Is_Third_Byte_Protected(unsigned char byte);
bool Corrupt_Buffer(QByteArray *buffer, qint64 startingPos, qint64 endingPos);
void Randomize_Byte(unsigned char &byte);
void Add_To_Byte(unsigned char &byte);
void Shift_Byte(unsigned char &byte);
bool Replace_Byte(unsigned char &byte);
void Handle_Increment();
QWidget *parent;
Settings *settings;
QString inFileLocation;
QString outFileLocation;
bool isNESROM;
qint64 fileSize;
};
#endif // CORRUPTOR_H