From d7559106d2d94a78b4c8a718a86c1655931b0429 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 2 Jun 2015 18:51:21 -0400 Subject: declaring stdout with dllimport --- dataimp/dllimp/a.c | 9 ++++ dataimp/dllimp/a.o | Bin 0 -> 953 bytes dataimp/dllimp/a.o.dis | 21 ++++++++ dataimp/dllimp/a.out | Bin 0 -> 19653 bytes dataimp/dllimp/a.out.dis | 130 ++++++++++++++++++++++++++++++++++++++++++++ dataimp/dllimp/a.s | 32 +++++++++++ dataimp/drctve/a.c | 7 +++ dataimp/drctve/a.o | Bin 0 -> 940 bytes dataimp/drctve/a.o.dis | 23 ++++++++ dataimp/drctve/a.out | Bin 0 -> 19766 bytes dataimp/drctve/a.out.dis | 137 +++++++++++++++++++++++++++++++++++++++++++++++ dataimp/drctve/a.s | 31 +++++++++++ 12 files changed, 390 insertions(+) create mode 100644 dataimp/dllimp/a.c create mode 100644 dataimp/dllimp/a.o create mode 100644 dataimp/dllimp/a.o.dis create mode 100755 dataimp/dllimp/a.out create mode 100644 dataimp/dllimp/a.out.dis create mode 100644 dataimp/dllimp/a.s create mode 100644 dataimp/drctve/a.c create mode 100644 dataimp/drctve/a.o create mode 100644 dataimp/drctve/a.o.dis create mode 100755 dataimp/drctve/a.out create mode 100644 dataimp/drctve/a.out.dis create mode 100644 dataimp/drctve/a.s diff --git a/dataimp/dllimp/a.c b/dataimp/dllimp/a.c new file mode 100644 index 0000000..9685083 --- /dev/null +++ b/dataimp/dllimp/a.c @@ -0,0 +1,9 @@ +typedef struct FILE FILE; + +extern FILE * __attribute__((dllimport)) const stdout; + +int main(int argc, char ** argv) +{ + fflush(stdout); + return argc; +} diff --git a/dataimp/dllimp/a.o b/dataimp/dllimp/a.o new file mode 100644 index 0000000..ae6d11c Binary files /dev/null and b/dataimp/dllimp/a.o differ diff --git a/dataimp/dllimp/a.o.dis b/dataimp/dllimp/a.o.dis new file mode 100644 index 0000000..89e17d8 --- /dev/null +++ b/dataimp/dllimp/a.o.dis @@ -0,0 +1,21 @@ + +a.o: Dateiformat pe-x86-64 + + +Disassembly of section .text.startup: + +0000000000000000
: + 0: 53 push %rbx + 1: 48 83 ec 20 sub $0x20,%rsp + 5: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # c + 8: R_X86_64_PC32 __imp_stdout + c: 89 cb mov %ecx,%ebx + e: 48 8b 08 mov (%rax),%rcx + 11: e8 00 00 00 00 callq 16 + 12: R_X86_64_PC32 fflush + 16: 89 d8 mov %ebx,%eax + 18: 48 83 c4 20 add $0x20,%rsp + 1c: 5b pop %rbx + 1d: c3 retq + 1e: 90 nop + 1f: 90 nop diff --git a/dataimp/dllimp/a.out b/dataimp/dllimp/a.out new file mode 100755 index 0000000..09d2010 Binary files /dev/null and b/dataimp/dllimp/a.out differ diff --git a/dataimp/dllimp/a.out.dis b/dataimp/dllimp/a.out.dis new file mode 100644 index 0000000..930d88c --- /dev/null +++ b/dataimp/dllimp/a.out.dis @@ -0,0 +1,130 @@ + +a.out: Dateiformat pei-x86-64 + + +Disassembly of section .text: + +0000000001921000 <.init>: + 1921000: 48 31 c0 xor %rax,%rax + 1921003: 50 push %rax + 1921004: 51 push %rcx + 1921005: 52 push %rdx + 1921006: 90 nop + 1921007: 90 nop + +0000000001921008 <.init>: + 1921008: 5a pop %rdx + 1921009: 59 pop %rcx + 192100a: 41 5a pop %r10 + 192100c: 4c 09 d0 or %r10,%rax + 192100f: c3 retq + +0000000001921010 <_start>: + 1921010: 48 83 ec 28 sub $0x28,%rsp + 1921014: 48 8d 05 e5 1f 00 00 lea 0x1fe5(%rip),%rax # 1923000 <.weak.__crtopt_posix._start> + 192101b: 8b 10 mov (%rax),%edx + 192101d: 48 8d 05 dc 1f 00 00 lea 0x1fdc(%rip),%rax # 1923000 <.weak.__crtopt_posix._start> + 1921024: 8b 00 mov (%rax),%eax + 1921026: 09 c2 or %eax,%edx + 1921028: 48 8b 05 5d 70 00 00 mov 0x705d(%rip),%rax # 192808c <__imp___psx_init> + 192102f: 41 89 d0 mov %edx,%r8d + 1921032: 48 89 c2 mov %rax,%rdx + 1921035: 48 8d 0d 44 00 00 00 lea 0x44(%rip),%rcx # 1921080
+ 192103c: 48 8b 05 29 70 00 00 mov 0x7029(%rip),%rax # 192806c <__IAT_start__> + 1921043: ff d0 callq *%rax + 1921045: 90 nop + 1921046: 48 83 c4 28 add $0x28,%rsp + 192104a: c3 retq + 192104b: 90 nop + 192104c: 90 nop + 192104d: 90 nop + 192104e: 90 nop + 192104f: 90 nop + +0000000001921050 <_pei386_runtime_relocator>: + 1921050: c3 retq + +0000000001921051 <_init>: + 1921051: e9 aa ff ff ff jmpq 1921000 <.init> + +0000000001921056 <_fini>: + 1921056: e9 65 00 00 00 jmpq 19210c0 <.fini> + 192105b: 90 nop + 192105c: 90 nop + 192105d: 90 nop + 192105e: 90 nop + 192105f: 90 nop + +0000000001921060 <__libc_entry_routine>: + 1921060: ff 25 06 70 00 00 jmpq *0x7006(%rip) # 192806c <__IAT_start__> + 1921066: 90 nop + 1921067: 90 nop + +0000000001921068 : + 1921068: ff 25 06 70 00 00 jmpq *0x7006(%rip) # 1928074 <__imp_fflush> + 192106e: 90 nop + 192106f: 90 nop + +0000000001921070 <__psx_init>: + 1921070: ff 25 16 70 00 00 jmpq *0x7016(%rip) # 192808c <__imp___psx_init> + 1921076: 90 nop + 1921077: 90 nop + 1921078: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) + 192107f: 00 + +0000000001921080
: + 1921080: 53 push %rbx + 1921081: 48 83 ec 20 sub $0x20,%rsp + 1921085: 48 8b 05 f0 6f 00 00 mov 0x6ff0(%rip),%rax # 192807c <__imp_stdout> + 192108c: 89 cb mov %ecx,%ebx + 192108e: 48 8b 08 mov (%rax),%rcx + 1921091: e8 d2 ff ff ff callq 1921068 + 1921096: 89 d8 mov %ebx,%eax + 1921098: 48 83 c4 20 add $0x20,%rsp + 192109c: 5b pop %rbx + 192109d: c3 retq + 192109e: 90 nop + 192109f: 90 nop + +00000000019210a0 <__CTOR_LIST__>: + 19210a0: ff (bad) + 19210a1: ff (bad) + 19210a2: ff (bad) + 19210a3: ff (bad) + 19210a4: ff (bad) + 19210a5: ff (bad) + 19210a6: ff (bad) + 19210a7: ff 00 incl (%rax) + 19210a9: 00 00 add %al,(%rax) + 19210ab: 00 00 add %al,(%rax) + 19210ad: 00 00 add %al,(%rax) + ... + +00000000019210b0 <__DTOR_LIST__>: + 19210b0: ff (bad) + 19210b1: ff (bad) + 19210b2: ff (bad) + 19210b3: ff (bad) + 19210b4: ff (bad) + 19210b5: ff (bad) + 19210b6: ff (bad) + 19210b7: ff 00 incl (%rax) + 19210b9: 00 00 add %al,(%rax) + 19210bb: 00 00 add %al,(%rax) + 19210bd: 00 00 add %al,(%rax) + ... + +00000000019210c0 <.fini>: + 19210c0: 48 31 c0 xor %rax,%rax + 19210c3: 50 push %rax + 19210c4: 51 push %rcx + 19210c5: 52 push %rdx + 19210c6: 90 nop + 19210c7: 90 nop + +00000000019210c8 <.fini>: + 19210c8: 5a pop %rdx + 19210c9: 59 pop %rcx + 19210ca: 41 5a pop %r10 + 19210cc: 4c 09 d0 or %r10,%rax + 19210cf: c3 retq diff --git a/dataimp/dllimp/a.s b/dataimp/dllimp/a.s new file mode 100644 index 0000000..6415afc --- /dev/null +++ b/dataimp/dllimp/a.s @@ -0,0 +1,32 @@ + .file "a.c" + .section .text.startup,"x" + .p2align 4,,15 + .globl main + .def main; .scl 2; .type 32; .endef + .seh_proc main +main: +.LFB0: + .cfi_startproc + .seh_pushreg %rbx + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + .seh_stackalloc 32 + subq $32, %rsp + .cfi_def_cfa_offset 48 + .seh_endprologue + movq __imp_stdout(%rip), %rax + movl %ecx, %ebx + movq (%rax), %rcx + call fflush + movl %ebx, %eax + addq $32, %rsp + .cfi_def_cfa_offset 16 + popq %rbx + .cfi_def_cfa_offset 8 + .cfi_restore 3 + ret + .cfi_endproc +.LFE0: + .seh_endproc + .def fflush; .scl 2; .type 32; .endef diff --git a/dataimp/drctve/a.c b/dataimp/drctve/a.c new file mode 100644 index 0000000..7e59bf3 --- /dev/null +++ b/dataimp/drctve/a.c @@ -0,0 +1,7 @@ +#include + +int main(int argc, char ** argv) +{ + fflush(stdout); + return argc; +} diff --git a/dataimp/drctve/a.o b/dataimp/drctve/a.o new file mode 100644 index 0000000..da64796 Binary files /dev/null and b/dataimp/drctve/a.o differ diff --git a/dataimp/drctve/a.o.dis b/dataimp/drctve/a.o.dis new file mode 100644 index 0000000..e0ebdcf --- /dev/null +++ b/dataimp/drctve/a.o.dis @@ -0,0 +1,23 @@ + +a.o: Dateiformat pe-x86-64 + + +Disassembly of section .text.startup: + +0000000000000000
: + 0: 53 push %rbx + 1: 48 83 ec 20 sub $0x20,%rsp + 5: 89 cb mov %ecx,%ebx + 7: 48 8b 0d 00 00 00 00 mov 0x0(%rip),%rcx # e + a: R_X86_64_PC32 stdout + e: e8 00 00 00 00 callq 13 + f: R_X86_64_PC32 fflush + 13: 89 d8 mov %ebx,%eax + 15: 48 83 c4 20 add $0x20,%rsp + 19: 5b pop %rbx + 1a: c3 retq + 1b: 90 nop + 1c: 90 nop + 1d: 90 nop + 1e: 90 nop + 1f: 90 nop diff --git a/dataimp/drctve/a.out b/dataimp/drctve/a.out new file mode 100755 index 0000000..2540a3f Binary files /dev/null and b/dataimp/drctve/a.out differ diff --git a/dataimp/drctve/a.out.dis b/dataimp/drctve/a.out.dis new file mode 100644 index 0000000..e288664 --- /dev/null +++ b/dataimp/drctve/a.out.dis @@ -0,0 +1,137 @@ + +a.out: Dateiformat pei-x86-64 + + +Disassembly of section .text: + +0000000001921000 <.init>: + 1921000: 48 31 c0 xor %rax,%rax + 1921003: 50 push %rax + 1921004: 51 push %rcx + 1921005: 52 push %rdx + 1921006: 90 nop + 1921007: 90 nop + +0000000001921008 <.init>: + 1921008: 5a pop %rdx + 1921009: 59 pop %rcx + 192100a: 41 5a pop %r10 + 192100c: 4c 09 d0 or %r10,%rax + 192100f: c3 retq + +0000000001921010 <_start>: + 1921010: 48 83 ec 28 sub $0x28,%rsp + 1921014: 48 8d 05 e5 1f 00 00 lea 0x1fe5(%rip),%rax # 1923000 <.weak.__crtopt_posix._start> + 192101b: 8b 10 mov (%rax),%edx + 192101d: 48 8d 05 dc 1f 00 00 lea 0x1fdc(%rip),%rax # 1923000 <.weak.__crtopt_posix._start> + 1921024: 8b 00 mov (%rax),%eax + 1921026: 09 c2 or %eax,%edx + 1921028: 48 8b 05 5d 70 00 00 mov 0x705d(%rip),%rax # 192808c <__imp___psx_init> + 192102f: 41 89 d0 mov %edx,%r8d + 1921032: 48 89 c2 mov %rax,%rdx + 1921035: 48 8d 0d 44 00 00 00 lea 0x44(%rip),%rcx # 1921080
+ 192103c: 48 8b 05 29 70 00 00 mov 0x7029(%rip),%rax # 192806c <__IAT_start__> + 1921043: ff d0 callq *%rax + 1921045: 90 nop + 1921046: 48 83 c4 28 add $0x28,%rsp + 192104a: c3 retq + 192104b: 90 nop + 192104c: 90 nop + 192104d: 90 nop + 192104e: 90 nop + 192104f: 90 nop + +0000000001921050 <_pei386_runtime_relocator>: + 1921050: c3 retq + +0000000001921051 <_init>: + 1921051: e9 aa ff ff ff jmpq 1921000 <.init> + +0000000001921056 <_fini>: + 1921056: e9 65 00 00 00 jmpq 19210c0 <.fini> + 192105b: 90 nop + 192105c: 90 nop + 192105d: 90 nop + 192105e: 90 nop + 192105f: 90 nop + +0000000001921060 <__libc_entry_routine>: + 1921060: ff 25 06 70 00 00 jmpq *0x7006(%rip) # 192806c <__IAT_start__> + 1921066: 90 nop + 1921067: 90 nop + +0000000001921068 : + 1921068: ff 25 06 70 00 00 jmpq *0x7006(%rip) # 1928074 <__imp_fflush> + 192106e: 90 nop + 192106f: 90 nop + +0000000001921070 <__psx_init>: + 1921070: ff 25 16 70 00 00 jmpq *0x7016(%rip) # 192808c <__imp___psx_init> + 1921076: 90 nop + 1921077: 90 nop + 1921078: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) + 192107f: 00 + +0000000001921080
: + 1921080: 53 push %rbx + 1921081: 48 83 ec 20 sub $0x20,%rsp + 1921085: 89 cb mov %ecx,%ebx + 1921087: 48 8b 0d ee 6f 00 00 mov 0x6fee(%rip),%rcx # 192807c <__imp_stdout> + +000000000192108a <__fu0_stdout>: + 192108a: ee out %al,(%dx) + 192108b: 6f outsl %ds:(%rsi),(%dx) + 192108c: 00 00 add %al,(%rax) + 192108e: e8 d5 ff ff ff callq 1921068 + 1921093: 89 d8 mov %ebx,%eax + 1921095: 48 83 c4 20 add $0x20,%rsp + 1921099: 5b pop %rbx + 192109a: c3 retq + 192109b: 90 nop + 192109c: 90 nop + 192109d: 90 nop + 192109e: 90 nop + 192109f: 90 nop + +00000000019210a0 <__CTOR_LIST__>: + 19210a0: ff (bad) + 19210a1: ff (bad) + 19210a2: ff (bad) + 19210a3: ff (bad) + 19210a4: ff (bad) + 19210a5: ff (bad) + 19210a6: ff (bad) + 19210a7: ff 00 incl (%rax) + 19210a9: 00 00 add %al,(%rax) + 19210ab: 00 00 add %al,(%rax) + 19210ad: 00 00 add %al,(%rax) + ... + +00000000019210b0 <__DTOR_LIST__>: + 19210b0: ff (bad) + 19210b1: ff (bad) + 19210b2: ff (bad) + 19210b3: ff (bad) + 19210b4: ff (bad) + 19210b5: ff (bad) + 19210b6: ff (bad) + 19210b7: ff 00 incl (%rax) + 19210b9: 00 00 add %al,(%rax) + 19210bb: 00 00 add %al,(%rax) + 19210bd: 00 00 add %al,(%rax) + ... + +00000000019210c0 <.fini>: + 19210c0: 48 31 c0 xor %rax,%rax + 19210c3: 50 push %rax + 19210c4: 51 push %rcx + 19210c5: 52 push %rdx + 19210c6: 90 nop + 19210c7: 90 nop + +00000000019210c8 <.fini>: + 19210c8: 5a pop %rdx + 19210c9: 59 pop %rcx + 19210ca: 41 5a pop %r10 + 19210cc: 4c 09 d0 or %r10,%rax + 19210cf: c3 retq diff --git a/dataimp/drctve/a.s b/dataimp/drctve/a.s new file mode 100644 index 0000000..b83280b --- /dev/null +++ b/dataimp/drctve/a.s @@ -0,0 +1,31 @@ + .file "a.c" + .section .text.startup,"x" + .p2align 4,,15 + .globl main + .def main; .scl 2; .type 32; .endef + .seh_proc main +main: +.LFB0: + .cfi_startproc + .seh_pushreg %rbx + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + .seh_stackalloc 32 + subq $32, %rsp + .cfi_def_cfa_offset 48 + .seh_endprologue + movl %ecx, %ebx + movq stdout(%rip), %rcx + call fflush + movl %ebx, %eax + addq $32, %rsp + .cfi_def_cfa_offset 16 + popq %rbx + .cfi_def_cfa_offset 8 + .cfi_restore 3 + ret + .cfi_endproc +.LFE0: + .seh_endproc + .def fflush; .scl 2; .type 32; .endef -- cgit v1.2.3