Gets the address of the calling function

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
zgneng1
Messages : 2
Inscription : mer. 17/févr./2016 11:42

Gets the address of the calling function

Message 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 @
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Gets the address of the calling function

Message 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
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Re: Gets the address of the calling function

Message par Ollivier »

Code : Tout sélectionner

! pop eax
! push eax

! mov [p_v], eax
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Re: Gets the address of the calling function

Message 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!
Répondre