diff options
| author | Root THC | 2026-02-24 12:42:47 +0000 |
|---|---|---|
| committer | Root THC | 2026-02-24 12:42:47 +0000 |
| commit | c9cbeced5b3f2bdd7407e29c0811e65954132540 (patch) | |
| tree | aefc355416b561111819de159ccbd86c3004cf88 /other/Kermit/include | |
| parent | 073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff) | |
initial
Diffstat (limited to 'other/Kermit/include')
| -rw-r--r-- | other/Kermit/include/DevMemPatt.hpp | 69 | ||||
| -rw-r--r-- | other/Kermit/include/Kermit | 16 | ||||
| -rw-r--r-- | other/Kermit/include/Makefile | 11 | ||||
| -rw-r--r-- | other/Kermit/include/Patch.hpp | 204 | ||||
| -rw-r--r-- | other/Kermit/include/SymbolFingp.hpp | 75 | ||||
| -rw-r--r-- | other/Kermit/include/SymbolTable.hpp | 113 | ||||
| -rw-r--r-- | other/Kermit/include/SystemMap.hpp | 61 | ||||
| -rw-r--r-- | other/Kermit/include/addresses.h | 30 | ||||
| -rw-r--r-- | other/Kermit/include/arch.hpp | 32 | ||||
| -rw-r--r-- | other/Kermit/include/itos16.hpp | 9 | ||||
| -rw-r--r-- | other/Kermit/include/name2add.h | 16 | ||||
| -rw-r--r-- | other/Kermit/include/pseudo_link.h | 58 | ||||
| -rw-r--r-- | other/Kermit/include/rwKernel.hpp | 94 | ||||
| -rw-r--r-- | other/Kermit/include/stoi16.hpp | 13 |
14 files changed, 801 insertions, 0 deletions
diff --git a/other/Kermit/include/DevMemPatt.hpp b/other/Kermit/include/DevMemPatt.hpp new file mode 100644 index 0000000..aa559e0 --- /dev/null +++ b/other/Kermit/include/DevMemPatt.hpp | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | /* | ||
| 2 | * DevMemPatt.hpp: | ||
| 3 | * search the kernel... | ||
| 4 | * written by palmers / teso | ||
| 5 | * | ||
| 6 | * ahh, btw. fuck. now you can grep for it :) | ||
| 7 | */ | ||
| 8 | #ifndef __DEVMEMPATT_C | ||
| 9 | #define __DEVMEMPATT_C | ||
| 10 | |||
| 11 | #define READ_BUFF_SIZE 4096 | ||
| 12 | |||
| 13 | #include <string> | ||
| 14 | #include <rwKernel.hpp> | ||
| 15 | #include <SymbolFingp.hpp> | ||
| 16 | |||
| 17 | |||
| 18 | /** | ||
| 19 | * Searching the kernel. This class helps you by seaching for | ||
| 20 | * patterns in kernel memory. Each function has a, more or less, unique structure. | ||
| 21 | * There is nothing to wonder about this: each function is for solving a different | ||
| 22 | * task. If the function, or parts of it, are know it can be found without any further | ||
| 23 | * knowledge about it. | ||
| 24 | */ | ||
| 25 | class DevMemPatt | ||
| 26 | { | ||
| 27 | private: | ||
| 28 | rwKernel *rw; | ||
| 29 | int compare_data_snippet (unsigned char *, struct sfp *); | ||
| 30 | |||
| 31 | public: | ||
| 32 | /** | ||
| 33 | * This constructor will initialize the object with a reference to a rwKernel object. | ||
| 34 | * @see rwKernel | ||
| 35 | */ | ||
| 36 | DevMemPatt (rwKernel *); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Another constructor. This one will generate a new rwKernel object. | ||
| 40 | */ | ||
| 41 | DevMemPatt (); | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Destruct DevMemPatt object. Local rwKernel object will not be deleted. | ||
| 45 | */ | ||
| 46 | ~DevMemPatt (); | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Find a data string in kernel memory. | ||
| 50 | * @param start start address of the search. | ||
| 51 | * @param end the search will go upto this address in kernel memory. | ||
| 52 | * @param length the length of the data. | ||
| 53 | * @param data the data searched for. | ||
| 54 | * @return the address of the first byte of the searched data or | ||
| 55 | * zero if it was not found. | ||
| 56 | */ | ||
| 57 | unsigned int find_patt (unsigned int start, unsigned int end, \ | ||
| 58 | unsigned short len, unsigned char *data); | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Find a data pattern in kernel memory. | ||
| 62 | * @param a search a data pattern defined by a. | ||
| 63 | * @return the address of the first byte of the searched pattern or | ||
| 64 | * zero if it was not found. | ||
| 65 | * @see SymbolFingp | ||
| 66 | */ | ||
| 67 | unsigned int find_patt (struct sfp *a); | ||
| 68 | }; | ||
| 69 | #endif /* __DEVMEMPATT_C */ | ||
diff --git a/other/Kermit/include/Kermit b/other/Kermit/include/Kermit new file mode 100644 index 0000000..bcdb720 --- /dev/null +++ b/other/Kermit/include/Kermit | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | /* | ||
| 2 | * common header for libKermit | ||
| 3 | * written palmers / teso | ||
| 4 | */ | ||
| 5 | #ifndef __Kermit__ | ||
| 6 | #define __Kermit__ | ||
| 7 | #include <DevMemPatt.hpp> | ||
| 8 | #include <Patch.hpp> | ||
| 9 | #include <SymbolFingp.hpp> | ||
| 10 | #include <SymbolTable.hpp> | ||
| 11 | #include <SystemMap.hpp> | ||
| 12 | #include <name2add.h> | ||
| 13 | #include <rwKernel.hpp> | ||
| 14 | #include <stoi16.hpp> | ||
| 15 | #include <itos16.hpp> | ||
| 16 | #endif /* __Kermit__ */ | ||
diff --git a/other/Kermit/include/Makefile b/other/Kermit/include/Makefile new file mode 100644 index 0000000..97cbe78 --- /dev/null +++ b/other/Kermit/include/Makefile | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | # written by palmers / teso | ||
| 2 | include ../MakeOpt | ||
| 3 | |||
| 4 | all: | ||
| 5 | $(UTIL_DIR)/gen_names_from_proto | ||
| 6 | $(UTIL_DIR)/gen_defines | ||
| 7 | $(UTIL_DIR)/gen_name2add | ||
| 8 | |||
| 9 | clean: | ||
| 10 | rm -rf addresses.h | ||
| 11 | |||
diff --git a/other/Kermit/include/Patch.hpp b/other/Kermit/include/Patch.hpp new file mode 100644 index 0000000..a784f9c --- /dev/null +++ b/other/Kermit/include/Patch.hpp | |||
| @@ -0,0 +1,204 @@ | |||
| 1 | /* | ||
| 2 | * Patch.hpp: | ||
| 3 | * representation of a kernel patch. | ||
| 4 | * written by palmers / teso | ||
| 5 | */ | ||
| 6 | #ifndef __PATCH_C | ||
| 7 | #define __PATCH_C | ||
| 8 | |||
| 9 | #include <rwKernel.hpp> | ||
| 10 | #include <SymbolTable.hpp> | ||
| 11 | #include <SystemMap.hpp> | ||
| 12 | #include <stoi16.hpp> | ||
| 13 | #include <itos16.hpp> | ||
| 14 | #include <utility> | ||
| 15 | #include <functional> | ||
| 16 | #include <algorithm> | ||
| 17 | #include <list> | ||
| 18 | #include <fstream> | ||
| 19 | #include <string> | ||
| 20 | #include <name2add.h> | ||
| 21 | |||
| 22 | |||
| 23 | typedef pair<unsigned int, unsigned int> Addr2Addr; | ||
| 24 | typedef list<Addr2Addr *> Addr2AddrList; | ||
| 25 | |||
| 26 | Addr2AddrList *genReplaceValMap (SymbolTable *st); | ||
| 27 | void genDummyValMap (); | ||
| 28 | extern SystemMap DummyValMap; | ||
| 29 | |||
| 30 | |||
| 31 | #define CLEAN 1 | ||
| 32 | #define LINKED 2 | ||
| 33 | #define APPLIED 4 | ||
| 34 | #define LFAILED 8 | ||
| 35 | #define AFAILED 16 | ||
| 36 | |||
| 37 | |||
| 38 | /** | ||
| 39 | * Representation of a kernel patch. A Patch is a amount of data, which is to be written | ||
| 40 | * to a given address. Patching means modification of kernel memory. Therefore, the data, | ||
| 41 | * which will be overwritten, is saved (before writting). | ||
| 42 | * Additionally the status of the Patch is tracked. Thus, you are able to undo, reapply | ||
| 43 | * and debug patches. The states a Patch must be in are: | ||
| 44 | * CLEAN (the patch was never touched) | ||
| 45 | * LINKED (it was linked without an error) | ||
| 46 | * APPLIED (it was applied without an error) | ||
| 47 | * LFAILED (linking failed) | ||
| 48 | * AFAILED (applying failed) | ||
| 49 | */ | ||
| 50 | class Patch | ||
| 51 | { | ||
| 52 | private: | ||
| 53 | int state; | ||
| 54 | unsigned short len; | ||
| 55 | unsigned char *back_data, *data, *overwr; | ||
| 56 | unsigned int address; | ||
| 57 | rwKernel *local_rw; | ||
| 58 | |||
| 59 | bool initObjects (unsigned char *, unsigned short, unsigned int, rwKernel *); | ||
| 60 | string state2string (); | ||
| 61 | void string2state (string); | ||
| 62 | string data2string (unsigned char *); | ||
| 63 | void string2data (string, unsigned char *); | ||
| 64 | void parse (string); | ||
| 65 | |||
| 66 | public: | ||
| 67 | /** | ||
| 68 | * Create, but init nothing. | ||
| 69 | */ | ||
| 70 | Patch (); | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Create a patch with supplied data. | ||
| 74 | * @param data patch data. | ||
| 75 | * @param len length of patch data. | ||
| 76 | * @param addr memory address to where the data shall be written. | ||
| 77 | */ | ||
| 78 | Patch (unsigned char *data, unsigned short len, unsigned int addr); | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Create a patch with supplied data. This constructor, compared with the above, | ||
| 82 | * will set a local reference to a rwKernel object. | ||
| 83 | * @param x pointer to a rwKernel object. | ||
| 84 | */ | ||
| 85 | Patch (unsigned char *data, unsigned short len, unsigned int addr, rwKernel *x); | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Initialize the object from a string as created by dump (). | ||
| 89 | * @see dump() | ||
| 90 | */ | ||
| 91 | Patch (string); | ||
| 92 | |||
| 93 | /** | ||
| 94 | * Initialize the object from a string as created by dump (). | ||
| 95 | * @see dump() | ||
| 96 | */ | ||
| 97 | Patch (string, rwKernel *); | ||
| 98 | |||
| 99 | /** | ||
| 100 | * Foo. | ||
| 101 | */ | ||
| 102 | ~Patch (); | ||
| 103 | |||
| 104 | |||
| 105 | /** | ||
| 106 | * init object from a string. | ||
| 107 | */ | ||
| 108 | void initFromString (string); | ||
| 109 | |||
| 110 | /** | ||
| 111 | * Foo. | ||
| 112 | */ | ||
| 113 | string getPatchAsString (); | ||
| 114 | |||
| 115 | /** | ||
| 116 | * tells you if the patch data was modified. (e.g. by linking). | ||
| 117 | * @return true if backup data and data differ. | ||
| 118 | */ | ||
| 119 | bool wasChanged (); | ||
| 120 | |||
| 121 | /** | ||
| 122 | * @return true if the linking returned no error messages. | ||
| 123 | */ | ||
| 124 | bool isLinked (); | ||
| 125 | |||
| 126 | /** | ||
| 127 | * @return true if the applying was successful. | ||
| 128 | */ | ||
| 129 | bool isApplied (); | ||
| 130 | |||
| 131 | /** | ||
| 132 | * @return true if linking or applying failed. | ||
| 133 | */ | ||
| 134 | bool isFailed (); | ||
| 135 | |||
| 136 | /** | ||
| 137 | * @return true if the patch was not touched. | ||
| 138 | */ | ||
| 139 | bool isClean (); | ||
| 140 | |||
| 141 | /** | ||
| 142 | * @return the status. | ||
| 143 | */ | ||
| 144 | int getState (); | ||
| 145 | |||
| 146 | /** | ||
| 147 | * Restore patch data. Might be helpful if linking failed. | ||
| 148 | */ | ||
| 149 | void restore (); | ||
| 150 | |||
| 151 | /** | ||
| 152 | * Remove applied Patch (Undo changes done to memory). | ||
| 153 | */ | ||
| 154 | bool remove (); | ||
| 155 | |||
| 156 | /** | ||
| 157 | * Remove applied Patch (Undo changes done to memory). | ||
| 158 | */ | ||
| 159 | bool remove (rwKernel *); | ||
| 160 | |||
| 161 | /** | ||
| 162 | * Get a pointer to patch data. | ||
| 163 | */ | ||
| 164 | unsigned char *getData (); | ||
| 165 | |||
| 166 | /** | ||
| 167 | * Apply the patch to the kernel. Effectivly write the patch data to the supplied address. | ||
| 168 | * The method allows you to supply a a reference to a rwKernel object. you can supply on | ||
| 169 | * construction of the patch. However, there might be none at that time. | ||
| 170 | */ | ||
| 171 | void apply (rwKernel *); | ||
| 172 | |||
| 173 | /** | ||
| 174 | * Apply the patch to the kernel. Use this apply method if you supplied a reference to a | ||
| 175 | * rwKernel object at creation time. | ||
| 176 | */ | ||
| 177 | void apply (); | ||
| 178 | |||
| 179 | /** | ||
| 180 | * link the patch with the kernel. Replace all placeholders with real addresses. | ||
| 181 | */ | ||
| 182 | void link (Addr2AddrList *); | ||
| 183 | |||
| 184 | /** | ||
| 185 | * Dump patch information into a file. This will produce human readable output. It | ||
| 186 | * can be used e.g. for restoring and debugging. Because the output is line based | ||
| 187 | * and can be used to initialize a Patch object you are effecitvely able to reproduce | ||
| 188 | * patching sessions. | ||
| 189 | * @see Patch(string) | ||
| 190 | * @param file filename. | ||
| 191 | */ | ||
| 192 | void dump (string file); | ||
| 193 | |||
| 194 | /** | ||
| 195 | * Foo. | ||
| 196 | */ | ||
| 197 | friend istream& operator>> (istream&, Patch&); | ||
| 198 | |||
| 199 | /** | ||
| 200 | * Foo. | ||
| 201 | */ | ||
| 202 | friend ostream& operator<< (ostream&, Patch&); | ||
| 203 | }; | ||
| 204 | #endif /* __PATCH_C */ | ||
diff --git a/other/Kermit/include/SymbolFingp.hpp b/other/Kermit/include/SymbolFingp.hpp new file mode 100644 index 0000000..248ed13 --- /dev/null +++ b/other/Kermit/include/SymbolFingp.hpp | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | /* | ||
| 2 | * SymbolFingp.hpp: | ||
| 3 | * some fingerprint | ||
| 4 | * written by palmers / teso | ||
| 5 | */ | ||
| 6 | #ifndef __SymbolFingp_H | ||
| 7 | #define __SymbolFingp_H | ||
| 8 | #include <map> | ||
| 9 | #include <fstream> | ||
| 10 | #include <string> | ||
| 11 | #include <iostream> | ||
| 12 | |||
| 13 | /* default file to open */ | ||
| 14 | #define DEFAULT_FILE "SymbolFind.conf" | ||
| 15 | |||
| 16 | /* defines used for the type field in struct cell */ | ||
| 17 | #define WWCARD 1 | ||
| 18 | #define NOCARD 0 | ||
| 19 | |||
| 20 | |||
| 21 | struct cell | ||
| 22 | { | ||
| 23 | unsigned char type; | ||
| 24 | unsigned char val; | ||
| 25 | }; | ||
| 26 | |||
| 27 | |||
| 28 | struct sfp | ||
| 29 | { | ||
| 30 | char *name; | ||
| 31 | unsigned long start_addr; | ||
| 32 | unsigned long stop_addr; | ||
| 33 | long offset; | ||
| 34 | unsigned short length; | ||
| 35 | struct cell *fp; | ||
| 36 | }; | ||
| 37 | |||
| 38 | |||
| 39 | /** | ||
| 40 | * class to hold fingerprints of a function (a [kernel-]symbol). | ||
| 41 | */ | ||
| 42 | class SymbolFingp | ||
| 43 | { | ||
| 44 | private: | ||
| 45 | |||
| 46 | typedef map<string, struct sfp> FingerThing; | ||
| 47 | FingerThing Fingers; | ||
| 48 | |||
| 49 | void readFingers (ifstream); | ||
| 50 | bool addFinger (struct sfp *); | ||
| 51 | |||
| 52 | public: | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Reads configuration from default file. | ||
| 56 | */ | ||
| 57 | SymbolFingp (); | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Reads configuration from specified file. | ||
| 61 | */ | ||
| 62 | SymbolFingp (string); | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Foo. | ||
| 66 | */ | ||
| 67 | ~SymbolFingp (); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * Return the Fingerprint matching the supplied name. | ||
| 71 | */ | ||
| 72 | struct sfp *getFinger (string); | ||
| 73 | }; | ||
| 74 | |||
| 75 | #endif /* __SymbolFingp_H */ | ||
diff --git a/other/Kermit/include/SymbolTable.hpp b/other/Kermit/include/SymbolTable.hpp new file mode 100644 index 0000000..b0f8aa3 --- /dev/null +++ b/other/Kermit/include/SymbolTable.hpp | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | /* | ||
| 2 | * SymbolTable.hpp: | ||
| 3 | * a container for "on-demand" symbol address fetching | ||
| 4 | * written by palmers / teso | ||
| 5 | */ | ||
| 6 | #ifndef __SYMBOL_TABLE_C | ||
| 7 | #define __SYMBOL_TABLE_C | ||
| 8 | |||
| 9 | #include <SymbolFingp.hpp> | ||
| 10 | #include <SystemMap.hpp> | ||
| 11 | #include <DevMemPatt.hpp> | ||
| 12 | #include <rwKernel.hpp> | ||
| 13 | #include <list> | ||
| 14 | #include <string> | ||
| 15 | #include <iostream> | ||
| 16 | #include <fstream> | ||
| 17 | #include <algorithm> | ||
| 18 | #include <iterator> | ||
| 19 | |||
| 20 | #define DEFAULTDUMP "SymbolTableDump" | ||
| 21 | #define DEFAULTSYSTEMMAP "System.map" | ||
| 22 | |||
| 23 | typedef struct | ||
| 24 | { | ||
| 25 | string Name; | ||
| 26 | unsigned int Address; | ||
| 27 | } zzSym; | ||
| 28 | typedef list<zzSym *> zzSymList; | ||
| 29 | |||
| 30 | |||
| 31 | /** | ||
| 32 | * A container class for "on-demand" symbol address fetching. | ||
| 33 | */ | ||
| 34 | class SymbolTable | ||
| 35 | { | ||
| 36 | private: | ||
| 37 | SymbolFingp *fing; | ||
| 38 | DevMemPatt *patt; | ||
| 39 | SystemMap exported; | ||
| 40 | SystemMap mapp; | ||
| 41 | SystemMap rest; | ||
| 42 | string dump_file; | ||
| 43 | |||
| 44 | bool createObjects (rwKernel *); | ||
| 45 | bool loadFiles (string, string); | ||
| 46 | |||
| 47 | public: | ||
| 48 | /** | ||
| 49 | * List of name, address pairs. | ||
| 50 | */ | ||
| 51 | zzSymList symList; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Construct a SymbolTable object and load configuration from default files. | ||
| 55 | */ | ||
| 56 | SymbolTable (); | ||
| 57 | |||
| 58 | /** | ||
| 59 | * Construct a SymbolTable object and load configuration from defined files. | ||
| 60 | * @param res file name of restore file. | ||
| 61 | * @param sys System.map file to load. | ||
| 62 | */ | ||
| 63 | SymbolTable (string res, string sys); | ||
| 64 | |||
| 65 | /** | ||
| 66 | * Construct a SymbolTable object and use the referenced rwKernel object in all | ||
| 67 | * member attributes and methods. | ||
| 68 | */ | ||
| 69 | SymbolTable (rwKernel *); | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Foo. | ||
| 73 | */ | ||
| 74 | ~SymbolTable (); | ||
| 75 | |||
| 76 | /** | ||
| 77 | * Define the file written to on saveCache (). | ||
| 78 | * @see saveCache() | ||
| 79 | */ | ||
| 80 | void setSaveFile (string); | ||
| 81 | |||
| 82 | /** | ||
| 83 | * get the address of a known symbol. | ||
| 84 | * @return If the symbol is unknow zero is returned. | ||
| 85 | * (hey, would you call 0x00000000?). Else, the address | ||
| 86 | * of the symbol. | ||
| 87 | */ | ||
| 88 | unsigned int getSymbol (string); | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Find a symbol. This will try all available methods to | ||
| 92 | * find a symbol and cache the address, name pair (zero | ||
| 93 | * if search was not successfull). | ||
| 94 | * @return true on success. | ||
| 95 | */ | ||
| 96 | bool findSymbol (string); | ||
| 97 | |||
| 98 | /** | ||
| 99 | * add a symbol, address pair to the cache. | ||
| 100 | */ | ||
| 101 | void addSymbolToCache (string, unsigned int); | ||
| 102 | |||
| 103 | /** | ||
| 104 | * flush the address cache. | ||
| 105 | */ | ||
| 106 | void clearCache (); | ||
| 107 | |||
| 108 | /** | ||
| 109 | * save the cache to a file (human readable, System.map style). | ||
| 110 | */ | ||
| 111 | bool saveCache (); | ||
| 112 | }; | ||
| 113 | #endif /* __SYMBOL_TABLE_C */ | ||
diff --git a/other/Kermit/include/SystemMap.hpp b/other/Kermit/include/SystemMap.hpp new file mode 100644 index 0000000..ff59094 --- /dev/null +++ b/other/Kermit/include/SystemMap.hpp | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * SystemMap.hpp: | ||
| 3 | * representation if a system map file (and alike). | ||
| 4 | * written by palmers / teso | ||
| 5 | */ | ||
| 6 | #ifndef SYSTEM_MAP_C | ||
| 7 | #define SYSTEM_MAP_C | ||
| 8 | |||
| 9 | #include <map> | ||
| 10 | #include <string> | ||
| 11 | #include <fstream> | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Representation of a System.map file. It maps names to addresses. | ||
| 15 | */ | ||
| 16 | class SystemMap | ||
| 17 | { | ||
| 18 | private: | ||
| 19 | typedef map<string, unsigned int> blamap; | ||
| 20 | typedef blamap::value_type bla_val; | ||
| 21 | |||
| 22 | blamap add_map; | ||
| 23 | |||
| 24 | public: | ||
| 25 | /** | ||
| 26 | * Create a SystemMap object and read symbol names and addresses from a file. | ||
| 27 | */ | ||
| 28 | SystemMap (string file); | ||
| 29 | |||
| 30 | /** | ||
| 31 | * Create a SystemMap object and leave it empty. | ||
| 32 | */ | ||
| 33 | SystemMap (); | ||
| 34 | |||
| 35 | /** | ||
| 36 | * Foo. | ||
| 37 | */ | ||
| 38 | ~SystemMap (); | ||
| 39 | |||
| 40 | /** | ||
| 41 | * Check if a symbol (by name) is part of the object. | ||
| 42 | * @return true if the questioned symbol is part of the object (else false). | ||
| 43 | */ | ||
| 44 | bool contains (string); | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Add a name, address pair to the object. | ||
| 48 | * @param name Symbolname. If a symbol with this name already exists | ||
| 49 | * it will not be added. | ||
| 50 | * @param address the address of the symbol. | ||
| 51 | */ | ||
| 52 | void add (string name, unsigned int address); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Random access operator for accessing elements in the form x = <name>[<symbol>]. | ||
| 56 | * @param name of a symbol. | ||
| 57 | * @return the address of symbol name. | ||
| 58 | */ | ||
| 59 | unsigned int operator[] (string name); | ||
| 60 | }; | ||
| 61 | #endif /* SYSTEM_MAP_C */ | ||
diff --git a/other/Kermit/include/addresses.h b/other/Kermit/include/addresses.h new file mode 100644 index 0000000..8f9dee6 --- /dev/null +++ b/other/Kermit/include/addresses.h | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | /* | ||
| 2 | * addresses.h: | ||
| 3 | * this file was automaticly generated by gen_defines | ||
| 4 | */ | ||
| 5 | #define SYS_FORK_ADD 0xf8f8f8f8 | ||
| 6 | #define SYS_READ_ADD 0xf8f8f7f7 | ||
| 7 | #define SYS_WRITE_ADD 0xf8f8f6f6 | ||
| 8 | #define SYS_EXIT_ADD 0xf8f8f5f5 | ||
| 9 | #define SYS_SETUID_ADD 0xf8f8f4f4 | ||
| 10 | #define SYS_SETGID_ADD 0xf8f8f3f3 | ||
| 11 | #define SYS_GETUID_ADD 0xf8f8f2f2 | ||
| 12 | #define SYS_GETGID_ADD 0xf8f8f1f1 | ||
| 13 | #define SYS_OPEN_ADD 0xf8f8f0f0 | ||
| 14 | #define SYS_CLOSE_ADD 0xf8f8efef | ||
| 15 | #define KMALLOC_ADD 0xf8f8eeee | ||
| 16 | /* | ||
| 17 | * addresses.h: | ||
| 18 | * this file was automaticly generated by gen_defines | ||
| 19 | */ | ||
| 20 | #define SYS_FORK_ADD 0xf8f8f8f8 | ||
| 21 | #define SYS_READ_ADD 0xf8f8f7f7 | ||
| 22 | #define SYS_WRITE_ADD 0xf8f8f6f6 | ||
| 23 | #define SYS_EXIT_ADD 0xf8f8f5f5 | ||
| 24 | #define SYS_SETUID_ADD 0xf8f8f4f4 | ||
| 25 | #define SYS_SETGID_ADD 0xf8f8f3f3 | ||
| 26 | #define SYS_GETUID_ADD 0xf8f8f2f2 | ||
| 27 | #define SYS_GETGID_ADD 0xf8f8f1f1 | ||
| 28 | #define SYS_OPEN_ADD 0xf8f8f0f0 | ||
| 29 | #define SYS_CLOSE_ADD 0xf8f8efef | ||
| 30 | #define KMALLOC_ADD 0xf8f8eeee | ||
diff --git a/other/Kermit/include/arch.hpp b/other/Kermit/include/arch.hpp new file mode 100644 index 0000000..3ac1a90 --- /dev/null +++ b/other/Kermit/include/arch.hpp | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* | ||
| 2 | * maybe used for porting ... | ||
| 3 | * (ignore this file.) | ||
| 4 | */ | ||
| 5 | #ifdef __ALWAYS_UNDEFINED | ||
| 6 | template <class Ad_t, bool BE, unsigned short A> | ||
| 7 | class Architecture | ||
| 8 | { | ||
| 9 | private: | ||
| 10 | le_replace (unsigned char *, AddressType); | ||
| 11 | be_replace (unsigned char *, AddressType); | ||
| 12 | |||
| 13 | public: | ||
| 14 | typedef Ad_t AddressType; /* type capable for holding a memory address as integer */ | ||
| 15 | bool BigEndian; /* true if machine uses big endian */ | ||
| 16 | unsigned short Align; /* data alignment - needed? (sanity checks) */ | ||
| 17 | |||
| 18 | Architecture () | ||
| 19 | { | ||
| 20 | BigEndian = BE; | ||
| 21 | Align = A; | ||
| 22 | } | ||
| 23 | |||
| 24 | replaceAddress (unsigned char *, AddressType); | ||
| 25 | }; | ||
| 26 | |||
| 27 | |||
| 28 | Architecture<unsigned int, false, 4> x86; | ||
| 29 | // ... | ||
| 30 | |||
| 31 | #define x86 this_arch; | ||
| 32 | #endif | ||
diff --git a/other/Kermit/include/itos16.hpp b/other/Kermit/include/itos16.hpp new file mode 100644 index 0000000..21ce390 --- /dev/null +++ b/other/Kermit/include/itos16.hpp | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | /* | ||
| 2 | * itos16.hpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #ifndef __ITOS16_C | ||
| 6 | #define __ITOS16_C | ||
| 7 | #include <string> | ||
| 8 | string itos16 (unsigned int); | ||
| 9 | #endif /* __ITOS16_C */ | ||
diff --git a/other/Kermit/include/name2add.h b/other/Kermit/include/name2add.h new file mode 100644 index 0000000..ad10c88 --- /dev/null +++ b/other/Kermit/include/name2add.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | /* | ||
| 2 | * name2add.h: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #ifndef __NAME2ADD | ||
| 6 | #define __NAME2ADD | ||
| 7 | |||
| 8 | typedef struct | ||
| 9 | { | ||
| 10 | char *name; | ||
| 11 | unsigned int add; | ||
| 12 | } __name2add; | ||
| 13 | |||
| 14 | extern __name2add __n2a[]; | ||
| 15 | |||
| 16 | #endif /* __NAME2ADD*/ | ||
diff --git a/other/Kermit/include/pseudo_link.h b/other/Kermit/include/pseudo_link.h new file mode 100644 index 0000000..44a139c --- /dev/null +++ b/other/Kermit/include/pseudo_link.h | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | /* | ||
| 2 | * pseudo_link.h: | ||
| 3 | * file for pseudolinking. | ||
| 4 | * put all your pointer to function prototypes here. | ||
| 5 | * written by palmers / teso | ||
| 6 | */ | ||
| 7 | #include <glob.h> | ||
| 8 | #include <linux/types.h> | ||
| 9 | #include <sys/stat.h> | ||
| 10 | #include <sys/types.h> | ||
| 11 | #include <asm/ptrace.h> | ||
| 12 | #include <addresses.h> | ||
| 13 | |||
| 14 | #define USE_SYS_FORK \ | ||
| 15 | int (*sys_fork)(struct pt_regs) = \ | ||
| 16 | (int (*)(struct pt_regs))SYS_FORK_ADD; /* arch dependant! */ | ||
| 17 | |||
| 18 | #define USE_SYS_READ \ | ||
| 19 | size_t (*sys_read)(unsigned int, char *, size_t) = \ | ||
| 20 | (size_t (*)(unsigned int, char *, size_t))SYS_READ_ADD; | ||
| 21 | |||
| 22 | #define USE_SYS_WRITE \ | ||
| 23 | size_t (*sys_write)(unsigned int, char *, size_t) = \ | ||
| 24 | (size_t (*)(unsigned int, char *, size_t))SYS_WRITE_ADD; | ||
| 25 | |||
| 26 | #define USE_SYS_EXIT \ | ||
| 27 | int (*sys_exit)(int) = \ | ||
| 28 | (int (*)(int))SYS_EXIT_ADD; | ||
| 29 | |||
| 30 | #define USE_SYS_SETUID \ | ||
| 31 | int (*sys_setuid)(uid_t) = \ | ||
| 32 | (int (*)(uid_t))SYS_SETUID_ADD; | ||
| 33 | |||
| 34 | #define USE_SYS_SETGID \ | ||
| 35 | int (*sys_setgid)(gid_t) = \ | ||
| 36 | (int (*)(gid_t))SYS_SETGID_ADD; | ||
| 37 | |||
| 38 | #define USE_SYS_GETUID \ | ||
| 39 | int (*sys_getuid)(void) = \ | ||
| 40 | (int (*)(void))SYS_GETUID_ADD; | ||
| 41 | |||
| 42 | #define USE_SYS_GETGID \ | ||
| 43 | int (*sys_getgid)(void) = \ | ||
| 44 | (int (*)(void))SYS_GETGID_ADD; | ||
| 45 | |||
| 46 | #define USE_SYS_OPEN \ | ||
| 47 | int (*sys_open)(const char *, int, int) = \ | ||
| 48 | (int (*)(const char *, int, int))SYS_OPEN_ADD; | ||
| 49 | |||
| 50 | #define USE_SYS_CLOSE \ | ||
| 51 | int (*sys_close)(int) = \ | ||
| 52 | (int (*)(int))SYS_CLOSE_ADD; | ||
| 53 | |||
| 54 | #define USE_KMALLOC \ | ||
| 55 | void *(*kmalloc)(size_t, int) = \ | ||
| 56 | (void *(*)(size_t, int)) KMALLOC_ADD; | ||
| 57 | |||
| 58 | |||
diff --git a/other/Kermit/include/rwKernel.hpp b/other/Kermit/include/rwKernel.hpp new file mode 100644 index 0000000..3b57750 --- /dev/null +++ b/other/Kermit/include/rwKernel.hpp | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* | ||
| 2 | * rwKernel.hpp: | ||
| 3 | * access to kernel memory. | ||
| 4 | * written by palmers / teso | ||
| 5 | */ | ||
| 6 | #ifndef __RW_KERNEL_C | ||
| 7 | #define __RW_KERNEL_C | ||
| 8 | |||
| 9 | #include <algorithm> | ||
| 10 | |||
| 11 | #define PROCKCORE 213 | ||
| 12 | #define DEVMEM 23846 | ||
| 13 | |||
| 14 | #define CONF_1GB 34 | ||
| 15 | #define CONF_2GB 33 | ||
| 16 | #define CONF_3GB 32 | ||
| 17 | #define IGNORE 31 | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Wrapper around kernel memory access. It lets you read from | ||
| 21 | * and write to the kernel without taking care of offsets or file access. | ||
| 22 | */ | ||
| 23 | class rwKernel | ||
| 24 | { | ||
| 25 | private: | ||
| 26 | |||
| 27 | char *fd; | ||
| 28 | int which; | ||
| 29 | unsigned int mem_conf; | ||
| 30 | |||
| 31 | bool openFile (int); | ||
| 32 | void closeFile (); | ||
| 33 | void setOffset (int); | ||
| 34 | |||
| 35 | |||
| 36 | public: | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Create the object with a fairly standard configuration. This constructor will assume | ||
| 40 | * that you want to use /dev/mem and a standard offset (as used by any 2.4.x and any | ||
| 41 | * 2.2.x kernel not defined to use more than 1GB of ram). | ||
| 42 | */ | ||
| 43 | rwKernel (); | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Create a rwKernel object with the defined parameters. | ||
| 47 | * @param file sets the file to use. This must be either | ||
| 48 | * PROCKCORE (to use /proc/kcore as the memory device) or | ||
| 49 | * DEVMEM (to use /dev/mem as the memory device). | ||
| 50 | * @param offset sets the offset from real memory addresses | ||
| 51 | * to virtual (kernel-) addresses. This is only needed if | ||
| 52 | * (file == DEVMEM), otherways supply IGNORE. | ||
| 53 | */ | ||
| 54 | rwKernel (int file, int offset); | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Destructor. Will unmap the used device. | ||
| 58 | */ | ||
| 59 | ~rwKernel (); | ||
| 60 | |||
| 61 | /** | ||
| 62 | * read from kernel. | ||
| 63 | * @param dest read data to this address. | ||
| 64 | * @param len amount of bytes to read. | ||
| 65 | * @param addr read data from this address. | ||
| 66 | */ | ||
| 67 | void read (unsigned char *dest, unsigned int len, unsigned int addr); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * write to kernel. | ||
| 71 | * @param src read data from this address. | ||
| 72 | * @param len amount of bytes to write. | ||
| 73 | * @param addr write data to this address. | ||
| 74 | */ | ||
| 75 | void write (unsigned char *src, unsigned int len, unsigned int addr); | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Foo. | ||
| 79 | */ | ||
| 80 | void read (char *a, unsigned int b, unsigned int c) | ||
| 81 | { | ||
| 82 | read ((unsigned char *) a, b, c); | ||
| 83 | } | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Foo. | ||
| 87 | */ | ||
| 88 | void write (char *a, unsigned int b, unsigned int c) | ||
| 89 | { | ||
| 90 | write ((unsigned char *) a, b, c); | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | |||
| 94 | #endif /* __RW_KERNEL_C */ | ||
diff --git a/other/Kermit/include/stoi16.hpp b/other/Kermit/include/stoi16.hpp new file mode 100644 index 0000000..cbf75b6 --- /dev/null +++ b/other/Kermit/include/stoi16.hpp | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | /* | ||
| 2 | * stoi16.hpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #ifndef __STOI16_C | ||
| 6 | #define __STOI16_C | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | /** | ||
| 10 | * Convert a string of hexadecimal charcters to an unsigned integer. | ||
| 11 | */ | ||
| 12 | unsigned int stoi16 (string); | ||
| 13 | #endif /* __STOI16_C */ | ||
