Re: API CallBacks Using an Object's Procedure
Hello, I am the original author of GetClassProcAddress.
I recently developed a small IDE plugin, and accidentally came across this thread while searching for data. I noticed you are discussing how to retrieve function addresses in class modules – I once spent quite a bit of time figuring this out myself. If you'd like me to offer any advice, please feel free to let me know.
Funny enough, since I developed this technology around 15 or 16 years ago, some details are a bit fuzzy now. However, when I write small programs for my own use, I still use iSucClass.cls (implemented with GetClassProcAddress) for subclassing. So I still remember the core technical principles, and I have my original blog post that can help jog my memory.
I'm really glad to register on this forum for the first time, and also found such a comprehensive WinAPI declaration library!
Re: API CallBacks Using an Object's Procedure
Quote:
Originally Posted by
nbdld
Hello, I am the original author of GetClassProcAddress.
I recently developed a small IDE plugin, and accidentally came across this thread while searching for data. I noticed you are discussing how to retrieve function addresses in class modules – I once spent quite a bit of time figuring this out myself. If you'd like me to offer any advice, please feel free to let me know.
Funny enough, since I developed this technology around 15 or 16 years ago, some details are a bit fuzzy now. However, when I write small programs for my own use, I still use iSucClass.cls (implemented with GetClassProcAddress) for subclassing. So I still remember the core technical principles, and I have my original blog post that can help jog my memory.
I'm really glad to register on this forum for the first time, and also found such a comprehensive WinAPI declaration library!
I appreciate your offer, but I believe it's all figured out in the above, with, hopefully, self-explanatory comments for anyone's edification. Also, it's not quite as simple as getting the address of a class procedure. There's also the issue of 'implicit' arguments on the stack when calling a class's procedure, which is all discussed in the above ... specifically in the thunk included in the above.
Re: API CallBacks Using an Object's Procedure
good job :thumb:
I still roughly remember the situation being like this:
Retrieving the address isn’t the hard part. What you get from the vtable is the address of a jump table – it’s a jmp class.xxx instruction.
You can read the value of this class.xxx and then fetch the exact final address.
However, you can’t call it directly due to the presence of implicit parameters. You have to construct a dedicated forwarding function through a thunk.
A small piece of advice:
From my experience, it’s best to store this thunk function in a module-level array variable.
byebye :wave: