Re: How to patch overload function/method?



Chau Chee Yang a écrit :
I am confuse here. There seems to be 2 ways of patching:

1. To Patch function or procedure
2. To Patch methods in class

An unit function can be represented as a single pointer (the address of the code), an object function need 2 pointers to be stored (the instance of the object and the address of the code - this record is called a closure). That why you cannot assign an unit function to an object event and vise-versa:

type
TMyObjectFunc = procedure of object; // this type is a record of 2 pointers
TMyUnitFunc = procedure; // this type is a single pointer

While patching an object method, you just want to patch its code, not its instance, that's why you'll have to select the Code field :)

- Florent
.