Re: Thiscall



Avatar Zondertau wrote:
Indeed it looks like the function is not perofrming a check for that
case.

Try this one:

function Thiscall(ClassRef, ProcRef: Pointer; Params: array of Longword): LongWord;
asm
PUSH EBX
MOV EBX, [EBP+8]
TEST EBX, EBX
JS @@ParamsDone


  LEA        ECX,      [ECX+EBX*4]
@@ParamLoop:
  PUSH       DWORD PTR [ECX]
  LEA        ECX,      [ECX-4]
  DEC        EBX
  JNS        @@ParamLoop

@@ParamsDone:
  MOV        ECX,      [EBP-8]
  CALL       EDX
  POP        EBX
end;

Still having problems. Calling your routine with:

thiscall(classref,procref,[200,200]);

Gives:

exception message : Access violation at address 004F492B in module '<module name...>'. Write of address 00003D8C.

While the code I've written as a test performs fine:

asm
 mov ecx, classref
 mov edx, procref
 mov eax, 200
 push eax
 mov eax, 200
 push eax
 call edx
end;

Cheers,
Nicholas Sherlock
.



Relevant Pages