GetMapFileAddress and overloads

delphi package - automated exception handling
Post Reply
obones
Posts: 66
Joined: Fri May 15, 2009 11:47 am

GetMapFileAddress and overloads

Post by obones »

Hello,

I'm using the following code to retrieve the address of a procedure:

Code: Select all

  FScrollIntoView := GetMapFileAddress(GetModuleName(0), 'VirtualTrees', 'TBaseVirtualTree.ScrollIntoView');
This works fine for methods that do not have overloads. However, as is the case with the above method, there are tow versions of the method:

Code: Select all

function ScrollIntoView(Node: PVirtualNode; Center: Boolean; Horizontally: Boolean = False): Boolean; overload;
function ScrollIntoView(Column: TColumnIndex; Center: Boolean; Node: PVirtualNode = nil): Boolean; overload;
Right now, GetMapFileAddress returns the first overload address, but I feel it is just "pure luck" and if I'm interested in the second one, I'm lost on how to do that.
I tried looking at the code inside madMapFile, but nothing obvious jumped at me. Would you have any suggestion?

Regards
Olivier
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: GetMapFileAddress and overloads

Post by madshi »

You can get yourself an TMapFile class instance, e.g. using FindMapFile() or LoadMapFile(), as explained in the documentation. Caution: Do NOT free it!!

Then you can use the following undocumented method:

Code: Select all

function TMapFile.FindPublic(index: integer) : TMfPublic;
Simply loop from index 0 up to infinite, until "result.IsValid = false". This way you can enumerate all public functions/methods in the map file. Of course it's kinda ugly and will be slow(ish). But hey, it should work.
obones
Posts: 66
Joined: Fri May 15, 2009 11:47 am

Re: GetMapFileAddress and overloads

Post by obones »

Yes, you are right, I could basically copy what FindAddress() is doing.

Looking at the content of FPItems, I can see that there are two entries for ScrollIntoView, but I don't see any indications as to what parameters they accept.
I was kind of expecting suffixes like $qqrv, $bctr$qqrp and the like, but it seems they are stripped out of the embedded MAP file.

I'll assume the overloads appear in this list in the order they are declared in the code, which seems valid for the time being.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: GetMapFileAddress and overloads

Post by madshi »

Yes, parameters are stripped, if they're there in the first place. Listing function parameters didn't seem very useful to me. I understand it might be useful for overloaded functions, but really, the line number should already tell you which of the overloaded functions a callstack item is referring to.
obones
Posts: 66
Joined: Fri May 15, 2009 11:47 am

Re: GetMapFileAddress and overloads

Post by obones »

Yes, line number helps.

As to stripping parameters, maybe this could only be done if there are no overloads?
I mean, I don't mind them and this way, inside bug reports I could identify more clearly which one was called.
Post Reply