m_javaloader.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
00025 #ifndef __BARRY_M_JAVALOADER_H__
00026 #define __BARRY_M_JAVALOADER_H__
00027
00028 #include "dll.h"
00029 #include "m_mode_base.h"
00030 #include "socket.h"
00031 #include "record.h"
00032 #include "data.h"
00033
00034 namespace Barry {
00035
00036
00037 class Parser;
00038 class Builder;
00039 class Controller;
00040 class CodFileBuilder;
00041
00042 class JLDirectoryEntry;
00043
00044 class JLEventlogEntry;
00045
00046 class BXEXPORT JLDirectory : public std::vector<JLDirectoryEntry>
00047 {
00048 public:
00049 typedef std::vector<JLDirectoryEntry> BaseType;
00050 typedef BaseType::iterator BaseIterator;
00051 typedef std::vector<uint16_t> TableType;
00052 typedef TableType::iterator TableIterator;
00053
00054 private:
00055 TableType m_idTable;
00056
00057 int m_level;
00058
00059 public:
00060 JLDirectory(int level = 0);
00061 ~JLDirectory();
00062
00063 int Level() const { return m_level; }
00064 TableIterator TableBegin() { return m_idTable.begin(); }
00065 TableIterator TableEnd() { return m_idTable.end(); }
00066
00067 void ParseTable(const Data &table_packet);
00068
00069 void Dump(std::ostream &os) const;
00070 };
00071 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const JLDirectory &d) {
00072 d.Dump(os);
00073 return os;
00074 }
00075
00076 class BXEXPORT JLDirectoryEntry
00077 {
00078 private:
00079 int m_level;
00080
00081 public:
00082 uint16_t Id;
00083 std::string Name;
00084 std::string Version;
00085 uint32_t CodSize;
00086 time_t Timestamp;
00087
00088 JLDirectory SubDir;
00089
00090 public:
00091 explicit JLDirectoryEntry(int level);
00092
00093 void Parse(uint16_t id, const Data &entry_packet);
00094
00095 void Dump(std::ostream &os) const;
00096 };
00097 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const JLDirectoryEntry &e) {
00098 e.Dump(os);
00099 return os;
00100 }
00101
00102
00103 class BXEXPORT JLScreenInfo {
00104 public:
00105 uint16_t width;
00106 uint16_t height;
00107
00108 public:
00109 JLScreenInfo();
00110 ~JLScreenInfo();
00111 };
00112
00113
00114 class BXEXPORT JLEventlog : public std::vector<JLEventlogEntry>
00115 {
00116 public:
00117 void Dump(std::ostream &os) const;
00118 };
00119 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const JLEventlog &log) {
00120 log.Dump(os);
00121 return os;
00122 }
00123
00124
00125 class BXEXPORT JLEventlogEntry
00126 {
00127 public:
00128 typedef enum {
00129 ALWAYS_LOG,
00130 SEVERE_ERROR,
00131 ERROR,
00132 WARNING,
00133 INFORMATION,
00134 DEBUG_INFO
00135 } Severity_t;
00136
00137 typedef enum {
00138 NUMBER = 1,
00139 STRING,
00140 EXCEPTION
00141 } ViewerType_t;
00142
00143 std::string Guid;
00144 uint64_t MSTimestamp;
00145 Severity_t Severity;
00146 ViewerType_t Type;
00147 std::string App;
00148 std::string Data;
00149
00150 protected:
00151 static Severity_t SeverityProto2Rec(unsigned int s);
00152 static unsigned int SeverityRec2Proto(Severity_t s);
00153
00154 static ViewerType_t ViewerTypeProto2Rec(unsigned int v);
00155 static unsigned int ViewerTypeRec2Proto(ViewerType_t v);
00156
00157 public:
00158 void Parse(uint16_t size, const char* str);
00159
00160 std::string GetFormattedTimestamp() const;
00161
00162 void Dump(std::ostream &os) const;
00163 };
00164
00165
00166 class BXEXPORT JLDeviceInfo
00167 {
00168 public:
00169 struct VersionQuad {
00170 VersionQuad() { }
00171 VersionQuad(uint32_t v) {
00172 Major = (v & 0xff000000) >> 24;
00173 Minor = (v & 0xff0000) >> 16;
00174 SubMinor = (v & 0xff00) >> 8;
00175 Build = (v & 0xff);
00176 }
00177
00178 unsigned int Major;
00179 unsigned int Minor;
00180 unsigned int SubMinor;
00181 unsigned int Build;
00182 };
00183
00184 public:
00185 uint32_t HardwareId;
00186 uint32_t Pin;
00187 VersionQuad OsVersion;
00188 VersionQuad VmVersion;
00189 uint32_t RadioId;
00190 uint32_t VendorId;
00191 uint32_t ActiveWafs;
00192 Data OsMetrics;
00193 Data BootromMetrics;
00194
00195 public:
00196 void Dump(std::ostream &os) const;
00197 };
00198 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const JLDeviceInfo &info) {
00199 info.Dump(os);
00200 return os;
00201 }
00202
00203
00204 namespace Mode {
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 class BXEXPORT JavaLoader : public Mode
00220 {
00221 private:
00222 bool m_StreamStarted;
00223
00224 protected:
00225 void GetDirectoryEntries(JLPacket &packet, uint8_t entry_cmd,
00226 JLDirectory &dir, bool include_subdirs);
00227 void GetDir(JLPacket &packet, uint8_t entry_cmd, JLDirectory &dir,
00228 bool include_subdirs);
00229 void ThrowJLError(const std::string &msg, uint8_t cmd);
00230 void DoErase(uint8_t cmd, const std::string &cod_name);
00231 void SaveData(JLPacket &packet, uint16_t, CodFileBuilder &builder,
00232 std::ostream &output);
00233
00234
00235
00236
00237 virtual void OnOpen();
00238
00239 public:
00240 JavaLoader(Controller &con);
00241 ~JavaLoader();
00242
00243
00244
00245 void StartStream();
00246 bool StopStream();
00247
00248
00249 void SendStream(std::istream &input, size_t module_size);
00250 void LoadApp(std::istream &input);
00251 void SetTime(time_t when);
00252 void GetDirectory(JLDirectory &dir, bool include_subdirs);
00253 void GetScreenshot(JLScreenInfo &info, Data &image);
00254 void Erase(const std::string &cod_name);
00255 void ForceErase(const std::string &cod_name);
00256 void GetEventlog(JLEventlog &log);
00257 void ClearEventlog();
00258 void Save(const std::string &cod_name, std::ostream &output);
00259 void DeviceInfo(JLDeviceInfo &info);
00260 void Wipe(bool apps = true, bool fs = true);
00261 void LogStackTraces();
00262 void ResetToFactory();
00263 };
00264
00265 }}
00266
00267 #endif
00268