-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
globalptr.go
36 lines (29 loc) · 1.1 KB
/
globalptr.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
// Copyright 2022 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
package pe
const (
// AnoInvalidGlobalPtrReg is reported when the global pointer register offset is outide the image.
AnoInvalidGlobalPtrReg = "Global pointer register offset outside of PE image"
)
// RVA of the value to be stored in the global pointer register. The size must
// be set to 0. This data directory is set to all zeros if the target
// architecture (for example, I386 or AMD64) does not use the concept of a
// global pointer.
func (pe *File) parseGlobalPtrDirectory(rva, size uint32) error {
var err error
// RVA of the value to be stored in the global pointer register.
offset := pe.GetOffsetFromRva(rva)
if offset == ^uint32(0) {
// Fake global pointer data directory
// sample: 0101f36de484fbc7bfbe6cb942a1ecf6fac0c3acd9f65b88b19400582d7e7007
pe.Anomalies = append(pe.Anomalies, AnoInvalidGlobalPtrReg)
return nil
}
pe.GlobalPtr, err = pe.ReadUint32(offset)
if err != nil {
return err
}
pe.HasGlobalPtr = true
return nil
}