From: Jay Freeman (saurik) Date: Fri, 16 Oct 2009 18:04:26 +0000 (+0000) Subject: Changed console commands to start with ? and added ?expand to unescape strings. X-Git-Tag: v0.9.432~338 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/6ec85c5be5608e263a1a2dbbd8397da8f2b23125 Changed console commands to start with ? and added ?expand to unescape strings. --- diff --git a/Application.cpp b/Application.cpp index 725e246..25f624e 100644 --- a/Application.cpp +++ b/Application.cpp @@ -72,13 +72,15 @@ static void sigint(int) { longjmp(ctrlc_, 1); } -void Run(int socket, const char *data, size_t size, FILE *fout) { +void Run(int socket, const char *data, size_t size, FILE *fout, bool expand = false) { CYPool pool; const char *json; - if (socket == -1) + if (socket == -1) { json = CYExecute(pool, data); - else { + if (json != NULL) + size = strlen(json); + } else { CYSendAll(socket, &size, sizeof(size)); CYSendAll(socket, data, size); CYRecvAll(socket, &size, sizeof(size)); @@ -93,19 +95,39 @@ void Run(int socket, const char *data, size_t size, FILE *fout) { } if (json != NULL && fout != NULL) { - fputs(json, fout); + if (!expand || json[0] != '"' && json[0] != '\'') + fputs(json, fout); + else for (size_t i(0); i != size; ++i) + if (json[i] != '\\') + fputc(json[i], fout); + else switch(json[++i]) { + case '\0': goto done; + case '\\': fputc('\\', fout); break; + case '\'': fputc('\'', fout); break; + case '"': fputc('"', fout); break; + case 'b': fputc('\b', fout); break; + case 'f': fputc('\f', fout); break; + case 'n': fputc('\n', fout); break; + case 'r': fputc('\r', fout); break; + case 't': fputc('\t', fout); break; + case 'v': fputc('\v', fout); break; + default: fputc('\\', fout); --i; break; + } + + done: fputs("\n", fout); fflush(fout); } } -void Run(int socket, std::string &code, FILE *fout) { - Run(socket, code.c_str(), code.size(), fout); +void Run(int socket, std::string &code, FILE *fout, bool expand = false) { + Run(socket, code.c_str(), code.size(), fout, expand); } static void Console(int socket) { bool bypass(false); bool debug(false); + bool expand(false); FILE *fout(stdout); @@ -137,7 +159,7 @@ static void Console(int socket) { if (!extra) { extra = true; - if (line[0] == '\\') { + if (line[0] == '?') { std::string data(line + 1); if (data == "bypass") { bypass = !bypass; @@ -147,6 +169,10 @@ static void Console(int socket) { debug = !debug; fprintf(fout, "debug == %s\n", debug ? "true" : "false"); fflush(fout); + } else if (data == "expand") { + expand = !expand; + fprintf(fout, "expand == %s\n", expand ? "true" : "false"); + fflush(fout); } add_history(line); goto restart; @@ -216,7 +242,7 @@ static void Console(int socket) { if (debug) std::cout << code << std::endl; - Run(socket, code, fout); + Run(socket, code, fout, expand); } fputs("\n", fout); diff --git a/Library.mm b/Library.mm index 7a1872c..2eeb1c7 100644 --- a/Library.mm +++ b/Library.mm @@ -1378,6 +1378,7 @@ NSString *CYCopyNSCYON(id value) { string = @"_NSZombie_"; else if (_class == NSZombie_) string = [NSString stringWithFormat:@"<_NSZombie_: %p>", value]; + // XXX: frowny /in/ the pants else if (value == NSMessageBuilder_ || value == Object_) string = nil; else