Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 740565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:31:50+00:00 2026-05-14T08:31:50+00:00

EDIT: I am attempting to encapsulate a 3rd party com object in .net classes

  • 0

EDIT:

I am attempting to encapsulate a 3rd party com object in .net classes and at the same time fix a bug with it. I was hoping to replace a method in the com object’s vtable with a call to my own method which would provide a bug free implementation of the method.

I was trying to test this out on something very basic, but given the answers below i’m on completely the wrong track. By creating a reference to my com object I presume i’ve created a runtime callable wrapper, is there any way to get a pointer to the real underlying com object?


I’m attempting to access a com object’s vtable in memory and getting nowhere.

From what I have read, the first 4 bytes in memory of a com object should be a pointer to the vtableptr, which in turn is a pointer to the vtable.

Although I’m not sure I expect to find my test method at slot 7 in this com object I have tried them all and nothing looks like the address of my function.

If anyone can make the necessary changes to this sample to get it to work (the aim is just to try and invoke the Test method on the Tester class by accessing the com object’s vtable and locating the method in whichever row it turns up) I would be very grateful.

I know it is rare that anyone would need to do this, but please accept I do need to do something quite similar and have considered the alternatives

Thanks in advance

[ComVisible(true)]
public class Tester
{
    public void Test()
    {
        MessageBox.Show("Here");
    }

}

public delegate void TestDelegate();

private void main()
{

    Tester t = new Tester();

    GCHandle objectHandle = GCHandle.Alloc(t);

    IntPtr objectPtr = GCHandle.ToIntPtr(objectHandle);

    IntPtr vTable = (IntPtr)Marshal.ReadInt32(objectPtr);

    IntPtr vTablePtr = (IntPtr)Marshal.ReadInt32(vTable);

    IntPtr functionPtr = (IntPtr)Marshal.ReadInt32(vTablePtr, 7 * 4); // 7 may be incorrect but i have tried many different values

    TestDelegate func = (TestDelegate)Marshal.GetDelegateForFunctionPointer(functionPtr, typeof(TestDelegate));

    func();

    objectHandle.Free();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:31:51+00:00Added an answer on May 14, 2026 at 8:31 am

    You are completely on the wrong track with this. The t object is not a COM interface pointer, it is a .NET object reference. A COM interface pointer (and its v-table) doesn’t get created until unmanaged code creates the CCW (COM Callable Wrapper). It has to be unmanaged code, the CLR interop layer doesn’t permit managed code to create a CCW.

    The only way to keep this thread moving is by explaining why you want to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 386k
  • Answers 386k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could also target it using the IDs of the… May 14, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer The entry point of a binary is not main(), but… May 14, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer Are you trying to use file system permissions to allow… May 14, 2026 at 11:39 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.