Jump to content
Tuts 4 You

Where is MethodDesc::Call ??? Framework 4.0


Recommended Posts

Where is MethodDesc::Call ??? Framework 4.0



execution of managed code can be found in MethodDesc::Call, which we discussed in Chapter 5 (and which can be found in sscli/clr/src/vm/method.cpp).

Is not inside method.cpp, in fact I can't find there any method starting with "Call"
Alternatives? Any other simple way of executing .NET methods at low level?

  • Like 1
Link to comment

@kao: Doesn't help, I need to run methods in Framework 4.0 not on old Framework,
in Framework 4.0 that method "MethodDesc::Call" seems to be missing! Alternatives?

  • Like 1
Link to comment

@CodeExplorer you can use MethodDesc::GetMultiCallableAddrOfCode function to obtain pointer to the method which you can later invoke,call it with CORINFO_ACCESS_LDFTN and then later on you can invoke the code directly or wrap it up into a managed delagate and invoke like that

Edited by BataBo
More clarification
  • Like 1
Link to comment

I did find MethodDesc::CallDescr(), but there is a problem:

// The m_argDescs array is constructed in the following "canonical" order:
    // 1. 'this' pointer
    // 2. signature arguments
    // 3. return buffer
    // 4. type parameter -or- vararg cookie
    // argOffsets_ is passed in this order, and serves to establish the offsets to arguments
    // when the interpreter is invoked using the native calling convention (i.e., not directly).
    // When the interpreter is invoked directly, the arguments will appear in the same order
    // and form as arguments passed to MethodDesc::CallDescr().  This ordering is as follows:
    // 1. 'this' pointer
    // 2. return buffer
    // 3. signature arguments
    // MethodDesc::CallDescr() does not support generic parameters or varargs functions. (the problem)

MethodDesc::GetMultiCallableAddrOfCode has no parameter, this calls DoPrestub on that method?

Link to comment

I was wrong, MethodDesc::GetMultiCallableAddrOfCode has one parameter


PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags /*=CORINFO_ACCESS_LDFTN*/)

    PCODE ret = TryGetMultiCallableAddrOfCode(accessFlags);

    if (ret == NULL)

        // We have to allocate funcptr stub
        ret = GetLoaderAllocator()->GetFuncPtrStubs()->GetFuncPtrStub(this);

    return ret;

Unfortunate from what I could see doesn't call DoPrestub!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...