Page 1 sur 1

Gets the address of the calling function

Publié : mer. 24/févr./2016 14:49
par zgneng1

Code : Tout sélectionner

Global p.l

Procedure pp1()
  
  ; I want To get the one who calls me
  
  ; I want To get the one who calls me
  
  ; I want To get the one who calls me
  
  ; I want To get the one who calls me

!mov [v_p],ebp 

Debug  Hex(p+4) ;ERRO


EndProcedure


Procedure pp2()
  
  
  pp1()
  
  
EndProcedure


Debug "address:" + Hex(@pp2())
                                   
pp2()
@pp2() unknown


Get the call pp2() function address


Gets the address of the calling function

or (PP2) the caller.


Can not use @

Re: Gets the address of the calling function

Publié : mer. 24/févr./2016 15:12
par falsam
Ce sujet est aussi posté sur le forum anglophone.
This topic is also placed on the English forum.

:arrow: http://www.purebasic.fr/english/viewtop ... 07#p483107

Re: Gets the address of the calling function

Publié : mer. 24/févr./2016 19:20
par Ollivier

Code : Tout sélectionner

! pop eax
! push eax

! mov [p_v], eax

Re: Gets the address of the calling function

Publié : mer. 24/févr./2016 19:49
par Ollivier
(ça, c'était l'adresse de l'instruction appelant)


Et ça c'est l'adresse de l'instruction appelant la fonction contenant l'instruction appelant:

Code : Tout sélectionner

! pop ebx
! pop eax
! push eax
! push ebx

! mov [p_v], eax
Après ben notre ami va se débrouiller pour chercher l'offset de l'adresse (de -8 à 7)

Code : Tout sélectionner

For Offset = -8 To 7

InvAddr = PeekI( p + Offset)
NormAddr = InvertAddress(InvAddr) ; y fra 1 proc pour inverser les octets FIFO/LIFO (Abcd en dcba ou cdab, j'en sais rien duquel des 3 et j'avoue, m'en fous...)
debug @pp2() + "    =?=     " + NormAddr
Next
Ptêt qu'un jour je déscellerai ce carton mais pour l'instant chuis bien sans!

Add: merd corrigé le v en p!