Is there any way in C# to access a COM object’s virtual method table in order to get a function’s address?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
After a lot of searching and piecing together different partial solutions, I figured out how to do it.
First you need to define the COM coclass for the object you’re trying to access:
Next you need to instantiate the COM object. There are a couple of ways to do that. Since I was interested in DirectSound, I used:
Since I now had my COM object, I could then use Hans’ suggestion of
Marshal.GetComInterfaceForObject():As an added bonus, you can then iterate through the vtable functions like this:
Extra Reading / References: