forked from chef/win32-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructs.rb
More file actions
127 lines (109 loc) · 3.02 KB
/
structs.rb
File metadata and controls
127 lines (109 loc) · 3.02 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
require "ffi" unless defined?(FFI)
module Windows
module ServiceStructs
extend FFI::Library
typedef :ulong, :dword
class SERVICE_STATUS < FFI::Struct
layout(
:dwServiceType, :ulong,
:dwCurrentState, :ulong,
:dwControlsAccepted, :ulong,
:dwWin32ExitCode, :ulong,
:dwServiceSpecificExitCode, :ulong,
:dwCheckPoint, :ulong,
:dwWaitHint, :ulong
)
end
class SERVICE_STATUS_PROCESS < FFI::Struct
layout(
:dwServiceType, :dword,
:dwCurrentState, :dword,
:dwControlsAccepted, :dword,
:dwWin32ExitCode, :dword,
:dwServiceSpecificExitCode, :dword,
:dwCheckPoint, :dword,
:dwWaitHint, :dword,
:dwProcessId, :dword,
:dwServiceFlags, :dword
)
end
class SERVICE_DESCRIPTION < FFI::Struct
layout(:lpDescription, :pointer)
end
class SERVICE_DELAYED_AUTO_START_INFO < FFI::Struct
layout(:fDelayedAutostart, :int) # BOOL
alias aset []=
# Intercept the accessor so that we can handle either true/false or 1/0.
# Since there is only one member, there's no need to check the key name.
#
def []=(key, value)
[0, false].include?(value) ? aset(key, 0) : aset(key, 1)
end
end
class QUERY_SERVICE_CONFIG < FFI::Struct
layout(
:dwServiceType, :dword,
:dwStartType, :dword,
:dwErrorControl, :dword,
:lpBinaryPathName, :pointer,
:lpLoadOrderGroup, :pointer,
:dwTagId, :dword,
:lpDependencies, :pointer,
:lpServiceStartName, :pointer,
:lpDisplayName, :pointer
)
def dependencies
length = self[:lpServiceStartName].address - self[:lpDependencies].address - 1
self[:lpDependencies].read_bytes(length).split(0.chr)
end
end
class ENUM_SERVICE_STATUS_PROCESS < FFI::Struct
layout(
:lpServiceName, :pointer,
:lpDisplayName, :pointer,
:ServiceStatusProcess, SERVICE_STATUS_PROCESS
)
end
class SC_ACTION < FFI::Struct
layout(:Type, :int, :Delay, :dword)
end
class SERVICE_FAILURE_ACTIONS < FFI::Struct
layout(
:dwResetPeriod, :dword,
:lpRebootMsg, :pointer,
:lpCommand, :pointer,
:cActions, :dword,
:lpsaActions, :pointer # Array of SC_ACTION structs
)
end
class SERVICE_FAILURE_ACTIONS_FLAG < FFI::Struct
layout(
:fFailureActionsOnNonCrashFailures, :int
)
end
class SERVICE_TABLE_ENTRY < FFI::Struct
layout(
:lpServiceName, :pointer,
:lpServiceProc, :pointer
)
end
class LUID < FFI::Struct
layout(
:LowPart, :ulong,
:HighPart, :long
)
end
class LUID_AND_ATTRIBUTES < FFI::Struct
layout(
:Luid, LUID,
:Attributes, :ulong
)
end
class TOKEN_PRIVILEGES < FFI::Struct
layout(
:PrivilegeCount, :dword,
:Privileges, [LUID_AND_ATTRIBUTES, 1]
)
end
end
end