-
Notifications
You must be signed in to change notification settings - Fork 3
/
pe.go
51 lines (41 loc) · 1.3 KB
/
pe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package dash
import (
"io"
"github.com/itchio/spellbook"
"github.com/itchio/wizardry/wizardry/wizutil"
)
func sniffPE(r io.ReadSeeker, size int64) (*Candidate, error) {
sr := wizutil.NewSliceReader(&readerAtFromSeeker{r}, 0, size)
spell := spellbook.Identify(sr, 0)
if !spellHas(spell, "PE") {
// uh oh
return nil, nil
}
result := &Candidate{
Flavor: FlavorNativeWindows,
Spell: spell,
WindowsInfo: &WindowsInfo{},
}
if spellHas(spell, "\\b32 executable") {
result.Arch = Arch386
} else if spellHas(spell, "\\b32+ executable") {
result.Arch = ArchAmd64
}
if spellHas(spell, "\\b, InnoSetup installer") {
result.WindowsInfo.InstallerType = WindowsInstallerTypeInno
} else if spellHas(spell, "\\b, InnoSetup uninstaller") {
result.WindowsInfo.InstallerType = WindowsInstallerTypeInno
result.WindowsInfo.Uninstaller = true
} else if spellHas(spell, "\\b, Nullsoft Installer self-extracting archive") {
result.WindowsInfo.InstallerType = WindowsInstallerTypeNullsoft
} else if spellHas(spell, "\\b, InstallShield self-extracting archive") {
result.WindowsInfo.InstallerType = WindowsInstallerTypeArchive
}
if spellHas(spell, "(GUI)") {
result.WindowsInfo.Gui = true
}
if spellHas(spell, "Mono/.Net assembly") {
result.WindowsInfo.DotNet = true
}
return result, nil
}