https://forum.dlang.org/thread/ddckhvcxlyuvuiyaz...@forum.dlang.org is similar 
to what I want to do, but the code by Adam cannot be used when using Better C 
(I assume slicing isn't supported).

I have the following code:

environment.d

    public __gshared header* GPT_header;
    public __gshared partition_entry[128] GPT_entries;

main.d

    GPT_header = cast(header*)0x00007e00;
    *(GPT_entries).ptr = *(cast(partition_entry*)0x00008000);

Disassembled, the code from main.d looks like this:

mov     ds:_D4boot11environment10GPT_headerPSQBg3gpt6header, 7E00h
mov     esi, 8000h
mov edi, offset _D4boot11environment11GPT_entriesG128SQBk3gpt15partition_entry
mov     ecx, 20h
rep movsd

So GPT_header points to 0x7e00 as desired, but for GPT_entries it copies the first array element to a different location and makes it point to that location instead of 0x8000.

I should point out that I only have a vague idea of what I'm doing, I tried things until it compiled and worked (at first glance). If there are any docs that properly explain the casting of pointers, I'd appreciate the links.

Reply via email to