From djberg96 at gmail.com Thu Dec 2 10:19:28 2010 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 2 Dec 2010 08:19:28 -0700 Subject: [Win32utils-devel] Fwd: [win32utils-help][95414] RE: EventLog.open("Application") fails In-Reply-To: <20101202150640.D82C6185835E@rubyforge.org> References: <20101202150640.D82C6185835E@rubyforge.org> Message-ID: I haven't had the chance to dig into this yet, but I suspect a language/code page issue. Regards, Dan ---------- Forwarded message ---------- From: Little Snake Date: Thu, Dec 2, 2010 at 8:06 AM Subject: [win32utils-help][95414] RE: EventLog.open("Application") fails To: noreply at rubyforge.org Read and respond to this message at: http://rubyforge.org/forum/message.php?msg_id=95414 By: Little Snake Hi, The OS is Windows XP (polish language version) with service pack 3 the ruby version is: ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] (the latest from the repository) as shown above it is version for cygwin (ver. 1.7.7-1). As I looked at the problem, I've traced it to windows-pr eventlog.rb line 33 where the OpenEventLog function is created, and then to API::initialize in windows-api api.rb line 316 (which I'm sure, is obvious for you) and there I was stuck, for the next step was win32-api api.c file which I'd rather not analyze myself at the moment ? I'm too much of a noob at the area :-(. But I run the test program for win32-api and surprise: it failed: $ ruby test_win32_api.rb Loaded suite test_win32_api Started F.....F........... ?1) Failure: test_call(TC_Win32_API) [test_win32_api.rb:37]: <"\lib\ruby\gems\1.8\gems\win32-api-1.4.6\test"> expected but was <"C:\cygwin\lib\ruby\gems\1.8\gems\win32-api-1.4.6\test">. diff: - \lib\ruby\gems\1.8\gems\win32-api-1.4.6\test + C:\cygwin\lib\ruby\gems\1.8\gems\win32-api-1.4.6\test ? +++++++++ ?2) Failure: test_constructor_expected_failures(TC_Win32_API) [test_win32_api.rb:95]: exception expected but was Class: Message: <"Attempt to format message failed (error = '1815')"> ---Backtrace--- test_win32_api.rb:95:in `initialize' test_win32_api.rb:95:in `new' test_win32_api.rb:95:in `test_constructor_expected_failures' test_win32_api.rb:95:in `test_constructor_expected_failures' --------------- Finished in 0.103 seconds. 18 tests, 40 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.8889% passed The first failure is obvious and irrelevant, but the second ? To double check I installed another instance of ruby from rubyinstaller for windows (the two instances do not interfere). The version according to ruby -v is: ruby 1.8.7 (2010-06-23 patchlevel 299) [i386-mingw32] The result of the same program was slightly different, but again it was a failure: C:/prg/Ruby187/lib/ruby/gems/1.8/gems/windows-api-0.4.0/lib/windows/api.rb:336:in `initialize': Attempt to format message failed (error = '1815') (Win32::API::Error) ? ? ? ?from C:/prg/Ruby187/lib/ruby/gems/1.8/gems/windows-api-0.4.0/lib/windows /api.rb:336:in `new' ? ? ? ?from C:/prg/Ruby187/lib/ruby/gems/1.8/gems/windows-api-0.4.0/lib/windows /api.rb:336:in `initialize' ? ? ? ?from C:/prg/Ruby187/lib/ruby/gems/1.8/gems/windows-pr-1.1.2/lib/windows/ eventlog.rb:39:in `new' ? ? ? ?from C:/prg/Ruby187/lib/ruby/gems/1.8/gems/windows-pr-1.1.2/lib/windows/ eventlog.rb:39 ? ? ? ?from C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' ? ? ? ?from C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' ? ? ? ?from C:/prg/Ruby187/lib/ruby/gems/1.8/gems/win32-eventlog-0.5.2/lib/win3 2/eventlog.rb:2 ? ? ? ?from C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' ? ? ? ?from C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' ? ? ? ?from wlogex.rb:4 Then again ruby test_win32_api.rb C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem test-unit (>= 0) (Gem::LoadError) ? ? ? ?from C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate' ? ? ? ?from C:/prg/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem' ? ? ? ?from test_win32_api.rb:8 C:\prg\Ruby187\lib\ruby\gems\1.8\gems\win32-api-1.4.6-x86-mingw32\test>ruby test_win32_api.rb Loaded suite test_win32_api Started ......F........... ?1) Failure: test_constructor_expected_failures(TC_Win32_API) [test_win32_api.rb:95]: exception expected but was Class: Message: <"Attempt to format message failed (error = '1815')"> ---Backtrace--- test_win32_api.rb:95:in `initialize' test_win32_api.rb:95:in `new' test_win32_api.rb:95:in `test_constructor_expected_failures' test_win32_api.rb:95:in `test_constructor_expected_failures' --------------- Finished in 0.078066 seconds. 18 tests, 40 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.4444% passed And again the "Attempt to format message failed? error. I would be very gratefull for any help in resolving the issue. ?What I dreamed for was a nice script checking eventlogs on a number of windows servers, and I really long for such a thing ;-). Thank you for your time. Little Snake ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to RubyForge and visit: http://rubyforge.org/forum/monitor.php?forum_id=320&group_id=85&stop=1 From billagee at gmail.com Tue Dec 14 15:13:52 2010 From: billagee at gmail.com (Bill Agee) Date: Tue, 14 Dec 2010 12:13:52 -0800 Subject: [Win32utils-devel] How to initialize and pass a VARIANT to IAccessible::get_accName? Message-ID: Hi all, First off, thanks for Win32Utils! The libraries have been really beneficial for me. I have a question (hope this is an appropriate place for it): I'm trying to write some demo scripts that use the IAccessible interface: http://msdn.microsoft.com/en-us/library/dd318466%28v=vs.85%29.aspx I've had some success so far (for example, I can successfully call the "IAccessible::get_accChildCount" method). But I'm stuck on IAccessible::get_accName. In fact, any method like get_accName that takes a VARIANT (note: not a VARIANT*) seems to be failing for me. Does anyone have experience using win32-api to define and call a function that takes a VARIANT? In the case of get_accName, I can't get it to return successfully... Either ruby.exe crashes (when I pass a 16-byte packed string as the VARIANT) or I get the HRESULT 'The parameter is incorrect.' (when I use a >=28-byte packed string as the VARIANT). I'm wondering if the problem is one of: - the Win32::API function prototype I'm using for the VARIANT param is wrong, or: - the way I'm initializing the VARIANT before passing it is incorrect I'd be really grateful if anyone could weigh in on how to achieve this. :) Right now I'm treating the VARIANT as a pointer in the get_accName prototype (note the full example program this came from is at the end of the email): Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L') The C prototype for the function (from OleAcc.h) is: /* [id][propget][hidden] */ HRESULT ( STDMETHODCALLTYPE *get_accName )( __RPC__in IAccessible * This, /* [optional][in] */ VARIANT varChild, /* [retval][out] */ __RPC__deref_out_opt BSTR *pszName); I combed through the windows-pr code looking for examples of functions that take a VARIANT param, but so far I've only found functions that take a pointer-to-VARIANT. Also, I suspect this code, which initializes my VARIANT, might be causing my problem (it was cobbled together from snippets on the win32utils-devel list and the pr-win32ole source): # Initialize VARIANT that holds CHILDID_SELF self_var = 0.chr * 16 VariantInit(self_var) self_var[0, 2] = [VT_I4].pack('S') self_var[2, 2] = [0].pack('S') self_var[4, 2] = [0].pack('S') self_var[6, 2] = [0].pack('S') self_var[8, 4] = [CHILDID_SELF].pack('L') self_var[12, 4] = [0].pack('L') Here's a complete script that shows the get_accName problem - please let me know if there are any questions I could answer that might help resolve the issue. If it would help I also have a working C demo program where get_accName is used. # print_desktop_name.rb require 'rubygems' require 'win32/api' require 'windows/com' require 'windows/com/variant' require 'windows/error' require 'windows/msvcrt/buffer' require 'windows/unicode' require 'windows/window' require 'windows/window/menu' include Windows::COM include Windows::COM::Variant include Windows::Error include Windows::MSVCRT::Buffer include Windows::Unicode include Windows::Window include Windows::Window::Menu IID_IAccessible = [0x618736e0, 0x3c3d, 0x11cf, 0x81, 0x0c, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71].pack('LSSC8') CHILDID_SELF = 0 CoInitialize(nil) # Initialize COM desktop_hwnd = GetDesktopWindow.call() # Get the desktop's HWND # Use the HWND to get the desktop's IAccessible object AccessibleObjectFromWindow = Win32::API.new('AccessibleObjectFromWindow', 'LLPP', 'L', 'oleacc') desktop_iacc = 0.chr * 4 hr = AccessibleObjectFromWindow.call(desktop_hwnd, OBJID_WINDOW, IID_IAccessible, desktop_iacc) raise "Failed to instantiate IAcc object!" if (hr != S_OK) # Get the memory address of the IAcc pointer - need to use it later as a # 'this' pointer to pass to get_accName desktop_iacc_ptr = desktop_iacc.unpack('L').first # Get the IAccessibleVtbl C interface. It contains 28 functions (see OleAcc.h). lpVtbl = 0.chr * 4 table = 0.chr * (4 * 28) # Unpack the IAccessibleVtbl: memcpy(lpVtbl, desktop_iacc_ptr, 4) memcpy(table, lpVtbl.unpack('L').first, 4 * 28) table = table.unpack('L*') # Define get_accName Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L') # Create buffer for the BSTR that will receive the IAcc object name name_bstr = 0.chr * 4 # Initialize CHILDID_SELF variant self_var = 0.chr * 16 VariantInit(self_var) self_var[0, 2] = [VT_I4].pack('S') self_var[2, 2] = [0].pack('S') self_var[4, 2] = [0].pack('S') self_var[6, 2] = [0].pack('S') self_var[8, 4] = [CHILDID_SELF].pack('L') self_var[12, 4] = [0].pack('L') # This segfaults on XP and Win7: # (using ruby 1.8.7 i386-mingw32, 2010-08-16 patchlevel 302) hr = Get_accName.call(desktop_iacc_ptr, self_var, name_bstr) puts "HRESULT from get_accName is: " + hr.to_s puts "HRESULT message is: '#{get_last_error(hr)}'" -------------- next part -------------- An HTML attachment was scrubbed... URL: From phasis at gmail.com Tue Dec 14 21:36:06 2010 From: phasis at gmail.com (Heesob Park) Date: Wed, 15 Dec 2010 11:36:06 +0900 Subject: [Win32utils-devel] How to initialize and pass a VARIANT to IAccessible::get_accName? In-Reply-To: References: Message-ID: Hi, 2010/12/15 Bill Agee : > Hi all, > > First off, thanks for Win32Utils!? The libraries have been really beneficial > for me. > > I have a question (hope this is an appropriate place for it): > > I'm trying to write some demo scripts that use the IAccessible interface: > > http://msdn.microsoft.com/en-us/library/dd318466%28v=vs.85%29.aspx > > I've had some success so far (for example, I can successfully call the > "IAccessible::get_accChildCount" method). > > But I'm stuck on IAccessible::get_accName. > > In fact, any method like get_accName that takes a VARIANT (note: not a > VARIANT*) seems to be failing for me. > > Does anyone have experience using win32-api to define and call a function > that takes a VARIANT? > > In the case of get_accName, I can't get it to return successfully... > > Either ruby.exe crashes (when I pass a 16-byte packed string as the VARIANT) > or I get the HRESULT 'The parameter is incorrect.' (when I use a >=28-byte > packed string as the VARIANT). > > > I'm wondering if the problem is one of: > > - the Win32::API function prototype I'm using for the VARIANT param is > wrong, or: > > - the way I'm initializing the VARIANT before passing it is incorrect > > I'd be really grateful if anyone could weigh in on how to achieve this. :) > > Right now I'm treating the VARIANT as a pointer in the get_accName prototype > (note the full example program this came from is at the end of the email): > > ? Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L') > > The C prototype for the function (from OleAcc.h) is: > > ? /* [id][propget][hidden] */ HRESULT ( STDMETHODCALLTYPE *get_accName )( > ????? __RPC__in IAccessible * This, > ????? /* [optional][in] */ VARIANT varChild, > ????? /* [retval][out] */ __RPC__deref_out_opt BSTR *pszName); > > > I combed through the windows-pr code looking for examples of functions that > take a VARIANT param, but so far I've only found functions that take a > pointer-to-VARIANT. > > Also, I suspect this code, which initializes my VARIANT, might be causing my > problem (it was cobbled together from snippets on the win32utils-devel list > and the pr-win32ole source): > > ? # Initialize VARIANT that holds CHILDID_SELF > ? self_var = 0.chr * 16 > ? VariantInit(self_var) > ? self_var[0, 2] = [VT_I4].pack('S') > ? self_var[2, 2] = [0].pack('S') > ? self_var[4, 2] = [0].pack('S') > ? self_var[6, 2] = [0].pack('S') > ? self_var[8, 4] = [CHILDID_SELF].pack('L') > ? self_var[12, 4] = [0].pack('L') > > > Here's a complete script that shows the get_accName problem - please let me > know if there are any questions I could answer that might help resolve the > issue.? If it would help I also have a working C demo program where > get_accName is used. > > # print_desktop_name.rb > > require 'rubygems' > require 'win32/api' > require 'windows/com' > require 'windows/com/variant' > require 'windows/error' > require 'windows/msvcrt/buffer' > require 'windows/unicode' > require 'windows/window' > require 'windows/window/menu' > > include Windows::COM > include Windows::COM::Variant > include Windows::Error > include Windows::MSVCRT::Buffer > include Windows::Unicode > include Windows::Window > include Windows::Window::Menu > > IID_IAccessible = [0x618736e0, 0x3c3d, 0x11cf, 0x81, 0x0c, 0x00, 0xaa, 0x00, > 0x38, 0x9b, 0x71].pack('LSSC8') > CHILDID_SELF = 0 > > CoInitialize(nil) # Initialize COM > > desktop_hwnd = GetDesktopWindow.call() # Get the desktop's HWND > > # Use the HWND to get the desktop's IAccessible object > AccessibleObjectFromWindow = Win32::API.new('AccessibleObjectFromWindow', > ??????????????????????????????????????????? 'LLPP', 'L', 'oleacc') > desktop_iacc = 0.chr * 4 > hr = AccessibleObjectFromWindow.call(desktop_hwnd, > ???????????????????????????????????? OBJID_WINDOW, > ???????????????????????????????????? IID_IAccessible, > ???????????????????????????????????? desktop_iacc) > raise "Failed to instantiate IAcc object!" if (hr != S_OK) > > # Get the memory address of the IAcc pointer - need to use it later as a > # 'this' pointer to pass to get_accName > desktop_iacc_ptr = desktop_iacc.unpack('L').first > > # Get the IAccessibleVtbl C interface. It contains 28 functions (see > OleAcc.h). > lpVtbl = 0.chr * 4 > table = 0.chr * (4 * 28) > > # Unpack the IAccessibleVtbl: > memcpy(lpVtbl, desktop_iacc_ptr, 4) > memcpy(table, lpVtbl.unpack('L').first, 4 * 28) > table = table.unpack('L*') > > # Define get_accName > Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L') > > # Create buffer for the BSTR that will receive the IAcc object name > name_bstr = 0.chr * 4 > > # Initialize CHILDID_SELF variant > self_var = 0.chr * 16 > VariantInit(self_var) > self_var[0, 2] = [VT_I4].pack('S') > self_var[2, 2] = [0].pack('S') > self_var[4, 2] = [0].pack('S') > self_var[6, 2] = [0].pack('S') > self_var[8, 4] = [CHILDID_SELF].pack('L') > self_var[12, 4] = [0].pack('L') > > # This segfaults on XP and Win7: > # (using ruby 1.8.7 i386-mingw32, 2010-08-16 patchlevel 302) > hr = Get_accName.call(desktop_iacc_ptr, self_var, name_bstr) > puts "HRESULT from get_accName is: " + hr.to_s > puts "HRESULT message is: '#{get_last_error(hr)}'" > After some debugging, I found that passing VARIANT parameter is same to passing four DWORD parameters with each VARIANT content element. Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L') should be Get_accName = Win32::API::Function.new(table[10], 'PLLLLP', 'L') hr = Get_accName.call(desktop_iacc_ptr, self_var, name_bstr) should be hr = Get_accName.call(desktop_iacc_ptr,self_var[0,4].unpack('L').first,self_var[4,4].unpack('L').first,self_var[8,4].unpack('L').first,self_var[12,4].unpack('L').first,name_bstr) Regards, Park Heesob From billagee at gmail.com Wed Dec 15 00:38:16 2010 From: billagee at gmail.com (Bill Agee) Date: Tue, 14 Dec 2010 21:38:16 -0800 Subject: [Win32utils-devel] How to initialize and pass a VARIANT to IAccessible::get_accName? In-Reply-To: References: Message-ID: On Tue, Dec 14, 2010 at 6:36 PM, Heesob Park wrote: > After some debugging, I found that passing VARIANT parameter is same > to passing four DWORD parameters with each VARIANT content element. > > Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L') > should be > Get_accName = Win32::API::Function.new(table[10], 'PLLLLP', 'L') > > hr = Get_accName.call(desktop_iacc_ptr, self_var, name_bstr) > should be > hr = > Get_accName.call(desktop_iacc_ptr,self_var[0,4].unpack('L').first,self_var[4,4].unpack('L').first,self_var[8,4].unpack('L').first,self_var[12,4].unpack('L').first,name_bstr) > Outstanding! The code works great now. With your changes in place, get_accName return S_OK, and the BSTR contains the expected string ('Desktop') when I print it with wprintf: Wprintf = Windows::API.new('wprintf', 'PP', 'I', 'msvcrt') format_str = multi_to_wide("The object name is: '%s'\n") format_str_ptr = [format_str].pack('p').unpack('L').first Wprintf.call(format_str_ptr, name_bstr.unpack('L').first) This is huge; being able to pass a VARIANT means that the IAccessible and IUIAutomation interfaces are now wide open. :) Thanks so much! Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From noreply at rubyforge.org Sat Dec 25 05:02:54 2010 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Sat, 25 Dec 2010 05:02:54 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Bugs-28801 ] unclosed handle in Process.setpriority/getpriority Message-ID: <20101225100254.AE7D31858317@rubyforge.org> Bugs item #28801, was opened at 2010-12-25 11:02 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 Category: win32-process Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Rafa? Michalski (royaltm) Assigned to: Nobody (None) Summary: unclosed handle in Process.setpriority/getpriority Initial Comment: Using Process.setpriority/getpriority was crashing my ruby program. I think the problem was with unclosed handle from OpenProcess() function. my patch for lib/win32/process.rb (0.6.4) follows, however the bug exists also in previous releases. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 From noreply at rubyforge.org Sun Dec 26 12:59:08 2010 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Sun, 26 Dec 2010 12:59:08 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Bugs-28801 ] unclosed handle in Process.setpriority/getpriority Message-ID: <20101226175908.E00981858300@rubyforge.org> Bugs item #28801, was opened at 2010-12-25 03:02 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 Category: win32-process Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Rafa? Michalski (royaltm) Assigned to: Nobody (None) Summary: unclosed handle in Process.setpriority/getpriority Initial Comment: Using Process.setpriority/getpriority was crashing my ruby program. I think the problem was with unclosed handle from OpenProcess() function. my patch for lib/win32/process.rb (0.6.4) follows, however the bug exists also in previous releases. ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2010-12-26 10:59 Message: Yeah, I need to clean up getpriority and setpriority in general to more strictly match the current spec. I think I originally avoided CloseHandle because I seem to recall it causing issues because it would affect the current process somehow. Maybe I'm imagining things, though. I'll definitely take a look. Thanks, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 From noreply at rubyforge.org Mon Dec 27 03:02:38 2010 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 27 Dec 2010 03:02:38 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Bugs-28801 ] unclosed handle in Process.setpriority/getpriority Message-ID: <20101227080238.2B4B11858356@rubyforge.org> Bugs item #28801, was opened at 2010-12-25 11:02 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 Category: win32-process Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Rafa? Michalski (royaltm) Assigned to: Nobody (None) Summary: unclosed handle in Process.setpriority/getpriority Initial Comment: Using Process.setpriority/getpriority was crashing my ruby program. I think the problem was with unclosed handle from OpenProcess() function. my patch for lib/win32/process.rb (0.6.4) follows, however the bug exists also in previous releases. ---------------------------------------------------------------------- >Comment By: Rafa? Michalski (royaltm) Date: 2010-12-27 09:02 Message: I'm applying this patch since version 0.6.2 in production environment (though didn't report it until now) and it servers me right. I'm using Process.setpriority from ruby program to give more cpu attention to one of (not ruby) child processes (spawned with Process.create) which handles serial communication with card reader device. Didn't notice any trouble on WinXP and Vista64. ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2010-12-26 18:59 Message: Yeah, I need to clean up getpriority and setpriority in general to more strictly match the current spec. I think I originally avoided CloseHandle because I seem to recall it causing issues because it would affect the current process somehow. Maybe I'm imagining things, though. I'll definitely take a look. Thanks, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 From noreply at rubyforge.org Mon Dec 27 11:32:03 2010 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 27 Dec 2010 11:32:03 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Bugs-28801 ] unclosed handle in Process.setpriority/getpriority Message-ID: <20101227163203.EF4CD1858354@rubyforge.org> Bugs item #28801, was opened at 2010-12-25 03:02 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 Category: win32-process Group: Code >Status: Closed >Resolution: Accepted Priority: 3 Submitted By: Rafa? Michalski (royaltm) >Assigned to: Daniel Berger (djberg96) Summary: unclosed handle in Process.setpriority/getpriority Initial Comment: Using Process.setpriority/getpriority was crashing my ruby program. I think the problem was with unclosed handle from OpenProcess() function. my patch for lib/win32/process.rb (0.6.4) follows, however the bug exists also in previous releases. ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2010-12-27 09:32 Message: Ok, I've fixed it in 0.6.5, which I just pushed. Please note that I've made the API for getpriority and setpriority stricter, i.e. there are no longer any default arguments. This was so that it matched the MRI spec. Thanks for the report. Regards, Dan ---------------------------------------------------------------------- Comment By: Rafa? Michalski (royaltm) Date: 2010-12-27 01:02 Message: I'm applying this patch since version 0.6.2 in production environment (though didn't report it until now) and it servers me right. I'm using Process.setpriority from ruby program to give more cpu attention to one of (not ruby) child processes (spawned with Process.create) which handles serial communication with card reader device. Didn't notice any trouble on WinXP and Vista64. ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2010-12-26 10:59 Message: Yeah, I need to clean up getpriority and setpriority in general to more strictly match the current spec. I think I originally avoided CloseHandle because I seem to recall it causing issues because it would affect the current process somehow. Maybe I'm imagining things, though. I'll definitely take a look. Thanks, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 From noreply at rubyforge.org Mon Dec 27 11:55:28 2010 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 27 Dec 2010 11:55:28 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Bugs-28801 ] unclosed handle in Process.setpriority/getpriority Message-ID: <20101227165528.730911858354@rubyforge.org> Bugs item #28801, was opened at 2010-12-25 11:02 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85 Category: win32-process Group: Code Status: Closed Resolution: Accepted Priority: 3 Submitted By: Rafa? Michalski (royaltm) Assigned to: Daniel Berger (djberg96) Summary: unclosed handle in Process.setpriority/getpriority Initial Comment: Using Process.setpriority/getpriority was crashing my ruby program. I think the problem was with unclosed handle from OpenProcess() function. my patch for lib/win32/process.rb (0.6.4) follows, however the bug exists also in previous releases. ---------------------------------------------------------------------- >Comment By: Rafa? Michalski (royaltm) Date: 2010-12-27 17:55 Message: Oh, i forgot to thank you for the great library. ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2010-12-27 17:32 Message: Ok, I've fixed it in 0.6.5, which I just pushed. Please note that I've made the API for getpriority and setpriority stricter, i.e. there are no longer any default arguments. This was so that it matched the MRI spec. Thanks for the report. Regards, Dan ---------------------------------------------------------------------- Comment By: Rafa? Michalski (royaltm) Date: 2010-12-27 09:02 Message: I'm applying this patch since version 0.6.2 in production environment (though didn't report it until now) and it servers me right. I'm using Process.setpriority from ruby program to give more cpu attention to one of (not ruby) child processes (spawned with Process.create) which handles serial communication with card reader device. Didn't notice any trouble on WinXP and Vista64. ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2010-12-26 18:59 Message: Yeah, I need to clean up getpriority and setpriority in general to more strictly match the current spec. I think I originally avoided CloseHandle because I seem to recall it causing issues because it would affect the current process somehow. Maybe I'm imagining things, though. I'll definitely take a look. Thanks, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28801&group_id=85