Skip to content

Commit

Permalink
Merge pull request #2509 from spvkgn/inside
Browse files Browse the repository at this point in the history
inside: add PE format
  • Loading branch information
elfmz authored Nov 19, 2024
2 parents 6aff2f5 + b761a5d commit b4594b0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
14 changes: 14 additions & 0 deletions inside/configs/plug/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ ProgramHeaders.txt=readelf -W -l $F
Symbols.txt=nm $F
SymbolsDynamic.txt=nm --dynamic $F

[PE]
Info.txt=readpe -A $F

[Disasm_20]
PPC.s=powerpc-linux-gnu-objdump -d -w -z $F
PPC_VLE.s=powerpc-eabivle-objdump -d -w -z $F
Expand Down Expand Up @@ -53,6 +56,9 @@ Info.txt=exiftool $F
ASCIIArt.txt=jp2a $F
ASCIIArt.ans=jp2a --colors $F

[PNG]
Info.txt=exiftool $F

[MP3]
Info.txt=exiftool $F

Expand All @@ -64,3 +70,11 @@ Info.txt=exiftool $F

[WV]
Info.txt=exiftool $F

[OGG]
Info.txt=exiftool $F
mediainfo.txt=mediainfo $F

[M4A]
Info.txt=exiftool $F
mediainfo.txt=mediainfo $F
21 changes: 19 additions & 2 deletions inside/src/inside.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ static const char *DetectPlainKind(const char *Name, const unsigned char *Data,
&& ext && (strcasecmp(ext, ".jpg") == 0 || strcasecmp(ext, ".jpeg") == 0)) {
return "JPG";

} else if (DataSize >= 8 && Data[0] == 0x89 && Data[1] == 0x50 && Data[2] == 0x4e && Data[3] == 0x47
&& ext && strcasecmp(ext, ".png") == 0) {
return "PNG";

} else if (DataSize >= 8 && Data[0] == 'A' && Data[1] == 'T' && Data[2] == '&' && Data[3] == 'T'
&& Data[4] == 'F' && Data[5] == 'O' && Data[6] == 'R' && Data[7] == 'M'
&& ext && strcasecmp(ext, ".djvu") == 0) { // Ensure

return "DJVU";

} else if (DataSize >= 8 && ext && strcasecmp(ext, ".mp3") == 0) {
} else if (DataSize >= 8 && Data[0] == 0x49 && Data[1] == 0x44 && Data[2] == 0x33
&& ext && strcasecmp(ext, ".mp3") == 0) {
return "MP3";

} else if (DataSize >= 8 && Data[0] == 'M' && Data[1] == 'A' && Data[2] == 'C'
Expand All @@ -99,6 +103,19 @@ static const char *DetectPlainKind(const char *Name, const unsigned char *Data,
} else if (DataSize >= 8 && Data[0] == 'f' && Data[1] == 'L' && Data[2] == 'a' && Data[3] == 'C'
&& ext && strcasecmp(ext, ".flac") == 0) {
return "FLAC";

} else if (DataSize >= 8 && Data[0] == 'O' && Data[1] == 'g' && Data[2] == 'g' && Data[3] == 'S'
&& ext && (strcasecmp(ext, ".ogg") == 0 || strcasecmp(ext, ".oga") == 0 || strcasecmp(ext, ".opus") == 0)) {
return "OGG";

} else if (DataSize >= 12 && memcmp(Data + 4, "ftypM4A ", 8) == 0
&& ext && strcasecmp(ext, ".m4a") == 0) {
return "M4A";

} else if (DataSize >= 4 && Data[0] == 0x4d && Data[1] == 0x5a
&& ext && (strcasecmp(ext, ".exe") == 0 || strcasecmp(ext, ".dll") == 0 || strcasecmp(ext, ".sys") == 0
|| strcasecmp(ext, ".drv") == 0 || strcasecmp(ext, ".ocx") == 0 || strcasecmp(ext, ".efi") == 0)) {
return "PE";
}

return nullptr;
Expand Down

0 comments on commit b4594b0

Please sign in to comment.