How do i get the address of the variable holding an event handler?
e.g.
TExample = class(TObject)
private
FOnChange: TNotifyEvent;
end;
i want the address of the FOnChange
private member, event handler, variable.
Why?
i'm trying to figure out who is overwriting my FOnChange
handler variable with junk.
i am stepping through code:
if Assigned(FOnChange) then
FOnChange(Self);
No event handler is ever assigned, and for a while the FOnChange
variable is nil
in the Watch Window:
@FOnChange: nil
Addr(FOnChange): nil
But later the FOnChange
variable is getting turned into junk:
@FOnChange: $2C
Addr(FOnChange): $2C
So i want to watch the FOnChange
variable in data pane of the CPU window, so that i can watch it to from:
00410018 00000000
to
00410018 0000002C
Except i don't know the address of FOnChange
; i just made up the $410018
.
How can i find the address of an event variable?
Things i've tried
Watch List
OnChange: nil
@OnChange: nil
@@OnChange: Variable required
@FOnChange: nil
Assigned(OnChange): False
Assigned(FOnChange): False
@@FOnChange: $253B588
addr(addr(FOnChange)): $253B588
Alt+F5
- OnChange:
OnChange: TNotifyEvent $253B588
- FOnChange: Error inspecting 'FOnChange': expression error
- Self.FOnChange: Error inspecting 'Self.FOnChange': expression error
- @OnChange:
@OnChange: Pointer $253B588
- @@OnChange: Error inspecting '@@OnChange': expression error
- @FOnChange:
@FOnChange: Pointer $253B588
- @@FOnChange:
@@FOnChange: ^Untyped (no address)
Data: @@FOnChange $253B588`
The concensus seems to be at address 0x253B588
.
Yet when i run some sample code:
MyControl1.OnChange := TheOnChangeHandler;
That turns into:
mov edx,[ebp+$08] ;move stack variable $08 into edx
mov [eax+$00000208],edx ;and then into offset $208 of my control
mov edx,[ebp+$0c] ;move stack variable $0c into edx
mov [eax+$0000020c],edx ;and then into offset $20c of my control
No wonder i can't find an address of FOnChange
, it's two addresses!