summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2016-10-06 01:44:35 -0400
committerJune McEnroe <june@causal.agency>2016-10-06 01:44:35 -0400
commit2426b08749686d57ec7f71519a2b20b563d58389 (patch)
tree6380f08cacd104b49d69ef5aec0f88fb0c205c2f
parentRearrange OP_PUSH so immediate is high dword in jrp (diff)
downloadsrc-2426b08749686d57ec7f71519a2b20b563d58389.tar.gz
src-2426b08749686d57ec7f71519a2b20b563d58389.zip
Define IMMED_PUSH macro in jrp
Diffstat (limited to '')
-rwxr-xr-x.bin/jrp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/.bin/jrp.c b/.bin/jrp.c
index cd117f23..b0060386 100755
--- a/.bin/jrp.c
+++ b/.bin/jrp.c
@@ -34,6 +34,8 @@ enum {
     OP_SHR  = 0x906666242cd34859, // pop rcx; shr qword [rsp], cl
 };
 
+#define IMMED_PUSH(x) ((op)(x) << 32)
+
 int main() {
     int error;
     int page = getpagesize();
@@ -47,8 +49,8 @@ int main() {
 
     op *p = ops;
     *p++ = OP_PROL;
-    *p++ = OP_PUSH | (op)1 << 32;
-    *p++ = OP_PUSH | (op)2 << 32;
+    *p++ = OP_PUSH | IMMED_PUSH(1);
+    *p++ = OP_PUSH | IMMED_PUSH(2);
     *p++ = OP_ADD;
     *p++ = OP_DUP;
     *p++ = OP_MUL;
@@ -57,7 +59,7 @@ int main() {
     error = mprotect(ops, page, PROT_READ | PROT_EXEC);
     if (error) err(EX_OSERR, "mprotect");
 
-    fptr fn = (fptr) ops;
+    fptr fn = (fptr)ops;
     stack = fn(stack);
 
     printf("%lld\n", *stack);