FASM dll can't run in C (GCC) executable and return 0xC000007B exit code

0

i have a question about DLL. i want to create a DLL in Assembly with FASM and this is my source code:

format PE64 DLL GUI 5.0
entry DllMain

include 'EXPORT.INC'

SECTION '.test' CODE READABLE EXECUTABLE

DllMain:
        mov     eax, 1
        ret

myfunction:
        mov     eax, 112
        ret

SECTION '.edata' EXPORT DATA READABLE

        export 'mydll.dll', \
               myfunction, 'myfunction'

section '.reloc' fixups data readable discardable   

here i have a function named 'myfunction' which returns 112 in FASM, there is no problem for creating this DLL and the created DLL size is 2Kb ...

now i want to link this library to my C program (GCC) so this is my CMAKE :

cmake_minimum_required(VERSION 3.15)
project(untitled6 C)

set(CMAKE_C_STANDARD 11)

add_executable(untitled6 main.c)

set(EXECUTABLE_OUTPUT_PATH "../")

target_link_libraries(untitled6 "D:\\untitled6\\mydll.dll")

and this is my C code:

#include <stdio.h>

int myfunction();

int main() {

    printf("(%d)", myfunction());
    return 0;
}

this source compiled success too but when i want to run my C (executable), i get this exit code (Process finished with exit code -1073741701 (0xC000007B))

yes ... my C program is 64-bit too (mingw64)...

what is the problem ? why my C program can't run the function of my DLL ?

question 2 : why FASM generated a 2kb DLL and when i want to create a DLL with GCC (C language), with the same function, my DLL size is about 48Kb ??? !!!

gcc
dll
fasm
asked on Stack Overflow Dec 28, 2019 by ELHASKSERVERS

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0