GetMapFileAddress and overloads

delphi package - automated exception handling

GetMapFileAddress and overloads

Postby obones » Mon Dec 17, 2018 9:48 am

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
obones
 
Posts: 54
Joined: Fri May 15, 2009 11:47 am

Re: GetMapFileAddress and overloads

Postby madshi » Mon Dec 17, 2018 11:06 pm

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.
madshi
Site Admin
 
Posts: 9957
Joined: Sun Mar 21, 2004 5:25 pm

Re: GetMapFileAddress and overloads

Postby obones » Tue Dec 18, 2018 8:45 am

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.
obones
 
Posts: 54
Joined: Fri May 15, 2009 11:47 am

Re: GetMapFileAddress and overloads

Postby madshi » Tue Dec 18, 2018 9:07 am

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.
madshi
Site Admin
 
Posts: 9957
Joined: Sun Mar 21, 2004 5:25 pm

Re: GetMapFileAddress and overloads

Postby obones » Tue Dec 18, 2018 12:08 pm

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.
obones
 
Posts: 54
Joined: Fri May 15, 2009 11:47 am


Return to madExcept

Who is online

Users browsing this forum: No registered users and 5 guests