How do I decode Visual C++ method parameters for mangled decorated names?
Given the exported names examples below:
0x00cf ?GetI@PyIDispatch@@SAPAUIDispatch@@PAU_object@@@Z
0x0119 ?ParseTypeInformation@PythonOleArgHelper@@QAEHPAU_object@@@Z
0x014f ?PyObject_FromSTGMEDIUM@@YAPAVPySTGMEDIUM@@PAUtagSTGMEDIUM@@@Z
What are the method parameters for methods GetI, ParseTypeInformation, PyObject_FromSTGMEDIUM?
Current workaround is to skip parsing the parameters, but then I have the uninforma开发者_开发知识库tive gap as shown below :)
PyObject_FromSTGMEDIUM(...)
ParseTypeInformation(...)
GetI(...)
References:
- http://theory.uwinnipeg.ca/localfiles/infofiles/gcc/gxxint_15.html#SEC20
- http://sourcery.mentor.com/public/cxx-abi/abi.html
- http://www.kegel.com/mangle.html
- http://www.unixwiz.net/techtips/win32-callconv.html#decor
- http://www.int0x80.gr/papers/name_mangling.pdf
stdcall has the form of _name@x and fastcall has the form of @name@x
How should the algorithm to decode parameters look like? Example in C# would be awesome.
Constraints: PInvoke is not available.
Please give also the parameters for the examples above within the anwser. Thank you!
Run the undname.exe utility from the Visual Studio command prompt. Use the Edit + Paste command in the system menu to avoid having to type the name. Sample output:
C:\temp>undname ?GetI@PyIDispatch@@SAPAUIDispatch@@PAU_object@@@Z
Microsoft (R) C++ Name Undecorator
Copyright (C) Microsoft Corporation. All rights reserved.
Undecoration of :- "?GetI@PyIDispatch@@SAPAUIDispatch@@PAU_object@@@Z"
is :- "public: static struct IDispatch * __cdecl PyIDispatch::GetI(struct _objec
t *)"
Here is an article explaining the mangling algorithm used by Visual C++.
In your case, I think that the first function will be:
static ::IDispatch* PyIDispatch::GetI(::_object*);
I don't have access to a Windows machine to test however.
You can use the UnDecorateSymbolName
function.
Unfortunately, no p/invoke declaration available on pinvoke.net yet.
Try something like:
[DllImport("Dbghelp.dll", SetLastError = true)]
static extern uint UnDecorateSymbolName(string decorated, StringBuffer undecoratedBuffer, uint undecoratedBufferLength, uint flags);
精彩评论