2010-12-08 08:26:18 +01:00
|
|
|
#ifndef TOOLS_H
|
|
|
|
#define TOOLS_H
|
|
|
|
#include "includes.h"
|
2010-12-10 04:50:08 +01:00
|
|
|
//#include "
|
2010-12-08 08:26:18 +01:00
|
|
|
|
|
|
|
#define RU(x,n) (-(-(x) & -(n))) //round up
|
|
|
|
|
|
|
|
#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
|
|
|
|
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
|
|
|
|
|
2010-12-10 04:50:08 +01:00
|
|
|
char ascii( char s );
|
2010-12-08 08:26:18 +01:00
|
|
|
void hexdump( const void *d, int len );
|
|
|
|
void hexdump( const QByteArray &d, int from = 0, int len = -1 );
|
|
|
|
|
|
|
|
void hexdump12( const void *d, int len );
|
|
|
|
void hexdump12( const QByteArray &d, int from = 0, int len = -1 );
|
|
|
|
|
|
|
|
//simplified functions for crypto shit
|
|
|
|
void AesSetKey( const QByteArray key );
|
|
|
|
QByteArray AesDecrypt( quint16 index, const QByteArray source );
|
2010-12-08 19:07:57 +01:00
|
|
|
QByteArray AesEncrypt( quint16 index, const QByteArray source );
|
2010-12-08 08:26:18 +01:00
|
|
|
|
|
|
|
QByteArray GetSha1( QByteArray stuff );
|
|
|
|
|
|
|
|
//get a padded version of the given buffer
|
|
|
|
QByteArray PaddedByteArray( const QByteArray &orig, quint32 padTo );
|
|
|
|
|
2010-12-08 19:07:57 +01:00
|
|
|
//read a file into a bytearray
|
|
|
|
QByteArray ReadFile( const QString &path );
|
|
|
|
|
2010-12-09 12:30:25 +01:00
|
|
|
//save a file to disc
|
|
|
|
bool WriteFile( const QString &path, const QByteArray ba );
|
|
|
|
|
2010-12-08 08:26:18 +01:00
|
|
|
//keep track of the last folder browsed to when looking for files
|
2010-12-10 04:50:08 +01:00
|
|
|
//extern QString currentDir;
|
2010-12-08 08:26:18 +01:00
|
|
|
|
|
|
|
//folder used to cache stuff downloaded from NUS so duplicate titles dont need to be downloaded
|
2010-12-10 04:50:08 +01:00
|
|
|
//extern QString cachePath;
|
2010-12-08 08:26:18 +01:00
|
|
|
|
|
|
|
//folder to use as the base path for the nand
|
2010-12-10 04:50:08 +01:00
|
|
|
//extern QString nandPath;
|
2010-12-08 08:26:18 +01:00
|
|
|
|
2010-12-08 19:07:57 +01:00
|
|
|
#define CERTS_DAT_SIZE 2560
|
|
|
|
extern const quint8 certs_dat[ CERTS_DAT_SIZE ];
|
|
|
|
extern const quint8 root_dat[];
|
|
|
|
|
2010-12-08 08:26:18 +01:00
|
|
|
#endif // TOOLS_H
|