mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
crypto/windows and utils/injector were the last public packages, against the no-library-API rule, and utils/ named nothing. They move as one unit; only import paths and Makefile variables change, and the built payload is byte-identical.
33 lines
539 B
Go
33 lines
539 B
Go
//go:build windows
|
|
|
|
package injector
|
|
|
|
import (
|
|
"bytes"
|
|
"debug/pe"
|
|
"fmt"
|
|
)
|
|
|
|
type Arch string
|
|
|
|
const (
|
|
ArchAMD64 Arch = "amd64"
|
|
Arch386 Arch = "386"
|
|
ArchUnknown Arch = "unknown"
|
|
)
|
|
|
|
func DetectPEArch(peBytes []byte) (Arch, error) {
|
|
f, err := pe.NewFile(bytes.NewReader(peBytes))
|
|
if err != nil {
|
|
return ArchUnknown, fmt.Errorf("parse PE: %w", err)
|
|
}
|
|
switch f.Machine {
|
|
case pe.IMAGE_FILE_MACHINE_AMD64:
|
|
return ArchAMD64, nil
|
|
case pe.IMAGE_FILE_MACHINE_I386:
|
|
return Arch386, nil
|
|
default:
|
|
return ArchUnknown, nil
|
|
}
|
|
}
|