win32-process 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/win32/process.rb CHANGED
@@ -1,7 +1,7 @@
1
- require_relative 'process/functions'
2
- require_relative 'process/constants'
3
- require_relative 'process/structs'
4
- require_relative 'process/helper'
1
+ require_relative "process/functions"
2
+ require_relative "process/constants"
3
+ require_relative "process/structs"
4
+ require_relative "process/helper"
5
5
 
6
6
  module Process
7
7
  include Process::Constants
@@ -10,7 +10,7 @@ module Process
10
10
  extend Process::Constants
11
11
 
12
12
  # The version of the win32-process library.
13
- WIN32_PROCESS_VERSION = '0.9.0'
13
+ WIN32_PROCESS_VERSION = "1.0.0"
14
14
 
15
15
  # Disable popups. This mostly affects the Process.kill method.
16
16
  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX)
@@ -95,9 +95,10 @@ module Process
95
95
  # 32768 => Process::ABOVE_NORMAL_PRIORITY_CLASS
96
96
  #
97
97
  def getpriority(kind, int)
98
- raise TypeError, kind unless kind.is_a?(Fixnum) # Match spec
99
- raise TypeError, int unless int.is_a?(Fixnum) # Match spec
100
- int = Process.pid if int == 0 # Match spec
98
+ raise TypeError, kind unless kind.is_a?(Integer) # Match spec
99
+ raise TypeError, int unless int.is_a?(Integer) # Match spec
100
+
101
+ int = Process.pid if int == 0 # Match spec
101
102
 
102
103
  handle = OpenProcess(PROCESS_QUERY_INFORMATION, 0, int)
103
104
 
@@ -139,6 +140,7 @@ module Process
139
140
  raise TypeError unless kind.is_a?(Integer) # Match spec
140
141
  raise TypeError unless int.is_a?(Integer) # Match spec
141
142
  raise TypeError unless int_priority.is_a?(Integer) # Match spec
143
+
142
144
  int = Process.pid if int == 0 # Match spec
143
145
 
144
146
  handle = OpenProcess(PROCESS_SET_INFORMATION, 0 , int)
@@ -155,7 +157,7 @@ module Process
155
157
  CloseHandle(handle)
156
158
  end
157
159
 
158
- return 0 # Match the spec
160
+ 0 # Match the spec
159
161
  end
160
162
 
161
163
  remove_method :uid
@@ -193,7 +195,7 @@ module Process
193
195
  raise SystemCallError, FFI.errno, "GetTokenInformation"
194
196
  end
195
197
 
196
- string_sid = tuser[FFI.type_size(:pointer)*2, (rlength.read_ulong - FFI.type_size(:pointer)*2)]
198
+ string_sid = tuser[FFI.type_size(:pointer) * 2, (rlength.read_ulong - FFI.type_size(:pointer) * 2)]
197
199
 
198
200
  if sid
199
201
  string_sid
@@ -204,7 +206,7 @@ module Process
204
206
  raise SystemCallError, FFI.errno, "ConvertSidToStringSid"
205
207
  end
206
208
 
207
- psid.read_pointer.read_string.split('-').last.to_i
209
+ psid.read_pointer.read_string.split("-").last.to_i
208
210
  end
209
211
  end
210
212
 
@@ -244,7 +246,7 @@ module Process
244
246
  #
245
247
  def getrlimit(resource)
246
248
  if resource == RLIMIT_FSIZE
247
- if volume_type == 'NTFS'
249
+ if volume_type == "NTFS"
248
250
  return ((1024**4) * 4) - (1024 * 64) # ~ 4TB
249
251
  else
250
252
  return (1024**3) * 4 # 4 GB
@@ -259,7 +261,7 @@ module Process
259
261
  handle = OpenJobObjectA(JOB_OBJECT_QUERY, 1, @win32_process_job_name)
260
262
  raise SystemCallError, FFI.errno, "OpenJobObject" if handle == 0
261
263
  else
262
- @win32_process_job_name = 'ruby_' + Process.pid.to_s
264
+ @win32_process_job_name = "ruby_" + Process.pid.to_s
263
265
  handle = CreateJobObjectA(nil, @win32_process_job_name)
264
266
  raise SystemCallError, FFI.errno, "CreateJobObject" if handle == 0
265
267
  end
@@ -304,7 +306,7 @@ module Process
304
306
  end
305
307
 
306
308
  ensure
307
- at_exit{ CloseHandle(handle) if handle }
309
+ at_exit { CloseHandle(handle) if handle }
308
310
  end
309
311
 
310
312
  [val, val]
@@ -350,7 +352,7 @@ module Process
350
352
  handle = OpenJobObjectA(JOB_OBJECT_SET_ATTRIBUTES, 1, @win32_process_job_name)
351
353
  raise SystemCallError, FFI.errno, "OpenJobObject" if handle == 0
352
354
  else
353
- @win32_process_job_name = 'ruby_' + Process.pid.to_s
355
+ @win32_process_job_name = "ruby_" + Process.pid.to_s
354
356
  handle = CreateJobObjectA(nil, @win32_process_job_name)
355
357
  raise SystemCallError, FFI.errno, "CreateJobObject" if handle == 0
356
358
  end
@@ -384,7 +386,7 @@ module Process
384
386
  raise SystemCallError, FFI.errno, "SetInformationJobObject"
385
387
  end
386
388
  ensure
387
- at_exit{ CloseHandle(handle) if handle }
389
+ at_exit { CloseHandle(handle) if handle }
388
390
  end
389
391
  end
390
392
 
@@ -468,79 +470,81 @@ module Process
468
470
  # Process.spawn method instead of Process.create where possible.
469
471
  #
470
472
  def create(args)
471
- unless args.kind_of?(Hash)
472
- raise TypeError, 'hash keyword arguments expected'
473
+ unless args.is_a?(Hash)
474
+ raise TypeError, "hash keyword arguments expected"
473
475
  end
474
476
 
475
- valid_keys = %w[
477
+ valid_keys = %w{
476
478
  app_name command_line inherit creation_flags cwd environment
477
479
  startup_info thread_inherit process_inherit close_handles with_logon
478
480
  domain password
479
- ]
481
+ }
480
482
 
481
- valid_si_keys = %w[
483
+ valid_si_keys = %w{
482
484
  startf_flags desktop title x y x_size y_size x_count_chars
483
485
  y_count_chars fill_attribute sw_flags stdin stdout stderr
484
- ]
486
+ }
485
487
 
486
488
  # Set default values
487
489
  hash = {
488
- 'app_name' => nil,
489
- 'creation_flags' => 0,
490
- 'close_handles' => true
490
+ "app_name" => nil,
491
+ "creation_flags" => 0,
492
+ "close_handles" => true,
491
493
  }
492
494
 
493
495
  # Validate the keys, and convert symbols and case to lowercase strings.
494
- args.each{ |key, val|
496
+ args.each { |key, val|
495
497
  key = key.to_s.downcase
496
498
  unless valid_keys.include?(key)
497
499
  raise ArgumentError, "invalid key '#{key}'"
498
500
  end
501
+
499
502
  hash[key] = val
500
503
  }
501
504
 
502
505
  si_hash = {}
503
506
 
504
507
  # If the startup_info key is present, validate its subkeys
505
- if hash['startup_info']
506
- hash['startup_info'].each{ |key, val|
508
+ if hash["startup_info"]
509
+ hash["startup_info"].each { |key, val|
507
510
  key = key.to_s.downcase
508
511
  unless valid_si_keys.include?(key)
509
512
  raise ArgumentError, "invalid startup_info key '#{key}'"
510
513
  end
514
+
511
515
  si_hash[key] = val
512
516
  }
513
517
  end
514
518
 
515
519
  # The +command_line+ key is mandatory unless the +app_name+ key
516
520
  # is specified.
517
- unless hash['command_line']
518
- if hash['app_name']
519
- hash['command_line'] = hash['app_name']
520
- hash['app_name'] = nil
521
+ unless hash["command_line"]
522
+ if hash["app_name"]
523
+ hash["command_line"] = hash["app_name"]
524
+ hash["app_name"] = nil
521
525
  else
522
- raise ArgumentError, 'command_line or app_name must be specified'
526
+ raise ArgumentError, "command_line or app_name must be specified"
523
527
  end
524
528
  end
525
529
 
526
530
  env = nil
527
531
 
528
532
  # The env string should be passed as a string of ';' separated paths.
529
- if hash['environment']
530
- env = hash['environment']
533
+ if hash["environment"]
534
+ env = hash["environment"]
531
535
 
532
536
  unless env.respond_to?(:join)
533
- env = hash['environment'].split(File::PATH_SEPARATOR)
537
+ env = hash["environment"].split(File::PATH_SEPARATOR)
534
538
  end
535
539
 
536
- env = env.map{ |e| e + 0.chr }.join('') + 0.chr
537
- env.to_wide_string! if hash['with_logon']
540
+ env = env.map { |e| e + 0.chr }.join("") + 0.chr
541
+ env.to_wide_string! if hash["with_logon"]
538
542
  end
539
543
 
540
544
  # Process SECURITY_ATTRIBUTE structure
541
545
  process_security = nil
542
546
 
543
- if hash['process_inherit']
547
+ if hash["process_inherit"]
544
548
  process_security = SECURITY_ATTRIBUTES.new
545
549
  process_security[:nLength] = 12
546
550
  process_security[:bInheritHandle] = 1
@@ -549,7 +553,7 @@ module Process
549
553
  # Thread SECURITY_ATTRIBUTE structure
550
554
  thread_security = nil
551
555
 
552
- if hash['thread_inherit']
556
+ if hash["thread_inherit"]
553
557
  thread_security = SECURITY_ATTRIBUTES.new
554
558
  thread_security[:nLength] = 12
555
559
  thread_security[:bInheritHandle] = 1
@@ -560,7 +564,7 @@ module Process
560
564
  # will not work on JRuby because of the way it handles internal file
561
565
  # descriptors.
562
566
  #
563
- ['stdin', 'stdout', 'stderr'].each{ |io|
567
+ %w{stdin stdout stderr}.each { |io|
564
568
  if si_hash[io]
565
569
  if si_hash[io].respond_to?(:fileno)
566
570
  handle = get_osfhandle(si_hash[io].fileno)
@@ -591,9 +595,9 @@ module Process
591
595
  raise SystemCallError.new("SetHandleInformation", FFI.errno) unless bool
592
596
 
593
597
  si_hash[io] = handle
594
- si_hash['startf_flags'] ||= 0
595
- si_hash['startf_flags'] |= STARTF_USESTDHANDLES
596
- hash['inherit'] = true
598
+ si_hash["startf_flags"] ||= 0
599
+ si_hash["startf_flags"] |= STARTF_USESTDHANDLES
600
+ hash["inherit"] = true
597
601
  end
598
602
  }
599
603
 
@@ -602,53 +606,53 @@ module Process
602
606
 
603
607
  unless si_hash.empty?
604
608
  startinfo[:cb] = startinfo.size
605
- startinfo[:lpDesktop] = si_hash['desktop'] if si_hash['desktop']
606
- startinfo[:lpTitle] = si_hash['title'] if si_hash['title']
607
- startinfo[:dwX] = si_hash['x'] if si_hash['x']
608
- startinfo[:dwY] = si_hash['y'] if si_hash['y']
609
- startinfo[:dwXSize] = si_hash['x_size'] if si_hash['x_size']
610
- startinfo[:dwYSize] = si_hash['y_size'] if si_hash['y_size']
611
- startinfo[:dwXCountChars] = si_hash['x_count_chars'] if si_hash['x_count_chars']
612
- startinfo[:dwYCountChars] = si_hash['y_count_chars'] if si_hash['y_count_chars']
613
- startinfo[:dwFillAttribute] = si_hash['fill_attribute'] if si_hash['fill_attribute']
614
- startinfo[:dwFlags] = si_hash['startf_flags'] if si_hash['startf_flags']
615
- startinfo[:wShowWindow] = si_hash['sw_flags'] if si_hash['sw_flags']
609
+ startinfo[:lpDesktop] = si_hash["desktop"] if si_hash["desktop"]
610
+ startinfo[:lpTitle] = si_hash["title"] if si_hash["title"]
611
+ startinfo[:dwX] = si_hash["x"] if si_hash["x"]
612
+ startinfo[:dwY] = si_hash["y"] if si_hash["y"]
613
+ startinfo[:dwXSize] = si_hash["x_size"] if si_hash["x_size"]
614
+ startinfo[:dwYSize] = si_hash["y_size"] if si_hash["y_size"]
615
+ startinfo[:dwXCountChars] = si_hash["x_count_chars"] if si_hash["x_count_chars"]
616
+ startinfo[:dwYCountChars] = si_hash["y_count_chars"] if si_hash["y_count_chars"]
617
+ startinfo[:dwFillAttribute] = si_hash["fill_attribute"] if si_hash["fill_attribute"]
618
+ startinfo[:dwFlags] = si_hash["startf_flags"] if si_hash["startf_flags"]
619
+ startinfo[:wShowWindow] = si_hash["sw_flags"] if si_hash["sw_flags"]
616
620
  startinfo[:cbReserved2] = 0
617
- startinfo[:hStdInput] = si_hash['stdin'] if si_hash['stdin']
618
- startinfo[:hStdOutput] = si_hash['stdout'] if si_hash['stdout']
619
- startinfo[:hStdError] = si_hash['stderr'] if si_hash['stderr']
621
+ startinfo[:hStdInput] = si_hash["stdin"] if si_hash["stdin"]
622
+ startinfo[:hStdOutput] = si_hash["stdout"] if si_hash["stdout"]
623
+ startinfo[:hStdError] = si_hash["stderr"] if si_hash["stderr"]
620
624
  end
621
625
 
622
626
  app = nil
623
627
  cmd = nil
624
628
 
625
629
  # Convert strings to wide character strings if present
626
- if hash['app_name']
627
- app = hash['app_name'].to_wide_string
630
+ if hash["app_name"]
631
+ app = hash["app_name"].to_wide_string
628
632
  end
629
633
 
630
- if hash['command_line']
631
- cmd = hash['command_line'].to_wide_string
634
+ if hash["command_line"]
635
+ cmd = hash["command_line"].to_wide_string
632
636
  end
633
637
 
634
- if hash['cwd']
635
- cwd = hash['cwd'].to_wide_string
638
+ if hash["cwd"]
639
+ cwd = hash["cwd"].to_wide_string
636
640
  end
637
641
 
638
- if hash['with_logon']
639
- logon = hash['with_logon'].to_wide_string
642
+ if hash["with_logon"]
643
+ logon = hash["with_logon"].to_wide_string
640
644
 
641
- if hash['password']
642
- passwd = hash['password'].to_wide_string
645
+ if hash["password"]
646
+ passwd = hash["password"].to_wide_string
643
647
  else
644
- raise ArgumentError, 'password must be specified if with_logon is used'
648
+ raise ArgumentError, "password must be specified if with_logon is used"
645
649
  end
646
650
 
647
- if hash['domain']
648
- domain = hash['domain'].to_wide_string
651
+ if hash["domain"]
652
+ domain = hash["domain"].to_wide_string
649
653
  end
650
654
 
651
- hash['creation_flags'] |= CREATE_UNICODE_ENVIRONMENT
655
+ hash["creation_flags"] |= CREATE_UNICODE_ENVIRONMENT
652
656
 
653
657
  bool = CreateProcessWithLogonW(
654
658
  logon, # User
@@ -657,7 +661,7 @@ module Process
657
661
  LOGON_WITH_PROFILE, # Logon flags
658
662
  app, # App name
659
663
  cmd, # Command line
660
- hash['creation_flags'], # Creation flags
664
+ hash["creation_flags"], # Creation flags
661
665
  env, # Environment
662
666
  cwd, # Working directory
663
667
  startinfo, # Startup Info
@@ -668,7 +672,7 @@ module Process
668
672
  raise SystemCallError.new("CreateProcessWithLogonW", FFI.errno)
669
673
  end
670
674
  else
671
- inherit = hash['inherit'] ? 1 : 0
675
+ inherit = hash["inherit"] ? 1 : 0
672
676
 
673
677
  bool = CreateProcessW(
674
678
  app, # App name
@@ -676,7 +680,7 @@ module Process
676
680
  process_security, # Process attributes
677
681
  thread_security, # Thread attributes
678
682
  inherit, # Inherit handles?
679
- hash['creation_flags'], # Creation flags
683
+ hash["creation_flags"], # Creation flags
680
684
  env, # Environment
681
685
  cwd, # Working directory
682
686
  startinfo, # Startup Info
@@ -690,7 +694,7 @@ module Process
690
694
 
691
695
  # Automatically close the process and thread handles in the
692
696
  # PROCESS_INFORMATION struct unless explicitly told not to.
693
- if hash['close_handles']
697
+ if hash["close_handles"]
694
698
  CloseHandle(procinfo[:hProcess])
695
699
  CloseHandle(procinfo[:hThread])
696
700
  end
@@ -760,8 +764,8 @@ module Process
760
764
  # Older versions of JRuby did not include KILL, so we've made an explicit exception
761
765
  # for that here, too.
762
766
  if signal.is_a?(String) || signal.is_a?(Symbol)
763
- signal = signal.to_s.sub('SIG', '')
764
- unless Signal.list.keys.include?(signal) || ['KILL', 'BRK'].include?(signal)
767
+ signal = signal.to_s.sub("SIG", "")
768
+ unless Signal.list.keys.include?(signal) || %w{KILL BRK}.include?(signal)
765
769
  raise ArgumentError, "unsupported name '#{signal}'"
766
770
  end
767
771
  end
@@ -771,32 +775,33 @@ module Process
771
775
  hash = pids.pop
772
776
  opts = {}
773
777
 
774
- valid = %w[exit_proc dll_module wait_time]
778
+ valid = %w{exit_proc dll_module wait_time}
775
779
 
776
- hash.each{ |k,v|
780
+ hash.each { |k, v|
777
781
  k = k.to_s.downcase
778
782
  unless valid.include?(k)
779
783
  raise ArgumentError, "invalid option '#{k}'"
780
784
  end
785
+
781
786
  opts[k] = v
782
787
  }
783
788
 
784
- exit_proc = opts['exit_proc'] || 'ExitProcess'
785
- dll_module = opts['dll_module'] || 'kernel32'
786
- wait_time = opts['wait_time'] || 5
789
+ exit_proc = opts["exit_proc"] || "ExitProcess"
790
+ dll_module = opts["dll_module"] || "kernel32"
791
+ wait_time = opts["wait_time"] || 5
787
792
  else
788
793
  wait_time = 5
789
- exit_proc = 'ExitProcess'
790
- dll_module = 'kernel32'
794
+ exit_proc = "ExitProcess"
795
+ dll_module = "kernel32"
791
796
  end
792
797
 
793
798
  count = 0
794
799
 
795
- pids.each{ |pid|
800
+ pids.each { |pid|
796
801
  raise TypeError unless pid.is_a?(Numeric) # Match spec, pid must be a number
797
802
  raise SystemCallError.new(22) if pid < 0 # Match spec, EINVAL if pid less than zero
798
803
 
799
- sigint = [Signal.list['INT'], 'INT', 'SIGINT', :INT, :SIGINT, 2]
804
+ sigint = [Signal.list["INT"], "INT", "SIGINT", :INT, :SIGINT, 2]
800
805
 
801
806
  # Match the spec
802
807
  if pid == 0 && !sigint.include?(signal)
@@ -829,19 +834,19 @@ module Process
829
834
  raise SystemCallError.new(3) # ESRCH
830
835
  end
831
836
  end
832
- when Signal.list['INT'], 'INT', 'SIGINT', :INT, :SIGINT, 2
837
+ when Signal.list["INT"], "INT", "SIGINT", :INT, :SIGINT, 2
833
838
  if GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid)
834
839
  count += 1
835
840
  else
836
841
  raise SystemCallError.new("GenerateConsoleCtrlEvent", FFI.errno)
837
842
  end
838
- when Signal.list['BRK'], 'BRK', 'SIGBRK', :BRK, :SIGBRK, 3
843
+ when Signal.list["BRK"], "BRK", "SIGBRK", :BRK, :SIGBRK, 3
839
844
  if GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid)
840
845
  count += 1
841
846
  else
842
847
  raise SystemCallError.new("GenerateConsoleCtrlEvent", FFI.errno)
843
848
  end
844
- when Signal.list['KILL'], 'KILL', 'SIGKILL', :KILL, :SIGKILL, 9
849
+ when Signal.list["KILL"], "KILL", "SIGKILL", :KILL, :SIGKILL, 9
845
850
  if TerminateProcess(handle, pid)
846
851
  count += 1
847
852
  else
@@ -944,15 +949,15 @@ module Process
944
949
  # # Show pids of all running processes
945
950
  # p Process.snapshot(:process).keys
946
951
  #
947
- def snapshot(info_type = 'thread')
952
+ def snapshot(info_type = "thread")
948
953
  case info_type.to_s.downcase
949
- when 'thread'
954
+ when "thread"
950
955
  flag = TH32CS_SNAPTHREAD
951
- when 'heap'
956
+ when "heap"
952
957
  flag = TH32CS_SNAPHEAPLIST
953
- when 'module'
958
+ when "module"
954
959
  flag = TH32CS_SNAPMODULE
955
- when 'process'
960
+ when "process"
956
961
  flag = TH32CS_SNAPPROCESS
957
962
  else
958
963
  raise ArgumentError, "info_type '#{info_type}' unsupported"
@@ -962,17 +967,17 @@ module Process
962
967
  handle = CreateToolhelp32Snapshot(flag, Process.pid)
963
968
 
964
969
  if handle == INVALID_HANDLE_VALUE
965
- raise SystemCallError.new('CreateToolhelp32Snapshot', FFI.errno)
970
+ raise SystemCallError.new("CreateToolhelp32Snapshot", FFI.errno)
966
971
  end
967
972
 
968
973
  case info_type.to_s.downcase
969
- when 'thread'
974
+ when "thread"
970
975
  array = get_thread_info(handle)
971
- when 'heap'
976
+ when "heap"
972
977
  array = get_heap_info(handle)
973
- when 'module'
978
+ when "module"
974
979
  array = get_module_info(handle)
975
- when 'process'
980
+ when "process"
976
981
  array = get_process_info(handle)
977
982
  end
978
983
 
@@ -998,7 +1003,7 @@ module Process
998
1003
  lpte = THREADENTRY32.new
999
1004
  lpte[:dwSize] = lpte.size
1000
1005
 
1001
- hash = Hash.new{ |h,k| h[k] = [] }
1006
+ hash = Hash.new { |h, k| h[k] = [] }
1002
1007
 
1003
1008
  if Thread32First(handle, lpte)
1004
1009
  hash[lpte[:th32OwnerProcessID]] << ThreadSnapInfo.new(lpte[:th32ThreadID], lpte[:th32OwnerProcessID], lpte[:tpBasePri])
@@ -1006,20 +1011,18 @@ module Process
1006
1011
  if FFI.errno == ERROR_NO_MORE_FILES
1007
1012
  return hash
1008
1013
  else
1009
- raise SystemCallError.new('Thread32First', FFI.errno)
1014
+ raise SystemCallError.new("Thread32First", FFI.errno)
1010
1015
  end
1011
1016
  end
1012
1017
 
1013
- while Thread32Next(handle, lpte)
1014
- hash[lpte[:th32OwnerProcessID]] << ThreadSnapInfo.new(lpte[:th32ThreadID], lpte[:th32OwnerProcessID], lpte[:tpBasePri])
1015
- end
1018
+ hash[lpte[:th32OwnerProcessID]] << ThreadSnapInfo.new(lpte[:th32ThreadID], lpte[:th32OwnerProcessID], lpte[:tpBasePri]) while Thread32Next(handle, lpte)
1016
1019
 
1017
1020
  hash
1018
1021
  end
1019
1022
 
1020
1023
  # Return heap info for Process.snapshot
1021
1024
  def get_heap_info(handle)
1022
- hash = Hash.new{ |h,k| h[k] = [] }
1025
+ hash = Hash.new { |h, k| h[k] = [] }
1023
1026
 
1024
1027
  hl = HEAPLIST32.new
1025
1028
  hl[:dwSize] = hl.size
@@ -1035,13 +1038,11 @@ module Process
1035
1038
  if FFI.errno == ERROR_NO_MORE_FILES
1036
1039
  break
1037
1040
  else
1038
- raise SystemCallError.new('Heap32First', FFI.errno)
1041
+ raise SystemCallError.new("Heap32First", FFI.errno)
1039
1042
  end
1040
1043
  end
1041
1044
 
1042
- while Heap32Next(he)
1043
- hash[he[:th32ProcessID]] << HeapSnapInfo.new(he[:dwAddress], he[:dwBlockSize], he[:dwFlags], he[:th32ProcessID], he[:th32HeapID])
1044
- end
1045
+ hash[he[:th32ProcessID]] << HeapSnapInfo.new(he[:dwAddress], he[:dwBlockSize], he[:dwFlags], he[:th32ProcessID], he[:th32HeapID]) while Heap32Next(he)
1045
1046
  end
1046
1047
  end
1047
1048
 
@@ -1050,7 +1051,7 @@ module Process
1050
1051
 
1051
1052
  # Return module info for Process.snapshot
1052
1053
  def get_module_info(handle)
1053
- hash = Hash.new{ |h,k| h[k] = [] }
1054
+ hash = Hash.new { |h, k| h[k] = [] }
1054
1055
 
1055
1056
  me = MODULEENTRY32.new
1056
1057
  me[:dwSize] = me.size
@@ -1068,7 +1069,7 @@ module Process
1068
1069
  if FFI.errno == ERROR_NO_MORE_FILES
1069
1070
  return hash
1070
1071
  else
1071
- raise SystemCallError.new('Module32First', FFI.errno)
1072
+ raise SystemCallError.new("Module32First", FFI.errno)
1072
1073
  end
1073
1074
  end
1074
1075
 
@@ -1088,7 +1089,7 @@ module Process
1088
1089
 
1089
1090
  # Return process info for Process.snapshot
1090
1091
  def get_process_info(handle)
1091
- hash = Hash.new{ |h,k| h[k] = [] }
1092
+ hash = Hash.new { |h, k| h[k] = [] }
1092
1093
 
1093
1094
  pe = PROCESSENTRY32.new
1094
1095
  pe[:dwSize] = pe.size
@@ -1106,7 +1107,7 @@ module Process
1106
1107
  if FFI.errno == ERROR_NO_MORE_FILES
1107
1108
  return hash
1108
1109
  else
1109
- raise SystemCallError.new('Process32First', FFI.errno)
1110
+ raise SystemCallError.new("Process32First", FFI.errno)
1110
1111
  end
1111
1112
  end
1112
1113
 
data/lib/win32-process.rb CHANGED
@@ -1 +1 @@
1
- require_relative 'win32/process'
1
+ require_relative "win32/process"