From c04788620c65016d077649aff33f41420eea4abf Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Sun, 7 Aug 2016 18:41:42 +0300 Subject: [PATCH] removed accidentally added assembler test file --- mono/c | 9 +++++++++ zasmtest.d | 41 ----------------------------------------- 2 files changed, 9 insertions(+), 41 deletions(-) create mode 100644 mono/c delete mode 100644 zasmtest.d diff --git a/mono/c b/mono/c new file mode 100644 index 0000000..0b41b82 --- /dev/null +++ b/mono/c @@ -0,0 +1,9 @@ +#!/bin/sh + +odir=`pwd` +mdir=`dirname "$0"` +cd "$mdir" +rdmd --force --build-only -shared -defaultlib=libphobos2.a -fPIC injed.d +res=$? +cd "odir" +exit $res diff --git a/zasmtest.d b/zasmtest.d deleted file mode 100644 index f27d1ea..0000000 --- a/zasmtest.d +++ /dev/null @@ -1,41 +0,0 @@ -import assembler; - - -immutable string injectCode = q{ - ; choose the amount of memory to allocate with malloc() based on the size - ; of the path to the shared library passed via ecx - push ECX ; 1st argument to malloc - call EDI ; call malloc - int3 ; break back in so that the injector can get the return value - - ; call __libc_dlopen_mode() to load the shared library - push 1 ; 2nd argument to __libc_dlopen_mode(): flag = RTLD_LAZY - push ECX ; 1st argument to __libc_dlopen_mode(): filename = the buffer we allocated earlier - call EDI ; call __libc_dlopen_mode() - int3 ; break back in so that the injector can check the return value - - ; call __libc_dlsym() to find the symbol; EAX: dlh; ECX: symbol name; EDI: __libc_dlsym - push ECX ; 2nd argument to __libc_dlsym() - push EAX ; 1st argument to __libc_dlsym() - call EDI ; call __libc_dlsym() - ; call the function (injector will skip it if EAX is 0) - or EAX,EAX - jz skipcall - call EAX -skipcall: - int3 ; break back in so that the injector can setup registers - - ; call free() on the previously malloced buffer - push ECX ; 1st argument to free(): ptr = the buffer we allocated earlier - call EDI ; call free() - int3 ; final out -}; - - -void main () { - auto ass = new Assembler(0x00400000); - ass.addLines(injectCode); - auto code = ass.getCode(); - { import std.stdio; writeln("assembled to ", code.length, " bytes"); } - Assembler.disasmCode(code, ass.orgpc); -} -- 2.11.4.GIT