SImple C++ code to D

Alexandre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 13 19:40:48 PDT 2014


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);
}


More information about the Digitalmars-d-learn mailing list