16 เมษายน 2555 3:58
I've been able to successfully iterate over the names of local variables using the DIA API using the various, exposed methods. However, I have been completely at a loss when trying to find the name of function parameters using the API (an inspection of the output from the Dia2Sample http://msdn.microsoft.com/en-us/library/b5ke49f5.aspx also yields absolutely nothing in the way of function parameter names).
Is such a thing possible?
This particular thread leans on the DbgHelp API (which I'm not using). And this particular link states:
"To get the function parameters, we can call findChildren on the function type with the symbol tag SymTagFunctionArgType. From this call we can extract the parameter name, and use the expandType function to extract a string that can represent the parameter type."
...but is utter rubbish and simply does not work. My eventual goal here is to allow someone to extract the value of the parameter by name.
16 เมษายน 2555 13:32
Go to this webpage and look and tthe same enumsymbols.cpp. The parameter list of main is different from the origianal example.
- เสนอเป็นคำตอบโดย Mike FengMicrosoft, Moderator 17 เมษายน 2555 8:20
19 เมษายน 2555 5:01ผู้ดูแล
I am not sure if DIA exposes a way to get that info, however you can get it directly from the managed assembly. Try taking a look at IMetaDataImport APIs, in particular the EnumParams() method. Alternatively if your tool is written in managed code you can load the target assembly for reflection and use MethodInfo.GetParameters().
Let me know if you need more details, HTH
19 เมษายน 2555 20:00Thanks Noah, your answer was on the mark.
I am using C++ to do this, and was looking in all of the wrong places. To be frank, I find the API somewhat confusing and convoluted; I suppose with time it would make sense, but it seems strange to me that I would be able to get stack variables using the DIA API and be forced to resort to an entirely different API-set to get the parameters.
Nonetheless, your answer worked. Thanks!