win32-service 2.1.6 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62f007030dada04e304cef4f4313683963c5bf0cb7f14a850a80737c5a21f1cf
4
- data.tar.gz: db6532bfa3181487a86ed875a078621c4c67583b80ffd15ca805b605d14efabd
3
+ metadata.gz: ef70f0e8d16323dd531f4a6558b910121fa02ed62a432e5e82a70bfa19736805
4
+ data.tar.gz: f1128b7daa3ec6d64cb374c554c291b222f37dd10079865f5be6ae930287c0bc
5
5
  SHA512:
6
- metadata.gz: 033bc35538753dde884295b62c6b30ea12cff01b607e3ca7313c64cdcc01e5a915bd18248062f779e75c1fa37b9b81270942943bf18770b569eb62623dab5232
7
- data.tar.gz: c7c95bd52e6e41273e008f3c3c43bf588cdd1fe4f5728e05fa5d3751de070192e7986c3a3735b257a4d9a175f762f47e25f37eb0f4b15544464cf5c946dfb648
6
+ metadata.gz: a9bb4ac05263a141d2a4fc1030e16b9d6df66af501917f3403fa082412055bd6c1118404e06b35531845bcbaa55ecd3f89e8677ec57c422b40c7cfa61d3a8e3d
7
+ data.tar.gz: be2e0f6108dd0093e582659ef201d78266cbcaa428e08eac3624146695bdc46337edbb3b5823179f3f5c541b881bb0e3d95c64fe1ef92ef636f1521a72053ef7
@@ -898,59 +898,41 @@ module Win32
898
898
  # Service.status('W32Time') => <struct Struct::ServiceStatus ...>
899
899
  #
900
900
  def self.status(service, host=nil)
901
- handle_scm = OpenSCManager(host, nil, SC_MANAGER_ENUMERATE_SERVICE)
902
-
903
- FFI.raise_windows_error('OpenSCManager') if handle_scm == 0
904
-
905
- begin
906
- handle_scs = OpenService(
907
- handle_scm,
908
- service,
909
- SERVICE_QUERY_STATUS
910
- )
911
-
912
- FFI.raise_windows_error('OpenService') if handle_scs == 0
913
-
914
- # SERVICE_STATUS_PROCESS struct
915
- status = SERVICE_STATUS_PROCESS.new
916
- bytes = FFI::MemoryPointer.new(:ulong)
917
-
918
- bool = QueryServiceStatusEx(
919
- handle_scs,
920
- SC_STATUS_PROCESS_INFO,
921
- status,
922
- status.size,
923
- bytes
924
- )
901
+ status = SERVICE_STATUS_PROCESS.new
902
+ bytes = FFI::MemoryPointer.new(:ulong)
903
+
904
+ open_sc_manager(host) do |scm_handle|
905
+ open_service(scm_handle, service, SERVICE_QUERY_STATUS) do |service_handle|
906
+ bool = QueryServiceStatusEx(
907
+ service_handle,
908
+ SC_STATUS_PROCESS_INFO,
909
+ status,
910
+ status.size,
911
+ bytes
912
+ )
925
913
 
926
- FFI.raise_windows_error('QueryServiceStatusEx') unless bool
927
-
928
- service_type = get_service_type(status[:dwServiceType])
929
- current_state = get_current_state(status[:dwCurrentState])
930
- controls = get_controls_accepted(status[:dwControlsAccepted])
931
- interactive = status[:dwServiceType] & SERVICE_INTERACTIVE_PROCESS > 0
932
-
933
- # Note that the pid and service flags will always return 0 if you're
934
- # on Windows NT 4 or using a version of Ruby compiled with VC++ 6
935
- # or earlier.
936
- #
937
- status_struct = StatusStruct.new(
938
- service_type,
939
- current_state,
940
- controls,
941
- status[:dwWin32ExitCode],
942
- status[:dwServiceSpecificExitCode],
943
- status[:dwCheckPoint],
944
- status[:dwWaitHint],
945
- interactive,
946
- status[:dwProcessId],
947
- status[:dwServiceFlags]
948
- )
949
- ensure
950
- close_service_handle(handle_scs)
951
- close_service_handle(handle_scm)
914
+ FFI.raise_windows_error('QueryServiceStatusEx') unless bool
915
+ end
952
916
  end
953
917
 
918
+ service_type = get_service_type(status[:dwServiceType])
919
+ current_state = get_current_state(status[:dwCurrentState])
920
+ controls = get_controls_accepted(status[:dwControlsAccepted])
921
+ interactive = status[:dwServiceType] & SERVICE_INTERACTIVE_PROCESS > 0
922
+
923
+ status_struct = StatusStruct.new(
924
+ service_type,
925
+ current_state,
926
+ controls,
927
+ status[:dwWin32ExitCode],
928
+ status[:dwServiceSpecificExitCode],
929
+ status[:dwCheckPoint],
930
+ status[:dwWaitHint],
931
+ interactive,
932
+ status[:dwProcessId],
933
+ status[:dwServiceFlags]
934
+ )
935
+
954
936
  status_struct
955
937
  end
956
938
 
@@ -1,6 +1,6 @@
1
1
  module Win32
2
2
  class Service
3
- VERSION = "2.1.6"
3
+ VERSION = "2.2.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-17 00:00:00.000000000 Z
12
+ date: 2020-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi