275 lines
14 KiB
C
275 lines
14 KiB
C
|
|
#ifndef JRPCPP_H
|
||
|
|
#define JRPCPP_H
|
||
|
|
|
||
|
|
#include "JRPCpp_global.h"
|
||
|
|
|
||
|
|
#include <QString>
|
||
|
|
#include <QVector>
|
||
|
|
#include <QDebug>
|
||
|
|
|
||
|
|
#include "jrpcpp_enums.h"
|
||
|
|
#include "XDevkit.h"
|
||
|
|
|
||
|
|
typedef _exception COMException;
|
||
|
|
|
||
|
|
|
||
|
|
static uint connectionId;
|
||
|
|
static const uint JRPCVersion = 2;
|
||
|
|
|
||
|
|
class JRPCPP_EXPORT JRPCpp
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
static const uint Void = 0;
|
||
|
|
static const uint Int = 1;
|
||
|
|
static const uint String = 2;
|
||
|
|
static const uint Float = 3;
|
||
|
|
static const uint Byte = 4;
|
||
|
|
static const uint IntArray = 5;
|
||
|
|
static const uint FloatArray = 6;
|
||
|
|
static const uint ByteArray = 7;
|
||
|
|
static const uint Uint64 = 8;
|
||
|
|
static const uint Uint64Array = 9;
|
||
|
|
|
||
|
|
JRPCpp();
|
||
|
|
|
||
|
|
static QString ToHexString(const QString& aString);
|
||
|
|
|
||
|
|
static QByteArray Push(QByteArray aInArray, char aValue);
|
||
|
|
|
||
|
|
static QByteArray ToByteArray(const QString& aString);
|
||
|
|
|
||
|
|
static bool Connect(const IXboxConsole& aConsole, QString aXboxNameOrIP = "default");
|
||
|
|
|
||
|
|
static QString XboxIP(const IXboxConsole& aConsole);
|
||
|
|
|
||
|
|
/*static*/ QMap<QMetaType, int> ValueTypeSizeMap =
|
||
|
|
{
|
||
|
|
{ QMetaType::fromType<bool>(), 4 },
|
||
|
|
{ QMetaType::fromType<byte>(), 1 },
|
||
|
|
{ QMetaType::fromType<short>(), 2 },
|
||
|
|
{ QMetaType::fromType<int>(), 4 },
|
||
|
|
{ QMetaType::fromType<long>(), 8 },
|
||
|
|
{ QMetaType::fromType<ushort>(), 2 },
|
||
|
|
{ QMetaType::fromType<uint>(), 4 },
|
||
|
|
{ QMetaType::fromType<unsigned long>(), 8 },
|
||
|
|
{ QMetaType::fromType<float>(), 4 },
|
||
|
|
{ QMetaType::fromType<double>(), 8 }
|
||
|
|
};
|
||
|
|
static QMap<QMetaType, int> StructPrimitiveSizeMap;
|
||
|
|
|
||
|
|
static QSet<QMetaType> ValidReturnTypes;
|
||
|
|
|
||
|
|
static void ReverseBytes(QByteArray buffer, int groupSize);
|
||
|
|
|
||
|
|
// Reading Memory
|
||
|
|
static QByteArray GetMemory(const IXboxConsole& aConsole, uint aAddress, uint aLength);
|
||
|
|
static byte ReadSByte(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static byte ReadByte(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static bool ReadBool(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static float ReadFloat(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<float> ReadFloat(const IXboxConsole& aConsole, uint aAddress, uint ArraySize);
|
||
|
|
static short ReadInt16(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<short> ReadInt16(const IXboxConsole& aConsole, uint aAddress, uint ArraySize);
|
||
|
|
static ushort ReadUInt16(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<short> ReadUInt16(const IXboxConsole& aConsole, uint aAddress, uint ArraySize);
|
||
|
|
static int ReadInt32(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<int> ReadInt32(const IXboxConsole& aConsole, uint aAddress, uint ArraySize);
|
||
|
|
static uint ReadUInt32(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<uint> ReadUInt32(const IXboxConsole& aConsole, uint aAddress, uint ArraySize);
|
||
|
|
static long ReadInt64(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<qint64> ReadInt64(const IXboxConsole& aConsole, uint aAddress, uint aArraySize);
|
||
|
|
static unsigned long ReadUInt64(const IXboxConsole& aConsole, uint aAddress);
|
||
|
|
static QVector<unsigned long> ReadUInt64(const IXboxConsole& aConsole, uint aAddress, uint ArraySize);
|
||
|
|
static QString ReadString(const IXboxConsole& aConsole, uint aAddress, uint size);
|
||
|
|
|
||
|
|
//Writing Memory
|
||
|
|
static void SetMemory(const IXboxConsole& aConsole, uint aAddress, QByteArray aData);
|
||
|
|
static void WriteSByte(const IXboxConsole& aConsole, uint aAddress, char Value);
|
||
|
|
static void WriteSByte(const IXboxConsole& aConsole, uint aAddress, QByteArray Value);
|
||
|
|
static void WriteByte(const IXboxConsole& aConsole, uint aAddress, byte Value);
|
||
|
|
static void WriteByte(const IXboxConsole& aConsole, uint aAddress, QByteArray Value);
|
||
|
|
static void WriteBool(const IXboxConsole& aConsole, uint aAddress, bool Value);
|
||
|
|
static void WriteBool(const IXboxConsole& aConsole, uint aAddress, QVector<bool> Value);
|
||
|
|
static void WriteFloat(const IXboxConsole& aConsole, uint aAddress, float Value);
|
||
|
|
static void WriteFloat(const IXboxConsole& aConsole, uint aAddress, QVector<float> Value);
|
||
|
|
static void WriteInt16(const IXboxConsole& aConsole, uint aAddress, short Value);
|
||
|
|
static void WriteInt16(const IXboxConsole& aConsole, uint aAddress, QVector<short> Value);
|
||
|
|
static void WriteUInt16(const IXboxConsole& aConsole, uint aAddress, ushort Value);
|
||
|
|
static void WriteUInt16(const IXboxConsole& aConsole, uint aAddress, QVector<short> Value);
|
||
|
|
static void WriteInt32(const IXboxConsole& aConsole, uint aAddress, int Value);
|
||
|
|
static void WriteInt32(const IXboxConsole& aConsole, uint aAddress, QVector<int> Value);
|
||
|
|
static void WriteUInt32(const IXboxConsole& aConsole, uint aAddress, uint aValue);
|
||
|
|
static void WriteUInt32(const IXboxConsole& aConsole, uint aAddress, QVector<uint> Value);
|
||
|
|
static void WriteInt64(const IXboxConsole& aConsole, uint aAddress, long Value);
|
||
|
|
static void WriteInt64(const IXboxConsole& aConsole, uint aAddress, QVector<long> Value);
|
||
|
|
static void WriteUInt64(const IXboxConsole& aConsole, uint aAddress, unsigned long Value);
|
||
|
|
static void WriteUInt64(const IXboxConsole& aConsole, uint aAddress, QVector<unsigned long> Value);
|
||
|
|
static void WriteString(const IXboxConsole& aConsole, uint aAddress, QString String);
|
||
|
|
static uint ResolveFunction(const IXboxConsole& aConsole, QString ModuleName, uint Ordinal);
|
||
|
|
static QString GetCPUKey(const IXboxConsole& aConsole);
|
||
|
|
static void ShutDownConsole(const IXboxConsole& aConsole);
|
||
|
|
static QByteArray WCHAR(QString String);
|
||
|
|
static QByteArray ToWCHAR(QString String);
|
||
|
|
static uint GetKernalVersion(const IXboxConsole& aConsole);
|
||
|
|
static void SetLeds(const IXboxConsole& aConsole, LEDState aTopLeft, LEDState aTopRight, LEDState aBottomLeft, LEDState aBottomRight);
|
||
|
|
static uint GetTemperature(const IXboxConsole& aConsole, TemperatureType TemperatureType);
|
||
|
|
static void XNotify(const IXboxConsole& aConsole, QString aText);
|
||
|
|
static void XNotify(const IXboxConsole& aConsole, XNotifyLogo aType, QString aText);
|
||
|
|
static uint XamGetCurrentTitleId(const IXboxConsole& aConsole);
|
||
|
|
static QString ConsoleType(const IXboxConsole& aConsole);
|
||
|
|
static void constantMemorySet(const IXboxConsole& aConsole, uint aAddress, uint aValue);
|
||
|
|
static void constantMemorySet(const IXboxConsole& aConsole, uint aAddress, uint aValue, uint TitleID);
|
||
|
|
static void constantMemorySet(const IXboxConsole& aConsole, uint aAddress, uint aValue, uint IfValue, uint TitleID);
|
||
|
|
static void constantMemorySetting(IXboxConsole aConsole, uint aAddress, uint aValue, bool useIfValue, uint IfValue, bool usetitleID, uint TitleID);
|
||
|
|
|
||
|
|
template <typename T>
|
||
|
|
static uint TypeToType(bool aArray)
|
||
|
|
{
|
||
|
|
QMetaType Type = QMetaType::fromType<T>();
|
||
|
|
if (Type == QMetaType::fromType<int>()
|
||
|
|
|| Type == QMetaType::fromType<uint>()
|
||
|
|
|| Type == QMetaType::fromType<short>()
|
||
|
|
|| Type == QMetaType::fromType<ushort>())
|
||
|
|
{
|
||
|
|
if(aArray) { return JRPCpp::IntArray; }
|
||
|
|
|
||
|
|
return JRPCpp::Int;
|
||
|
|
}
|
||
|
|
if (Type == QMetaType::fromType<QString>()
|
||
|
|
|| Type == QMetaType::fromType<QVector<char>>())
|
||
|
|
return JRPCpp::String;
|
||
|
|
if (Type == QMetaType::fromType<float>()
|
||
|
|
|| Type == QMetaType::fromType<double>()) {
|
||
|
|
if (aArray)
|
||
|
|
return JRPCpp::FloatArray;
|
||
|
|
return JRPCpp::Float;
|
||
|
|
}
|
||
|
|
if (Type == QMetaType::fromType<byte>()
|
||
|
|
|| Type == QMetaType::fromType<char>()) {
|
||
|
|
if (aArray)
|
||
|
|
return JRPCpp::ByteArray;
|
||
|
|
return JRPCpp::Byte;
|
||
|
|
}
|
||
|
|
if (Type == QMetaType::fromType<unsigned long>()
|
||
|
|
|| Type == QMetaType::fromType<long>()) {
|
||
|
|
if (aArray)
|
||
|
|
return JRPCpp::Uint64Array;
|
||
|
|
return JRPCpp::Uint64;
|
||
|
|
}
|
||
|
|
return JRPCpp::Uint64;
|
||
|
|
}
|
||
|
|
|
||
|
|
template <typename T>
|
||
|
|
static T Call(const IXboxConsole& aConsole, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static T Call(const IXboxConsole& aConsole, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static T Call(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static T Call(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static void CallVoid(const IXboxConsole& aConsole, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
static void CallVoid(const IXboxConsole& aConsole, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
static void CallVoid(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
static void CallVoid(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> ArrayReturn(const IXboxConsole& aConsole, uint aAddress, uint Size);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallArray(const IXboxConsole& aConsole, uint aAddress, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallArray(const IXboxConsole& aConsole, QString module, int ordinal, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallArray(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallArray(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static QString CallString(const IXboxConsole& aConsole, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
static QString CallString(const IXboxConsole& aConsole, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
static QString CallString(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
static QString CallString(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
static int UIntToInt(uint aValue);
|
||
|
|
static QByteArray IntArrayToByte(QVector<int> iArray);
|
||
|
|
|
||
|
|
template <typename T>
|
||
|
|
static T CallVM(const IXboxConsole& aConsole, uint aAddress, QVector<QVariant> aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static T CallVM(const IXboxConsole& aConsole, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static T CallVM(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static T CallVM(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static void CallVMVoid(const IXboxConsole& aConsole, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
static void CallVMVoid(const IXboxConsole& aConsole, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
static void CallVMVoid(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
static void CallVMVoid(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallVMArray(const IXboxConsole& aConsole, uint aAddress, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallVMArray(const IXboxConsole& aConsole, QString module, int ordinal, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallVMArray(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
template <typename T>
|
||
|
|
static QVector<T> CallVMArray(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, uint ArraySize, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static QString CallVMString(const IXboxConsole& aConsole, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static QString CallVMString(const IXboxConsole& aConsole, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static QString CallVMString(const IXboxConsole& aConsole, ThreadType Type, uint aAddress, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static QString CallVMString(const IXboxConsole& aConsole, ThreadType Type, QString module, int ordinal, const QVector<QVariant>& aArguments);
|
||
|
|
|
||
|
|
static QString SendCommand(const IXboxConsole& aConsole, QString Command);
|
||
|
|
|
||
|
|
static QVariant CallArgs(
|
||
|
|
const IXboxConsole& aConsole,
|
||
|
|
bool aSystemThread,
|
||
|
|
uint aType,
|
||
|
|
QMetaType t,
|
||
|
|
QString module,
|
||
|
|
int ordinal,
|
||
|
|
uint aAddress,
|
||
|
|
uint ArraySize,
|
||
|
|
bool VM,
|
||
|
|
const QVector<QVariant>& aArguments
|
||
|
|
);
|
||
|
|
|
||
|
|
static ulong ConvertToUInt64(QVariant aVariant);
|
||
|
|
static bool IsValidStructType(QMetaType t);
|
||
|
|
static bool isNumericPrimitive(QMetaType t);
|
||
|
|
static bool IsValidReturnType(QMetaType t);
|
||
|
|
void constantMemorySetting(const IXboxConsole &aConsole, uint aAddress, uint aValue, bool useIfValue, uint IfValue, bool usetitleID, uint TitleID);
|
||
|
|
};
|
||
|
|
|
||
|
|
QSet<QMetaType> JRPCpp::ValidReturnTypes =
|
||
|
|
{
|
||
|
|
QMetaType::fromType<void>(),
|
||
|
|
QMetaType::fromType<bool>(),
|
||
|
|
QMetaType::fromType<byte>(),
|
||
|
|
QMetaType::fromType<short>(),
|
||
|
|
QMetaType::fromType<int>(),
|
||
|
|
QMetaType::fromType<long>(),
|
||
|
|
QMetaType::fromType<ushort>(),
|
||
|
|
QMetaType::fromType<uint>(),
|
||
|
|
QMetaType::fromType<unsigned long>(),
|
||
|
|
QMetaType::fromType<float>(),
|
||
|
|
QMetaType::fromType<double>(),
|
||
|
|
QMetaType::fromType<QString>(),
|
||
|
|
QMetaType::fromType<QVector<bool>>(),
|
||
|
|
QMetaType::fromType<QByteArray>(),
|
||
|
|
QMetaType::fromType<QVector<short>>(),
|
||
|
|
QMetaType::fromType<QVector<int>>(),
|
||
|
|
QMetaType::fromType<QVector<long>>(),
|
||
|
|
QMetaType::fromType<QVector<short>>(),
|
||
|
|
QMetaType::fromType<QVector<uint>>(),
|
||
|
|
QMetaType::fromType<QVector<unsigned long>>(),
|
||
|
|
QMetaType::fromType<QVector<float>>(),
|
||
|
|
QMetaType::fromType<QVector<double>>(),
|
||
|
|
QMetaType::fromType<QStringList>()
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // JRPCPP_H
|