Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Array Mapped Address Ending Address math is awkward #16

Open
jrgerber opened this issue May 21, 2021 · 0 comments
Open

Memory Array Mapped Address Ending Address math is awkward #16

jrgerber opened this issue May 21, 2021 · 0 comments

Comments

@jrgerber
Copy link

pr_attr("Ending Address", "0x%08X%03X",
    DWORD(data + 0x08) >> 2,
    ((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF);

The above math results in an awkward looking value on an Azure VM:

Handle 0x0052, DMI type 19, 15 bytes
Memory Array Mapped Address
        Starting Address: 0x00000000000
        Ending Address: 0x000400003FF
        Range Size: 1 GB
        Physical Array Handle: 0x0051
        Partition Width: 1

Handle 0x0053, DMI type 19, 15 bytes
Memory Array Mapped Address
        Starting Address: 0x00100000000
        Ending Address: 0x001400003FF
        Range Size: 1 GB
        Physical Array Handle: 0x0051
        Partition Width: 1

Clearly the VM is off by a byte. No memory range is going to be from 0x0 to 0x00100000 kB. The range would be 0x0 to 0x000FFFFF.

The above math attempts to convert an ending address in kB to an ending address in bytes. After a multiply by 1024 the 0x3FF is an attempt to fill the bits to the right. In a normal case we would have:
0x000FFFFF kB becomes 3FFFFC00 bytes. Add 0x3FF and you get 0x3FFFFFFF.

A solution that would avoid the odd look (granted, yes this would never have happened if the VM calculated correctly) and more to the intent would be to detect if the last bit is a 1 (an odd number) and IIF, then add the 0x3FF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant