win32-service 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,143 +1,143 @@
1
- module Windows
2
- module ServiceConstants
3
- SC_MANAGER_ALL_ACCESS = 0xF003F
4
- SC_MANAGER_CREATE_SERVICE = 0x0002
5
- SC_MANAGER_CONNECT = 0x0001
6
- SC_MANAGER_ENUMERATE_SERVICE = 0x0004
7
- SC_MANAGER_LOCK = 0x0008
8
- SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020
9
- SC_MANAGER_QUERY_LOCK_STATUS = 0x0010
10
- SC_STATUS_PROCESS_INFO = 0
11
- SC_ENUM_PROCESS_INFO = 0
12
-
13
- # Service control action types
14
- SC_ACTION_NONE = 0
15
- SC_ACTION_RESTART = 1
16
- SC_ACTION_REBOOT = 2
17
- SC_ACTION_RUN_COMMAND = 3
18
-
19
- # Service access rights
20
- SERVICE_ALL_ACCESS = 0xF01FF
21
- SERVICE_CHANGE_CONFIG = 0x0002
22
- SERVICE_ENUMERATE_DEPENDENTS = 0x0008
23
- SERVICE_INTERROGATE = 0x0080
24
- SERVICE_PAUSE_CONTINUE = 0x0040
25
- SERVICE_QUERY_CONFIG = 0x0001
26
- SERVICE_QUERY_STATUS = 0x0004
27
- SERVICE_START = 0x0010
28
- SERVICE_STOP = 0x0020
29
- SERVICE_USER_DEFINED_CONTROL = 0x0100
30
-
31
- # Service types
32
- SERVICE_KERNEL_DRIVER = 0x00000001
33
- SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
34
- SERVICE_ADAPTER = 0x00000004
35
- SERVICE_RECOGNIZER_DRIVER = 0x00000008
36
- SERVICE_WIN32_OWN_PROCESS = 0x00000010
37
- SERVICE_WIN32_SHARE_PROCESS = 0x00000020
38
- SERVICE_WIN32 = 0x00000030
39
- SERVICE_INTERACTIVE_PROCESS = 0x00000100
40
- SERVICE_DRIVER = 0x0000000B
41
- SERVICE_TYPE_ALL = 0x0000013F
42
-
43
- # Error control
44
- SERVICE_ERROR_IGNORE = 0x00000000
45
- SERVICE_ERROR_NORMAL = 0x00000001
46
- SERVICE_ERROR_SEVERE = 0x00000002
47
- SERVICE_ERROR_CRITICAL = 0x00000003
48
-
49
- # Start types
50
- SERVICE_BOOT_START = 0x00000000
51
- SERVICE_SYSTEM_START = 0x00000001
52
- SERVICE_AUTO_START = 0x00000002
53
- SERVICE_DEMAND_START = 0x00000003
54
- SERVICE_DISABLED = 0x00000004
55
-
56
- # Service control
57
-
58
- SERVICE_CONTROL_STOP = 0x00000001
59
- SERVICE_CONTROL_PAUSE = 0x00000002
60
- SERVICE_CONTROL_CONTINUE = 0x00000003
61
- SERVICE_CONTROL_INTERROGATE = 0x00000004
62
- SERVICE_CONTROL_SHUTDOWN = 0x00000005
63
- SERVICE_CONTROL_PARAMCHANGE = 0x00000006
64
- SERVICE_CONTROL_NETBINDADD = 0x00000007
65
- SERVICE_CONTROL_NETBINDREMOVE = 0x00000008
66
- SERVICE_CONTROL_NETBINDENABLE = 0x00000009
67
- SERVICE_CONTROL_NETBINDDISABLE = 0x0000000A
68
- SERVICE_CONTROL_DEVICEEVENT = 0x0000000B
69
- SERVICE_CONTROL_HARDWAREPROFILECHANGE = 0x0000000C
70
- SERVICE_CONTROL_POWEREVENT = 0x0000000D
71
- SERVICE_CONTROL_SESSIONCHANGE = 0x0000000E
72
- SERVICE_CONTROL_PRESHUTDOWN = 0x0000000F
73
- SERVICE_CONTROL_TIMECHANGE = 0x00000010
74
- SERVICE_CONTROL_TRIGGEREVENT = 0x00000020
75
-
76
- # Service controls accepted
77
-
78
- SERVICE_ACCEPT_STOP = 0x00000001
79
- SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
80
- SERVICE_ACCEPT_SHUTDOWN = 0x00000004
81
- SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
82
- SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
83
- SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020
84
- SERVICE_ACCEPT_POWEREVENT = 0x00000040
85
- SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
86
- SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100
87
- SERVICE_ACCEPT_TIMECHANGE = 0x00000200
88
- SERVICE_ACCEPT_TRIGGEREVENT = 0x00000400
89
-
90
- # Service states
91
- SERVICE_ACTIVE = 0x00000001
92
- SERVICE_INACTIVE = 0x00000002
93
- SERVICE_STATE_ALL = 0x00000003
94
-
95
- # Service current states
96
- SERVICE_STOPPED = 0x00000001
97
- SERVICE_START_PENDING = 0x00000002
98
- SERVICE_STOP_PENDING = 0x00000003
99
- SERVICE_RUNNING = 0x00000004
100
- SERVICE_CONTINUE_PENDING = 0x00000005
101
- SERVICE_PAUSE_PENDING = 0x00000006
102
- SERVICE_PAUSED = 0x00000007
103
-
104
- # Info levels
105
- SERVICE_CONFIG_DESCRIPTION = 1
106
- SERVICE_CONFIG_FAILURE_ACTIONS = 2
107
- SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3
108
- SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4
109
- SERVICE_CONFIG_SERVICE_SID_INFO = 5
110
- SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
111
- SERVICE_CONFIG_PRESHUTDOWN_INFO = 7
112
-
113
- # Configuration
114
- SERVICE_NO_CHANGE = 0xffffffff
115
-
116
- # Misc
117
-
118
- WAIT_OBJECT_0 = 0
119
- WAIT_TIMEOUT = 0x00000102
120
- INFINITE = 0xFFFFFFFF
121
-
122
- IDLE_CONTROL_CODE = 0
123
-
124
- DELETE = 0x00010000
125
- FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
126
- FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200
127
-
128
- NO_ERROR = 0
129
-
130
- SE_PRIVILEGE_ENABLED = 0x00000002
131
- TOKEN_ADJUST_PRIVILEGES = 0x0020
132
- TOKEN_QUERY = 0x0008
133
-
134
- # Errors
135
-
136
- ERROR_INSUFFICIENT_BUFFER = 122
137
- ERROR_MORE_DATA = 234
138
- ERROR_FILE_NOT_FOUND = 2
139
- ERROR_RESOURCE_TYPE_NOT_FOUND = 1813
140
- ERROR_RESOURCE_NAME_NOT_FOUND = 1814
141
- WAIT_FAILED = 0xFFFFFFFF
142
- end
143
- end
1
+ module Windows
2
+ module ServiceConstants
3
+ SC_MANAGER_ALL_ACCESS = 0xF003F
4
+ SC_MANAGER_CREATE_SERVICE = 0x0002
5
+ SC_MANAGER_CONNECT = 0x0001
6
+ SC_MANAGER_ENUMERATE_SERVICE = 0x0004
7
+ SC_MANAGER_LOCK = 0x0008
8
+ SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020
9
+ SC_MANAGER_QUERY_LOCK_STATUS = 0x0010
10
+ SC_STATUS_PROCESS_INFO = 0
11
+ SC_ENUM_PROCESS_INFO = 0
12
+
13
+ # Service control action types
14
+ SC_ACTION_NONE = 0
15
+ SC_ACTION_RESTART = 1
16
+ SC_ACTION_REBOOT = 2
17
+ SC_ACTION_RUN_COMMAND = 3
18
+
19
+ # Service access rights
20
+ SERVICE_ALL_ACCESS = 0xF01FF
21
+ SERVICE_CHANGE_CONFIG = 0x0002
22
+ SERVICE_ENUMERATE_DEPENDENTS = 0x0008
23
+ SERVICE_INTERROGATE = 0x0080
24
+ SERVICE_PAUSE_CONTINUE = 0x0040
25
+ SERVICE_QUERY_CONFIG = 0x0001
26
+ SERVICE_QUERY_STATUS = 0x0004
27
+ SERVICE_START = 0x0010
28
+ SERVICE_STOP = 0x0020
29
+ SERVICE_USER_DEFINED_CONTROL = 0x0100
30
+
31
+ # Service types
32
+ SERVICE_KERNEL_DRIVER = 0x00000001
33
+ SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
34
+ SERVICE_ADAPTER = 0x00000004
35
+ SERVICE_RECOGNIZER_DRIVER = 0x00000008
36
+ SERVICE_WIN32_OWN_PROCESS = 0x00000010
37
+ SERVICE_WIN32_SHARE_PROCESS = 0x00000020
38
+ SERVICE_WIN32 = 0x00000030
39
+ SERVICE_INTERACTIVE_PROCESS = 0x00000100
40
+ SERVICE_DRIVER = 0x0000000B
41
+ SERVICE_TYPE_ALL = 0x0000013F
42
+
43
+ # Error control
44
+ SERVICE_ERROR_IGNORE = 0x00000000
45
+ SERVICE_ERROR_NORMAL = 0x00000001
46
+ SERVICE_ERROR_SEVERE = 0x00000002
47
+ SERVICE_ERROR_CRITICAL = 0x00000003
48
+
49
+ # Start types
50
+ SERVICE_BOOT_START = 0x00000000
51
+ SERVICE_SYSTEM_START = 0x00000001
52
+ SERVICE_AUTO_START = 0x00000002
53
+ SERVICE_DEMAND_START = 0x00000003
54
+ SERVICE_DISABLED = 0x00000004
55
+
56
+ # Service control
57
+
58
+ SERVICE_CONTROL_STOP = 0x00000001
59
+ SERVICE_CONTROL_PAUSE = 0x00000002
60
+ SERVICE_CONTROL_CONTINUE = 0x00000003
61
+ SERVICE_CONTROL_INTERROGATE = 0x00000004
62
+ SERVICE_CONTROL_SHUTDOWN = 0x00000005
63
+ SERVICE_CONTROL_PARAMCHANGE = 0x00000006
64
+ SERVICE_CONTROL_NETBINDADD = 0x00000007
65
+ SERVICE_CONTROL_NETBINDREMOVE = 0x00000008
66
+ SERVICE_CONTROL_NETBINDENABLE = 0x00000009
67
+ SERVICE_CONTROL_NETBINDDISABLE = 0x0000000A
68
+ SERVICE_CONTROL_DEVICEEVENT = 0x0000000B
69
+ SERVICE_CONTROL_HARDWAREPROFILECHANGE = 0x0000000C
70
+ SERVICE_CONTROL_POWEREVENT = 0x0000000D
71
+ SERVICE_CONTROL_SESSIONCHANGE = 0x0000000E
72
+ SERVICE_CONTROL_PRESHUTDOWN = 0x0000000F
73
+ SERVICE_CONTROL_TIMECHANGE = 0x00000010
74
+ SERVICE_CONTROL_TRIGGEREVENT = 0x00000020
75
+
76
+ # Service controls accepted
77
+
78
+ SERVICE_ACCEPT_STOP = 0x00000001
79
+ SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
80
+ SERVICE_ACCEPT_SHUTDOWN = 0x00000004
81
+ SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
82
+ SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
83
+ SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020
84
+ SERVICE_ACCEPT_POWEREVENT = 0x00000040
85
+ SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
86
+ SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100
87
+ SERVICE_ACCEPT_TIMECHANGE = 0x00000200
88
+ SERVICE_ACCEPT_TRIGGEREVENT = 0x00000400
89
+
90
+ # Service states
91
+ SERVICE_ACTIVE = 0x00000001
92
+ SERVICE_INACTIVE = 0x00000002
93
+ SERVICE_STATE_ALL = 0x00000003
94
+
95
+ # Service current states
96
+ SERVICE_STOPPED = 0x00000001
97
+ SERVICE_START_PENDING = 0x00000002
98
+ SERVICE_STOP_PENDING = 0x00000003
99
+ SERVICE_RUNNING = 0x00000004
100
+ SERVICE_CONTINUE_PENDING = 0x00000005
101
+ SERVICE_PAUSE_PENDING = 0x00000006
102
+ SERVICE_PAUSED = 0x00000007
103
+
104
+ # Info levels
105
+ SERVICE_CONFIG_DESCRIPTION = 1
106
+ SERVICE_CONFIG_FAILURE_ACTIONS = 2
107
+ SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3
108
+ SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4
109
+ SERVICE_CONFIG_SERVICE_SID_INFO = 5
110
+ SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
111
+ SERVICE_CONFIG_PRESHUTDOWN_INFO = 7
112
+
113
+ # Configuration
114
+ SERVICE_NO_CHANGE = 0xffffffff
115
+
116
+ # Misc
117
+
118
+ WAIT_OBJECT_0 = 0
119
+ WAIT_TIMEOUT = 0x00000102
120
+ INFINITE = 0xFFFFFFFF
121
+
122
+ IDLE_CONTROL_CODE = 0
123
+
124
+ DELETE = 0x00010000
125
+ FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
126
+ FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200
127
+
128
+ NO_ERROR = 0
129
+
130
+ SE_PRIVILEGE_ENABLED = 0x00000002
131
+ TOKEN_ADJUST_PRIVILEGES = 0x0020
132
+ TOKEN_QUERY = 0x0008
133
+
134
+ # Errors
135
+
136
+ ERROR_INSUFFICIENT_BUFFER = 122
137
+ ERROR_MORE_DATA = 234
138
+ ERROR_FILE_NOT_FOUND = 2
139
+ ERROR_RESOURCE_TYPE_NOT_FOUND = 1813
140
+ ERROR_RESOURCE_NAME_NOT_FOUND = 1814
141
+ WAIT_FAILED = 0xFFFFFFFF
142
+ end
143
+ end
@@ -1,75 +1,75 @@
1
- require 'ffi'
2
-
3
- module Windows
4
- module Functions
5
- extend FFI::Library
6
-
7
- # Make FFI functions private
8
- module FFI::Library
9
- def attach_pfunc(*args)
10
- attach_function(*args)
11
- private args[0]
12
- end
13
- end
14
-
15
- typedef :ulong, :dword
16
- typedef :uintptr_t, :handle
17
- typedef :pointer, :ptr
18
- typedef :string, :str
19
-
20
- ffi_convention :stdcall
21
-
22
- ffi_lib :kernel32
23
-
24
- attach_pfunc :CloseHandle, [:handle], :bool
25
- attach_pfunc :CreateEvent, :CreateEventA, [:ptr, :bool, :bool, :str], :handle
26
- attach_pfunc :CreateThread, [:ptr, :size_t, :ptr, :ptr, :dword, :ptr], :handle, :blocking => true
27
- attach_pfunc :EnterCriticalSection, [:ptr], :void
28
- attach_pfunc :FormatMessage, :FormatMessageA, [:ulong, :ptr, :ulong, :ulong, :str, :ulong, :ptr], :ulong
29
- attach_pfunc :GetCurrentProcess, [], :handle
30
- attach_pfunc :InitializeCriticalSection, [:ptr], :void
31
- attach_pfunc :LeaveCriticalSection, [:ptr], :void
32
- attach_pfunc :SetEvent, [:handle], :bool
33
- attach_pfunc :WaitForSingleObject, [:handle, :dword], :dword, :blocking => true
34
- attach_pfunc :WaitForMultipleObjects, [:dword, :ptr, :bool, :dword], :dword
35
-
36
- ffi_lib :advapi32
37
-
38
- callback :handler_ex, [:ulong, :ulong, :ptr, :ptr], :void
39
-
40
- attach_pfunc :AdjustTokenPrivileges, [:handle, :bool, :ptr, :dword, :ptr, :ptr], :bool
41
- attach_pfunc :CloseServiceHandle, [:handle], :bool
42
-
43
- attach_pfunc :ChangeServiceConfig, :ChangeServiceConfigA,
44
- [:handle, :dword, :dword, :dword, :str, :str, :ptr, :str, :str, :str, :str],
45
- :bool
46
-
47
- attach_pfunc :ChangeServiceConfig2, :ChangeServiceConfig2A, [:handle, :dword, :ptr], :bool
48
-
49
- attach_pfunc :CreateService, :CreateServiceA,
50
- [:handle, :string, :string, :dword, :dword, :dword, :dword,
51
- :string, :string, :ptr, :pointer, :string, :string],
52
- :handle
53
-
54
- attach_pfunc :ControlService, [:handle, :dword, :ptr], :bool
55
- attach_pfunc :DeleteService, [:handle], :bool
56
-
57
- attach_pfunc :EnumServicesStatusEx, :EnumServicesStatusExA,
58
- [:handle, :int, :dword, :dword, :ptr, :dword, :ptr, :ptr, :ptr, :string],
59
- :bool
60
-
61
- attach_pfunc :GetServiceDisplayName, :GetServiceDisplayNameA, [:handle, :string, :ptr, :ptr], :bool
62
- attach_pfunc :GetServiceKeyName, :GetServiceKeyNameA, [:handle, :string, :ptr, :ptr], :bool
63
- attach_pfunc :LookupPrivilegeValue, :LookupPrivilegeValueA, [:string, :string, :ptr], :bool
64
- attach_pfunc :OpenSCManager, :OpenSCManagerA, [:ptr, :ptr, :dword], :handle
65
- attach_pfunc :OpenProcessToken, [:handle, :dword, :ptr], :bool
66
- attach_pfunc :OpenService, :OpenServiceA, [:handle, :string, :dword], :handle
67
- attach_pfunc :QueryServiceConfig, :QueryServiceConfigA, [:handle, :ptr, :dword, :ptr], :bool
68
- attach_pfunc :QueryServiceConfig2, :QueryServiceConfig2A, [:handle, :dword, :ptr, :dword, :ptr], :bool
69
- attach_pfunc :QueryServiceStatusEx, [:handle, :int, :ptr, :dword, :ptr], :bool
70
- attach_pfunc :RegisterServiceCtrlHandlerEx, :RegisterServiceCtrlHandlerExA, [:str, :handler_ex, :ptr], :handle
71
- attach_pfunc :SetServiceStatus, [:handle, :ptr], :bool
72
- attach_pfunc :StartService, :StartServiceA, [:handle, :dword, :ptr], :bool
73
- attach_pfunc :StartServiceCtrlDispatcher, :StartServiceCtrlDispatcherA, [:ptr], :bool, :blocking => true
74
- end
75
- end
1
+ require 'ffi'
2
+
3
+ module Windows
4
+ module Functions
5
+ extend FFI::Library
6
+
7
+ # Make FFI functions private
8
+ module FFI::Library
9
+ def attach_pfunc(*args)
10
+ attach_function(*args)
11
+ private args[0]
12
+ end
13
+ end
14
+
15
+ typedef :ulong, :dword
16
+ typedef :uintptr_t, :handle
17
+ typedef :pointer, :ptr
18
+ typedef :string, :str
19
+
20
+ ffi_convention :stdcall
21
+
22
+ ffi_lib :kernel32
23
+
24
+ attach_pfunc :CloseHandle, [:handle], :bool
25
+ attach_pfunc :CreateEvent, :CreateEventA, [:ptr, :bool, :bool, :str], :handle
26
+ attach_pfunc :CreateThread, [:ptr, :size_t, :ptr, :ptr, :dword, :ptr], :handle, :blocking => true
27
+ attach_pfunc :EnterCriticalSection, [:ptr], :void
28
+ attach_pfunc :FormatMessage, :FormatMessageA, [:ulong, :ptr, :ulong, :ulong, :str, :ulong, :ptr], :ulong
29
+ attach_pfunc :GetCurrentProcess, [], :handle
30
+ attach_pfunc :InitializeCriticalSection, [:ptr], :void
31
+ attach_pfunc :LeaveCriticalSection, [:ptr], :void
32
+ attach_pfunc :SetEvent, [:handle], :bool
33
+ attach_pfunc :WaitForSingleObject, [:handle, :dword], :dword, :blocking => true
34
+ attach_pfunc :WaitForMultipleObjects, [:dword, :ptr, :bool, :dword], :dword
35
+
36
+ ffi_lib :advapi32
37
+
38
+ callback :handler_ex, [:ulong, :ulong, :ptr, :ptr], :void
39
+
40
+ attach_pfunc :AdjustTokenPrivileges, [:handle, :bool, :ptr, :dword, :ptr, :ptr], :bool
41
+ attach_pfunc :CloseServiceHandle, [:handle], :bool
42
+
43
+ attach_pfunc :ChangeServiceConfig, :ChangeServiceConfigA,
44
+ [:handle, :dword, :dword, :dword, :str, :str, :ptr, :str, :str, :str, :str],
45
+ :bool
46
+
47
+ attach_pfunc :ChangeServiceConfig2, :ChangeServiceConfig2A, [:handle, :dword, :ptr], :bool
48
+
49
+ attach_pfunc :CreateService, :CreateServiceA,
50
+ [:handle, :string, :string, :dword, :dword, :dword, :dword,
51
+ :string, :string, :ptr, :pointer, :string, :string],
52
+ :handle
53
+
54
+ attach_pfunc :ControlService, [:handle, :dword, :ptr], :bool
55
+ attach_pfunc :DeleteService, [:handle], :bool
56
+
57
+ attach_pfunc :EnumServicesStatusEx, :EnumServicesStatusExA,
58
+ [:handle, :int, :dword, :dword, :ptr, :dword, :ptr, :ptr, :ptr, :string],
59
+ :bool
60
+
61
+ attach_pfunc :GetServiceDisplayName, :GetServiceDisplayNameA, [:handle, :string, :ptr, :ptr], :bool
62
+ attach_pfunc :GetServiceKeyName, :GetServiceKeyNameA, [:handle, :string, :ptr, :ptr], :bool
63
+ attach_pfunc :LookupPrivilegeValue, :LookupPrivilegeValueA, [:string, :string, :ptr], :bool
64
+ attach_pfunc :OpenSCManager, :OpenSCManagerA, [:ptr, :ptr, :dword], :handle
65
+ attach_pfunc :OpenProcessToken, [:handle, :dword, :ptr], :bool
66
+ attach_pfunc :OpenService, :OpenServiceA, [:handle, :string, :dword], :handle
67
+ attach_pfunc :QueryServiceConfig, :QueryServiceConfigA, [:handle, :ptr, :dword, :ptr], :bool
68
+ attach_pfunc :QueryServiceConfig2, :QueryServiceConfig2A, [:handle, :dword, :ptr, :dword, :ptr], :bool
69
+ attach_pfunc :QueryServiceStatusEx, [:handle, :int, :ptr, :dword, :ptr], :bool
70
+ attach_pfunc :RegisterServiceCtrlHandlerEx, :RegisterServiceCtrlHandlerExA, [:str, :handler_ex, :ptr], :handle
71
+ attach_pfunc :SetServiceStatus, [:handle, :ptr], :bool
72
+ attach_pfunc :StartService, :StartServiceA, [:handle, :dword, :ptr], :bool
73
+ attach_pfunc :StartServiceCtrlDispatcher, :StartServiceCtrlDispatcherA, [:ptr], :bool, :blocking => true
74
+ end
75
+ end
@@ -1,41 +1,41 @@
1
- require 'ffi'
2
-
3
- class FFI::Pointer
4
- def read_array_of_null_separated_strings
5
- elements = []
6
- loc = self
7
-
8
- while element = loc.read_string
9
- break if element.nil? || element == ""
10
- elements << element
11
- loc += element.size + 1
12
- end
13
-
14
- elements
15
- end
16
- end
17
-
18
- module FFI
19
- extend FFI::Library
20
-
21
- ffi_lib :kernel32
22
-
23
- attach_function :FormatMessage, :FormatMessageA,
24
- [:ulong, :pointer, :ulong, :ulong, :pointer, :ulong, :pointer], :ulong
25
-
26
- def win_error(function, err=FFI.errno)
27
- flags = 0x00001000 | 0x00000200
28
- buf = FFI::MemoryPointer.new(:char, 1024)
29
-
30
- FormatMessage(flags, nil, err , 0x0409, buf, 1024, nil)
31
-
32
- function + ': ' + buf.read_string.strip
33
- end
34
-
35
- def raise_windows_error(function, err=FFI.errno)
36
- raise SystemCallError.new(win_error(function, err), err)
37
- end
38
-
39
- module_function :win_error
40
- module_function :raise_windows_error
41
- end
1
+ require 'ffi'
2
+
3
+ class FFI::Pointer
4
+ def read_array_of_null_separated_strings
5
+ elements = []
6
+ loc = self
7
+
8
+ while element = loc.read_string
9
+ break if element.nil? || element == ""
10
+ elements << element
11
+ loc += element.size + 1
12
+ end
13
+
14
+ elements
15
+ end
16
+ end
17
+
18
+ module FFI
19
+ extend FFI::Library
20
+
21
+ ffi_lib :kernel32
22
+
23
+ attach_function :FormatMessage, :FormatMessageA,
24
+ [:ulong, :pointer, :ulong, :ulong, :pointer, :ulong, :pointer], :ulong
25
+
26
+ def win_error(function, err=FFI.errno)
27
+ flags = 0x00001000 | 0x00000200
28
+ buf = FFI::MemoryPointer.new(:char, 1024)
29
+
30
+ FormatMessage(flags, nil, err , 0x0409, buf, 1024, nil)
31
+
32
+ function + ': ' + buf.read_string.strip
33
+ end
34
+
35
+ def raise_windows_error(function, err=FFI.errno)
36
+ raise SystemCallError.new(win_error(function, err), err)
37
+ end
38
+
39
+ module_function :win_error
40
+ module_function :raise_windows_error
41
+ end