Oh, thanks a lot!!

With a little change all work!

look:

struct IMAGE_DOS_HEADER {
        WORD e_magic,
             e_cblp,

//...

void main() {
        import std.stdio;
        import std.file;
        import core.stdc.string;
        
        auto dosh = cast(PIMAGE_DOS_HEADER)image.ptr;
        dosh.e_magic = ('Z' << 8) + 'M';

        immutable stub = x"b8 01 4c cd 21";
        memcpy(&image[IMAGE_DOS_HEADER.sizeof],stub.ptr, stub.length);

        std.file.write("a.exe", image);
}

Reply via email to