Where does nativeGetUninitializedObject really exist?

I was curious what serialization material is, so I went around FormatterServicesand found a method called nativeGetUninitializedObjectthat actually handles initialization (without calling a caster) of a given type. This method is decorated with a keyword externand the following attribute:[MethodImpl(MethodImplOptions.InternalCall), SecurityCritical]

I was left wondering: where does this method really exist? What code calls the CLR to get initialized this type (without calling the constructor)?

+3
source share
2 answers

This method actually exists in the native part of the CLR. MethodImplOptions.InternalCalldenotes a call that is redirected to native CLR code and implemented there.

MSDN:

. - , .

+4

CLR. JIT CLR, MethodImplOptions.InternalCall. , , SSCLI20 (clr/src/vm/ecall.cpp):

FCFuncStart(gSerializationFuncs)
    FCFuncElement("nativeGetSafeUninitializedObject", ReflectionSerialization::GetSafeUninitializedObject)
    FCFuncElement("nativeGetUninitializedObject", ReflectionSerialization::GetUninitializedObject)
FCFuncEnd()

, CALL , . , , ++ CLR.

ReflectionSerialization:: GetUninitializedObject() clr/src/vm/reflectioninvocation.cpp, , . SSCLI20. , Allocate() . .

+6

Source: https://habr.com/ru/post/1789299/


All Articles