packet.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __BARRY_PACKET_H__
00025 #define __BARRY_PACKET_H__
00026
00027 #include <string>
00028 #include <stdint.h>
00029 #include "protocol.h"
00030 #include "data.h"
00031
00032 namespace Barry { class Data; }
00033
00034 namespace Barry {
00035
00036
00037 class Parser;
00038 class Builder;
00039 class SocketZero;
00040 class Socket;
00041 class IConverter;
00042 namespace Mode {
00043 class Desktop;
00044 class JavaLoader;
00045 }
00046
00047 class Packet
00048 {
00049 friend class SocketZero;
00050 friend class Socket;
00051
00052 protected:
00053 Data &m_send;
00054 Data *m_receive;
00055
00056 Data& GetSend() { return m_send; }
00057 Data& GetReceive() { return *m_receive; }
00058
00059 public:
00060 Packet(Data &send, Data &receive)
00061 : m_send(send), m_receive(&receive)
00062 {}
00063 virtual ~Packet() {}
00064
00065
00066
00067
00068
00069 void SetNewReceive(Data &receive) { m_receive = &receive; }
00070
00071
00072
00073
00074 unsigned int Command() const;
00075 };
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 class ZeroPacket : public Packet
00088 {
00089 friend class Socket;
00090
00091 public:
00092 ZeroPacket(Data &send, Data &receive);
00093 ~ZeroPacket();
00094
00095
00096
00097
00098
00099
00100
00101 void GetAttribute(unsigned int object, unsigned int attribute);
00102 void Echo(uint64_t us_ticks);
00103 void Reset();
00104
00105
00106
00107
00108
00109 unsigned int ObjectID() const;
00110 unsigned int AttributeID() const;
00111 uint32_t ChallengeSeed() const;
00112 unsigned int RemainingTries() const;
00113 unsigned int SocketResponse() const;
00114 unsigned char SocketSequence() const;
00115 uint8_t CommandResponse() const;
00116 };
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 class DBPacket : public Packet
00134 {
00135 friend class Socket;
00136
00137 private:
00138 Mode::Desktop &m_con;
00139 unsigned int m_last_dbop;
00140
00141 protected:
00142
00143 public:
00144 DBPacket(Mode::Desktop &con, Data &send, Data &receive);
00145 ~DBPacket();
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 void ClearDatabase(unsigned int dbId);
00156 void GetDBDB();
00157 void GetRecordStateTable(unsigned int dbId);
00158 void SetRecordFlags(unsigned int dbId, unsigned int stateTableIndex, uint8_t flag1);
00159 void DeleteRecordByIndex(unsigned int dbId, unsigned int stateTableIndex);
00160 void GetRecordByIndex(unsigned int dbId, unsigned int stateTableIndex);
00161 bool SetRecordByIndex(unsigned int dbId, unsigned int stateTableIndex, Builder &build, const IConverter *ic);
00162 void GetRecords(unsigned int dbId);
00163 bool SetRecord(unsigned int dbId, Builder &build, const IConverter *ic);
00164
00165
00166
00167
00168
00169
00170 unsigned int ReturnCode() const;
00171 unsigned int DBOperation() const;
00172
00173 bool Parse(Parser &parser, const std::string &dbname,
00174 const IConverter *ic);
00175 bool ParseMeta(DBData &data);
00176
00177
00178 };
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 class JLPacket : public Packet
00196 {
00197 friend class Socket;
00198
00199 private:
00200 Data &m_cmd, &m_data;
00201 int m_last_set_size;
00202
00203 public:
00204 JLPacket(Data &cmd, Data &send, Data &receive);
00205 ~JLPacket();
00206
00207
00208
00209
00210 bool HasData() const { return m_last_set_size == 2; }
00211 Data& GetReceive() { return *m_receive; }
00212
00213
00214
00215
00216
00217
00218
00219
00220 int SimpleCmd(uint8_t cmd, uint8_t unknown = 0, uint16_t size = 0);
00221 int SimpleData(const void *data, uint16_t size);
00222 int BigEndianData(uint16_t value);
00223 int BigEndianData(uint32_t value);
00224
00225 int Hello() { return SimpleCmd(SB_COMMAND_JL_HELLO); }
00226 int Goodbye() { return SimpleCmd(SB_COMMAND_JL_GOODBYE); }
00227 int SetUnknown1();
00228 int SetCodFilename(const std::string &filename);
00229 int SetCodSize(off_t size);
00230 int SetTime(time_t when);
00231 int GetScreenshot();
00232 int GetData() { return SimpleCmd(SB_COMMAND_JL_SEND_DATA); }
00233 int DeviceInfo() { return SimpleCmd(SB_COMMAND_JL_DEVICE_INFO); }
00234 int OsMetrics() { return SimpleCmd(SB_COMMAND_JL_OS_METRICS); }
00235 int BootromMetrics() { return SimpleCmd(SB_COMMAND_JL_BOOTROM_METRICS); }
00236 int GetDirectory() { return SimpleCmd(SB_COMMAND_JL_GET_DIRECTORY); }
00237 int GetSubDir(uint16_t id);
00238 int GetDirEntry(uint8_t entry_cmd, uint16_t id);
00239 int Erase(uint16_t cmd, uint16_t id);
00240 int GetEventlog() { return SimpleCmd(SB_COMMAND_JL_GET_LOG); }
00241 int GetEventlogEntry(uint16_t entry_num);
00242 int ClearEventlog() { return SimpleCmd(SB_COMMAND_JL_CLEAR_LOG); }
00243 int SaveModule(uint16_t id);
00244 int PutData(const void *data, uint16_t size);
00245 int WipeApps() { return SimpleCmd(SB_COMMAND_JL_WIPE_APPS); }
00246 int WipeFs() { return SimpleCmd(SB_COMMAND_JL_WIPE_FS); }
00247 int LogStackTraces() { return SimpleCmd(SB_COMMAND_JL_LOG_STRACES); }
00248 int ResetToFactory() { return SimpleCmd(SB_COMMAND_JL_RESET_FACTORY); }
00249
00250
00251
00252 unsigned int Size();
00253 };
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 class JVMPacket : public Packet
00271 {
00272 friend class Socket;
00273
00274 private:
00275 Data &m_cmd;
00276
00277 public:
00278 JVMPacket(Data &cmd, Data &receive);
00279 ~JVMPacket();
00280
00281
00282
00283
00284 Data& GetReceive() { return *m_receive; }
00285
00286
00287
00288
00289
00290
00291
00292
00293 void SimpleCmd(uint8_t cmd);
00294 void ComplexCmd(uint8_t cmd, const void *param, uint16_t size = 0);
00295
00296 void Unknown01();
00297 void Unknown02();
00298 void Unknown03();
00299 void Unknown04();
00300 void Unknown05();
00301 void Unknown06();
00302 void Unknown07();
00303 void Unknown08();
00304 void Unknown09();
00305 void Unknown10();
00306 void Unknown11(uint32_t id);
00307 void Unknown12(uint32_t id);
00308 void Unknown13(uint32_t id);
00309 void Unknown14(uint32_t id);
00310 void Unknown15(uint32_t id);
00311 void GetModulesList(uint32_t id);
00312 void GetThreadsList();
00313 void GetConsoleMessage();
00314 void Go();
00315 void Stop();
00316 void GetStatus();
00317
00318
00319
00320 unsigned int Size();
00321 };
00322
00323
00324 }
00325
00326 #endif
00327