70typedef uint32_t rva_t;
73typedef void generic_function_t();
77 typedef __w64 int32_t mdiff_t;
78 mdiff_t member_offset;
79 mdiff_t vbtable_offset;
83 T * operator()(T *
const thisptr)
const
85 uintptr_t tp =
reinterpret_cast<uintptr_t
>(thisptr);
86 uintptr_t ptr = tp + member_offset;
87 if ( vbtable_offset != -1 )
89 ptr += *
reinterpret_cast<mdiff_t*
>(
static_cast<intptr_t
>(vdisp_offset + *
reinterpret_cast<mdiff_t*
>(tp + vbtable_offset)) )
92 return reinterpret_cast<T*
>(ptr);
98 typedef void (* dtor_ptr )(eobject*);
99 typedef void (* ctor_ptr )(eobject*, eobject*);
100 typedef void (* ctor_ptr2)(eobject*, eobject*,
int);
106 uint32_t memmoveable : 1;
108 uint32_t refonly : 1;
110 uint32_t hasvirtbase : 1;
115 ptrtomember thiscast;
117 uint32_t object_size;
127struct catchabletypearray
137 typedef exception_disposition __cdecl forwardcompathandler_t(...);
140 uint32_t evolatile : 1;
143 rva_t exception_dtor;
144 rva_t forwardcompathandler;
145 rva_t catchabletypearray;
153 uint32_t isconst : 1;
154 uint32_t isvolatile : 1;
155 uint32_t isunaligned : 1;
156 uint32_t isreference : 1;
163 int eobject_bpoffset;
178 constructcatchobject(
179 cxxregistration * cxxreg,
180 const ehandler *
const catchblock,
181 catchabletype *
const convertible,
182 const dispatcher_context*
const dispatch
189 struct typeinfo_t {
void* vtbl;
void* spare;
char name[1]; };
190 enum catchable_info { cidefault, cicomplex, civirtual } cinfo = cidefault;
192 const typeinfo_t* ti = catchblock->typeinfo ? dispatch->va<typeinfo_t*>(catchblock->typeinfo) : NULL;
193 if(ti && *ti->name && (catchblock->eobject_bpoffset || catchblock->ishz)){
194 eobject** objplace = catchblock->ishz
195 ?
reinterpret_cast<eobject**
>(cxxreg)
196 :
reinterpret_cast<eobject**
>(catchblock->eobject_bpoffset + cxxreg->fp.FramePointers);
197 if(catchblock->isreference){
199 *objplace = adjust_pointer(get_object(), convertible);
200 }
else if(convertible->memmoveable){
202 std::memcpy(objplace, get_object(), convertible->object_size);
203 if(convertible->object_size ==
sizeof(
void*) && *objplace)
204 *objplace = adjust_pointer((
void*)*objplace, convertible);
207 if(convertible->copyctor){
208 cinfo = convertible->hasvirtbase ? civirtual : cicomplex;
210 std::memcpy(objplace, (
const void*)adjust_pointer(get_object(), convertible), convertible->object_size);
215 if(cinfo != cidefault){
216 eobject* objthis = catchblock->ishz
217 ?
reinterpret_cast<eobject*
>(cxxreg)
218 :
reinterpret_cast<eobject*
>(catchblock->eobject_bpoffset + cxxreg->fp.FramePointers);
219 void* copyctor = thrown_va(convertible->copyctor);
220 eobject* copyarg = adjust_pointer(get_object(), convertible);
221 if(cinfo == cicomplex)
222 (eobject::ctor_ptr (copyctor))(objthis, copyarg);
224 (eobject::ctor_ptr2(copyctor))(objthis, copyarg, 1);
227 __except(cxxregistration::unwindfilter(
static_cast<nt::ntstatus
>(_exception_code())))
229 nt::exception::inconsistency();
245#include <rtl/alloc.h>
246#include <rtl/strbuf.hxx>
247#include <rtl/ustrbuf.hxx>
250#include <com/sun/star/uno/Any.hxx>
261 ::uno_copyData(pExcThis, pSource, pTD, uno::cpp_acquire);
267 ::uno_destructData(pExcThis, pTD, uno::cpp_release);
276 unsigned char*
p =
code;
281 *
reinterpret_cast<void**
>(
p) = pTD;
287 *
reinterpret_cast<void**
>(
p) =
reinterpret_cast<void*
>(&
copyConstruct);
300 unsigned char*
p =
code;
305 *
reinterpret_cast<void**
>(
p) = pTD;
311 *
reinterpret_cast<void**
>(
p) =
reinterpret_cast<void*
>(&
destruct);
329 , exc_type_info(
nullptr,
"")
338 memcpy(
static_cast<void*
>(&exc_type_info),
static_cast<void*
>(pRTTI), len);
339 _pTypeInfo =
static_cast<sal_uInt32
>(
reinterpret_cast<sal_uInt64
>(&exc_type_info) - pCodeBase);
342 assert(pCodeBase <=
reinterpret_cast<sal_uInt64
>(pCode)
343 && (
reinterpret_cast<sal_uInt64
>(pCode) - pCodeBase < 0x100000000));
344 _pCopyCtor =
static_cast<sal_uInt32
>(
reinterpret_cast<sal_uInt64
>(pCode) - pCodeBase);
364 typelib_CompoundTypeDescription* pCompTD;
371 for (pCompTD =
reinterpret_cast<typelib_CompoundTypeDescription*
>(pTD); pCompTD;
372 pCompTD = pCompTD->pBaseTypeDescription)
379 int typeInfoArraySize = 4 + 4 * nLen;
384 auto exceptionTypeSizeArray = std::make_unique<int[]>(nLen);
387 for (pCompTD =
reinterpret_cast<typelib_CompoundTypeDescription*
>(pTD); pCompTD;
388 pCompTD = pCompTD->pBaseTypeDescription)
393 if (typeInfoLen % 4 != 0)
395 int n = typeInfoLen / 4;
399 exceptionTypeSizeArray[nLen++] = typeInfoLen +
sizeof(
ExceptionType);
403 int excTypeAddLen = 0;
404 for (
int i = 0;
i < nLen;
i++)
406 excTypeAddLen += exceptionTypeSizeArray[
i];
411 const int totalSize = codeSize + typeInfoArraySize + excTypeAddLen;
412 unsigned char* pCode = _code =
static_cast<unsigned char*
>(std::malloc(totalSize));
416 DWORD* types =
reinterpret_cast<DWORD*
>(pCode + codeSize);
419 unsigned char* etMem = pCode + codeSize + typeInfoArraySize;
422 _codeBase =
reinterpret_cast<sal_uInt64
>(pCode)
426 bool success = VirtualProtect(pCode, codeSize, PAGE_EXECUTE_READWRITE, &old_protect);
428 assert(success &&
"VirtualProtect() failed!");
430 ::typelib_typedescription_acquire(pTD);
434 _pDtor =
static_cast<sal_Int32
>(
reinterpret_cast<sal_uInt64
>(pCode) - _codeBase);
439 _types =
static_cast<sal_Int32
>(
reinterpret_cast<sal_uInt64
>(types) - _codeBase);
444 for (pCompTD =
reinterpret_cast<typelib_CompoundTypeDescription*
>(pTD); pCompTD;
445 pCompTD = pCompTD->pBaseTypeDescription)
454 etMemOffset += exceptionTypeSizeArray[
nPos - 1];
457 types[
nPos++] =
static_cast<DWORD
>(
reinterpret_cast<sal_uInt64
>(et) - _codeBase);
460 assert(etMem + etMemOffset == pCode + totalSize);
static DWORD allocationGranularity
static type_info * get(OUString const &rUNOname, int *len=nullptr) noexcept
struct _typelib_TypeDescription typelib_TypeDescription
const int codeSnippetSize
static void *__cdecl destruct(void *pExcThis, typelib_TypeDescription *pTD) noexcept
static void GenerateDestructorTrampoline(unsigned char *code, typelib_TypeDescription *pTD) noexcept
static void GenerateConstructorTrampoline(unsigned char *code, typelib_TypeDescription *pTD) noexcept
static void *__cdecl copyConstruct(void *pExcThis, void *pSource, typelib_TypeDescription *pTD) noexcept
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
ExceptionType(unsigned char *pCode, sal_uInt64 pCodeBase, typelib_TypeDescription *pTD) noexcept
RaiseInfo(typelib_TypeDescription *pTD) noexcept