本文整理汇总了C++中qcall::ModuleHandle::SetDynamicIL方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleHandle::SetDynamicIL方法的具体用法?C++ ModuleHandle::SetDynamicIL怎么用?C++ ModuleHandle::SetDynamicIL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qcall::ModuleHandle
的用法示例。
在下文中一共展示了ModuleHandle::SetDynamicIL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMethodIL
//.........这里部分代码省略.........
{
clauses[i].SetClassToken(mdTypeRefNil);
}
}
}
unsigned ehSize = ExceptionHandlingSize(numExceptions, clauses.Ptr());
S_UINT32 totalSizeSafe = S_UINT32(headerSize) + S_UINT32(codeSizeAligned) + S_UINT32(ehSize);
if (totalSizeSafe.IsOverflow())
COMPlusThrowOM();
UINT32 totalSize = totalSizeSafe.Value();
ICeeGen* pGen = pRCW->GetCeeGen();
BYTE* buf = NULL;
ULONG methodRVA;
pGen->AllocateMethodBuffer(totalSize, &buf, &methodRVA);
if (buf == NULL)
COMPlusThrowOM();
_ASSERTE(buf != NULL);
_ASSERTE((((size_t) buf) & 3) == 0); // header is dword aligned
#ifdef _DEBUG
BYTE* endbuf = &buf[totalSize];
#endif
BYTE * startBuf = buf;
// Emit the header
buf += COR_ILMETHOD::Emit(headerSize, &fatHeader, moreSections, buf);
//Emit the code
//The fatHeader.CodeSize is a workaround to see if we have an interface or an
//abstract method. Force enough verification in native to ensure that
//this is true.
if (fatHeader.GetCodeSize()!=0) {
memcpy(buf, pBody, fatHeader.GetCodeSize());
}
buf += codeSizeAligned;
// Emit the eh
CQuickArray<ULONG> ehTypeOffsets;
if (numExceptions > 0)
{
// Allocate space for the the offsets to the TypeTokens in the Exception headers
// in the IL stream.
ehTypeOffsets.AllocThrows(numExceptions);
// Emit the eh. This will update the array ehTypeOffsets with offsets
// to Exception type tokens. The offsets are with reference to the
// beginning of eh section.
buf += COR_ILMETHOD_SECT_EH::Emit(ehSize, numExceptions, clauses.Ptr(),
false, buf, ehTypeOffsets.Ptr());
}
_ASSERTE(buf == endbuf);
//Get the IL Section.
HCEESECTION ilSection;
IfFailThrow(pGen->GetIlSection(&ilSection));
// Token Fixup data...
ULONG ilOffset = methodRVA + headerSize;
//Add all of the relocs based on the info which I saved from ILGenerator.
//Add the Token Fixups
for (int iTokenFixup=0; iTokenFixup<numTokenFixups; iTokenFixup++)
{
IfFailThrow(pGen->AddSectionReloc(ilSection, pTokenFixups[iTokenFixup] + ilOffset, ilSection, srRelocMapToken));
}
// Add token fixups for exception type tokens.
for (int iException=0; iException < numExceptions; iException++)
{
if (ehTypeOffsets[iException] != (ULONG) -1)
{
IfFailThrow(pGen->AddSectionReloc(
ilSection,
ehTypeOffsets[iException] + codeSizeAligned + ilOffset,
ilSection, srRelocMapToken));
}
}
//nasty interface workaround. What does this mean for abstract methods?
if (fatHeader.GetCodeSize() != 0)
{
// add the starting address of the il blob to the il blob hash table
// we need to find this information from out of process for debugger inspection
// APIs so we have to store this information where we can get it later
pModule->SetDynamicIL(mdToken(tk), TADDR(startBuf), FALSE);
DWORD dwImplFlags;
//Set the RVA of the method.
IfFailThrow(pRCW->GetMDImport()->GetMethodImplProps(tk, NULL, &dwImplFlags));
dwImplFlags |= (miManaged | miIL);
IfFailThrow(pRCW->GetEmitter()->SetMethodProps(tk, (DWORD) -1, methodRVA, dwImplFlags));
}
END_QCALL;
}