Page 1 of 1

Plugins x64. Invalid combination of opcode and operands

Posted: Mon Sep 11, 2023 7:34 am
by Alexeynico
Доброго дня!
Я пытаюсь перевести плагины x86 в x64. Однако для участков в ассемблере возникает ошибка:
[dcc64 Error] outputdebugstring.dpr(42): E2116 Invalid combination of opcode and operands
Это касается строки "push eax".
Подскажите, могу ли я обойтись без ассемблера, как мне переписать на delphi отображение сообщения и выход из программы на x64?

Re: Plugins x64. Invalid combination of opcode and operands

Posted: Mon Sep 11, 2023 7:43 am
by Enigma
Для x64 набор регистров другой, например вместо push eax надо использовать push rax.

Но я советую просто удалить все эти ассмеблерные инструкции и завершать программу с помощью ExitProcess(1).

Re: Plugins x64. Invalid combination of opcode and operands

Posted: Mon Sep 11, 2023 8:39 am
by Alexeynico
Верно ли будет заменить так?
Вот это:

Code: Select all

procedure ExitWithMessage; assembler;
asm
  // Clear some addresses in stack
  mov ecx, 5
  @clear_loop:
  dec ecx
  mov dword ptr [ecx * 4 + esp], 0
  cmp ecx, 0
  jnz @clear_loop
  // Parameter for ExitProcess
  push 0
  // Parameters for MessageBoxA
  push MB_ICONERROR
  push Title
  push Text
  push 0
  // Return address of MessageBox that points to ExitProcess
  lea eax, ExitProcess
  push eax
  jmp MessageBoxA
end;
на это:

Code: Select all

procedure ExitWithMessage;
begin
	MessageBox(0, 'Сообщение об ошибке', 'Ошибка!', MB_ICONERROR);
	ExitProcess(0)
end;

Re: Plugins x64. Invalid combination of opcode and operands

Posted: Mon Sep 11, 2023 10:24 am
by Enigma
Верно, но давайте лучше так:

Code: Select all

procedure ExitWithMessage;
begin
	MessageBox(0, 'Сообщение об ошибке', 'Ошибка!', MB_ICONERROR);
	ExitProcess(1);
	raise Exception.Create('');
end;

Re: Plugins x64. Invalid combination of opcode and operands

Posted: Mon Sep 11, 2023 10:34 am
by Alexeynico
Спасибо!