diff --git a/VERSION b/VERSION index 867bf6b..2136ac9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0-rc1 +1.0.0-rc2 diff --git a/doc/e9patch.1 b/doc/e9patch.1 index 3143e0e..3982604 100644 --- a/doc/e9patch.1 +++ b/doc/e9patch.1 @@ -183,6 +183,6 @@ Default: \fBfalse\fR (disabled) \fB\-\-version\fR Print the version and exit. .SH "SEE ALSO" -\fIe9tool\fR(1), \fIe9compile\fR, \fIe9afl\fR(1), \fIredfat\fR(1) +\fIe9tool\fR(1), \fIe9compile\fR(1), \fIe9afl\fR(1), \fIredfat\fR(1) .SH AUTHOR \fBe9patch\fR is written by Gregory J. Duck . diff --git a/src/e9patch/e9api.cpp b/src/e9patch/e9api.cpp index b3258e5..75ab131 100644 --- a/src/e9patch/e9api.cpp +++ b/src/e9patch/e9api.cpp @@ -181,7 +181,7 @@ static void queuePatch(Binary *B, Instr *I, const Trampoline *T) */ static Binary *parseBinary(const Message &msg) { - const char *filename = nullptr; + const char *filename = nullptr, *version = nullptr; Mode mode = MODE_ELF_EXE; bool have_mode = false, dup = false; for (unsigned i = 0; i < msg.num_params; i++) @@ -197,6 +197,10 @@ static Binary *parseBinary(const Message &msg) mode = (Mode)msg.params[i].value.integer; have_mode = true; break; + case PARAM_VERSION: + dup = dup || (version != nullptr); + version = msg.params[i].value.string; + break; default: break; } @@ -204,6 +208,13 @@ static Binary *parseBinary(const Message &msg) if (filename == nullptr) error("failed to parse \"binary\" message (id=%u); missing " "\"filename\" parameter", msg.id); + if (version == nullptr) + error("failed to parse \"binary\" message (id=%u); missing " + "\"version\" parameter", msg.id); + if (strcmp(version, STRING(VERSION)) != 0) + error("failed to parse \"binary\" message (id=%u); invalid " + "version \"%s\"; expected \"%s\"", msg.id, version, + STRING(VERSION)); if (dup) error("failed to parse \"binary\" message (id=%u); duplicate " "parameters detected", msg.id); diff --git a/src/e9patch/e9json.cpp b/src/e9patch/e9json.cpp index f60816f..5aa645e 100644 --- a/src/e9patch/e9json.cpp +++ b/src/e9patch/e9json.cpp @@ -505,6 +505,7 @@ static bool validateParam(Method method, ParamName paramName) { case PARAM_FILENAME: case PARAM_MODE: + case PARAM_VERSION: return true; default: return false; @@ -1113,6 +1114,10 @@ static void parseParams(Parser &parser, Message &msg) else if (strcmp(parser.s, "template") == 0) name = PARAM_TEMPLATE; break; + case 'v': + if (strcmp(parser.s, "version") == 0) + name = PARAM_VERSION; + break; } expectToken(parser, ':'); if (!validateParam(msg.method, name)) @@ -1144,6 +1149,7 @@ static void parseParams(Parser &parser, Message &msg) break; case PARAM_FILENAME: case PARAM_NAME: + case PARAM_VERSION: expectToken(parser, TOKEN_STRING); value.string = dupString(parser.s); break; diff --git a/src/e9patch/e9json.h b/src/e9patch/e9json.h index 82afcd1..518228a 100644 --- a/src/e9patch/e9json.h +++ b/src/e9patch/e9json.h @@ -62,6 +62,7 @@ enum ParamName PARAM_PROTECTION, PARAM_TEMPLATE, PARAM_TRAMPOLINE, + PARAM_VERSION, }; /* diff --git a/src/e9tool/e9frontend.cpp b/src/e9tool/e9frontend.cpp index 2a8daf9..a88109b 100644 --- a/src/e9tool/e9frontend.cpp +++ b/src/e9tool/e9frontend.cpp @@ -278,6 +278,9 @@ unsigned e9tool::sendBinaryMessage(FILE *out, const char *mode, const char *filename) { sendMessageHeader(out, "binary"); + sendParamHeader(out, "version"); + sendString(out, STRING(VERSION)); + sendSeparator(out); sendParamHeader(out, "filename"); sendString(out, filename); sendSeparator(out);