C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extend std::type_info with more information

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 9 Apr 2024 08:13:29 +0100
On Tue, Apr 9, 2024 at 8:05 AM Frederick Virchanza Gotham wrote
>
> Okay so I need to see what machine code is located at the address
> specified by: *(progam_counter + 0xfde). So I wrote this little
> program:
>
> int main(void)
> {
> cout << "Machine Code: ";
> char unsigned const *const p = (char unsigned*)&__RTDynamicCast;
> for ( unsigned i = 0u; i < 16u; ++i ) cout << hex << setfill('0')
> << setw(2) << (unsigned)p[i];
> cout << endl;
>
> int32_t offset;
> memcpy(&offset, p+2, sizeof offset);
> cout << "Offset = 0x" << hex << offset << endl;
>
> cout << "Machine Code: ";
> void **address_of_pointer = (void**)((char*)&__RTDynamicCast +
> offset + 6); // 6 is the size of the jump instruction
> char unsigned *address_of_jump_destination = (char
> unsigned*)*address_of_pointer;
> for ( unsigned i = 0u; i < 512u; ++i ) cout << hex << setfill('0')
> << setw(2) << (unsigned)address_of_jump_destination[i];
> cout << endl;
> }


I didn't mean to hit Send there. So the above program prints the
machine code of the 'dynamic_cast', which I copy-pasted into the
following online webform:

    https://defuse.ca/online-x86-assembler.htm

to see the x86_64 assembler. Over the next few days I'll try to figure
out what it's doing to see what information I can get from Microsoft's
std::type_info.

Ultimately I'll produce a list of things that are common to Itanium
and Microsoft, and then write a paper to add these commonalities to
the C++ standard.

Received on 2024-04-09 07:13:42