Skip to content

Commit 561408f

Browse files
committed
metric.go: add type BOOL int32 for structure align, refactor DTStatus.
1 parent d4e9de9 commit 561408f

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

metric/metric.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
package metric
22

3+
// BOOL is an int32 for structure align.
4+
type BOOL int32
5+
6+
// ToBool is used to convert to go bool.
7+
func (b BOOL) ToBool() bool {
8+
return b != 0
9+
}
10+
11+
func (b BOOL) String() string {
12+
if b.ToBool() {
13+
return "true"
14+
}
15+
return "false"
16+
}
17+
318
// Metrics contains status about runtime submodules.
419
type Metrics struct {
520
Library LTStatus `toml:"library" json:"library"`
@@ -49,27 +64,29 @@ type RTStatus struct {
4964

5065
// DTStatus contains status about detector.
5166
type DTStatus struct {
52-
IsEnabled bool `toml:"is_enabled" json:"is_enabled"`
53-
HasDebugger bool `toml:"has_debugger" json:"has_debugger"`
54-
HasMemoryScanner bool `toml:"has_memory_scanner" json:"has_memory_scanner"`
55-
InSandbox bool `toml:"in_sandbox" json:"in_sandbox"`
56-
InVirtualMachine bool `toml:"in_virtual_machine" json:"in_virtual_machine"`
57-
InEmulator bool `toml:"in_emulator" json:"in_emulator"`
58-
IsAccelerated bool `toml:"is_accelerated" json:"is_accelerated"`
59-
SafeRank int8 `toml:"safe_rank" json:"safe_rank"`
67+
IsEnabled BOOL `toml:"is_enabled" json:"is_enabled"`
68+
HasDebugger BOOL `toml:"has_debugger" json:"has_debugger"`
69+
HasMemoryScanner BOOL `toml:"has_memory_scanner" json:"has_memory_scanner"`
70+
InSandbox BOOL `toml:"in_sandbox" json:"in_sandbox"`
71+
InVirtualMachine BOOL `toml:"in_virtual_machine" json:"in_virtual_machine"`
72+
InEmulator BOOL `toml:"in_emulator" json:"in_emulator"`
73+
IsAccelerated BOOL `toml:"is_accelerated" json:"is_accelerated"`
74+
SafeRank int32 `toml:"safe_rank" json:"safe_rank"`
6075
}
6176

6277
// SMStatus contains status about sysmon.
6378
type SMStatus struct {
64-
IsEnabled bool `toml:"is_enabled" json:"is_enabled"`
79+
IsEnabled BOOL `toml:"is_enabled" json:"is_enabled"`
80+
Reserved int32 `toml:"-" json:"-"`
6581
NumNormal int64 `toml:"num_normal" json:"num_normal"`
6682
NumRecover int64 `toml:"num_recover" json:"num_recover"`
6783
NumPanic int64 `toml:"num_panic" json:"num_panic"`
6884
}
6985

7086
// WDStatus contains status about watchdog.
7187
type WDStatus struct {
72-
IsEnabled bool `toml:"is_enabled" json:"is_enabled"`
88+
IsEnabled BOOL `toml:"is_enabled" json:"is_enabled"`
89+
Reserved int32 `toml:"-" json:"-"`
7390
NumKick int64 `toml:"num_kick" json:"num_kick"`
7491
NumNormal int64 `toml:"num_normal" json:"num_normal"`
7592
NumReset int64 `toml:"num_reset" json:"num_reset"`

0 commit comments

Comments
 (0)