Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
Signed-off-by: Shravani Roy <Shravani.Roy@progress.com>
  • Loading branch information
RoyShravani committed Apr 13, 2022
1 parent 5862e18 commit 59e28a1
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions lib/win32/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ def initialize(options = {})
raise TypeError if host && !host.is_a?(String)

begin
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CREATE_SERVICE)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CREATE_SERVICE)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

# Display name defaults to service_name
opts["display_name"] ||= service_name
Expand Down Expand Up @@ -504,23 +504,23 @@ def self.configure(options = {})
end

begin
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CONNECT)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CONNECT)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

desired_access = SERVICE_CHANGE_CONFIG

if opts["failure_actions"]
desired_access |= SERVICE_START
end

handle_scs = OpenService(
handle_scs = OpenServiceA(
handle_scm,
service,
desired_access
)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

dependencies = opts["dependencies"]

Expand Down Expand Up @@ -601,11 +601,11 @@ def self.exists?(service, host = nil)
bool = false

begin
handle_scm = OpenSCManager(host, nil, SC_MANAGER_ENUMERATE_SERVICE)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_ENUMERATE_SERVICE)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

handle_scs = OpenService(handle_scm, service, SERVICE_QUERY_STATUS)
handle_scs = OpenServiceA(handle_scm, service, SERVICE_QUERY_STATUS)
bool = true if handle_scs > 0
ensure
close_service_handle(handle_scm)
Expand All @@ -628,9 +628,9 @@ def self.exists?(service, host = nil)
# Service.get_display_name('W32Time') => 'Windows Time'
#
def self.get_display_name(service, host = nil)
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CONNECT)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CONNECT)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

display_name = FFI::MemoryPointer.new(260)
display_size = FFI::MemoryPointer.new(:ulong)
Expand All @@ -644,7 +644,7 @@ def self.get_display_name(service, host = nil)
display_size
)

FFI.raise_windows_error("OpenSCManager") unless bool
FFI.raise_windows_error("OpenSCManagerA") unless bool
ensure
close_service_handle(handle_scm)
end
Expand All @@ -665,9 +665,9 @@ def self.get_display_name(service, host = nil)
# Service.get_service_name('Windows Time') => 'W32Time'
#
def self.get_service_name(display_name, host = nil)
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CONNECT)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CONNECT)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

service_name = FFI::MemoryPointer.new(260)
service_size = FFI::MemoryPointer.new(:ulong)
Expand Down Expand Up @@ -702,14 +702,14 @@ def self.get_service_name(display_name, host = nil)
# Service.start('SomeSvc', 'foo', 'hello') => self
#
def self.start(service, host = nil, *args)
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CONNECT)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CONNECT)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

begin
handle_scs = OpenService(handle_scm, service, SERVICE_START)
handle_scs = OpenServiceA(handle_scm, service, SERVICE_START)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

num_args = 0

Expand Down Expand Up @@ -813,14 +813,14 @@ def self.resume(service, host = nil)
# Service.delete('SomeService') => self
#
def self.delete(service, host = nil)
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CREATE_SERVICE)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CREATE_SERVICE)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

begin
handle_scs = OpenService(handle_scm, service, DELETE)
handle_scs = OpenServiceA(handle_scm, service, DELETE)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

unless DeleteService(handle_scs)
FFI.raise_windows_error("DeleteService")
Expand Down Expand Up @@ -848,14 +848,14 @@ def self.delete(service, host = nil)
def self.config_info(service, host = nil)
raise TypeError if host && !host.is_a?(String)

handle_scm = OpenSCManager(host, nil, SC_MANAGER_ENUMERATE_SERVICE)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_ENUMERATE_SERVICE)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

begin
handle_scs = OpenService(handle_scm, service, SERVICE_QUERY_CONFIG)
handle_scs = OpenServiceA(handle_scm, service, SERVICE_QUERY_CONFIG)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

# First, get the buf size needed
bytes = FFI::MemoryPointer.new(:ulong)
Expand Down Expand Up @@ -968,9 +968,9 @@ def self.services(host = nil, group = nil)
raise TypeError unless group.is_a?(String) # Avoid strange errors
end

handle_scm = OpenSCManager(host, nil, SC_MANAGER_ENUMERATE_SERVICE)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_ENUMERATE_SERVICE)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

bytes_needed = FFI::MemoryPointer.new(:ulong)
services_returned = FFI::MemoryPointer.new(:ulong)
Expand Down Expand Up @@ -1036,13 +1036,13 @@ def self.services(host = nil, group = nil)
service_flags = struct[:ServiceStatusProcess][:dwServiceFlags]

begin
handle_scs = OpenService(
handle_scs = OpenServiceA(
handle_scm,
service_name,
SERVICE_QUERY_CONFIG
)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

config_struct = get_config_info(handle_scs)

Expand Down Expand Up @@ -1197,17 +1197,17 @@ def self.services(host = nil, group = nil)
# a problem of some kind.
#
def self.delayed_start(service, host = nil)
handle_scm = OpenSCManager(host, nil, SC_MANAGER_ENUMERATE_SERVICE)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_ENUMERATE_SERVICE)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

handle_scs = OpenService(
handle_scs = OpenServiceA(
handle_scm,
service,
SERVICE_QUERY_CONFIG
)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

delayed_start_buf = get_config2_info(handle_scs, SERVICE_CONFIG_DELAYED_AUTO_START_INFO)
if delayed_start_buf.is_a?(FFI::MemoryPointer)
Expand Down Expand Up @@ -1252,12 +1252,12 @@ def self.close_service_handle(handle)
# @see Windows::ServiceConstants
#
def self.open_service(scm_handle, service_name, desired_access)
service_handle = OpenService(
service_handle = OpenServiceA(
scm_handle,
service_name,
desired_access
)
FFI.raise_windows_error("OpenService") if service_handle == 0
FFI.raise_windows_error("OpenServiceA") if service_handle == 0

if block_given?
yield service_handle
Expand Down Expand Up @@ -1289,8 +1289,8 @@ def self.open_service(scm_handle, service_name, desired_access)
# @see Windows::ServiceConstants
#
def self.open_sc_manager(host = nil, desired_access = SC_MANAGER_CONNECT)
scm_handle = OpenSCManager(host, nil, desired_access)
FFI.raise_windows_error("OpenSCManager") if scm_handle == 0
scm_handle = OpenSCManagerA(host, nil, desired_access)
FFI.raise_windows_error("OpenSCManagerA") if scm_handle == 0

if block_given?
yield scm_handle
Expand Down Expand Up @@ -1635,14 +1635,14 @@ def self.get_service_type(service_type)
# A shortcut method that simplifies the various service control methods.
#
def self.send_signal(service, host, service_signal, control_signal)
handle_scm = OpenSCManager(host, nil, SC_MANAGER_CONNECT)
handle_scm = OpenSCManagerA(host, nil, SC_MANAGER_CONNECT)

FFI.raise_windows_error("OpenSCManager") if handle_scm == 0
FFI.raise_windows_error("OpenSCManagerA") if handle_scm == 0

begin
handle_scs = OpenService(handle_scm, service, service_signal)
handle_scs = OpenServiceA(handle_scm, service, service_signal)

FFI.raise_windows_error("OpenService") if handle_scs == 0
FFI.raise_windows_error("OpenServiceA") if handle_scs == 0

status = SERVICE_STATUS.new

Expand Down

0 comments on commit 59e28a1

Please sign in to comment.