/* The exception #0 stub header is duplicated in an allocated pool with extra 4-byte/8-byte to store the exception handler data. The new allocated memory layout follows structure  */
VOID SetExceptionHandlerData(IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
/* The exception #0 stub header is duplicated in an allocated pool with extra 4-byte/8-byte to store the exception handler data. The new allocated memory layout follows structure  */
VOID SetExceptionHandlerData(IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
{
  EXCEPTION0_STUB_HEADER    *Exception0StubHeader;
  IA32_DESCRIPTOR           IdtDescriptor;
  IA32_IDT_GATE_DESCRIPTOR  *IdtTable;
  AsmReadIdtr (&IdtDescriptor);
  IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
  Exception0StubHeader = AllocatePool (sizeof (*Exception0StubHeader));
  ASSERT (Exception0StubHeader != NULL);
  CopyMem (
    Exception0StubHeader->ExceptionStubHeader,
    (VOID *)ArchGetIdtHandler (&IdtTable[0]),
    sizeof (Exception0StubHeader->ExceptionStubHeader)
    );
  Exception0StubHeader->ExceptionHandlerData = ExceptionHandlerData;
  ArchUpdateIdtEntry (&IdtTable[0], (UINTN)Exception0StubHeader->ExceptionStubHeader);
}