as the title says I am facing a problem on compiling a Delphi XE2 project with x64 compiler witch contains ASM code. When I try to compile it I get error "Unsupported language feature: 'ASM'".
I tried to remove delphi code from procedure witch contains ASM code then I get "Invalid combination of opcode and operands".
Here is some part of the code..
type
TDllLoadInfo = record
Module: pointer;
EntryPoint: pointer;
end;
TGetProcAddrExInfo = record
pExitThread: pointer;
pGetProcAddress: pointer;
pGetModuleHandle: pointer;
lpModuleName: pointer;
lpProcName: pointer;
end;
TInjectLibraryInfo = record
pLoadLibrary: pointer;
lpModuleName: pointer;
pSleep: pointer;
end;
procedure DllEntryPoint(lpParameter: pointer); stdcall;
var
LoadInfo: TDllLoadInfo;
begin
LoadInfo := TDllLoadInfo(lpParameter^);
asm
xor eax, eax
push eax
push DLL_PROCESS_ATTACH
push LoadInfo.Module
call LoadInfo.EntryPoint
end;
end;
procedure GetProcAddrExThread(lpParameter: pointer); stdcall;
var
GetProcAddrExInfo: TGetProcAddrExInfo;
begin
GetProcAddrExInfo := TGetProcAddrExInfo(lpParameter^);
asm
push GetProcAddrExInfo.lpModuleName
call GetProcAddrExInfo.pGetModuleHandle
push GetProcAddrExInfo.lpProcName
push eax
call GetProcAddrExInfo.pGetProcAddress
push eax
call GetProcAddrExInfo.pExitThread
end;
end;
procedure InjectLibraryThread(lpParameter: pointer); stdcall;
var
InjectLibraryInfo: TInjectLibraryInfo;
begin
InjectLibraryInfo := TInjectLibraryInfo(lpParameter^);
asm
push InjectLibraryInfo.lpModuleName
call InjectLibraryInfo.pLoadLibrary
@noret:
mov eax, $FFFFFFFF
push eax
call InjectLibraryInfo.pSleep
jmp @noret
end;
end;
Is there any way to compile this project without getting any error or convert asm code to delphi/pascal? Thanks for your time. Btw, I don't know ASM.
You cannot use inline assembly inside of a non-assembly procedure in 64-bit, only in 32-bit. This is clearly stated in Embarcadero's documentation:
Converting 32-bit Delphi Applications to 64-bit Windows | Inline Assembly code
In your example, there is no reason to use inline assembly at all. You can (and should) use pure Pascal code instead to support both 32bit and 64bit: