29#include <com/sun/star/uno/genfunc.hxx>
32#include <typelib/typedescription.hxx>
47extern "C" typelib_TypeClass
cpp_vtable_call(sal_Int64 nOffsetAndIndex,
void ** pCallStack)
49 sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
50 sal_Int32 nVtableOffset = ((nOffsetAndIndex >> 32) & 0xFFFFFFFF);
51 return cpp_mediate(pCallStack, nFunctionIndex, nVtableOffset,
nullptr);
58typedef enum { REGPARAM_INT, REGPARAM_FLT } RegParamKind;
72 RegParamKind param_kind[4],
73 sal_Int32 nFunctionIndex,
74 sal_Int32 nVtableOffset )
76 sal_uInt64 nOffsetAndIndex = (
static_cast<sal_uInt64
>(nVtableOffset) << 32 ) |
static_cast<sal_uInt64
>(nFunctionIndex);
77 unsigned char *
p =
code;
80 if (param_kind[0] == REGPARAM_INT)
83 *
p++ = 0x48; *
p++ = 0x89; *
p++ = 0x4C; *
p++ = 0x24; *
p++ = 0x08;
88 *
p++ = 0xF2; *
p++ = 0x0F; *
p++ = 0x11; *
p++ = 0x44; *
p++ = 0x24; *
p++ = 0x08;
90 if ( param_kind[1] == REGPARAM_INT )
93 *
p++ = 0x48; *
p++ = 0x89; *
p++ = 0x54; *
p++ = 0x24; *
p++ = 0x10;
98 *
p++ = 0xF2; *
p++ = 0x0F; *
p++ = 0x11; *
p++ = 0x4C; *
p++ = 0x24; *
p++ = 0x10;
100 if ( param_kind[2] == REGPARAM_INT )
103 *
p++ = 0x4C; *
p++ = 0x89; *
p++ = 0x44; *
p++ = 0x24; *
p++ = 0x18;
108 *
p++ = 0xF2; *
p++ = 0x0F; *
p++ = 0x11; *
p++ = 0x54; *
p++ = 0x24; *
p++ = 0x18;
110 if ( param_kind[3] == REGPARAM_INT )
113 *
p++ = 0x4C;*
p++ = 0x89; *
p++ = 0x4C; *
p++ = 0x24; *
p++ = 0x20;
118 *
p++ = 0xF2; *
p++ = 0x0F; *
p++ = 0x11; *
p++ = 0x5C; *
p++ = 0x24; *
p++ = 0x20;
122 *
p++ = 0x48; *
p++ = 0xB9;
123 *
reinterpret_cast<sal_uInt64 *
>(
p) = nOffsetAndIndex;
p += 8;
126 *
p++ = 0x49; *
p++ = 0xBB;
130 *
p++ = 0x41; *
p++ = 0xFF; *
p++ = 0xE3;
143 return static_cast< Slot *
>(block) + 1;
154 reinterpret_cast<sal_uIntPtr
>(
p) >=
reinterpret_cast<sal_uIntPtr
>(&
__ImageBase)
155 &&
reinterpret_cast<sal_uIntPtr
>(
p) -
reinterpret_cast<sal_uIntPtr
>(&
__ImageBase)
156 <= std::numeric_limits<sal_uInt32>::max());
157 return reinterpret_cast<sal_uIntPtr
>(
p) -
reinterpret_cast<sal_uIntPtr
>(&
__ImageBase);
171struct RttiClassHierarchyDescriptor;
173#pragma warning (push)
174#pragma warning (disable: 4324)
176struct alignas(16) RttiBaseClassDescriptor {
180 sal_uInt32
n3 = 0xFFFFFFFF;
182 sal_uInt32
n5 = 0x40;
187struct alignas(4) RttiBaseClassArray {
193struct alignas(8) RttiClassHierarchyDescriptor {
201struct alignas(16) RttiCompleteObjectLocator {
212 RttiBaseClassDescriptor
bcd;
213 RttiBaseClassArray
bca;
214 RttiClassHierarchyDescriptor
chd;
215 RttiCompleteObjectLocator
col;
227 sal_Int32, typelib_InterfaceTypeDescription *)
231 Slot * slots = mapBlockToVtable(block);
232 slots[-1].fn = &rtti.col;
233 return slots + slotCount;
238 unsigned char * code,
239 typelib_InterfaceTypeDescription
const * type,
240 sal_Int32 nFunctionOffset,
241 sal_Int32 functionCount,
242 sal_Int32 nVtableOffset )
244 (*slots) -= functionCount;
247 for (
int member = 0; member <
type->nMembers; ++member) {
250 TYPELIB_DANGER_GET( &pTD,
type->ppMembers[ member ] );
253 RegParamKind param_kind[4];
256 for (
int i = 0;
i < 4; ++
i)
257 param_kind[i] = REGPARAM_INT;
262 if ( pTD->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE )
264 typelib_InterfaceAttributeTypeDescription * pIfaceAttrTD =
265 reinterpret_cast<typelib_InterfaceAttributeTypeDescription *
>( pTD );
270 code =
codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
271 if ( ! pIfaceAttrTD->bReadOnly )
274 TYPELIB_DANGER_GET( &pAttrTD, pIfaceAttrTD->pAttributeTypeRef );
278 if ( pAttrTD->eTypeClass == typelib_TypeClass_FLOAT ||
279 pAttrTD->eTypeClass == typelib_TypeClass_DOUBLE )
280 param_kind[nr++] = REGPARAM_FLT;
282 TYPELIB_DANGER_RELEASE( pAttrTD );
285 code =
codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
288 else if ( pTD->eTypeClass == typelib_TypeClass_INTERFACE_METHOD )
290 typelib_InterfaceMethodTypeDescription * pMethodTD =
291 reinterpret_cast<typelib_InterfaceMethodTypeDescription *
>( pTD );
294 TYPELIB_DANGER_GET( &pReturnTD, pMethodTD->pReturnTypeRef );
303 for (
int param = 0; nr < 4 && param < pMethodTD->nParams; ++param, ++nr)
307 TYPELIB_DANGER_GET( &pParamTD, pMethodTD->pParams[param].pTypeRef );
310 if ( pParamTD->eTypeClass == typelib_TypeClass_FLOAT ||
311 pParamTD->eTypeClass == typelib_TypeClass_DOUBLE )
312 param_kind[nr] = REGPARAM_FLT;
314 TYPELIB_DANGER_RELEASE( pParamTD );
317 code =
codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
319 TYPELIB_DANGER_RELEASE( pReturnTD );
324 TYPELIB_DANGER_RELEASE( pTD );
330 unsigned char const *,
331 unsigned char const *)
static Slot * mapBlockToVtable(void *block)
Given a pointer to a block, turn it into a vtable pointer.
static void flushCode(unsigned char const *begin, unsigned char const *end)
Flush all the generated code snippets of a vtable, on platforms that require it.
static unsigned char * addLocalFunctions(Slot **slots, unsigned char *code, sal_PtrDiff writetoexecdiff, typelib_InterfaceTypeDescription const *type, sal_Int32 functionOffset, sal_Int32 functionCount, sal_Int32 vtableOffset)
Fill the vtable slots corresponding to all local (i.e., not inherited) functions of a given interface...
static Slot * initializeBlock(void *block, sal_Int32 slotCount, sal_Int32 vtableNumber, typelib_InterfaceTypeDescription *type)
Initialize a raw vtable block.
static std::size_t getBlockSize(sal_Int32 slotCount)
Calculate the size of a raw vtable block.
struct _typelib_TypeDescription typelib_TypeDescription
typelib_TypeClass __cdecl cpp_mediate(void **pCallStack, const sal_Int32 nFunctionIndex, const sal_Int32 nVtableOffset, sal_Int64 *const pRegisterReturn)
RttiClassHierarchyDescriptor chd
RttiCompleteObjectLocator col
RttiBaseClassDescriptor bcd
typelib_TypeClass cpp_vtable_call(sal_Int64 nOffsetAndIndex, void **pCallStack)
int const codeSnippetSize
IMAGE_DOS_HEADER const __ImageBase
static unsigned char * codeSnippet(unsigned char *code, RegParamKind param_kind[4], sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset)
char privateSnippetExecutor
static sal_uInt32 imageRelative(void const *p)
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT,...