Plugins x64. Invalid combination of opcode and operands

Questions, downloads, issues related to plugins for Enigma Protector
Post Reply
Alexeynico
Posts: 12
Joined: Tue Sep 05, 2023 8:25 am

Plugins x64. Invalid combination of opcode and operands

Post by Alexeynico »

Доброго дня!
Я пытаюсь перевести плагины x86 в x64. Однако для участков в ассемблере возникает ошибка:
[dcc64 Error] outputdebugstring.dpr(42): E2116 Invalid combination of opcode and operands
Это касается строки "push eax".
Подскажите, могу ли я обойтись без ассемблера, как мне переписать на delphi отображение сообщения и выход из программы на x64?
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: Plugins x64. Invalid combination of opcode and operands

Post by Enigma »

Для x64 набор регистров другой, например вместо push eax надо использовать push rax.

Но я советую просто удалить все эти ассмеблерные инструкции и завершать программу с помощью ExitProcess(1).
Alexeynico
Posts: 12
Joined: Tue Sep 05, 2023 8:25 am

Re: Plugins x64. Invalid combination of opcode and operands

Post 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;
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: Plugins x64. Invalid combination of opcode and operands

Post by Enigma »

Верно, но давайте лучше так:

Code: Select all

procedure ExitWithMessage;
begin
	MessageBox(0, 'Сообщение об ошибке', 'Ошибка!', MB_ICONERROR);
	ExitProcess(1);
	raise Exception.Create('');
end;
Alexeynico
Posts: 12
Joined: Tue Sep 05, 2023 8:25 am

Re: Plugins x64. Invalid combination of opcode and operands

Post by Alexeynico »

Спасибо!
Post Reply