Skip to content

[Question] How to get DLLExport work correctly, even when debugging #271

@batzen

Description

@batzen

Hi there,

i am not sure if i am doing something wrong or if it's an issue with dnlib.
I don't know much about IL code and this is my first try to do IL code manipulation through dnlib.
I also tried to understand the code in PatchSdataBytesBlob from ManagedExportsWriter but i don't even understand whats done there :-(.

Using the way to write dllexports from the readme (+ some more code from me) causes the following sdata to be written:

.data D_00004000 = bytearray (
                 04 00 00 06 00 00 00 00) 

This causes the MDA (managed debugging assistant) to trap access violations while trying to call the exported method(s).
Changing the sdata to (for an x64 image)

.data D_00004000 = int64(0)

or to (for an x86 image)

.data D_00004000 = int32(0)

fixes the AC issues.

Am i thinking this wrong, or does dnlib something wrong here?

A project showcasing/reproducing what i am doing can be found here: https://github.com/batzen/NativeToManagedTest
To repro just clone the project, build and run the WPFTestApp.
If you run it from within visual studio and click the button "Call managed native" while having the MDA activated (from the exception settings) you should see a "FatalExecutionEngineError" being thrown.

If you need any more details from me feel free to ask. I am also on gitter (https://gitter.im/batzen), if that helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions