From 3d2f64674721c10c953968f86dd8da7e3c2c512f Mon Sep 17 00:00:00 2001 From: CleverMouse Date: Tue, 29 Nov 2016 17:54:32 +0000 Subject: [PATCH] example of forwarded exports in PE git-svn-id: svn://kolibrios.org@6768 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../examples/pe_forwarded_export/Tupfile.lua | 5 ++++ .../pe_forwarded_export/forwarded.asm | 28 +++++++++++++++++++ .../pe_forwarded_export/forwarder.asm | 11 ++++++++ .../examples/pe_forwarded_export/main.asm | 15 ++++++++++ 4 files changed, 59 insertions(+) create mode 100644 programs/develop/examples/pe_forwarded_export/Tupfile.lua create mode 100644 programs/develop/examples/pe_forwarded_export/forwarded.asm create mode 100644 programs/develop/examples/pe_forwarded_export/forwarder.asm create mode 100644 programs/develop/examples/pe_forwarded_export/main.asm diff --git a/programs/develop/examples/pe_forwarded_export/Tupfile.lua b/programs/develop/examples/pe_forwarded_export/Tupfile.lua new file mode 100644 index 0000000000..e55e5f2336 --- /dev/null +++ b/programs/develop/examples/pe_forwarded_export/Tupfile.lua @@ -0,0 +1,5 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +ROOT="../../../.." +tup.rule("main.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.exe") +tup.rule("forwarder.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.dll") +tup.rule("forwarded.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.dll") diff --git a/programs/develop/examples/pe_forwarded_export/forwarded.asm b/programs/develop/examples/pe_forwarded_export/forwarded.asm new file mode 100644 index 0000000000..e221d5ecde --- /dev/null +++ b/programs/develop/examples/pe_forwarded_export/forwarded.asm @@ -0,0 +1,28 @@ +format PE console 0.8 DLL at 420000h +include '../../../proc32.inc' +include '../../../import.inc' +include '../../../export.inc' + +forward_by_name: + invoke con_write_asciiz, forward_by_name_msg + ret + +forward_by_ordinal: + invoke con_write_asciiz, forward_by_ordinal_msg + ret + +forward_by_name_msg db 'Hello from forward_by_name!',13,10,0 +forward_by_ordinal_msg db 'Hello from forward_by_ordinal!',13,10,0 + +align 4 +data import +library console, 'console.dll' +import console, con_write_asciiz, 'con_write_asciiz' +end data + +align 4 +data export +export 'forwarded.dll', \ + forward_by_name, 'forward_by_name', \ + forward_by_ordinal, 'forward_by_ordinal' +end data diff --git a/programs/develop/examples/pe_forwarded_export/forwarder.asm b/programs/develop/examples/pe_forwarded_export/forwarder.asm new file mode 100644 index 0000000000..4fab80deab --- /dev/null +++ b/programs/develop/examples/pe_forwarded_export/forwarder.asm @@ -0,0 +1,11 @@ +format PE console 0.8 DLL at 410000h +include '../../../export.inc' + +align 4 +data export +export 'forwarder.dll', \ + func1, 'func1', \ + func2, 'func2' +func1 db 'forwarded.forward_by_name',0 +func2 db 'forwarded.#2',0 +end data diff --git a/programs/develop/examples/pe_forwarded_export/main.asm b/programs/develop/examples/pe_forwarded_export/main.asm new file mode 100644 index 0000000000..b9c5d1b8b2 --- /dev/null +++ b/programs/develop/examples/pe_forwarded_export/main.asm @@ -0,0 +1,15 @@ +format PE console 0.8 +include '../../../proc32.inc' +include '../../../import.inc' + invoke func1 + invoke func2 + invoke con_exit, 0 + xor eax, eax + ret + +align 4 +data import +library forwarder, 'forwarder.dll', console, 'console.dll' +import forwarder, func1, 'func1', func2, 'func2' +import console, con_exit, 'con_exit' +end data