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