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/src | |
| parent | 073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff) | |
initial
Diffstat (limited to 'other/Kermit/src')
| -rw-r--r-- | other/Kermit/src/Makefile | 27 | ||||
| -rw-r--r-- | other/Kermit/src/__exported_sym.c | 52 | ||||
| -rw-r--r-- | other/Kermit/src/call_syscall.c | 24 | ||||
| -rw-r--r-- | other/Kermit/src/findsym.cpp | 74 | ||||
| -rw-r--r-- | other/Kermit/src/load.cpp | 112 | ||||
| -rw-r--r-- | other/Kermit/src/readsym.cpp | 123 | ||||
| -rw-r--r-- | other/Kermit/src/sys_malloc.c | 27 | ||||
| -rw-r--r-- | other/Kermit/src/unload.cpp | 95 | ||||
| -rw-r--r-- | other/Kermit/src/writesym.cpp | 95 |
9 files changed, 629 insertions, 0 deletions
diff --git a/other/Kermit/src/Makefile b/other/Kermit/src/Makefile new file mode 100644 index 0000000..c5d923b --- /dev/null +++ b/other/Kermit/src/Makefile | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # written by palmers / teso | ||
| 2 | include ../MakeOpt | ||
| 3 | |||
| 4 | all: load unload findsym readsym writesym callsyscall | ||
| 5 | |||
| 6 | load: | ||
| 7 | $(CXX) $(CXXFLAGS) load.cpp -o $(BIN_DIR)/load $(AR_OUT) | ||
| 8 | |||
| 9 | unload: | ||
| 10 | $(CXX) $(CXXFLAGS) unload.cpp -o $(BIN_DIR)/unload $(AR_OUT) | ||
| 11 | |||
| 12 | readsym: | ||
| 13 | $(CXX) $(CXXFLAGS) readsym.cpp -o $(BIN_DIR)/readsym $(AR_OUT) | ||
| 14 | |||
| 15 | writesym: | ||
| 16 | $(CXX) $(CXXFLAGS) writesym.cpp -o $(BIN_DIR)/writesym $(AR_OUT) | ||
| 17 | |||
| 18 | findsym: | ||
| 19 | $(CXX) $(CXXFLAGS) findsym.cpp -o $(BIN_DIR)/findsym $(AR_OUT) | ||
| 20 | |||
| 21 | callsyscall: | ||
| 22 | $(CC) $(CFLAGS) -O2 call_syscall.c -o $(BIN_DIR)/call_syscall | ||
| 23 | |||
| 24 | clean: | ||
| 25 | rm -rf $(BIN_DIR)/findsym $(BIN_DIR)/readsym \ | ||
| 26 | $(BIN_DIR)/writesym $(BIN_DIR)/call_syscall \ | ||
| 27 | $(BIN_DIR)/unload $(BIN_DIR)/load | ||
diff --git a/other/Kermit/src/__exported_sym.c b/other/Kermit/src/__exported_sym.c new file mode 100644 index 0000000..3a9943a --- /dev/null +++ b/other/Kermit/src/__exported_sym.c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | #ifdef 0 | ||
| 2 | void | ||
| 3 | print_exported_symbols () | ||
| 4 | { | ||
| 5 | struct new_module_symbol | ||
| 6 | { | ||
| 7 | unsigned long value; | ||
| 8 | unsigned long name; | ||
| 9 | } | ||
| 10 | *syms = NULL, *s = NULL; | ||
| 11 | |||
| 12 | unsigned long long_tmp; | ||
| 13 | char *char_tmp = NULL; | ||
| 14 | size_t ret, bufsize, x = 800; | ||
| 15 | |||
| 16 | s = syms = new struct new_module_symbol[x]; | ||
| 17 | bufsize = sizeof (struct new_module_symbol) * x; | ||
| 18 | |||
| 19 | while (query_module (NULL, QM_SYMBOLS, syms, bufsize, &ret) == -1) | ||
| 20 | { | ||
| 21 | if (errno == ENOSPC) | ||
| 22 | { | ||
| 23 | delete syms; | ||
| 24 | x += 400; | ||
| 25 | s = syms = new struct new_module_symbol[x]; | ||
| 26 | bufsize = sizeof (struct new_module_symbol) * x; | ||
| 27 | } | ||
| 28 | else | ||
| 29 | { | ||
| 30 | if (Silent) | ||
| 31 | { | ||
| 32 | cout << "0" << endl; | ||
| 33 | exit (1); | ||
| 34 | } | ||
| 35 | cerr << "query_module error!" << endl; | ||
| 36 | abort (); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | cout.setf (ios::hex, ios::basefield); | ||
| 41 | for (x = 0; x < ret; x++, s++) | ||
| 42 | { | ||
| 43 | char_tmp = (char *) syms + s->name; | ||
| 44 | long_tmp = (unsigned long) s->value; | ||
| 45 | cout << long_tmp << " " << char_tmp << endl; | ||
| 46 | } | ||
| 47 | delete syms; | ||
| 48 | cout.setf (ios::dec, ios::basefield); | ||
| 49 | } | ||
| 50 | #endif | ||
| 51 | |||
| 52 | main (){} | ||
diff --git a/other/Kermit/src/call_syscall.c b/other/Kermit/src/call_syscall.c new file mode 100644 index 0000000..8b85ed5 --- /dev/null +++ b/other/Kermit/src/call_syscall.c | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* | ||
| 2 | * call_syscall.c: | ||
| 3 | * you can figure it out ;) | ||
| 4 | * written by palmers / teso | ||
| 5 | */ | ||
| 6 | #include <stdio.h> | ||
| 7 | #include <errno.h> | ||
| 8 | #include <asm/unistd.h> | ||
| 9 | |||
| 10 | #define __NR_evilmalloc 251 | ||
| 11 | |||
| 12 | int main () | ||
| 13 | { | ||
| 14 | int x = 1024; | ||
| 15 | void *xx = NULL; | ||
| 16 | |||
| 17 | _syscall1 (void *, evilmalloc, int, x); | ||
| 18 | xx = evilmalloc (x); | ||
| 19 | if ((unsigned int) xx == 0xffffffff) | ||
| 20 | printf ("evilmalloc failed?\n"); | ||
| 21 | printf ("evilmalloc: %d bytes at %p\n", x, (unsigned int) xx); | ||
| 22 | return 0; | ||
| 23 | } | ||
| 24 | |||
diff --git a/other/Kermit/src/findsym.cpp b/other/Kermit/src/findsym.cpp new file mode 100644 index 0000000..cceefab --- /dev/null +++ b/other/Kermit/src/findsym.cpp | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | * findsym.cpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #include <DevMemPatt.hpp> | ||
| 6 | #include <SymbolFingp.hpp> | ||
| 7 | #include <iostream> | ||
| 8 | |||
| 9 | |||
| 10 | #define PROGRAM "findsym" | ||
| 11 | #define AUTHOR "palmers / teso" | ||
| 12 | #define VERSION "0.0.2" | ||
| 13 | |||
| 14 | |||
| 15 | void usage (char *s) | ||
| 16 | { | ||
| 17 | cout << PROGRAM << VERSION << " by " << AUTHOR << endl; | ||
| 18 | cout << "Usage: " << s << " [Options] name0 [name1 ... nameN]" << endl; | ||
| 19 | cout << "Options:" << endl; | ||
| 20 | cout << "\t-s:\t\t silent mode" << endl; | ||
| 21 | cout << "\t-f <file>:\t set config file to <file>" << endl; | ||
| 22 | cout << endl; | ||
| 23 | exit (0); | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | int main (int argc, char **argv) | ||
| 28 | { | ||
| 29 | bool silent = false; | ||
| 30 | int x = 1; | ||
| 31 | DevMemPatt *a = new DevMemPatt (); | ||
| 32 | SymbolFingp *b = new SymbolFingp (); | ||
| 33 | |||
| 34 | if (argc < 2) | ||
| 35 | usage (argv[0]); | ||
| 36 | |||
| 37 | cout.setf (ios::hex, ios::basefield); | ||
| 38 | while (x < argc) | ||
| 39 | { | ||
| 40 | if (argv[x][0] == '-') | ||
| 41 | { | ||
| 42 | switch (argv[x][1]) | ||
| 43 | { | ||
| 44 | case 's': | ||
| 45 | if (silent == false) | ||
| 46 | silent = true; | ||
| 47 | else | ||
| 48 | silent = false; | ||
| 49 | break; | ||
| 50 | case 'f': | ||
| 51 | if (b != NULL) | ||
| 52 | delete b; | ||
| 53 | b = new SymbolFingp (string (argv[++x])); | ||
| 54 | break; | ||
| 55 | default: | ||
| 56 | cerr << "Illegal option!" << endl; | ||
| 57 | usage (argv[0]); | ||
| 58 | break; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | else | ||
| 62 | { | ||
| 63 | if (silent) | ||
| 64 | cout << a->find_patt (b->getFinger (string (argv[x]))) << endl; | ||
| 65 | else | ||
| 66 | cout << argv[x] << '\t' << a->find_patt (b->getFinger (string (argv[x]))) << endl; | ||
| 67 | } | ||
| 68 | x++; | ||
| 69 | } | ||
| 70 | |||
| 71 | delete a; | ||
| 72 | delete b; | ||
| 73 | return 0; | ||
| 74 | } | ||
diff --git a/other/Kermit/src/load.cpp b/other/Kermit/src/load.cpp new file mode 100644 index 0000000..2d40735 --- /dev/null +++ b/other/Kermit/src/load.cpp | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | /* | ||
| 2 | * load.cpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #include <Kermit> | ||
| 6 | #include <string> | ||
| 7 | #include <iostream> | ||
| 8 | #include <fstream> | ||
| 9 | #include <stack> | ||
| 10 | |||
| 11 | #define PROGRAM "load" | ||
| 12 | #define VERSION "0.0.1" | ||
| 13 | #define AUTHOR "palmers / teso" | ||
| 14 | |||
| 15 | #define LINE_LENGTH 16384 | ||
| 16 | |||
| 17 | |||
| 18 | void usage (char *s) | ||
| 19 | { | ||
| 20 | cout << PROGRAM << VERSION << " by " << AUTHOR << endl; | ||
| 21 | cout << "Usage: " << s << " [options] <file>" << endl; | ||
| 22 | cout << "Options:" << endl; | ||
| 23 | cout << "\t-v:\t be verbose" << endl; | ||
| 24 | cout << "\t-E:\t proceed even if errors occour" << endl; | ||
| 25 | cout << endl; | ||
| 26 | exit (0); | ||
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | int main (int argc, char **argv) | ||
| 31 | { | ||
| 32 | bool verbose = false, | ||
| 33 | err_continue = false; | ||
| 34 | int x = 0; | ||
| 35 | ifstream fs; | ||
| 36 | char line[LINE_LENGTH + 1]; | ||
| 37 | Patch *tp = NULL; | ||
| 38 | rwKernel *rw = NULL; | ||
| 39 | SymbolTable *st = NULL; | ||
| 40 | Addr2AddrList *a2a = NULL; | ||
| 41 | |||
| 42 | if (argc < 2) | ||
| 43 | usage (argv[0]); | ||
| 44 | |||
| 45 | for (x = 1; x < argc; x++) | ||
| 46 | { | ||
| 47 | if (argv[x][0] == '-') | ||
| 48 | { | ||
| 49 | switch (argv[x][1]) | ||
| 50 | { | ||
| 51 | case 'v': | ||
| 52 | verbose = true; | ||
| 53 | break; | ||
| 54 | case 'E': | ||
| 55 | err_continue = true; | ||
| 56 | break; | ||
| 57 | default: | ||
| 58 | cout << "unknow option: " << argv[x] << endl; | ||
| 59 | usage (argv[0]); | ||
| 60 | break; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | rw = new rwKernel (); | ||
| 66 | genDummyValMap (); | ||
| 67 | st = new SymbolTable (rw); | ||
| 68 | a2a = genReplaceValMap (st); | ||
| 69 | |||
| 70 | fs.open (argv[argc - 1]); | ||
| 71 | if (!fs.is_open ()) | ||
| 72 | { | ||
| 73 | cerr << "failed to open \"" << argv[argc - 1] << "\"" << endl; | ||
| 74 | abort (); | ||
| 75 | } | ||
| 76 | |||
| 77 | if (verbose) | ||
| 78 | cout << "done." << endl; | ||
| 79 | |||
| 80 | while (!fs.eof ()) | ||
| 81 | { | ||
| 82 | fs.getline (line, LINE_LENGTH, '\n'); | ||
| 83 | tp = new Patch (string (line), rw); | ||
| 84 | |||
| 85 | if (tp->isClean ()) | ||
| 86 | tp->link (a2a); | ||
| 87 | |||
| 88 | if (tp->isLinked ()) | ||
| 89 | tp->apply (); | ||
| 90 | else if (verbose) | ||
| 91 | { | ||
| 92 | cout << "#" << x << ": Linking Failed" << endl; | ||
| 93 | if (err_continue) | ||
| 94 | continue; | ||
| 95 | break; | ||
| 96 | } | ||
| 97 | if (tp->isApplied () && verbose) | ||
| 98 | cout << "#" << x << ": Success" << endl; | ||
| 99 | else | ||
| 100 | { | ||
| 101 | cout << "#" << x << ": Applying Failed" << endl; | ||
| 102 | if (err_continue) | ||
| 103 | continue; | ||
| 104 | break; | ||
| 105 | } | ||
| 106 | delete tp; | ||
| 107 | } | ||
| 108 | if (verbose) | ||
| 109 | cout << "done." << endl; | ||
| 110 | fs.close (); | ||
| 111 | return 0; | ||
| 112 | } | ||
diff --git a/other/Kermit/src/readsym.cpp b/other/Kermit/src/readsym.cpp new file mode 100644 index 0000000..541d594 --- /dev/null +++ b/other/Kermit/src/readsym.cpp | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | /* | ||
| 2 | * readsym.cpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #include <Kermit> | ||
| 6 | #include <iostream> | ||
| 7 | #include <fstream> | ||
| 8 | |||
| 9 | #define PROGRAM "readsym" | ||
| 10 | #define VERSION "0.1" | ||
| 11 | #define AUTHOR "palmers / teso" | ||
| 12 | |||
| 13 | |||
| 14 | void dump_c_array (char *arr, char *b, int x) | ||
| 15 | { | ||
| 16 | int y; | ||
| 17 | cout.setf (ios::hex, ios::basefield); | ||
| 18 | cout << "char " << arr << "[] = {" << endl; | ||
| 19 | for (y = 0; y < x; y++) | ||
| 20 | { | ||
| 21 | cout << "0x" << ((int) b[y] & 0xff); | ||
| 22 | if (y != (x - 1)) | ||
| 23 | cout << ", "; | ||
| 24 | if (!(y % 10)) | ||
| 25 | cout << endl; | ||
| 26 | } | ||
| 27 | cout << endl << "};" << endl; | ||
| 28 | cout.setf (ios::dec, ios::basefield); | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | void dump (char *a, int x) | ||
| 33 | { | ||
| 34 | int y; | ||
| 35 | cout.setf (ios::hex, ios::basefield); | ||
| 36 | |||
| 37 | for (y = 0; y < x; y++) | ||
| 38 | { | ||
| 39 | if ((a[y] & 0xff) < 16) | ||
| 40 | cout << '0'; | ||
| 41 | cout << ((int) a[y] & 0xff) << ' '; | ||
| 42 | } | ||
| 43 | cout.setf (ios::dec, ios::basefield); | ||
| 44 | cout << endl; | ||
| 45 | } | ||
| 46 | |||
| 47 | void usage (char *a) | ||
| 48 | { | ||
| 49 | cout << PROGRAM << VERSION << " by " << AUTHOR << endl; | ||
| 50 | cout << endl; | ||
| 51 | cout << "Usage: " << a << " [options] <d|p> <offset> <length>" << endl; | ||
| 52 | cout << "Options:" << endl; | ||
| 53 | cout << "\t-x:\t where x is 1, 2, 3: the amount of ram in GB the system is ought to run" << endl; | ||
| 54 | cout << "\t-c <name>:\t dump the read data as a c array" << endl; | ||
| 55 | cout << endl; | ||
| 56 | exit (0); | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | int main (int argc, char **argv) | ||
| 61 | { | ||
| 62 | rwKernel *rw = NULL; | ||
| 63 | char *inBuf = NULL, | ||
| 64 | *arr_name = NULL; | ||
| 65 | unsigned long length = 0, | ||
| 66 | offset = CONF_1GB; | ||
| 67 | int x = 0; | ||
| 68 | |||
| 69 | if (argc < 4) | ||
| 70 | usage (argv[0]); | ||
| 71 | |||
| 72 | while (x < argc) | ||
| 73 | { | ||
| 74 | if (argv[x][0] == '-') | ||
| 75 | { | ||
| 76 | switch (argv[x][1]) | ||
| 77 | { | ||
| 78 | case '1': | ||
| 79 | offset = CONF_1GB; | ||
| 80 | break; | ||
| 81 | case '2': | ||
| 82 | offset = CONF_2GB; | ||
| 83 | break; | ||
| 84 | case '3': | ||
| 85 | offset = CONF_3GB; | ||
| 86 | break; | ||
| 87 | case 'c': | ||
| 88 | arr_name = argv[x + 1]; | ||
| 89 | x++; | ||
| 90 | break; | ||
| 91 | case 'h': | ||
| 92 | usage (argv[0]); | ||
| 93 | break; | ||
| 94 | default: | ||
| 95 | usage (argv[0]); | ||
| 96 | break; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | x++; | ||
| 100 | } | ||
| 101 | |||
| 102 | if (argv[argc - 3][0] == 'd') | ||
| 103 | rw = new rwKernel (DEVMEM, offset); | ||
| 104 | else if (argv[argc - 3][0] == 'p') | ||
| 105 | rw = new rwKernel (PROCKCORE, offset); | ||
| 106 | |||
| 107 | offset = stoi16 (string (argv[argc - 2])); | ||
| 108 | length = stoi16 (string (argv[argc - 1])); | ||
| 109 | |||
| 110 | inBuf = new char[length + 1]; | ||
| 111 | rw->read (inBuf, length, offset); | ||
| 112 | |||
| 113 | if (arr_name != NULL) | ||
| 114 | { | ||
| 115 | dump_c_array (arr_name, inBuf, length); | ||
| 116 | delete inBuf; | ||
| 117 | exit (0); | ||
| 118 | } | ||
| 119 | |||
| 120 | dump (inBuf, length); | ||
| 121 | delete inBuf; | ||
| 122 | return 0; | ||
| 123 | } | ||
diff --git a/other/Kermit/src/sys_malloc.c b/other/Kermit/src/sys_malloc.c new file mode 100644 index 0000000..96a3b4d --- /dev/null +++ b/other/Kermit/src/sys_malloc.c | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* | ||
| 2 | * sys_malloc: system call for malloc'ing kernel memory | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #include <stdio.h> | ||
| 6 | #include <pseudo_link.h> | ||
| 7 | |||
| 8 | /* from linux/mm.h */ | ||
| 9 | #define __GFP_WAIT 0x01 | ||
| 10 | #define __GFP_MED 0x04 | ||
| 11 | #define __GFP_IO 0x10 | ||
| 12 | #define GFP_KERNEL (__GFP_MED | __GFP_WAIT | __GFP_IO) | ||
| 13 | |||
| 14 | |||
| 15 | void cbegin (){} | ||
| 16 | |||
| 17 | void *sys_malloc (size_t x) /* malloc x bytes */ | ||
| 18 | { | ||
| 19 | USE_KMALLOC | ||
| 20 | void *y = NULL; | ||
| 21 | |||
| 22 | y = kmalloc (x, GFP_KERNEL); | ||
| 23 | return y; | ||
| 24 | } | ||
| 25 | |||
| 26 | void cend(){} | ||
| 27 | |||
diff --git a/other/Kermit/src/unload.cpp b/other/Kermit/src/unload.cpp new file mode 100644 index 0000000..90630ea --- /dev/null +++ b/other/Kermit/src/unload.cpp | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* | ||
| 2 | * unload.cpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #include <Kermit> | ||
| 6 | #include <string> | ||
| 7 | #include <iostream> | ||
| 8 | #include <fstream> | ||
| 9 | #include <stack> | ||
| 10 | |||
| 11 | #define PROGRAM "unload" | ||
| 12 | #define VERSION "0.0.1" | ||
| 13 | #define AUTHOR "palmers / teso" | ||
| 14 | |||
| 15 | #define LINE_LENGTH 16384 | ||
| 16 | |||
| 17 | |||
| 18 | void usage (char *s) | ||
| 19 | { | ||
| 20 | cout << PROGRAM << VERSION << " by " << AUTHOR << endl; | ||
| 21 | cout << "Usage: " << s << " [options] <file>" << endl; | ||
| 22 | cout << "Options:" << endl; | ||
| 23 | cout << "\t-l:\t restore in linear order [default: reversed order]" << endl; | ||
| 24 | cout << endl; | ||
| 25 | exit (0); | ||
| 26 | } | ||
| 27 | |||
| 28 | |||
| 29 | int main (int argc, char **argv) | ||
| 30 | { | ||
| 31 | bool linear = false; | ||
| 32 | int x = 0; | ||
| 33 | ifstream fs; | ||
| 34 | char line[LINE_LENGTH + 1]; | ||
| 35 | Patch *tp = NULL; | ||
| 36 | rwKernel *rw = NULL; | ||
| 37 | |||
| 38 | if (argc < 2) | ||
| 39 | usage (argv[0]); | ||
| 40 | |||
| 41 | for (x = 1; x < argc; x++) | ||
| 42 | { | ||
| 43 | if (argv[x][0] == '-') | ||
| 44 | { | ||
| 45 | switch (argv[x][1]) | ||
| 46 | { | ||
| 47 | case 'l': | ||
| 48 | linear = true; | ||
| 49 | break; | ||
| 50 | default: | ||
| 51 | cout << "unknow option: " << argv[x] << endl; | ||
| 52 | usage (argv[0]); | ||
| 53 | break; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | fs.open (argv[argc - 1]); | ||
| 59 | if (!fs.is_open ()) | ||
| 60 | { | ||
| 61 | cerr << "failed to open \"" << argv[argc - 1] << "\"" << endl; | ||
| 62 | abort (); | ||
| 63 | } | ||
| 64 | |||
| 65 | if (linear) | ||
| 66 | { | ||
| 67 | while (!fs.eof ()) | ||
| 68 | { | ||
| 69 | fs.getline (line, LINE_LENGTH, '\n'); | ||
| 70 | tp = new Patch (string (line), rw); | ||
| 71 | tp->remove (); | ||
| 72 | delete tp; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | else | ||
| 76 | { | ||
| 77 | stack<Patch *> pstack; | ||
| 78 | while (!fs.eof ()) | ||
| 79 | { | ||
| 80 | fs.getline (line, LINE_LENGTH, '\n'); | ||
| 81 | tp = new Patch (string (line), rw); | ||
| 82 | pstack.push (tp); | ||
| 83 | } | ||
| 84 | |||
| 85 | while (!pstack.empty ()) | ||
| 86 | { | ||
| 87 | tp = pstack.top (); | ||
| 88 | tp->remove (); | ||
| 89 | delete tp; | ||
| 90 | pstack.pop (); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | return 0; | ||
| 95 | } | ||
diff --git a/other/Kermit/src/writesym.cpp b/other/Kermit/src/writesym.cpp new file mode 100644 index 0000000..13d521e --- /dev/null +++ b/other/Kermit/src/writesym.cpp | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* | ||
| 2 | * readsym.cpp: | ||
| 3 | * written by palmers / teso | ||
| 4 | */ | ||
| 5 | #include <Kermit> | ||
| 6 | #include <iostream> | ||
| 7 | #include <fstream> | ||
| 8 | |||
| 9 | #define PROGRAM "writesym" | ||
| 10 | #define VERSION "0.1" | ||
| 11 | #define AUTHOR "palmers / teso" | ||
| 12 | |||
| 13 | |||
| 14 | void | ||
| 15 | usage (char *a) | ||
| 16 | { | ||
| 17 | cout << PROGRAM << VERSION << " by " << AUTHOR << endl; | ||
| 18 | cout << endl; | ||
| 19 | cout << "Usage: " << a << " [options] <d|p> <offset> <length>" << endl; | ||
| 20 | cout << "Options:" << endl; | ||
| 21 | cout << "\t-x:\t where x is 1, 2, 3: ... " << endl; | ||
| 22 | cout << endl; | ||
| 23 | exit (0); | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | int | ||
| 28 | main (int argc, char **argv) | ||
| 29 | { | ||
| 30 | rwKernel *rw = NULL; | ||
| 31 | char *inBuf = NULL; | ||
| 32 | unsigned long y = 0, | ||
| 33 | length = 0, | ||
| 34 | out_offset = 0, | ||
| 35 | offset = CONF_1GB; | ||
| 36 | int x = 0; | ||
| 37 | |||
| 38 | if (argc < 4) | ||
| 39 | usage (argv[0]); | ||
| 40 | |||
| 41 | while (x < argc) | ||
| 42 | { | ||
| 43 | if (argv[x][0] == '-') | ||
| 44 | { | ||
| 45 | switch (argv[x][1]) | ||
| 46 | { | ||
| 47 | case '1': | ||
| 48 | offset = CONF_1GB; | ||
| 49 | break; | ||
| 50 | case '2': | ||
| 51 | offset = CONF_2GB; | ||
| 52 | break; | ||
| 53 | case '3': | ||
| 54 | offset = CONF_3GB; | ||
| 55 | break; | ||
| 56 | case 'h': | ||
| 57 | usage (argv[0]); | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | usage (argv[0]); | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | x++; | ||
| 65 | } | ||
| 66 | |||
| 67 | if (argv[argc - 3][0] == 'd') | ||
| 68 | rw = new rwKernel (DEVMEM, offset); | ||
| 69 | else if (argv[argc - 3][0] == 'p') | ||
| 70 | rw = new rwKernel (PROCKCORE, offset); | ||
| 71 | |||
| 72 | out_offset = stoi16 (string (argv[argc - 2])); | ||
| 73 | length = stoi16 (string (argv[argc - 1])); | ||
| 74 | |||
| 75 | if (length == 0) | ||
| 76 | { | ||
| 77 | cerr << "HaHa" << endl; | ||
| 78 | abort (); | ||
| 79 | } | ||
| 80 | |||
| 81 | inBuf = new char[length + 1]; | ||
| 82 | |||
| 83 | cin.setf (ios::hex, ios::basefield); | ||
| 84 | while (!cin.eof ()) | ||
| 85 | { | ||
| 86 | cin >> x; | ||
| 87 | if (y < length) | ||
| 88 | inBuf[y++] = (x & 0xff); | ||
| 89 | } | ||
| 90 | cin.setf (ios::dec, ios::basefield); | ||
| 91 | |||
| 92 | rw->write (inBuf, length, out_offset); | ||
| 93 | delete inBuf; | ||
| 94 | return 0; | ||
| 95 | } | ||
