From Daniel.Berger at qwest.com Mon Jun 2 09:50:53 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 2 Jun 2008 08:50:53 -0500 Subject: [Win32utils-devel] win32-open3: crashesafter 170 popen3 operations In-Reply-To: <20080530205407.89B4518585A7@rubyforge.org> References: <20080530205407.89B4518585A7@rubyforge.org> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D32D4@ITOMAE2KM01.AD.QINTRA.COM> Hi, > Distilled to it's essence, I think this snippet shows the problem: > > require "win32/open3" > i = 1 > while (i<200) > Open3.popen3("dir") do |stdin, stdout, stderr| > e = stdout.readlines > end > puts i > i += 1 > > end > > > > C:\Documents and Settings\me>ruby goober.rb > > 1 > ... etc ... > 170 > > goober.rb:6:in `readlines': closed stream (IOError) > from goober.rb:6 > from goober.rb:5:in `popen3' > from goober.rb:5 FYI, this was fixed in CVS and 0.2.6 was released this weekend. Thanks go to Park for the patch. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Wed Jun 4 11:49:58 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 4 Jun 2008 10:49:58 -0500 Subject: [Win32utils-devel] Ruby 1.8.7 Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D32E3@ITOMAE2KM01.AD.QINTRA.COM> Hi all, Has anyone else been able to build Ruby 1.8.7 from source on Windows? I get this when I run configure: C:\>win32\configure.bat find: =: No such file or directory Creating Makefile Creating Makefile(6) : fatal error C1085: Cannot write compiler generated file: '': Invalid argument NMAKE : fatal error U1077: 'cl' : return code '0x1' Stop. Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Wed Jun 4 13:15:04 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 4 Jun 2008 12:15:04 -0500 Subject: [Win32utils-devel] Win32-ole start Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D32E4@ITOMAE2KM01.AD.QINTRA.COM> Hi all, Since I didn't get any takers on the win32-ole rewrite I thought I'd take a stab at starting it. Here's what I've got so far (along with some extra constants in Windows::COM only in CVS), but the call to CoCreateInstance() isn't working. I'm not sure if I'm dealing with the IDispatch interface properly: # win32/ole.rb require 'windows/com' require 'windows/com/automation' require 'windows/error' require 'windows/unicode' require 'socket' module Win32 class OLE include Windows::Error include Windows::COM include Windows::COM::Automation include Windows::Unicode # Error raised if any of the OLE related methods fail. class Error < StandardError; end # The name of the OLE automation server specified in the constructor. attr_reader :server # The host the OLE automation object was created on. attr_reader :host # Did I declare these properly? # http://tinyurl.com/3z8z4h IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') IID_IDispatch = [132096,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') IID_IEnumVARIANT = [132100,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') def initialize(server, host = Socket.gethostname) @server = server @host = host clsid = 0.chr * 16 dispatch = 0.chr * 16 # I'm not sure what hr = CLSIDFromProgID(multi_to_wide(server, CP_UTF8), clsid) if FAILED(hr) hr = CLSIDFromString(multi_to_wide(server, CP_UTF8), clsid) if FAILED(hr) raise Error, "unknown OLE server '#{server}'" end end # Fails here hr = CoCreateInstance( clsid, nil, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IDispatch, dispatch ) if FAILED(hr) raise Error, "failed to create OLE object from '#{server}'" end end end end if $0 == __FILE__ include Win32 excel = OLE.new('excel.application') End Any ideas? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Wed Jun 4 21:28:20 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 5 Jun 2008 10:28:20 +0900 Subject: [Win32utils-devel] Ruby 1.8.7 In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D32E3@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D32E3@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/6/5 Berger, Daniel : > Hi all, > > Has anyone else been able to build Ruby 1.8.7 from source on Windows? I > get this when I run configure: > > C:\>win32\configure.bat > find: =: No such file or directory > Creating Makefile > Creating Makefile(6) : fatal error C1085: Cannot write compiler > generated file: '': Invalid argument > > NMAKE : fatal error U1077: 'cl' : return code '0x1' > Stop. > In my trial with Visual Studio 2008(VC++9.0), Ruby 1.8.7 is built without error and worked fine. Regards, Park Heesob From phasis at gmail.com Wed Jun 4 22:19:28 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 5 Jun 2008 11:19:28 +0900 Subject: [Win32utils-devel] Win32-ole start In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D32E4@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D32E4@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/6/5 Berger, Daniel : > Hi all, > > Since I didn't get any takers on the win32-ole rewrite I thought I'd > take a stab at starting it. Here's what I've got so far (along with some > extra constants in Windows::COM only in CVS), but the call to > CoCreateInstance() isn't working. I'm not sure if I'm dealing with the > IDispatch interface properly: > > # win32/ole.rb > require 'windows/com' > require 'windows/com/automation' > require 'windows/error' > require 'windows/unicode' > require 'socket' > > module Win32 > class OLE > include Windows::Error > include Windows::COM > include Windows::COM::Automation > include Windows::Unicode > > # Error raised if any of the OLE related methods fail. > class Error < StandardError; end > > # The name of the OLE automation server specified in the > constructor. > attr_reader :server > > # The host the OLE automation object was created on. > attr_reader :host > > # Did I declare these properly? > # http://tinyurl.com/3z8z4h > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') > IID_IDispatch = > [132096,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') > IID_IEnumVARIANT = > [132100,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') > > def initialize(server, host = Socket.gethostname) > @server = server > @host = host > > clsid = 0.chr * 16 > dispatch = 0.chr * 16 # I'm not sure what > > hr = CLSIDFromProgID(multi_to_wide(server, CP_UTF8), clsid) > > if FAILED(hr) > hr = CLSIDFromString(multi_to_wide(server, CP_UTF8), clsid) > if FAILED(hr) > raise Error, "unknown OLE server '#{server}'" > end > end > > # Fails here > hr = CoCreateInstance( > clsid, > nil, > CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, > IID_IDispatch, > dispatch > ) > > if FAILED(hr) > raise Error, "failed to create OLE object from '#{server}'" > end > end > end > end > > if $0 == __FILE__ > include Win32 > excel = OLE.new('excel.application') > End > > Any ideas? > The return value of CoCreateInstance() -2147221008 is due to the lack of CoInitialize() call. Insert hr = CoInitialize(nil) before hr = CoCreateInstance seems to work for me. Regards, Park Heesob From Daniel.Berger at qwest.com Thu Jun 5 10:58:11 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 5 Jun 2008 09:58:11 -0500 Subject: [Win32utils-devel] Win32-ole start In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D32E4@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D32E6@ITOMAE2KM01.AD.QINTRA.COM> Hi, > The return value of CoCreateInstance() -2147221008 is due to > the lack of CoInitialize() call. > > Insert > hr = CoInitialize(nil) > before > hr = CoCreateInstance > seems to work for me. Makes sense. That worked, thanks. Strange that win32ole.c never calls it. Anyway, I've made some initial commits to CVS to the 'win32-ole' project for those interested. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Jun 5 11:00:15 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 5 Jun 2008 10:00:15 -0500 Subject: [Win32utils-devel] Ruby 1.8.7 In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D32E3@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D32E7@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Wednesday, June 04, 2008 7:28 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Ruby 1.8.7 > > Hi, > > 2008/6/5 Berger, Daniel : > > Hi all, > > > > Has anyone else been able to build Ruby 1.8.7 from source > on Windows? > > I get this when I run configure: > > > > C:\>win32\configure.bat > > find: =: No such file or directory > > Creating Makefile > > Creating Makefile(6) : fatal error C1085: Cannot write compiler > > generated file: '': Invalid argument > > > > NMAKE : fatal error U1077: 'cl' : return code '0x1' > > Stop. > > > In my trial with Visual Studio 2008(VC++9.0), Ruby 1.8.7 is > built without error and worked fine. Hm, must be my lucky day or something. ;) I noticed they made some changes in win32.c and I wanted to see how the changes affected things. I think Luis mentioned that process status is now set properly on system calls, but I wanted to verify. Mostly I want to borrow things for Sapphire if they're useful. :) Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Thu Jun 5 11:02:27 2008 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 5 Jun 2008 17:02:27 +0200 Subject: [Win32utils-devel] Ruby 1.8.7 In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D32E7@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D32E3@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D32E7@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0806050802m206f708atfa2ba958c7a8e085@mail.gmail.com> On Thu, Jun 5, 2008 at 5:00 PM, Berger, Daniel wrote: > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Heesob Park >> Sent: Wednesday, June 04, 2008 7:28 PM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Ruby 1.8.7 >> >> Hi, >> >> 2008/6/5 Berger, Daniel : >> > Hi all, >> > >> > Has anyone else been able to build Ruby 1.8.7 from source >> on Windows? >> > I get this when I run configure: >> > >> > C:\>win32\configure.bat >> > find: =: No such file or directory >> > Creating Makefile >> > Creating Makefile(6) : fatal error C1085: Cannot write compiler >> > generated file: '': Invalid argument >> > >> > NMAKE : fatal error U1077: 'cl' : return code '0x1' >> > Stop. >> > >> In my trial with Visual Studio 2008(VC++9.0), Ruby 1.8.7 is >> built without error and worked fine. > > Hm, must be my lucky day or something. ;) > > I noticed they made some changes in win32.c and I wanted to see how the > changes affected things. I think Luis mentioned that process status is > now set properly on system calls, but I wanted to verify. Mostly I want > to borrow things for Sapphire if they're useful. :) > > Regards, > > Dan > I have some patches that applies directly to 1.8.6 codebase if you want to check them: http://dump.mmediasys.com/installer3/patches/ Didn't had chance to test 1.8.7 after preview2 but will try this weekend if time allows (last time was badly broken for me at least). Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From djberg96 at gmail.com Sat Jun 7 12:24:17 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 07 Jun 2008 10:24:17 -0600 Subject: [Win32utils-devel] Unraveling a protoent struct Message-ID: <484AB631.1080002@gmail.com> I'm spacing - how do I unravel a protent struct pointer? require 'win32/api' include Win32 getprotobyname = API.new('getprotobyname', 'P', 'P', 'ws2_32') ptr = getprotobyname.call('tcp') puts "Name: " + # ??? puts "Aliases: " + # ??? puts "Number: " + # ??? Thanks, Dan From phasis at gmail.com Sat Jun 7 22:15:30 2008 From: phasis at gmail.com (Park Heesob) Date: Sun, 8 Jun 2008 11:15:30 +0900 Subject: [Win32utils-devel] Unraveling a protoent struct References: <484AB631.1080002@gmail.com> Message-ID: <3A241807CA43449A8D6E435A1319D152@mycomputer> Hi, ----- Original Message ----- From: "Daniel Berger" To: "Development and ideas for win32utils projects" Sent: Sunday, June 08, 2008 1:24 AM Subject: [Win32utils-devel] Unraveling a protoent struct > I'm spacing - how do I unravel a protent struct pointer? > > require 'win32/api' > include Win32 > > getprotobyname = API.new('getprotobyname', 'P', 'P', 'ws2_32') > > ptr = getprotobyname.call('tcp') > > puts "Name: " + # ??? > puts "Aliases: " + # ??? > puts "Number: " + # ??? > Here is a little dirty but working code: require 'win32/api' require "windows/msvcrt/buffer" require 'windows/msvcrt/string' include Win32 include Windows::MSVCRT::Buffer include Windows::MSVCRT::String protent = "\0" * 12 name_buf = "\0" * 256 alias_ptr = "\0" * 256 getprotobyname = API.new('getprotobyname', 'P', 'L', 'ws2_32') ptr = getprotobyname.call('tcp') memcpy(protent,ptr,12) strcpy(name_buf,protent[0,4].unpack('L').first) memcpy(alias_ptr,protent[4,4].unpack('L').first,4) aliases = [] alias_ptr.unpack("L*").each do |name| break if name==0 alias_buf = "\0"*256 strcpy(alias_buf,name) aliases << alias_buf.strip end puts "Name: #{name_buf.strip}" puts "Aliases: #{aliases}" puts "Number: #{protent[8,4].unpack('L').first}" Regards, Park Heesob From Daniel.Berger at qwest.com Mon Jun 9 10:50:41 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 9 Jun 2008 09:50:41 -0500 Subject: [Win32utils-devel] Unraveling a protoent struct In-Reply-To: <3A241807CA43449A8D6E435A1319D152@mycomputer> References: <484AB631.1080002@gmail.com> <3A241807CA43449A8D6E435A1319D152@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3301@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Saturday, June 07, 2008 8:16 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a protoent struct > > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "Development and ideas for win32utils projects" > > Sent: Sunday, June 08, 2008 1:24 AM > Subject: [Win32utils-devel] Unraveling a protoent struct > > > > I'm spacing - how do I unravel a protent struct pointer? > > > > require 'win32/api' > > include Win32 > > > > getprotobyname = API.new('getprotobyname', 'P', 'P', 'ws2_32') > > > > ptr = getprotobyname.call('tcp') > > > > puts "Name: " + # ??? > > puts "Aliases: " + # ??? > > puts "Number: " + # ??? > > > Here is a little dirty but working code: > > require 'win32/api' > require "windows/msvcrt/buffer" > require 'windows/msvcrt/string' > include Win32 > include Windows::MSVCRT::Buffer > include Windows::MSVCRT::String > > protent = "\0" * 12 > name_buf = "\0" * 256 > alias_ptr = "\0" * 256 > getprotobyname = API.new('getprotobyname', 'P', 'L', 'ws2_32') > ptr = getprotobyname.call('tcp') > memcpy(protent,ptr,12) > strcpy(name_buf,protent[0,4].unpack('L').first) > memcpy(alias_ptr,protent[4,4].unpack('L').first,4) > aliases = [] > alias_ptr.unpack("L*").each do |name| > break if name==0 > alias_buf = "\0"*256 > strcpy(alias_buf,name) > aliases << alias_buf.strip > end > > puts "Name: #{name_buf.strip}" > puts "Aliases: #{aliases}" > puts "Number: #{protent[8,4].unpack('L').first}" That works, thanks! Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Tue Jun 10 10:55:40 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 10 Jun 2008 09:55:40 -0500 Subject: [Win32utils-devel] Unraveling a FAR* Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM> Hi all, Just looking over fole_s_connect() in win32ole.c and I noticed this bit: hr = CLSIDFromProgID(pBuf, &clsid); ... hr = GetActiveObject(&clsid, 0, &pUnknown); ... hr = pUnknown->lpVtbl->QueryInterface( pUnknown, &IID_IDispatch, (void **)&pDispatch ); Using win32-api, that would be something like: IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') clsid = 0.chr * 16 unknown = 0.chr * IID_IUnknown.size hr = CLSIDFromProgID(multi_to_wide(server), clsid) ... GetActiveObject(clsid, nil, unknown) ... ??? And here is where I'm stuck. How do I unravel a pointer to a struct and then call a function on it? What is the equivalent of pUnknown->lpVtbl->QueryInterface() ? BTW, the prototype for GetActiveObject is: HRESULT GetActiveObject( REFCLSID rclsid, void FAR* pvReserved, IUnknown FAR* FAR* ppunk ); Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Wed Jun 11 11:43:55 2008 From: phasis at gmail.com (Park Heesob) Date: Thu, 12 Jun 2008 00:43:55 +0900 Subject: [Win32utils-devel] Unraveling a FAR* References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <0F370764051E48CFB2E6567FD05228F5@mycomputer> Hi, ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Tuesday, June 10, 2008 11:55 PM Subject: [Win32utils-devel] Unraveling a FAR* > Hi all, > > Just looking over fole_s_connect() in win32ole.c and I noticed this bit: > > hr = CLSIDFromProgID(pBuf, &clsid); > ... > hr = GetActiveObject(&clsid, 0, &pUnknown); > ... > hr = pUnknown->lpVtbl->QueryInterface( > pUnknown, > &IID_IDispatch, > (void **)&pDispatch > ); > > Using win32-api, that would be something like: > > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') > > clsid = 0.chr * 16 > unknown = 0.chr * IID_IUnknown.size > > hr = CLSIDFromProgID(multi_to_wide(server), clsid) > ... > GetActiveObject(clsid, nil, unknown) > ... > ??? > > And here is where I'm stuck. How do I unravel a pointer to a struct and > then call a function on it? What is the equivalent of > pUnknown->lpVtbl->QueryInterface() ? > > BTW, the prototype for GetActiveObject is: > > HRESULT GetActiveObject( > REFCLSID rclsid, > void FAR* pvReserved, > IUnknown FAR* FAR* ppunk > ); > In order to call a function with address, we need a new Win32::API.new constructor like this: somefunc = Win32::API.new(procaddress,prototype,return) # procaddress is long integer for function pointer somefunc.call(...) I guess the implementation is quite simple. Regards, Park Heesob From Daniel.Berger at qwest.com Wed Jun 11 14:36:12 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 11 Jun 2008 13:36:12 -0500 Subject: [Win32utils-devel] Unraveling a FAR* In-Reply-To: <0F370764051E48CFB2E6567FD05228F5@mycomputer> References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM> <0F370764051E48CFB2E6567FD05228F5@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D330C@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Wednesday, June 11, 2008 9:44 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > Hi, > ----- Original Message ----- > From: "Berger, Daniel" > To: "Development and ideas for win32utils projects" > > Sent: Tuesday, June 10, 2008 11:55 PM > Subject: [Win32utils-devel] Unraveling a FAR* > > > > Hi all, > > > > Just looking over fole_s_connect() in win32ole.c and I > noticed this bit: > > > > hr = CLSIDFromProgID(pBuf, &clsid); > > ... > > hr = GetActiveObject(&clsid, 0, &pUnknown); > > ... > > hr = pUnknown->lpVtbl->QueryInterface( > > pUnknown, > > &IID_IDispatch, > > (void **)&pDispatch > > ); > > > > Using win32-api, that would be something like: > > > > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') > > > > clsid = 0.chr * 16 > > unknown = 0.chr * IID_IUnknown.size > > > > hr = CLSIDFromProgID(multi_to_wide(server), clsid) > > ... > > GetActiveObject(clsid, nil, unknown) > > ... > > ??? > > > > And here is where I'm stuck. How do I unravel a pointer to > a struct and > > then call a function on it? What is the equivalent of > > pUnknown->lpVtbl->QueryInterface() ? > > > > BTW, the prototype for GetActiveObject is: > > > > HRESULT GetActiveObject( > > REFCLSID rclsid, > > void FAR* pvReserved, > > IUnknown FAR* FAR* ppunk > > ); > > > In order to call a function with address, we need a new > Win32::API.new > constructor like this: > > somefunc = Win32::API.new(procaddress,prototype,return) # > procaddress is > long integer for function pointer > somefunc.call(...) > > I guess the implementation is quite simple. I'd rather not overload API.new if we can help it. What about a separate subclass? Win32::API::Function.new perhaps? Does that seem reasonable? Or do you feel we should overload the API.new constructor? As for the implementation, I think it would just be a matter of subclassing API and redefining initialize. It looks like API.call could be used as-is, correct? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Wed Jun 11 19:20:14 2008 From: phasis at gmail.com (Park Heesob) Date: Thu, 12 Jun 2008 08:20:14 +0900 Subject: [Win32utils-devel] Unraveling a FAR* References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM><0F370764051E48CFB2E6567FD05228F5@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D330C@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7FC76EC520294D4A82215C15A1C7CF99@mycomputer> ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Thursday, June 12, 2008 3:36 AM Subject: Re: [Win32utils-devel] Unraveling a FAR* > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Wednesday, June 11, 2008 9:44 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Unraveling a FAR* >> >> Hi, >> ----- Original Message ----- >> From: "Berger, Daniel" >> To: "Development and ideas for win32utils projects" >> >> Sent: Tuesday, June 10, 2008 11:55 PM >> Subject: [Win32utils-devel] Unraveling a FAR* >> >> >> > Hi all, >> > >> > Just looking over fole_s_connect() in win32ole.c and I >> noticed this bit: >> > >> > hr = CLSIDFromProgID(pBuf, &clsid); >> > ... >> > hr = GetActiveObject(&clsid, 0, &pUnknown); >> > ... >> > hr = pUnknown->lpVtbl->QueryInterface( >> > pUnknown, >> > &IID_IDispatch, >> > (void **)&pDispatch >> > ); >> > >> > Using win32-api, that would be something like: >> > >> > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') >> > >> > clsid = 0.chr * 16 >> > unknown = 0.chr * IID_IUnknown.size >> > >> > hr = CLSIDFromProgID(multi_to_wide(server), clsid) >> > ... >> > GetActiveObject(clsid, nil, unknown) >> > ... >> > ??? >> > >> > And here is where I'm stuck. How do I unravel a pointer to >> a struct and >> > then call a function on it? What is the equivalent of >> > pUnknown->lpVtbl->QueryInterface() ? >> > >> > BTW, the prototype for GetActiveObject is: >> > >> > HRESULT GetActiveObject( >> > REFCLSID rclsid, >> > void FAR* pvReserved, >> > IUnknown FAR* FAR* ppunk >> > ); >> > >> In order to call a function with address, we need a new >> Win32::API.new >> constructor like this: >> >> somefunc = Win32::API.new(procaddress,prototype,return) # >> procaddress is >> long integer for function pointer >> somefunc.call(...) >> >> I guess the implementation is quite simple. > > I'd rather not overload API.new if we can help it. What about a separate > subclass? > > Win32::API::Function.new perhaps? Does that seem reasonable? Or do you > feel we should overload the API.new constructor? > API::Function.new might be suitable. > As for the implementation, I think it would just be a matter of > subclassing API and redefining initialize. It looks like API.call could > be used as-is, correct? > Yes, you are correct. Regards, Park Heesob From Daniel.Berger at qwest.com Thu Jun 12 10:13:03 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 12 Jun 2008 09:13:03 -0500 Subject: [Win32utils-devel] Unraveling a FAR* In-Reply-To: <7FC76EC520294D4A82215C15A1C7CF99@mycomputer> References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM><0F370764051E48CFB2E6567FD05228F5@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D330C@ITOMAE2KM01.AD.QINTRA.COM> <7FC76EC520294D4A82215C15A1C7CF99@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D330F@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Wednesday, June 11, 2008 5:20 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > > ----- Original Message ----- > From: "Berger, Daniel" > To: "Development and ideas for win32utils projects" > > Sent: Thursday, June 12, 2008 3:36 AM > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > > > > >> -----Original Message----- > >> From: win32utils-devel-bounces at rubyforge.org > >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > >> Park Heesob > >> Sent: Wednesday, June 11, 2008 9:44 AM > >> To: Development and ideas for win32utils projects > >> Subject: Re: [Win32utils-devel] Unraveling a FAR* > >> > >> Hi, > >> ----- Original Message ----- > >> From: "Berger, Daniel" > >> To: "Development and ideas for win32utils projects" > >> > >> Sent: Tuesday, June 10, 2008 11:55 PM > >> Subject: [Win32utils-devel] Unraveling a FAR* > >> > >> > >> > Hi all, > >> > > >> > Just looking over fole_s_connect() in win32ole.c and I > >> noticed this bit: > >> > > >> > hr = CLSIDFromProgID(pBuf, &clsid); > >> > ... > >> > hr = GetActiveObject(&clsid, 0, &pUnknown); > >> > ... > >> > hr = pUnknown->lpVtbl->QueryInterface( > >> > pUnknown, > >> > &IID_IDispatch, > >> > (void **)&pDispatch > >> > ); > >> > > >> > Using win32-api, that would be something like: > >> > > >> > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack('ISSCCCCCCCC') > >> > > >> > clsid = 0.chr * 16 > >> > unknown = 0.chr * IID_IUnknown.size > >> > > >> > hr = CLSIDFromProgID(multi_to_wide(server), clsid) > >> > ... > >> > GetActiveObject(clsid, nil, unknown) > >> > ... > >> > ??? > >> > > >> > And here is where I'm stuck. How do I unravel a pointer to > >> a struct and > >> > then call a function on it? What is the equivalent of > >> > pUnknown->lpVtbl->QueryInterface() ? > >> > > >> > BTW, the prototype for GetActiveObject is: > >> > > >> > HRESULT GetActiveObject( > >> > REFCLSID rclsid, > >> > void FAR* pvReserved, > >> > IUnknown FAR* FAR* ppunk > >> > ); > >> > > >> In order to call a function with address, we need a new > >> Win32::API.new > >> constructor like this: > >> > >> somefunc = Win32::API.new(procaddress,prototype,return) # > >> procaddress is > >> long integer for function pointer > >> somefunc.call(...) > >> > >> I guess the implementation is quite simple. > > > > I'd rather not overload API.new if we can help it. What > about a separate > > subclass? > > > > Win32::API::Function.new perhaps? Does that seem > reasonable? Or do you > > feel we should overload the API.new constructor? > > > API::Function.new might be suitable. > > > As for the implementation, I think it would just be a matter of > > subclassing API and redefining initialize. It looks like > API.call could > > be used as-is, correct? > > > Yes, you are correct. Ok, I've added it to win32-api in CVS. Please take a look and let me know if it looks alright to you. The only thing I was concerned about was casting the function pointer address on line 380. If that's wrong then please go ahead and correct it. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Thu Jun 12 11:02:22 2008 From: phasis at gmail.com (Park Heesob) Date: Fri, 13 Jun 2008 00:02:22 +0900 Subject: [Win32utils-devel] Unraveling a FAR* References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM><0F370764051E48CFB2E6567FD05228F5@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D330C@ITOMAE2KM01.AD.QINTRA.COM><7FC76EC520294D4A82215C15A1C7CF99@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D330F@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <8985172CEBAC4278BD5C4F85309DA28F@mycomputer> Hi, ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Thursday, June 12, 2008 11:13 PM Subject: Re: [Win32utils-devel] Unraveling a FAR* >> >> > >> >> In order to call a function with address, we need a new >> >> Win32::API.new >> >> constructor like this: >> >> >> >> somefunc = Win32::API.new(procaddress,prototype,return) # >> >> procaddress is >> >> long integer for function pointer >> >> somefunc.call(...) >> >> >> >> I guess the implementation is quite simple. >> > >> > I'd rather not overload API.new if we can help it. What >> about a separate >> > subclass? >> > >> > Win32::API::Function.new perhaps? Does that seem >> reasonable? Or do you >> > feel we should overload the API.new constructor? >> > >> API::Function.new might be suitable. >> >> > As for the implementation, I think it would just be a matter of >> > subclassing API and redefining initialize. It looks like >> API.call could >> > be used as-is, correct? >> > >> Yes, you are correct. > > Ok, I've added it to win32-api in CVS. Please take a look and let me > know if it looks alright to you. The only thing I was concerned about > was casting the function pointer address on line 380. If that's wrong > then please go ahead and correct it. > You've done almose perfect. I think Win32APIFunc structure is needless. But If you want to define Win32APIFunc structure and call it with api_call, Win32APIFunc size and Win32API size must be same. After mofication of Win32APIFunc like this: typedef struct { HANDLE dummy; FARPROC function; int return_type; int prototype[16]; } Win32APIFunc; Following Test code works fine. require 'win32/api' require 'windows/library' include Windows::Library hlib = LoadLibrary('user32') addr = GetProcAddress(hlib,'MessageBeep') func = Win32::API::Function.new(addr,'L','L') func.call(0) Regards, Park Heesob From Daniel.Berger at qwest.com Thu Jun 12 15:07:58 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 12 Jun 2008 14:07:58 -0500 Subject: [Win32utils-devel] Unraveling a FAR* In-Reply-To: <8985172CEBAC4278BD5C4F85309DA28F@mycomputer> References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM><0F370764051E48CFB2E6567FD05228F5@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D330C@ITOMAE2KM01.AD.QINTRA.COM><7FC76EC520294D4A82215C15A1C7CF99@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D330F@ITOMAE2KM01.AD.QINTRA.COM> <8985172CEBAC4278BD5C4F85309DA28F@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3310@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Thursday, June 12, 2008 9:02 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > Hi, > ----- Original Message ----- > From: "Berger, Daniel" > To: "Development and ideas for win32utils projects" > > Sent: Thursday, June 12, 2008 11:13 PM > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > > > >> >> > > >> >> In order to call a function with address, we need a new > >> >> Win32::API.new > >> >> constructor like this: > >> >> > >> >> somefunc = Win32::API.new(procaddress,prototype,return) # > >> >> procaddress is > >> >> long integer for function pointer > >> >> somefunc.call(...) > >> >> > >> >> I guess the implementation is quite simple. > >> > > >> > I'd rather not overload API.new if we can help it. What > >> about a separate > >> > subclass? > >> > > >> > Win32::API::Function.new perhaps? Does that seem > >> reasonable? Or do you > >> > feel we should overload the API.new constructor? > >> > > >> API::Function.new might be suitable. > >> > >> > As for the implementation, I think it would just be a matter of > >> > subclassing API and redefining initialize. It looks like > >> API.call could > >> > be used as-is, correct? > >> > > >> Yes, you are correct. > > > > Ok, I've added it to win32-api in CVS. Please take a look and let me > > know if it looks alright to you. The only thing I was > concerned about > > was casting the function pointer address on line 380. If > that's wrong > > then please go ahead and correct it. > > > You've done almose perfect. > I think Win32APIFunc structure is needless. Ok, I got a bit overzealous trying to save 4 points. I've undone that part. :) > Following Test code works fine. > > require 'win32/api' > require 'windows/library' > include Windows::Library > hlib = LoadLibrary('user32') > addr = GetProcAddress(hlib,'MessageBeep') > func = Win32::API::Function.new(addr,'L','L') > func.call(0) Yep, works great. I'll release this as 1.1.0 this weekend, along with an updated windows-pr library (added a winsock module), and an updated win32-process library (now supports a real implementation of Process.ppid). Then I want to revisit win32-ole. :) Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Jun 12 15:20:59 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 12 Jun 2008 14:20:59 -0500 Subject: [Win32utils-devel] Unraveling a FAR* In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3310@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D3308@ITOMAE2KM01.AD.QINTRA.COM><0F370764051E48CFB2E6567FD05228F5@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D330C@ITOMAE2KM01.AD.QINTRA.COM><7FC76EC520294D4A82215C15A1C7CF99@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D330F@ITOMAE2KM01.AD.QINTRA.COM><8985172CEBAC4278BD5C4F85309DA28F@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3310@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3311@ITOMAE2KM01.AD.QINTRA.COM> Hi, > Ok, I got a bit overzealous trying to save 4 points. I've > undone that part. :) Make that 4 *bytes*. I was thinking about a game or something when I wrote that. :) Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From djberg96 at gmail.com Thu Jun 12 21:02:11 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 12 Jun 2008 19:02:11 -0600 Subject: [Win32utils-devel] Inno Message-ID: <4851C713.5010900@gmail.com> Hi all, I thought I would point out this article: http://rubyonwindows.blogspot.com/2007/09/installing-your-ruby-app-with-inno.html Anyone on the list tried it? Regards, Dan From luislavena at gmail.com Fri Jun 13 06:02:30 2008 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 13 Jun 2008 12:02:30 +0200 Subject: [Win32utils-devel] Inno In-Reply-To: <4851C713.5010900@gmail.com> References: <4851C713.5010900@gmail.com> Message-ID: <71166b3b0806130302mcdf9da3n3df9783f61fdc355@mail.gmail.com> On Fri, Jun 13, 2008 at 3:02 AM, Daniel Berger wrote: > Hi all, > > I thought I would point out this article: > > http://rubyonwindows.blogspot.com/2007/09/installing-your-ruby-app-with-inno.html > > Anyone on the list tried it? > I used Inno for lot of deployments, even ones that involved Rails applications and mongrel_service setup, and is great. But some sysadmins (yeah, Windows sysadmins) complained there was no easy way to roll updates to those applications easily, since they learned how to do net updates with MSI and they love it :-P Besides that, everything is cool with Inno, even better that it has LZMA compression builtin. -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From noreply at rubyforge.org Wed Jun 18 19:22:26 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 18 Jun 2008 19:22:26 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-20722 ] Windows::Error.get_last_error only returns the first character (PATCH) Message-ID: <20080618232226.ED2A218581AE@rubyforge.org> Bugs item #20722, was opened at 2008-06-18 15:16 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=20722&group_id=85 Category: windows-pr Group: Code Status: Open Resolution: None Priority: 3 Submitted By: John Whitley (whitley) Assigned to: Nobody (None) Summary: Windows::Error.get_last_error only returns the first character (PATCH) Initial Comment: Platform/version info: Windows XP SP3, ruby 1.8.6-p114, windows-pr-0.8.6 Repro code: require 'windows/error' class ErrTest; include Windows::Error; end et = ErrTest.new puts et.get_last_error(100) Expected result (on english Win XP SP3): Cannot create another system semaphore. Actual result: C It seems that FormatMessage is being bound to the widechar variant (FormatMessageW) instead of the narrow variant (FormatMessageA). I've included a simple patch, below. For test_error.rb, I'd recommend adding a simple test that verifies the length of the returned message for a known error code is greater than two characters or so; that should work around localization issues causing different messages to be returned. Proposed patch: --- error.rb.orig 2008-06-18 15:04:38.768967600 -0700 +++ error.rb 2008-06-18 15:03:50.489880600 -0700 @@ -401,7 +401,8 @@ API.new('GetLastError', 'V', 'L') API.new('SetLastError', 'L', 'V') API.new('SetErrorMode', 'I', 'I') - API.new('FormatMessage', 'LLLLPLP', 'L') + API.new('FormatMessageA', 'LLLLPLP', 'L') + FormatMessage = FormatMessageA begin API.new('SetLastErrorEx', 'LL', 'V', 'user32') ---------------------------------------------------------------------- >Comment By: John Whitley (whitley) Date: 2008-06-18 16:22 Message: Actually, I rescind my patch above. The deeper problem seems to lie in win32-api, api.c, this code: // The order of 'A' and 'W' is reversed if $KCODE is set to 'UTF8'. if(!strcmp(rb_get_kcode(), "UTF8")){ first = "W"; second = "A"; } W functions accept/return UTF16 not UTF8, which breaks the rest of the win32-* modules hard, as the bug above exhibits. For example, Win32::Events are now created by passing UTF8 Ruby string data to an interface expecting UTF16 (see the name parameter). Setting $KCODE to UTF8 should not change the interface of these functions, as it breaks unrelated client code. As it stands 'W' functions always require special conversion handling, and should be non-default. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=20722&group_id=85 From djberg96 at gmail.com Thu Jun 19 01:11:11 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 18 Jun 2008 23:11:11 -0600 Subject: [Win32utils-devel] [ win32utils-Bugs-20722 ] Windows::Error.get_last_error only returns the first character (PATCH) In-Reply-To: <20080618232226.ED2A218581AE@rubyforge.org> References: <20080618232226.ED2A218581AE@rubyforge.org> Message-ID: <6037b70c0806182211o15929721m11a09138e7257e40@mail.gmail.com> On Wed, Jun 18, 2008 at 5:22 PM, wrote: >>Comment By: John Whitley (whitley) > Date: 2008-06-18 16:22 > > Message: > Actually, I rescind my patch above. The deeper problem > seems to lie in win32-api, api.c, this code: > > // The order of 'A' and 'W' is reversed if $KCODE is set > to 'UTF8'. > if(!strcmp(rb_get_kcode(), "UTF8")){ > first = "W"; > second = "A"; > } > > W functions accept/return UTF16 not UTF8, which breaks the > rest of the win32-* modules hard, as the bug above exhibits. > For example, Win32::Events are now created by passing UTF8 > Ruby string data to an interface expecting UTF16 (see the > name parameter). > > Setting $KCODE to UTF8 should not change the interface of > these functions, as it breaks unrelated client code. As it > stands 'W' functions always require special conversion > handling, and should be non-default. Ow. Well, I _did_ ask about this when I first implemented it. I guess it wasn't such a good idea after all. Suggestions? Fixable? Or remove it completely? Dan From Daniel.Berger at qwest.com Thu Jun 19 16:03:48 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 19 Jun 2008 15:03:48 -0500 Subject: [Win32utils-devel] [ win32utils-Bugs-20722 ]Windows::Error.get_last_error only returns the firstcharacter (PATCH) In-Reply-To: <6037b70c0806182211o15929721m11a09138e7257e40@mail.gmail.com> References: <20080618232226.ED2A218581AE@rubyforge.org> <6037b70c0806182211o15929721m11a09138e7257e40@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3333@ITOMAE2KM01.AD.QINTRA.COM> Hi, Responding to myself here... > > W functions accept/return UTF16 not UTF8, which breaks the > rest of the > > win32-* modules hard, as the bug above exhibits. > > For example, Win32::Events are now created by passing UTF8 Ruby > > string data to an interface expecting UTF16 (see the name > parameter). > > > > Setting $KCODE to UTF8 should not change the interface of these > > functions, as it breaks unrelated client code. As it stands 'W' > > functions always require special conversion handling, and should be > > non-default. > > Ow. > > Well, I _did_ ask about this when I first implemented it. I > guess it wasn't such a good idea after all. > > Suggestions? Fixable? Or remove it completely? Actually, I don't know that I agree with John (the OP). I think it just goes with the territory that if you're going to use $KCODE/UTF8 then you have to deal with the wide character conversions on your end. That being said, I can't say that I've tested many of our libraries with $KCODE set to see if they work as expected. As for get_last_error, I think it just requires this change: - buf.split(0.chr).first.chomp rescue 'Unknown error' + buf.split(0.chr).join[ /^[^\0\r\n]*/ ] rescue 'Unknown error' Thoughts? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From djberg96 at gmail.com Sat Jun 21 21:49:51 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 21 Jun 2008 19:49:51 -0600 Subject: [Win32utils-devel] hostid on Windows Vista and later Message-ID: <485DAFBF.5090505@gmail.com> Hi all, According to my research, the equivalent of gethostid() on Windows is the IPXAddress member of the Win32_NetworkAdapterConfiguration class. You can see the equivalent if you type "ipconfig /all" and look at the "Physical Address" member. However, the MSDN docs say that the IPXAddress member is no longer valid on Windows Vista and later. Does anyone know how to get the hostid on Vista and later? Thanks, Dan From waynev at gmail.com Sat Jun 21 23:11:57 2008 From: waynev at gmail.com (Wayne Vucenic) Date: Sat, 21 Jun 2008 20:11:57 -0700 Subject: [Win32utils-devel] hostid on Windows Vista and later In-Reply-To: <485DAFBF.5090505@gmail.com> References: <485DAFBF.5090505@gmail.com> Message-ID: <88c9ce410806212011q72d96075r42aac5665c5e5c5d@mail.gmail.com> Hi Dan, I did a little research, and found the following code that's supposed to do this on Vista, although I didn't try running it myself: http://www.codeproject.com/KB/IP/Net_Adapter_Info_in_C_.aspx Since it's C# .NET code it probably isn't exactly what you're looking for, but maybe it will point out directions for further investigation. (Of course, on Vista, .NET 3.0 is always present.) Wayne On Sat, Jun 21, 2008 at 6:49 PM, Daniel Berger wrote: > Hi all, > > According to my research, the equivalent of gethostid() on Windows is the > IPXAddress member of the Win32_NetworkAdapterConfiguration class. You can > see the equivalent if you type "ipconfig /all" and look at the "Physical > Address" member. > > However, the MSDN docs say that the IPXAddress member is no longer valid on > Windows Vista and later. Does anyone know how to get the hostid on Vista and > later? > > Thanks, > > Dan > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel > From phasis at gmail.com Sat Jun 21 23:34:27 2008 From: phasis at gmail.com (Park Heesob) Date: Sun, 22 Jun 2008 12:34:27 +0900 Subject: [Win32utils-devel] hostid on Windows Vista and later References: <485DAFBF.5090505@gmail.com> Message-ID: <4763A5B729824B2FAE139444B632F66A@mycomputer> Hi, ----- Original Message ----- From: "Daniel Berger" To: "Development and ideas for win32utils projects" Sent: Sunday, June 22, 2008 10:49 AM Subject: [Win32utils-devel] hostid on Windows Vista and later > Hi all, > > According to my research, the equivalent of gethostid() on Windows is the > IPXAddress member of the Win32_NetworkAdapterConfiguration class. You can > see the equivalent if you type "ipconfig /all" and look at the "Physical > Address" member. > > However, the MSDN docs say that the IPXAddress member is no longer valid > on Windows Vista and later. Does anyone know how to get the hostid on > Vista and later? > Why do you need IPXAddress member? As I know, the IPX protocol is not installed by default on XP and 2003. In my test IPXAdress is just same to MACAddress and MACAddress member works on Vista. Following script works on XP, 2003 and Vista: strComputer = "." Set objWMIService = GetObject("winmgmts:\\" _ & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=true",,48) For Each objItem in colItems Wscript.Echo "MACAddress: " & objItem.MACAddress Next Regards, Park Heesob From djberg96 at gmail.com Sun Jun 22 02:42:37 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 22 Jun 2008 00:42:37 -0600 Subject: [Win32utils-devel] hostid on Windows Vista and later In-Reply-To: <4763A5B729824B2FAE139444B632F66A@mycomputer> References: <485DAFBF.5090505@gmail.com> <4763A5B729824B2FAE139444B632F66A@mycomputer> Message-ID: <6037b70c0806212342j49bb7518jf3c820490ef23fa8@mail.gmail.com> On Sat, Jun 21, 2008 at 9:34 PM, Park Heesob wrote: > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "Development and ideas for win32utils projects" > > Sent: Sunday, June 22, 2008 10:49 AM > Subject: [Win32utils-devel] hostid on Windows Vista and later > > >> Hi all, >> >> According to my research, the equivalent of gethostid() on Windows is the >> IPXAddress member of the Win32_NetworkAdapterConfiguration class. You can >> see the equivalent if you type "ipconfig /all" and look at the "Physical >> Address" member. >> >> However, the MSDN docs say that the IPXAddress member is no longer valid >> on Windows Vista and later. Does anyone know how to get the hostid on >> Vista and later? >> > Why do you need IPXAddress member? As I know, the IPX protocol is not > installed by default on XP and 2003. > In my test IPXAdress is just same to MACAddress and MACAddress member works > on Vista. > Following script works on XP, 2003 and Vista: > > strComputer = "." > Set objWMIService = GetObject("winmgmts:\\" _ > & strComputer & "\root\CIMV2") > Set colItems = objWMIService.ExecQuery( _ > "SELECT * FROM Win32_NetworkAdapterConfiguration where > IPEnabled=true",,48) > For Each objItem in colItems > Wscript.Echo "MACAddress: " & objItem.MACAddress > Next > > Regards, > > Park Heesob Ah, silly me, I missed that. Thanks, Dan PS - This is for the sys-host library From djberg96 at gmail.com Tue Jun 24 22:01:30 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 24 Jun 2008 20:01:30 -0600 Subject: [Win32utils-devel] 100,000 downloads Message-ID: <6037b70c0806241901p5d41d8d3s1e0df26c41c76c86@mail.gmail.com> Hi Everyone, It looks like Win32Utils has hit 100,000 downloads tonight! We are the 10th most popular project on RubyForge. I just wanted to thank everyone on the list for making this such a great project to work on, and for all the help and feedback you've all provided. Special thanks go to Park Heesob, who has been crucial in this project's success. Thanks! Dan From waynev at gmail.com Wed Jun 25 02:27:18 2008 From: waynev at gmail.com (Wayne Vucenic) Date: Tue, 24 Jun 2008 23:27:18 -0700 Subject: [Win32utils-devel] 100,000 downloads In-Reply-To: <6037b70c0806241901p5d41d8d3s1e0df26c41c76c86@mail.gmail.com> References: <6037b70c0806241901p5d41d8d3s1e0df26c41c76c86@mail.gmail.com> Message-ID: <88c9ce410806242327ma3e67b8t9737947b93238bab@mail.gmail.com> Hi Dan, > It looks like Win32Utils has hit 100,000 downloads tonight! We are the > 10th most popular project on RubyForge. Congratulations! Wayne On Tue, Jun 24, 2008 at 7:01 PM, Daniel Berger wrote: > Hi Everyone, > > It looks like Win32Utils has hit 100,000 downloads tonight! We are the > 10th most popular project on RubyForge. > > I just wanted to thank everyone on the list for making this such a > great project to work on, and for all the help and feedback you've all > provided. > > Special thanks go to Park Heesob, who has been crucial in this > project's success. > > Thanks! > > Dan > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Daniel.Berger at qwest.com Wed Jun 25 16:17:28 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 25 Jun 2008 15:17:28 -0500 Subject: [Win32utils-devel] [OT] Byacc error Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3351@ITOMAE2KM01.AD.QINTRA.COM> Hi all, Yeah, I'm going OT here... I'm not entirely sure I understand how Ruby builds parse.y on Windows, but it works. However, when I changed all instances of "Ruby" to "Sapphire", and renamed all the source files, I suddenly started getting this error: byacc ./parse.y 'byacc' is not recognized as an internal or external command, operable program or batch file. NMAKE : fatal error U1077: 'byacc' : return code '0x1' Stop. Does anyone have any idea what would cause that? Here's the code I used: # rename.rb require 'fileutils' Dir['sapphire/**/*'].each{ |file| # Skip directories next unless File.file?(file) # Rename 'ruby.h' to 'sapphire.h', for example if File.basename(file) =~ /ruby/ old_file = file.dup file = File.join(File.dirname(file), File.basename(file).gsub('ruby', 'sapphire')) File.rename(old_file, file) end ruby_found = false # Do a pass over the file first, looking for 'ruby'. IO.foreach(file){ |line| if line =~ /ruby/i ruby_found = true break end } # Skip over files that don't contain the word 'ruby' next unless ruby_found # Create a temp file new_file = file + '.temp' FileUtils.cp(file, new_file) fh = File.open(new_file, 'wb') # Replace all instances of 'Ruby' with 'Sapphire', preserving case IO.foreach(file){ |line| line.gsub!('ruby', 'sapphire') line.gsub!('Ruby', 'Sapphire') line.gsub!('RUBY', 'SAPPHIRE') fh.print line } fh.close # Rename the temp file to the original file File.rename(new_file, file) } This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Wed Jun 25 21:07:11 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 26 Jun 2008 10:07:11 +0900 Subject: [Win32utils-devel] [OT] Byacc error In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3351@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D3351@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/6/26 Berger, Daniel : > Hi all, > > Yeah, I'm going OT here... > > I'm not entirely sure I understand how Ruby builds parse.y on Windows, > but it works. However, when I changed all instances of "Ruby" to > "Sapphire", and renamed all the source files, I suddenly started getting > this error: > > byacc ./parse.y > 'byacc' is not recognized as an internal or external command, > operable program or batch file. > NMAKE : fatal error U1077: 'byacc' : return code '0x1' > Stop. > > Does anyone have any idea what would cause that? > > It is due to the time discrepancy of parse.y and parse.c. As far as I know, the Ruby source distribution comes with parse.y and parse.c for the lacking of yacc of windows. You can find following lines in win32/Makefile.sub {$(srcdir)}.y.c: $(YACC) $(YFLAGS) $(<:\=/) sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@ @del y.tab.c I guess if you make both parse.y and parse.c same file time, it will skip byacc. If you would like to build with byacc, you can install byacc. Refer to http://gnuwin32.sourceforge.net/packages/byacc.htm Regards, Park Heesob From luislavena at gmail.com Thu Jun 26 07:01:47 2008 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 26 Jun 2008 13:01:47 +0200 Subject: [Win32utils-devel] Replace DL with Windows-PR Message-ID: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> Hello Guys, I'm was starring my screen for many hours before send this. This is a problem related to Capistrano Pageant interface witch rely on DL interfaces to communicate. The thing is this mechanism sometimes works, sometimes fail by unknown reasons and sometimes segfault. Tried different versions of Ruby from 1.8.5-p114 to 1.8.6-p114 with same results. The code in charge of this is located now in GitHub: http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed54326b927c99e2075e/lib/net/ssh/authentication/pageant.rb When it fails? When you try to send two messages to the target window at the same time, which is basically the way to communicate with Pageant. This happens when you try to connect and authenticate to two or more servers at the same time. I tried sending a SMTO_BLOCK in SendMessageTimeout, all without success. Looks like there is a corruption of data before that, but that is making my eyes bleed. Even using Winspector to look at the messages and failed. Do you think that migration from DL to Windows-PR will help me pinpoint the bug? The code is not mine, but I'll love to fix this since it's annoying (sometimes works, sometimes it doesn't). Thanks in advance for pointer and suggestions how to tackle this problem. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From Daniel.Berger at qwest.com Thu Jun 26 10:45:59 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 26 Jun 2008 09:45:59 -0500 Subject: [Win32utils-devel] [OT] Byacc error In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D3351@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3357@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Wednesday, June 25, 2008 7:07 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] [OT] Byacc error > > Hi, > > 2008/6/26 Berger, Daniel : > > Hi all, > > > > Yeah, I'm going OT here... > > > > I'm not entirely sure I understand how Ruby builds parse.y > on Windows, > > but it works. However, when I changed all instances of "Ruby" to > > "Sapphire", and renamed all the source files, I suddenly started > > getting this error: > > > > byacc ./parse.y > > 'byacc' is not recognized as an internal or external > command, operable > > program or batch file. > > NMAKE : fatal error U1077: 'byacc' : return code '0x1' > > Stop. > > > > Does anyone have any idea what would cause that? > > > > > It is due to the time discrepancy of parse.y and parse.c. > As far as I know, the Ruby source distribution comes with > parse.y and parse.c for the lacking of yacc of windows. > > You can find following lines in win32/Makefile.sub > > {$(srcdir)}.y.c: > $(YACC) $(YFLAGS) $(<:\=/) > sed -e "s!^ *extern char \*getenv();!/* & > */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@ > @del y.tab.c > > I guess if you make both parse.y and parse.c same file time, > it will skip byacc. Yes, that worked, thanks! > If you would like to build with byacc, you can install byacc. > Refer to http://gnuwin32.sourceforge.net/packages/byacc.htm I've never tried it. Do you think there's any advantage to doing so? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Thu Jun 26 11:05:27 2008 From: phasis at gmail.com (Heesob Park) Date: Fri, 27 Jun 2008 00:05:27 +0900 Subject: [Win32utils-devel] [OT] Byacc error In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3357@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D3351@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D3357@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: 2008/6/26 Berger, Daniel : > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Heesob Park >> Sent: Wednesday, June 25, 2008 7:07 PM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] [OT] Byacc error >> >> Hi, >> >> 2008/6/26 Berger, Daniel : >> > Hi all, >> > >> > Yeah, I'm going OT here... >> > >> > I'm not entirely sure I understand how Ruby builds parse.y >> on Windows, >> > but it works. However, when I changed all instances of "Ruby" to >> > "Sapphire", and renamed all the source files, I suddenly started >> > getting this error: >> > >> > byacc ./parse.y >> > 'byacc' is not recognized as an internal or external >> command, operable >> > program or batch file. >> > NMAKE : fatal error U1077: 'byacc' : return code '0x1' >> > Stop. >> > >> > Does anyone have any idea what would cause that? >> > >> > >> It is due to the time discrepancy of parse.y and parse.c. >> As far as I know, the Ruby source distribution comes with >> parse.y and parse.c for the lacking of yacc of windows. >> >> You can find following lines in win32/Makefile.sub >> >> {$(srcdir)}.y.c: >> $(YACC) $(YFLAGS) $(<:\=/) >> sed -e "s!^ *extern char \*getenv();!/* & >> */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@ >> @del y.tab.c >> >> I guess if you make both parse.y and parse.c same file time, >> it will skip byacc. > > Yes, that worked, thanks! > >> If you would like to build with byacc, you can install byacc. >> Refer to http://gnuwin32.sourceforge.net/packages/byacc.htm > > I've never tried it. Do you think there's any advantage to doing so? > Except for the case of changing grammer or parsing rule, you have no advantage. Regards, Park Heesob From Daniel.Berger at qwest.com Thu Jun 26 11:27:02 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 26 Jun 2008 10:27:02 -0500 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3359@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Thursday, June 26, 2008 5:02 AM > To: Development and ideas for win32utils projects > Subject: [Win32utils-devel] Replace DL with Windows-PR > > Hello Guys, > > I'm was starring my screen for many hours before send this. > This is a problem related to Capistrano Pageant interface > witch rely on DL interfaces to communicate. > > The thing is this mechanism sometimes works, sometimes fail > by unknown reasons and sometimes segfault. > > Tried different versions of Ruby from 1.8.5-p114 to > 1.8.6-p114 with same results. > > The code in charge of this is located now in GitHub: > > http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed543 > 26b927c99e2075e/lib/net/ssh/authentication/pageant.rb > > When it fails? > When you try to send two messages to the target window at the > same time, which is basically the way to communicate with Pageant. > This happens when you try to connect and authenticate to two > or more servers at the same time. > > I tried sending a SMTO_BLOCK in SendMessageTimeout, all > without success. > > Looks like there is a corruption of data before that, but > that is making my eyes bleed. Even using Winspector to look > at the messages and failed. > > Do you think that migration from DL to Windows-PR will help > me pinpoint the bug? The code is not mine, but I'll love to > fix this since it's annoying (sometimes works, sometimes it doesn't). > > Thanks in advance for pointer and suggestions how to tackle > this problem. Well, there's only one way to find out. :) You could save yourself some effort by using win32-mmap, too. The only function I noticed that you'll have to define yourself is SendMessageTimeout. You can find FindWindow in the Windows::Window module. Note that I think I'm going to reorganize that for 0.9.0 so that it's under the Windows::Windowing:: namespace, because it seems like a better way to organize the windowing related functions, e.g. Messages, Windows, Timers, etc. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Jun 26 13:05:04 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 26 Jun 2008 12:05:04 -0500 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3359@ITOMAE2KM01.AD.QINTRA.COM> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D3359@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D335C@ITOMAE2KM01.AD.QINTRA.COM> Replying to myself... > You can find FindWindow in the Windows::Window module. Note > that I think I'm going to reorganize that for 0.9.0 so that > it's under the > Windows::Windowing:: namespace, because it seems like a > better way to organize the windowing related functions, e.g. > Messages, Windows, Timers, etc. Upon further review I better leave Windows::Window where it is, since it looks like at least one other major project (Watir) is using it. I'll put the rest of the Windowing related functions under "Windows::Window::", though. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Jun 26 21:19:24 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 26 Jun 2008 20:19:24 -0500 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Thursday, June 26, 2008 5:02 AM > To: Development and ideas for win32utils projects > Subject: [Win32utils-devel] Replace DL with Windows-PR > > Hello Guys, > > I'm was starring my screen for many hours before send this. > This is a problem related to Capistrano Pageant interface > witch rely on DL interfaces to communicate. > > The thing is this mechanism sometimes works, sometimes fail > by unknown reasons and sometimes segfault. > > Tried different versions of Ruby from 1.8.5-p114 to > 1.8.6-p114 with same results. > > The code in charge of this is located now in GitHub: > > http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed543 > 26b927c99e2075e/lib/net/ssh/authentication/pageant.rb After looking this over I don't understand this portion: # Start code snippet ptr = Win.mapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0, AGENT_MAX_MSGLEN) if ptr.nil? || ptr.null? raise Net::SSH::Exception, "Mapping of file failed" end ptr[0] = query # HUH? cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname]. pack("LLp").to_ptr succ = Win.sendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL, cds, Win::SMTO_NORMAL, 5000, id) if succ > 0 retlen = 4 + ptr.to_s(4).unpack("N")[0] res = ptr.to_s(retlen) end return res # End code snippet MapViewOfFile returns an address, not a pointer, unless this has something to do with DL. Even if it does return a pointer (ok, fine, unpack it), I don't understand why you are assigning 'query' to ptr[0]. Something tells me you don't want to change the address of the mapped view, but perhaps I don't understand something. Anyway, here's an attempt at using win32-mmap + windows-pr. Note that the portion at the end is undefined since I'm not sure what you're trying to do exactly: # UNTESTED! require 'win32/mmap' require 'windows/thread' require 'windows/window' require 'windows/window/message' module Net module SSH module Authentication module Pageant AGENT_MAX_MSGLEN = 8192 AGENT_COPYDATA_ID = 0x804e50ba class Socket include Windows::Thread include Windows::Window include Windows::Window::Message private_class_method :new def self.open(location=nil) new end def initialize @win = FindWindow("Pageant", "Pageant") if @win == 0 raise Net::SSH::Exception, "pageant process not running" end @res = nil @pos = 0 end def send(data, *args) @res = send_query(data) @pos = 0 end def send_query(query) mapname = "PageantRequest%08x\000" % GetCurrentThreadId() filemap = Win32::MMap.new( :name => mapname, :size => AGENT_MAX_MSGLEN ) result = [0].pack('L'0 cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname].pack("LLp") succ = SendMessageTimeout( @win, WM_COPYDATA, nil, cds, SMTO_NORMAL, 5000, result ) if succ > 0 # Do something # res = ??? end return res ensure filemap.close end end end end end end The Windows::Window::Message module you'll have to grab from the windows-pr cvs repo. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Fri Jun 27 03:53:10 2008 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 27 Jun 2008 09:53:10 +0200 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0806270053q6f3a9e5di95c1e47d78f95421@mail.gmail.com> On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel wrote: > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Luis Lavena >> Sent: Thursday, June 26, 2008 5:02 AM >> To: Development and ideas for win32utils projects >> Subject: [Win32utils-devel] Replace DL with Windows-PR >> >> Hello Guys, >> >> I'm was starring my screen for many hours before send this. >> This is a problem related to Capistrano Pageant interface >> witch rely on DL interfaces to communicate. >> >> The thing is this mechanism sometimes works, sometimes fail >> by unknown reasons and sometimes segfault. >> >> Tried different versions of Ruby from 1.8.5-p114 to >> 1.8.6-p114 with same results. >> >> The code in charge of this is located now in GitHub: >> >> http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed543 >> 26b927c99e2075e/lib/net/ssh/authentication/pageant.rb > > > > After looking this over I don't understand this portion: > > # Start code snippet > ptr = Win.mapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0, > AGENT_MAX_MSGLEN) > > if ptr.nil? || ptr.null? > raise Net::SSH::Exception, "Mapping of file failed" > end > > ptr[0] = query # HUH? > > cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname]. pack("LLp").to_ptr > succ = Win.sendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL, cds, > Win::SMTO_NORMAL, 5000, id) > > if succ > 0 > retlen = 4 + ptr.to_s(4).unpack("N")[0] > res = ptr.to_s(retlen) > end > > return res > # End code snippet > > MapViewOfFile returns an address, not a pointer, unless this has > something to do with DL. > > Even if it does return a pointer (ok, fine, unpack it), I don't > understand why you are assigning 'query' to ptr[0]. Something tells me > you don't want to change the address of the mapped view, but perhaps I > don't understand something. > me neither, been looking for code examples on internet (that communicate with Pageant) without success, I want fix this since is randomly crashing, whcih could be related to what you described here. > Anyway, here's an attempt at using win32-mmap + windows-pr. Note that > the portion at the end is undefined since I'm not sure what you're > trying to do exactly: > > # UNTESTED! > require 'win32/mmap' > require 'windows/thread' > require 'windows/window' > require 'windows/window/message' > > module Net > module SSH > module Authentication > module Pageant > > AGENT_MAX_MSGLEN = 8192 > AGENT_COPYDATA_ID = 0x804e50ba > > class Socket > include Windows::Thread > include Windows::Window > include Windows::Window::Message > > private_class_method :new > > def self.open(location=nil) > new > end > > def initialize > @win = FindWindow("Pageant", "Pageant") > > if @win == 0 > raise Net::SSH::Exception, "pageant process not > running" > end > > @res = nil > @pos = 0 > end > > def send(data, *args) > @res = send_query(data) > @pos = 0 > end > > def send_query(query) > mapname = "PageantRequest%08x\000" % > GetCurrentThreadId() > > filemap = Win32::MMap.new( > :name => mapname, > :size => AGENT_MAX_MSGLEN > ) > > result = [0].pack('L'0 > > cds = [AGENT_COPYDATA_ID, mapname.size + 1, > mapname].pack("LLp") > > succ = SendMessageTimeout( > @win, > WM_COPYDATA, > nil, > cds, > SMTO_NORMAL, > 5000, > result > ) > > if succ > 0 > # Do something > # res = ??? > end > > return res > ensure > filemap.close > end > end > end > end > end > end > > The Windows::Window::Message module you'll have to grab from the > windows-pr cvs repo. > > Regards, > Thank you Daniel, I'll give it a whirl later today. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From luislavena at gmail.com Fri Jun 27 04:25:25 2008 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 27 Jun 2008 10:25:25 +0200 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0806270125n4574263v8556bb7124f062cc@mail.gmail.com> On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel wrote: >... > > The Windows::Window::Message module you'll have to grab from the > windows-pr cvs repo. > Btw, just wondering, no planned upgrade to svn? It seems that Sapphire is using it also, just wanted to know your position about that. > Regards, > Regards and thank you for your time, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From djberg96 at gmail.com Fri Jun 27 07:18:31 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 27 Jun 2008 05:18:31 -0600 Subject: [Win32utils-devel] User sid Message-ID: <4864CC87.30406@gmail.com> Hi all, I was playing around with the idea of implementing Process.uid and Process.uid= for MS Windows. To that end I first wanted to get the user associated with the current process. Then I wanted the user's SID. I can't seem to get the stringified SID, though. Here's the code (use the latest cvs version of windows-pr): require 'windows/process' require 'windows/error' require 'windows/security' include Windows::Process include Windows::Error include Windows::Security handle = GetCurrentProcess() token_handle = [0].pack('L') unless OpenProcessToken(handle, TOKEN_QUERY, token_handle) raise get_last_error end token_handle = token_handle.unpack('L')[0] return_length = [0].pack('L') # First pass, get the buffer size needed GetTokenInformation(token_handle, TokenUser, 0, 0, return_length) token_info = 0.chr * return_length.unpack('L')[0] bool = GetTokenInformation( token_handle, TokenUser, token_info, token_info.size, return_length ) unless bool raise get_last_error end sid_addr = token_info.unpack('L')[0] name_buf = 0.chr * 80 name_cch = [name_buf.size].pack('L') domain_buf = 0.chr * 80 domain_cch = [domain_buf.size].pack('L') sid_name_use = 0.chr * 4 bool = LookupAccountSid( nil, sid_addr, name_buf, name_cch, domain_buf, domain_cch, sid_name_use ) unless bool raise get_last_error end p name_buf.strip # "djberge" sid_buf = 0.chr * 80 bool = ConvertSidToStringSid( sid_addr, [sid_buf].pack('p*').unpack('L')[0] ) unless bool raise get_last_error end # Junk p sid_buf.strip # Taken from http://search.cpan.org/src/TEVERETT/Win32-Security-0.50/lib/Win32/Security/SID.pm # but it doesn't quite match up. p token_info.unpack('CCnNV*') How can I get the stringified SID? Thanks, Dan PS - I'm trying to remember why I changed the prototype of ConvertSidToStringSid to 'PL', but I can't. It seems it ought to be 'LP', but I don't want to break code at this point. From phasis at gmail.com Fri Jun 27 08:52:03 2008 From: phasis at gmail.com (Park Heesob) Date: Fri, 27 Jun 2008 21:52:03 +0900 Subject: [Win32utils-devel] User sid References: <4864CC87.30406@gmail.com> Message-ID: <97391697688B44DBAF84C3196CE3D590@mycomputer> Hi, ----- Original Message ----- From: "Daniel Berger" To: "win32utils-devel" Sent: Friday, June 27, 2008 8:18 PM Subject: [Win32utils-devel] User sid > Hi all, > > I was playing around with the idea of implementing Process.uid and > Process.uid= for MS Windows. To that end I first wanted to get the user > associated with the current process. Then I wanted the user's SID. I can't > seem to get the stringified SID, though. > After modifying ConvertSidToStringSid like this: API.new('ConvertSidToStringSid', 'LP', 'B', 'advapi32') Here is a working code: require 'windows/process' require 'windows/error' require 'windows/security' require 'windows/msvcrt/string' include Windows::Process include Windows::Error include Windows::Security include Windows::Security include Windows::MSVCRT::String handle = GetCurrentProcess() token_handle = [0].pack('L') unless OpenProcessToken(handle, TOKEN_QUERY, token_handle) raise get_last_error end token_handle = token_handle.unpack('L')[0] return_length = [0].pack('L') # First pass, get the buffer size needed GetTokenInformation(token_handle, TokenUser, 0, 0, return_length) token_info = 0.chr * return_length.unpack('L')[0] bool = GetTokenInformation( token_handle, TokenUser, token_info, token_info.size, return_length ) unless bool raise get_last_error end sid_addr = token_info.unpack('L')[0] name_buf = 0.chr * 80 name_cch = [name_buf.size].pack('L') domain_buf = 0.chr * 80 domain_cch = [domain_buf.size].pack('L') sid_name_use = 0.chr * 4 bool = LookupAccountSid( nil, sid_addr, name_buf, name_cch, domain_buf, domain_cch, sid_name_use ) unless bool raise get_last_error end p name_buf.strip # "djberge" sid_buf = 0.chr * 80 sid_ptr = 0.chr * 4 bool = ConvertSidToStringSid( sid_addr, sid_ptr ) unless bool raise get_last_error end strcpy(sid_buf,sid_ptr.unpack('L').first) p sid_buf.strip p token_info.unpack('CCnNV*') Regards, Park Heesob From Daniel.Berger at qwest.com Fri Jun 27 09:42:58 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Fri, 27 Jun 2008 08:42:58 -0500 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <71166b3b0806270125n4574263v8556bb7124f062cc@mail.gmail.com> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0806270125n4574263v8556bb7124f062cc@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3362@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Friday, June 27, 2008 2:25 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Replace DL with Windows-PR > > On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel > wrote: > >... > > > > The Windows::Window::Message module you'll have to grab from the > > windows-pr cvs repo. > > > > Btw, just wondering, no planned upgrade to svn? It seems that > Sapphire is using it also, just wanted to know your position > about that. Nope, no plans. For small libraries like ours I see no real advantage to switching to SVN. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Fri Jun 27 10:04:49 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Fri, 27 Jun 2008 09:04:49 -0500 Subject: [Win32utils-devel] User sid In-Reply-To: <97391697688B44DBAF84C3196CE3D590@mycomputer> References: <4864CC87.30406@gmail.com> <97391697688B44DBAF84C3196CE3D590@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Friday, June 27, 2008 6:52 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] User sid > > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "win32utils-devel" > Sent: Friday, June 27, 2008 8:18 PM > Subject: [Win32utils-devel] User sid > > > > Hi all, > > > > I was playing around with the idea of implementing Process.uid and > > Process.uid= for MS Windows. To that end I first wanted to > get the user > > associated with the current process. Then I wanted the > user's SID. I can't > > seem to get the stringified SID, though. > > > After modifying ConvertSidToStringSid like this: > API.new('ConvertSidToStringSid', 'LP', 'B', 'advapi32') > > Here is a working code: > > require 'windows/process' > require 'windows/error' > require 'windows/security' > require 'windows/msvcrt/string' > > include Windows::Process > include Windows::Error > include Windows::Security > include Windows::Security > include Windows::MSVCRT::String > > handle = GetCurrentProcess() > > token_handle = [0].pack('L') > > unless OpenProcessToken(handle, TOKEN_QUERY, token_handle) > raise get_last_error > end > > token_handle = token_handle.unpack('L')[0] > return_length = [0].pack('L') > > # First pass, get the buffer size needed > GetTokenInformation(token_handle, TokenUser, 0, 0, return_length) > > token_info = 0.chr * return_length.unpack('L')[0] > > bool = GetTokenInformation( > token_handle, > TokenUser, > token_info, > token_info.size, > return_length > ) > > unless bool > raise get_last_error > end > > sid_addr = token_info.unpack('L')[0] > > name_buf = 0.chr * 80 > name_cch = [name_buf.size].pack('L') > > domain_buf = 0.chr * 80 > domain_cch = [domain_buf.size].pack('L') > > sid_name_use = 0.chr * 4 > > bool = LookupAccountSid( > nil, > sid_addr, > name_buf, > name_cch, > domain_buf, > domain_cch, > sid_name_use > ) > > unless bool > raise get_last_error > end > p name_buf.strip # "djberge" > > sid_buf = 0.chr * 80 > sid_ptr = 0.chr * 4 > bool = ConvertSidToStringSid( > sid_addr, > sid_ptr > ) > > unless bool > raise get_last_error > end > strcpy(sid_buf,sid_ptr.unpack('L').first) > p sid_buf.strip That works, thanks. What do you think about the idea of having Process.uid return a SID, and a Process.uid= method that would take a SID? I think this is possible with SetSecurityInfo, but I haven't tried yet. Possible enhancement for win32-process 0.6.0? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Fri Jun 27 10:30:54 2008 From: phasis at gmail.com (Park Heesob) Date: Fri, 27 Jun 2008 23:30:54 +0900 Subject: [Win32utils-devel] User sid References: <4864CC87.30406@gmail.com><97391697688B44DBAF84C3196CE3D590@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Friday, June 27, 2008 11:04 PM Subject: Re: [Win32utils-devel] User sid > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Friday, June 27, 2008 6:52 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] User sid >> >> Hi, >> ----- Original Message ----- >> From: "Daniel Berger" >> To: "win32utils-devel" >> Sent: Friday, June 27, 2008 8:18 PM >> Subject: [Win32utils-devel] User sid >> >> >> > Hi all, >> > >> > I was playing around with the idea of implementing Process.uid and >> > Process.uid= for MS Windows. To that end I first wanted to >> get the user >> > associated with the current process. Then I wanted the >> user's SID. I can't >> > seem to get the stringified SID, though. >> > >> After modifying ConvertSidToStringSid like this: >> API.new('ConvertSidToStringSid', 'LP', 'B', 'advapi32') >> >> Here is a working code: >> >> require 'windows/process' >> require 'windows/error' >> require 'windows/security' >> require 'windows/msvcrt/string' >> >> include Windows::Process >> include Windows::Error >> include Windows::Security >> include Windows::Security >> include Windows::MSVCRT::String >> >> handle = GetCurrentProcess() >> >> token_handle = [0].pack('L') >> >> unless OpenProcessToken(handle, TOKEN_QUERY, token_handle) >> raise get_last_error >> end >> >> token_handle = token_handle.unpack('L')[0] >> return_length = [0].pack('L') >> >> # First pass, get the buffer size needed >> GetTokenInformation(token_handle, TokenUser, 0, 0, return_length) >> >> token_info = 0.chr * return_length.unpack('L')[0] >> >> bool = GetTokenInformation( >> token_handle, >> TokenUser, >> token_info, >> token_info.size, >> return_length >> ) >> >> unless bool >> raise get_last_error >> end >> >> sid_addr = token_info.unpack('L')[0] >> >> name_buf = 0.chr * 80 >> name_cch = [name_buf.size].pack('L') >> >> domain_buf = 0.chr * 80 >> domain_cch = [domain_buf.size].pack('L') >> >> sid_name_use = 0.chr * 4 >> >> bool = LookupAccountSid( >> nil, >> sid_addr, >> name_buf, >> name_cch, >> domain_buf, >> domain_cch, >> sid_name_use >> ) >> >> unless bool >> raise get_last_error >> end >> p name_buf.strip # "djberge" >> >> sid_buf = 0.chr * 80 >> sid_ptr = 0.chr * 4 >> bool = ConvertSidToStringSid( >> sid_addr, >> sid_ptr >> ) >> >> unless bool >> raise get_last_error >> end >> strcpy(sid_buf,sid_ptr.unpack('L').first) >> p sid_buf.strip > > > > That works, thanks. > > What do you think about the idea of having Process.uid return a SID, and > a Process.uid= method that would take a SID? I think this is possible > with SetSecurityInfo, but I haven't tried yet. > > Possible enhancement for win32-process 0.6.0? > I'm not sure it is possible. but it is worthwhile. In relation to the SID, Finding the Owner of a File Object (http://msdn.microsoft.com/en-us/library/aa446629(VS.85).aspx) and Taking Object Ownership (http://msdn.microsoft.com/en-us/library/aa379620(VS.85).aspx) is also possible enhancement for win32-file, right? Regards, Park Heesob From Daniel.Berger at qwest.com Fri Jun 27 11:27:53 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Fri, 27 Jun 2008 10:27:53 -0500 Subject: [Win32utils-devel] User sid In-Reply-To: References: <4864CC87.30406@gmail.com><97391697688B44DBAF84C3196CE3D590@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> Hi, > > What do you think about the idea of having Process.uid > return a SID, and > > a Process.uid= method that would take a SID? I think this > is possible > > with SetSecurityInfo, but I haven't tried yet. > > > > Possible enhancement for win32-process 0.6.0? > > > I'm not sure it is possible. but it is worthwhile. Here's one possible solution I came across. http://hockeythoughts.net/forums/printthread.php?t=1210 There might be better ones, though. > In relation to the SID, > Finding the Owner of a File Object > (http://msdn.microsoft.com/en-us/library/aa446629(VS.85).aspx) > and Taking Object Ownership > (http://msdn.microsoft.com/en-us/library/aa379620(VS.85).aspx) > is also possible enhancement for win32-file, right? That looks like a good idea. With that we could implement a working File.chown (and File.owned?, too, I think), correct? Please go ahead and implement this if you have the desire and the time, as I will be out next week on vacation. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Fri Jun 27 11:46:19 2008 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 27 Jun 2008 17:46:19 +0200 Subject: [Win32utils-devel] Replace DL with Windows-PR In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3362@ITOMAE2KM01.AD.QINTRA.COM> References: <71166b3b0806260401i33678fdevbad235b78e209159@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D3360@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0806270125n4574263v8556bb7124f062cc@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D3362@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0806270846v5a86e332q69905bc138b1fab3@mail.gmail.com> On Fri, Jun 27, 2008 at 3:42 PM, Berger, Daniel wrote: > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Luis Lavena >> Sent: Friday, June 27, 2008 2:25 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Replace DL with Windows-PR >> >> On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel >> wrote: >> >... >> > >> > The Windows::Window::Message module you'll have to grab from the >> > windows-pr cvs repo. >> > >> >> Btw, just wondering, no planned upgrade to svn? It seems that >> Sapphire is using it also, just wanted to know your position >> about that. > > Nope, no plans. For small libraries like ours I see no real advantage to > switching to SVN. > Then I'll need to install CVS, last time I had it installed was in 2003 I think :-P > Regards, > Thank you again for your time Daniel, will check this tonight! -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From phasis at gmail.com Sun Jun 29 05:38:12 2008 From: phasis at gmail.com (Park Heesob) Date: Sun, 29 Jun 2008 18:38:12 +0900 Subject: [Win32utils-devel] User sid References: <4864CC87.30406@gmail.com><97391697688B44DBAF84C3196CE3D590@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Saturday, June 28, 2008 12:27 AM Subject: Re: [Win32utils-devel] User sid > Hi, > > > >> > What do you think about the idea of having Process.uid >> return a SID, and >> > a Process.uid= method that would take a SID? I think this >> is possible >> > with SetSecurityInfo, but I haven't tried yet. >> > >> > Possible enhancement for win32-process 0.6.0? >> > >> I'm not sure it is possible. but it is worthwhile. > > Here's one possible solution I came across. > > http://hockeythoughts.net/forums/printthread.php?t=1210 > > There might be better ones, though. > >> In relation to the SID, >> Finding the Owner of a File Object >> (http://msdn.microsoft.com/en-us/library/aa446629(VS.85).aspx) >> and Taking Object Ownership >> (http://msdn.microsoft.com/en-us/library/aa379620(VS.85).aspx) >> is also possible enhancement for win32-file, right? > > That looks like a good idea. With that we could implement a working > File.chown (and File.owned?, too, I think), correct? > > Please go ahead and implement this if you have the desire and the time, > as I will be out next week on vacation. > I have implemented it as you expected :) After adding following two lines to the security.rb: API.new('GetSecurityInfo', 'LLLPPPPP', 'L', 'advapi32') API.new('SetSecurityInfo', 'LLLPPPP', 'L', 'advapi32') Here is a working code for change_owner and get_owner : require 'windows/process' require 'windows/handle' require 'windows/file' require 'windows/error' require 'windows/security' require 'windows/msvcrt/string' require 'windows/msvcrt/buffer' include Windows::Process include Windows::Handle include Windows::File include Windows::Error include Windows::Security include Windows::MSVCRT::String include Windows::MSVCRT::Buffer SE_KERNEL_OBJECT = 6 SE_FILE_OBJECT = 1 OWNER_SECURITY_INFORMATION = 1 SECURITY_DESCRIPTOR_REVISION = 1 def get_sid(account) sid = 0.chr * 28 sid_cb = [sid.size].pack('L') name_buf = 0.chr * 80 name_cch = [name_buf.size].pack('L') domain_buf = 0.chr * 80 domain_cch = [domain_buf.size].pack('L') sid_name_use = 0.chr * 4 bool = LookupAccountName( nil, account, sid, sid_cb, domain_buf, domain_cch, sid_name_use ) unless bool raise get_last_error end sid_addr = [sid].pack('p*').unpack('L').first sid_buf = 0.chr * 80 sid_ptr = 0.chr * 4 unless ConvertSidToStringSid(sid_addr,sid_ptr) raise get_last_error end strcpy(sid_buf,sid_ptr.unpack('L').first) sid end def enable_privilege(privilege) modify_state(privilege, true) end def disable_privilege(privilege) modify_state(privilege, false) end def modify_state(privilege,enable) token_handle = [0].pack('L') unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, token_handle) raise get_last_error end token_handle = token_handle.unpack('L')[0] return_length = [0].pack('L') luid = 0.chr * 8 LookupPrivilegeValue("", privilege, luid) unless LookupPrivilegeValue("", privilege, luid) raise get_last_error end luid = luid.unpack('LL') if enable tkp1 = [ 1, luid[0], luid[1], 2 ].pack('LLLL') else tkp1 = [ 1, luid[0], luid[1], 0 ].pack('LLLL') end unless AdjustTokenPrivileges(token_handle, 0, tkp1, tkp1.size, nil, nil) raise get_last_error end CloseHandle(token_handle) true end def get_owner(file) handle = CreateFile( file, GENERIC_READ , FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0 ) if handle == INVALID_HANDLE_VALUE raise ArgumentError, get_last_error end sid = 0.chr * 28 sid_ptr = [0].pack('L') ret = GetSecurityInfo( handle, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, sid_ptr,nil,nil,nil,nil) if(ret!=0) raise get_last_error end name_buf = 0.chr * 80 name_cch = [name_buf.size].pack('L') domain_buf = 0.chr * 80 domain_cch = [domain_buf.size].pack('L') sid_name_use = 0.chr * 4 bool = LookupAccountSid( nil, sid_ptr.unpack('L').first, name_buf, name_cch, domain_buf, domain_cch, sid_name_use ) unless bool raise get_last_error end name_buf.strip end def change_owner(file,account) enable_privilege("SeRestorePrivilege") sid = get_sid(account) sec_desc = 0.chr * SECURITY_DESCRIPTOR_MIN_LENGTH unless InitializeSecurityDescriptor(sec_desc, 1) raise get_last_error end unless SetSecurityDescriptorOwner(sec_desc, sid, 0) raise get_last_error end unless SetFileSecurity(file, OWNER_SECURITY_INFORMATION, sec_desc) raise get_last_error end disable_privilege ("SeRestorePrivilege") end You can test it with change_owner('c:/test.txt','user') or get_owner('c:/test.txt') Regards, Park Heesob