Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

How to export function? #28

Closed
tagcode opened this issue Jul 27, 2022 · 2 comments
Closed

How to export function? #28

tagcode opened this issue Jul 27, 2022 · 2 comments

Comments

@tagcode
Copy link

tagcode commented Jul 27, 2022

[DllImport] imports a function from another .wasm binary, but how to export one?

wasm-objdump reveals only "_start."

wasm-objdump -x -j export ConsoleApp11.wasm

ConsoleApp11.wasm:      file format wasm 0x1

Section Details:

Export[6]:
 - memory[0] -> "memory"
 - func[24] <_start> -> "_start"
 - func[7565] <free> -> "free"
 - func[7563] <malloc> -> "malloc"
 - global[1] -> "__heap_base"
 - global[2] -> "__data_end"
@tagcode tagcode closed this as completed Jul 27, 2022
@Andres6936
Copy link

Solution?

@Neo-vortex
Copy link

Neo-vortex commented Oct 19, 2023

Solution?

you should use a combination of C and C# :

__attribute__((__export_name__("my_function")))
void greet()
{
    _start();
    if (!method_HandleIncomingRequest) {

        method_HandleIncomingRequest = lookup_dotnet_method("ConsoleApp5.dll", "main", "MainEntry", "Printsomething", -1);

        assert(method_HandleIncomingRequest);

    }


    MonoObject* out_exc = NULL;
    mono_wasm_invoke_method (method_HandleIncomingRequest, NULL, NULL, &out_exc);
    assert (!out_exc);

    
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants