ExceptionType::ExceptionType(unsignedchar* pCode, sal_uInt64 pCodeBase,
typelib_TypeDescription* pTD) noexcept
: _n0(0)
, _n1(0)
, _n2(-1)
, _n3(0)
, _n4(pTD->nSize)
, exc_type_info(nullptr, "")
{ // As _n0 is always initialized to zero, that means the // hasvirtbase flag (see the ONTL catchabletype struct) is // off, and thus the copyctor is of the ctor_ptr kind.
int len;
type_info* pRTTI = RTTInfos::get(pTD->pTypeName, &len);
/* Rewrite of 32-Bit-Code to work under 64 Bit: *Tousethe32BitoffsetvaluesintheExceptionTypewehaveto *allocateasingleallocationblockanduseitforallcodeanddate *alloffsetsinsidethisareaareguaranteedtobein32bitaddressrange. *SowehavetocalctotalmemoryallocationsizeforD-tor,C-Tors, *ExceptionTypeandtype_info.ExceptionTypeisallocatedviaplacementnew *tolocateeverythinginsideourmemblock. *Thereisonecaveat:Structtype_infoiskeptin *amapandwasreferencedfromclassExceptionType.Thereforetype_infonow *isalsomemberofExceptionTypeandcanbereferencedvia32bitoffset.
*/
// Count how many trampolines we need int codeSize = nCodeSnippetSize;
// Info count int nLen = 0; for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD); pCompTD;
pCompTD = pCompTD->pBaseTypeDescription)
{
++nLen;
codeSize += nCodeSnippetSize;
}
// Array with size (4) and all _pTypeInfo (4*nLen) int typeInfoArraySize = 4 + 4 * nLen;
// 2.Pass: Get the total needed memory for class ExceptionType // (with embedded type_info) and keep the sizes for each instance // is stored in allocated int array auto exceptionTypeSizeArray = std::make_unique<int[]>(nLen);
nLen = 0; for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD); pCompTD;
pCompTD = pCompTD->pBaseTypeDescription)
{ int typeInfoLen;
RTTInfos::get(pCompTD->aBase.pTypeName, &typeInfoLen); // Mem has to be on 4-byte Boundary if (typeInfoLen % 4 != 0)
{ int n = typeInfoLen / 4;
n++;
typeInfoLen = n * 4;
}
exceptionTypeSizeArray[nLen++] = typeInfoLen + sizeof(ExceptionType);
}
// Total ExceptionType related mem int excTypeAddLen = 0; for (int i = 0; i < nLen; i++)
{
excTypeAddLen += exceptionTypeSizeArray[i];
}
// Allocate mem for code and all dynamic data in one chunk to guarantee // 32 bit offsets constint totalSize = codeSize + typeInfoArraySize + excTypeAddLen; unsignedchar* pCode = _code = static_cast<unsignedchar*>(std::malloc(totalSize)); int pCodeOffset = 0;
// New base of types array, starts after Trampoline D-Tor / C-Tors
DWORD* types = reinterpret_cast<DWORD*>(pCode + codeSize);
// New base of ExceptionType array, starts after types array unsignedchar* etMem = pCode + codeSize + typeInfoArraySize; int etMemOffset = 0;
// Fill pCode with D-Tor code
GenerateDestructorTrampoline(pCode, pTD);
_pDtor = static_cast<sal_Int32>(reinterpret_cast<sal_uInt64>(pCode) - _codeBase);
pCodeOffset += nCodeSnippetSize;
// Info count accompanied by type info ptrs: type, base type, base base type, ... // Keep offset of types_array
_types = static_cast<sal_Int32>(reinterpret_cast<sal_uInt64>(types) - _codeBase); // Fill types: (nLen, _offset to ExceptionType1, ...ExceptionType2, ...)
types[0] = nLen;
int nPos = 1; for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD); pCompTD;
pCompTD = pCompTD->pBaseTypeDescription)
{ // Create instance in mem block with placement new
ExceptionType* et = new (etMem + etMemOffset) ExceptionType(
pCode + pCodeOffset, _codeBase, reinterpret_cast<typelib_TypeDescription*>(pCompTD));
// Next trampoline entry offset
pCodeOffset += nCodeSnippetSize; // Next ExceptionType placement offset
etMemOffset += exceptionTypeSizeArray[nPos - 1];
// Keep offset of addresses of ET for D-Tor call in ~RaiseInfo
types[nPos++] = static_cast<DWORD>(reinterpret_cast<sal_uInt64>(et) - _codeBase);
} // Final check: end of address calculation must be end of mem
assert(etMem + etMemOffset == pCode + totalSize);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.