[Issue 24079] New: core.sys.windows.winnt.IMAGE_FIRST_SECTION returns bad pointer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 8 15:48:26 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24079

          Issue ID: 24079
           Summary: core.sys.windows.winnt.IMAGE_FIRST_SECTION returns bad
                    pointer
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

IMAGE_FIRST_SECTION adds an integer representing a number of bytes to a pointer
of type IMAGE_OPTIONAL_HEADER* resulting in a change 240 times
(IMAGE_OPTIONAL_HEADER64*) or 224 times (IMAGE_OPTIONAL_HEADER32*) as large as
intended.

https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_file_header
"SizeOfOptionalHeader: The size of the optional header, in bytes."

core.sys.windows.winnt.d:
---
PIMAGE_SECTION_HEADER IMAGE_FIRST_SECTION(PIMAGE_NT_HEADERS h) {
    return cast(PIMAGE_SECTION_HEADER)
        (&h.OptionalHeader + h.FileHeader.SizeOfOptionalHeader);
}
---

--


More information about the Digitalmars-d-bugs mailing list