Применяю хак: объявляю дополнительную переменную, в которую записываю адрес.
Неэлегантно. Бесит.
- Код: Выделить всё
procedure _AllocateThreadExceptionState(thread_title: PUnicodeChar); cdecl;
var
pes: PMotherSehState;
ssaddr: ptruint;
begin
//no try block. If *this* simplest thing crashes it means things are already FUBAR.
pes:= GetExceptionState();
FillChar(pes^, sizeof(pes^), 0);
pes^.ThreadId:= GetCurrentThreadId();
pes^.IsModuleThread:= true;
if Assigned(thread_title) then pes^.ThreadTitle:= PUnicodeCharToUnicodeString(thread_title);
ssaddr:= ptruint(@pes^.StackSegment);
{$ifdef cpu64}
asm
push ax
push rsi
mov rsi, qword[ssaddr]
mov ax, ss
mov word[rsi], ax
pop rsi
pop ax
end;
{$else}
asm
push ax
push esi
mov esi, dword[ssaddr]
mov ax, ss
mov word[esi], ax
pop esi
pop ax
end;
{$endif}
end;