FTP | CCD | Buscar | Trucos | Trabajo | Foros |
#1
|
|||
|
|||
urgando las VMTs
En este otro hilo, Al González hizo algunos planteamientos que involucraban las famosas táblas de métodos virtuales (VMT's a partir de ahora).
No está muy claro este tema ya que no hay documentación oficial (al menos no la conozco). Lo poco que se conoce es por el Unit System.pas y por lo que algunos programadores han investigado haciendo un poco de ingeniería inversa. Sé que no es bueno andar por lugares tan oscuros como la VMT ya que no sólo hay poco información sino que son muy suceptibles a los cambios sin aviso previo (ni posterior)... De todos modos, muchas veces no hay otra opción. Cuando es así, no queda otra que manejarse con cautela y tener en cuenta las diferencias entre versiones. De hecho, en la versión 2009 se han introducido modificaciones en la VMT... A continuación pongo alguno links que tenía agendados y que estaban esperando a este momento. http://hallvards.blogspot.com/2004/0...id-object.html http://hallvards.blogspot.com/2006/0...structure.html http://hallvards.blogspot.com/2006/0...vmt-calls.html http://hallvards.blogspot.com/2007/0...s-part-ii.html Ya bien empapados en el tema vamos a lo nuestro: Miré código que tenía, algo de Hallvards, algo de GExperts y algo de JCL y terminé con lo siguiente: Tenía un unit dedicado al RTTI así que ustedes pueden tener uno llamado RttiUtils.pas o como prefieran. lo que nos compete va a continuación:
La respuesta la pregunta de Al se responde con la función GetVirtualMethodCount... aunque, como es de esperar, sólo devuelve los métodos declarados con la directiva "virtual", para los que estén declarados con "dinamic" ya es otro asunto. A propósito, los métodos virtuales y abstractos (sin implementación por decirlo de algún modo), apuntan (tal como lo decía Al), a la función _AbstractError pero indirectamente... o sea que se puede hookear. El puntero a interceptar está (como no podía ser de otra manera) en el System.pas: AbstractErrorProc: procedure; { Abstract method error handler } Allí, entonces, podremos colgar nuestra propia rutina para manejar el error, e inclusive llamar desde allí a la original. sólo bastará declarar la función... procedure CustomAbastractError; begin raise EAbstractError.Create('my custom abstract error'); end; y asignarla: AbstractErrorProc := CustomAbastractError; Última edición por poyo fecha: 31-01-2009 a las 00:07:38. Razón: errores |
Herramientas | Buscar en Tema |
Desplegado | |
|
|
|