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

  • SEARCH
  • Home
  • 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 8527655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:37:03+00:00 2026-06-11T08:37:03+00:00

Is it possible to call functions from C#, to an unmanaged function in a

  • 0

Is it possible to call functions from C#, to an unmanaged function in a struct (via VTable).

For example, I am in-process hooking an application, and I am re-creating the structs for each class (of the application).

public struct SomeStruct {
   [FieldOffset(0x00)]
   public IntPtr * VTable;

   [FieldOffset(0x10)]
   public uint SomeValue;
}

Then, I usually do:

var * data = (SomeStruct*)(Address);

And I wish to call a function from the VTable of the structure in either of the following ways

Invoke<delegate>(data->VTable[0x3C])(delegateArguments)

Or

var eax = Invoke<Func<uint,uint>(data->VTable[0x3C])(arg1,arg2)

Furthermore, could this be done efficiently (as these vtable funcs could be called numerous times)?

Perhaps via Reflection Emit?

From what I know, marshalling has to create the delegate function every time I call the Invoke<> func.

  • 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-06-11T08:37:05+00:00Added an answer on June 11, 2026 at 8:37 am

    Given that a virtual method table contains pointers to functions, assuming you know the offset (which it appears you do) you can get the pointer value in an IntPtr by calling the ReadIntPtr method on the Marshal class, like so:

    IntPtr ptr = Marshal.ReadIntPtr(data.VTable, 0x3C);
    

    Then you can call the GetDelegateForFunctionPointer method on the Marshal class to get a delegate of the appropriate type, like so:

    // Assuming a signature of f(int, int) returning int
    Func<int, int, int> func = (Func<int, int, int>)
        Marshal.GetDelegateForFunctionPointer(ptr, typeof(Func<int, int, int>));
    

    Then you can call the delegate as needed.

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

Sidebar

Related Questions

Is it possible to call functions from class like this: $class = new class;
I was wondering if it's possible to call the same kernel functions from different
Is it possible to call C++ functions/Use C++ classes from a silverlight web app?
In the code below, is it possible to call the error function from the
Possible Duplicate: How to call javascript function from c# Is there a way to
I want to call a controller function from a view. Is that possible in
Is it possible to call functions within a case statement? Example: (CASE WHEN (((POWER((1+x1/x2),Term)
It's possible to call C functions through CREATE FUNCTION but how can .NET functions
I've seen that it is possible to call MATLAB functions from VS2010 (VC++). I
I am wondering if it is possible to call Python functions from Java code

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.