Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/shared/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,7 +2371,27 @@ CreateProcessModules(
}
}

if (!dup)
// Does the offset in the module correspond to a valid MachO header?
bool isMachO = false;
int fd = open(moduleName, O_RDONLY);
if (fd != -1)
{
if (lseek(fd, rwpi.prp_prinfo.pri_offset, SEEK_SET) != (off_t)-1)
{
uint32_t magic = 0;
ssize_t bytesRead = read(fd, &magic, sizeof(magic));
if (bytesRead == sizeof(magic))
{
if (magic == 0xFEEDFACF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (magic == 0xFEEDFACF)
if (magic == 0xFEEDFACF || magic == 0xFEEDFACE)

{
isMachO = true;
}
}
}
close(fd);
}

if (!dup && isMachO)
{
int cbModuleName = strlen(moduleName) + 1;
ProcessModules *entry = (ProcessModules *)malloc(sizeof(ProcessModules) + cbModuleName);
Expand Down