AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Adresse eine Funktion / Prozedur ermitteln

Adresse eine Funktion / Prozedur ermitteln

Ein Thema von Fussball-Robby · begonnen am 15. Jun 2008 · letzter Beitrag vom 10. Dez 2013
Antwort Antwort
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Re: Adresse eine Funktion / Prozedur ermitteln

  Alt 15. Jun 2008, 16:03
*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
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
static_cast

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

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
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: Adresse eine Funktion / Prozedur ermitteln

  Alt 10. Dez 2013, 14:59
Hallo,

Also bisher nicht. Es sollte in 64Bit auch machbar sein, aber ich weiß halt nicht ob da die Parameter genauso abgelegt werden wie bei 32 Bit und die Register müssten angepasst werden..

Also wenn sich jemand freiwillig dran setzen will, dann kann er das gerne tun.
Generell würd ichs auch machen aber ich weiß nicht ob ich die Zeit dazu aufbringen kann/will.

Müsste mich auch erstmal wieder bisschen in ASM einarbeiten^^
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.342 Beiträge
 
Delphi 12 Athens
 
#4

AW: Adresse eine Funktion / Prozedur ermitteln

  Alt 10. Dez 2013, 15:00
Wenn ich es richtig im Kopf hab, dann gibt es in Win64 kein Inline-Assembler mehr.

- entweder die Funktion in Pascal umwandeln (wird nicht einfach)
- oder diese "komplett" als Assembler, also auch proc := MethodAddress(AMethod); hi := High(Params); (natürlich via IFDEFs für x86 und x64)
- oder mal versuchen das über die neue RTTI zu lösen
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
static_cast

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

AW: Adresse eine Funktion / Prozedur ermitteln

  Alt 10. Dez 2013, 16:58
Hallo und danke euch zwei für die Antworten

Dachte mir schon das es nicht so einfach ist, aber fragen kostet ja nichts ^^ und da ich jetzt auch kein ASM-Crack bin versuch ich das dann wohl anders umzusetzen, oder ich lass es so und es gibt halt kein x64 build

Viele Grüße
Daniel
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
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:24 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz