Einzelnen Beitrag anzeigen

static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#33

AW: Re: Adresse eine Funktion / Prozedur ermitteln

  Alt 10. Dez 2013, 13:25
Hallo,

gibt es von der "RunMethod" eine x64 Implementierung die auch mit XE5 laufen würde? Ich verwende Sie für diverse zwecke in meiner Anwendung, jedoch wollte ich diese nun in XE5 als 64Bit kompilieren und komme da nicht voran.

Viele Grüße
Daniel

*hust* Wie bestellt ist hier auch schon der neue Code *g*

Delphi-Quellcode:
class procedure TProceduren.RunMethod(AMethod: String;
  Params: array of Const);
var proc: Pointer;
    hi: Integer;
    i, off: Integer;
    param: Byte;
begin
  proc := MethodAddress(AMethod);
  hi := High(Params);
  asm
    mov param,0
    mov i,0
    @loop:
      mov eax,i
      cmp eax,hi
      jg @loopend
        imul eax,i,8
        add eax,4
        mov off,eax
         
        mov eax,[Params]
        add eax,off
        movzx ax,byte ptr [eax]
         
        cmp ax,vtExtended
        je @EditParam
          inc param
          cmp param,2
          jle @NextLoop
        @EditParam:
          sub off,4
          cmp ax,vtExtended
          jne @NoExt
            mov eax,[Params]
            add eax,off
            mov eax,[eax]
            movzx edx, word ptr [eax+$08]
            push edx
            push [eax+$04]
            push [eax]
            jmp @NextLoop
          @NoExt:
            mov eax,[Params]
            add eax,off
            push [eax]
        @NextLoop:
          inc i
          jmp @loop
    @loopend:

    mov param,0
    mov i,0
    @loop2:
      mov eax,i
      cmp eax,hi
      jnl @loop2end
        imul eax,i,8
        add eax,4
        mov off,eax
        
        mov eax,[Params]
        add eax,off
        mov eax,[eax]

        cmp eax,vtExtended
        je @NextLoop2
        inc param

        cmp param,1
        je @edx
        cmp param,2
        je @ecx
        jmp @loop2end

        @edx:
          sub off,4
          mov eax,[Params]
          add eax,off
          mov edx,[eax]
          jmp @NextLoop2
        @ecx:
          sub off,4
          mov eax,[Params]
          add eax,off
          mov ecx,[eax]
          jmp @Loop2End
      @NextLoop2:
        inc i
        jmp @loop2
    @loop2end:

    mov eax,self
    call proc
  end;
end;
Int64's werden jedoch noch nicht unterstützt. Ich arbeite aber daran

Gruß
Neutral General
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat