|
-
Apr 2nd, 2018, 12:28 PM
#17
Re: AddressOf for Class Methods (and other VTable exploration)?
I'll jump in here too, and show some of my continuing ignorance.
I feel that I could possibly get the address of a class method (Sub or Function) with a bit of work. However, it seems that there are two additional problems:
1) When you do that, you're not necessarily guaranteed that the object will stay instantiated. It was probably instantiated when you got the address, because I wouldn't know another way to do it without using ObjPtr, and ObjPtr will be zero unless it's instantiated. But again, there's no guarantee that it'll stay instantiated. And, if it's not instantiated, I've got no idea where local (possibly even Static) and/or module level variables would be created. It feels like crash-time to me.
2) And this may be even more important. I'm not totally on-top of this, but I thought the calling convention for methods of objects was different than the calling convention for standard BAS methods. If that's the case, nothing is going to work correctly.
And, as Olaf says, if it's a callback procedure, it probably shouldn't be in a class anyway. Are you trying to possibly have several instantiations of a class, each with its own callback procedure? To my eyes, this would still be done better in a BAS module, and possibly let Collections take care of different variables for the callback procedures. Personally, I always use ComCtl32 to do my subclassing. If what I need to store wouldn't fit into dwRefData, I'd use a Collection. And callbacks, hooks, enumerations typically have a similar variable to dwRefData.
Good Luck,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|