From Daniel.Berger at qwest.com Mon Jul 7 11:00:23 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 7 Jul 2008 10:00:23 -0500 Subject: [Win32utils-devel] User sid In-Reply-To: References: <4864CC87.30406@gmail.com><97391697688B44DBAF84C3196CE3D590@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM><7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> Hi everyone, I'm back from vacation. > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Sunday, June 29, 2008 3:38 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] User sid > 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 : Excellent, thanks! I think what I'll do is add this to win32-file 0.5.6, and just make these methods private for now. My ultimate plan, however, is to separate the security related functions into a separate win32-security library, modelled after Perl's Win32::Security module, which you can find at http://search.cpan.org/~teverett/Win32-Security-0.50/, and/or Python's win32security library. I have some non-working skeleton code for win32-security in CVS, but I need to think about the interface more before publishing it. I may have brought this up before, but I can't remember now. Anyay, once we publish win32-security, we'll make it a requirement for win32-file (among others) and use its interface instead of a bunch of internal, private methods in order to keep the code base a bit more maintainable and easier to read. The next major upgrade I have planned is to make our libraries more Unicode friendly, which means lots of manual string handling via multi_to_wide and so forth. The example that inspired me was http://tinyurl.com/6e473w. Sound like a plan? 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 Mon Jul 7 11:34:51 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 7 Jul 2008 10:34:51 -0500 Subject: [Win32utils-devel] User sid In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> References: <4864CC87.30406@gmail.com><97391697688B44DBAF84C3196CE3D590@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM><7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3373@ITOMAE2KM01.AD.QINTRA.COM> Hi, Quick followup to my own post. > My ultimate plan, however, is to separate the security > related functions into a separate win32-security library, > modelled after Perl's Win32::Security module, which you can > find at > http://search.cpan.org/~teverett/Win32-Security-0.50/, and/or > Python's win32security library. I have some non-working > skeleton code for win32-security in CVS, but I need to think > about the interface more before publishing it. Whoops, looks like I do NOT have win32-security in CVS, only on my local hard drive. It's just as well, since there isn't much to it yet anyway. I just didn't want anyone wondering where it was. :) 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 noreply at rubyforge.org Mon Jul 7 13:50:49 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 7 Jul 2008 13:50:49 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Support Requests-21110 ] Having problems creating junction on mounted network folder Message-ID: <20080707175050.006FD1858289@rubyforge.org> Support Requests item #21110, was opened at 2008-07-07 13:50 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=21110&group_id=85 Category: win32-dir Group: v1.0 (example) Status: Open Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Having problems creating junction on mounted network folder Initial Comment: Hey guys, I'm getting a permission denied error when trying to create a junction on a network folder that I have mounted.. I can stop the code right before the DeviceIoControl call (inside Dir.create_junction) and everything seems good (link has been created as a directory and filehandle is still open).. but then I get a: dir.rb:120:in `create_junction': DeviceIoControl() failed: Access is denied. (RuntimeError) from dir.rb:167 I'm using VERSION = '0.3.2' of dir.rb The code works fine on my local disk, so there is something different about the network permissions.. Do you guys have any advice? Thanks! -Blair BTW: I found that if you switch the order of the closing filehandle and removing directory it will remove the directory (which was going to be a link).. dir.rb: 116 unless bool error = 'DeviceIoControl() failed: ' + get_last_error CloseHandle(handle) RemoveDirectory(to) raise error end ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=21110&group_id=85 From Daniel.Berger at qwest.com Mon Jul 7 16:37:17 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 7 Jul 2008 15:37:17 -0500 Subject: [Win32utils-devel] win32-security rough idea Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3375@ITOMAE2KM01.AD.QINTRA.COM> Hi all, How does this look? require 'win32/security' include Win32 s = Security::SID.new('djberge') # s.length => 28 s.account => 'djberge' s.domain => 'mydomain' s.sid => '\001...' s.account_type => 'user' s.to_s => S-1-5-21-55555-444444-88-118888-999999 s.valid? => true s == s => true Here's the implementation so far (more comments at end): # win32/security/sid.rb require 'windows/security' require 'windows/error' require 'windows/msvcrt/string' require 'windows/msvcrt/buffer' require 'socket' module Win32 module Security class SID include Windows::Security include Windows::Error include Windows::MSVCRT::String include Windows::MSVCRT::Buffer extend Windows::Security extend Windows::Error extend Windows::MSVCRT::String class Error < StandardError; end # The binary SID object itself. attr_reader :sid # The account name passed to the constructor. attr_reader :account # The SID account type, e.g. 'user, 'group', etc. attr_reader :account_type # The domain the SID is on. attr_reader :domain # The host passed to the constructor, or the localhost if none # was specified. attr_reader :host # Converts a binary SID to a string in S-R-I-S-S... format. # def self.convert_sid_to_string_sid(sid) sid_addr = [sid].pack('p*').unpack('L')[0] sid_buf = 0.chr * 80 sid_ptr = 0.chr * 4 unless ConvertSidToStringSid(sid_addr, sid_ptr) raise Error, get_last_error end strcpy(sid_buf, sid_ptr.unpack('L')[0]) sid_buf.strip end # Converts a string in S-R-I-S-S... format back to a binary SID. # def self.convert_string_sid_to_sid(string) sid_buf = 0.chr * 80 string_addr = [string].pack('p*').unpack('L')[0] unless ConvertStringSidToSid(string_addr, sid_buf) raise Error, get_last_error end sid_buf.strip end # Creates and returns a new Win32::Security::SID object, based on # the account name. If a host is provided, then the information is # retrieved from that host. Otherwise, the local host is used. # # Note that this does NOT create a new SID, but merely retrieves # information for an existing SID. To create a new SID, use the # SID.create method. #-- # TODO: Add the SID.create method. # def initialize(account, host=Socket.gethostname) sid = 0.chr * 28 sid_cb = [sid.size].pack('L') domain_buf = 0.chr * 80 domain_cch = [domain_buf.size].pack('L') sid_name_use = 0.chr * 4 bool = LookupAccountName( host, account, sid, sid_cb, domain_buf, domain_cch, sid_name_use ) unless bool raise Error, get_last_error end @sid = sid.strip @host = host @domain = domain_buf.strip @account = account @account_type = get_account_type(sid_name_use.unpack('L')[0]) sid end # Returns the binary SID in string format suitable for display, # storage or transmission. # def to_s 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 Error, get_last_error end strcpy(sid_buf, sid_ptr.unpack('L').first) sid_buf.strip end alias to_str to_s # Returns whether or not the SID object is equal to +other+. # def ==(other) EqualSid(@sid, other.sid) end # Returns whether or not the SID is a valid sid. # def valid? IsValidSid(@sid) end # Returns the length of the SID object, in bytes. # def length GetLengthSid(@sid) end private # Converts a numeric account type into a human readable string. # def get_account_type(value) case value when SidTypeUser 'user' when SidTypeGroup 'group' when SidTypeDomain 'domain' when SidTypeAlias 'alias' when SidTypeWellKnownGroup 'well known group' when SidTypeDeletedAccount 'deleted account' when SidTypeInvalid 'invalid' when SidTypeUnknown 'unknown' when SidComputer 'computer' end end end end end # end sid.rb I wasn't sure if SID.new should refer to an existing account, or actually create a new SID via InitializeSid() or something. My current idea is to setup a SID.create method for actually creating a new SID. Does that seem reasonable? Or does that seem counterintuitive? Anyway, there you go. Please let me know what you think. 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 Mon Jul 7 22:59:32 2008 From: phasis at gmail.com (Heesob Park) Date: Tue, 8 Jul 2008 11:59:32 +0900 Subject: [Win32utils-devel] User sid In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> References: <4864CC87.30406@gmail.com> <97391697688B44DBAF84C3196CE3D590@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/7/8 Berger, Daniel : > Hi everyone, I'm back from vacation. > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Sunday, June 29, 2008 3:38 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] User sid > > > >> 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 : > > > > Excellent, thanks! > > I think what I'll do is add this to win32-file 0.5.6, and just make > these methods private for now. > > My ultimate plan, however, is to separate the security related functions > into a separate win32-security library, modelled after Perl's > Win32::Security module, which you can find at > http://search.cpan.org/~teverett/Win32-Security-0.50/, and/or Python's > win32security library. I have some non-working skeleton code for > win32-security in CVS, but I need to think about the interface more > before publishing it. > > I may have brought this up before, but I can't remember now. > > Anyay, once we publish win32-security, we'll make it a requirement for > win32-file (among others) and use its interface instead of a bunch of > internal, private methods in order to keep the code base a bit more > maintainable and easier to read. > > The next major upgrade I have planned is to make our libraries more > Unicode friendly, which means lots of manual string handling via > multi_to_wide and so forth. The example that inspired me was > http://tinyurl.com/6e473w. > I can't find any example :) > Sound like a plan? > Please let me know your idea about unicode handling. Regards, Park Heesob From phasis at gmail.com Mon Jul 7 23:05:25 2008 From: phasis at gmail.com (Heesob Park) Date: Tue, 8 Jul 2008 12:05:25 +0900 Subject: [Win32utils-devel] win32-security rough idea In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3375@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D3375@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: 2008/7/8 Berger, Daniel : > Hi all, > > How does this look? > > require 'win32/security' > include Win32 > > s = Security::SID.new('djberge') > > # @domain="mydomain", > @host="myhost", > @sid="\001\005\000...", > @account_type="user", > @account="djberge" >> > > s.length => 28 > s.account => 'djberge' > s.domain => 'mydomain' > s.sid => '\001...' > s.account_type => 'user' > s.to_s => S-1-5-21-55555-444444-88-118888-999999 > s.valid? => true > s == s => true > It looks good. > Here's the implementation so far (more comments at end): > > I wasn't sure if SID.new should refer to an existing account, or > actually create a new SID via InitializeSid() or something. My current > idea is to setup a SID.create method for actually creating a new SID. > Does that seem reasonable? Or does that seem counterintuitive? > > Anyway, there you go. Please let me know what you think. > That seems reasonable. Go ahead please. Regards, Park Heesob From djberg96 at gmail.com Mon Jul 7 23:42:41 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 7 Jul 2008 21:42:41 -0600 Subject: [Win32utils-devel] User sid In-Reply-To: References: <4864CC87.30406@gmail.com> <97391697688B44DBAF84C3196CE3D590@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <6037b70c0807072042t67dce16fw9feffe51ff8dd80e@mail.gmail.com> On Mon, Jul 7, 2008 at 8:59 PM, Heesob Park wrote: > Hi, >> >> The next major upgrade I have planned is to make our libraries more >> Unicode friendly, which means lots of manual string handling via >> multi_to_wide and so forth. The example that inspired me was >> http://tinyurl.com/6e473w. >> > I can't find any example :) > >> Sound like a plan? >> > Please let me know your idea about unicode handling. File.size("C:\\Documents and Settings\\Art?ras") was the example. Although, come to think of it, maybe all we need to do is alter win32-file-stat so that it uses wstat64() + multi_to_wide, and that would probably solve a good number of the File class methods. Regards, Dan From djberg96 at gmail.com Mon Jul 7 23:51:21 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 7 Jul 2008 21:51:21 -0600 Subject: [Win32utils-devel] win32-security rough idea In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D3375@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <6037b70c0807072051p44ef4149ke3893498ec9bb842@mail.gmail.com> Hi, On Mon, Jul 7, 2008 at 9:05 PM, Heesob Park wrote: > 2008/7/8 Berger, Daniel : >> Hi all, >> >> How does this look? >> >> require 'win32/security' >> include Win32 >> >> s = Security::SID.new('djberge') >> >> #> @domain="mydomain", >> @host="myhost", >> @sid="\001\005\000...", >> @account_type="user", >> @account="djberge" >>> >> >> s.length => 28 >> s.account => 'djberge' >> s.domain => 'mydomain' >> s.sid => '\001...' >> s.account_type => 'user' >> s.to_s => S-1-5-21-55555-444444-88-118888-999999 >> s.valid? => true >> s == s => true >> > It looks good. > >> Here's the implementation so far (more comments at end): >> > >> I wasn't sure if SID.new should refer to an existing account, or >> actually create a new SID via InitializeSid() or something. My current >> idea is to setup a SID.create method for actually creating a new SID. >> Does that seem reasonable? Or does that seem counterintuitive? >> >> Anyway, there you go. Please let me know what you think. >> > That seems reasonable. Go ahead please. Ok, I've committed what I've got so far to CVS. :) Thanks, Dan From djberg96 at gmail.com Tue Jul 8 00:38:04 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 7 Jul 2008 22:38:04 -0600 Subject: [Win32utils-devel] User sid In-Reply-To: <6037b70c0807072042t67dce16fw9feffe51ff8dd80e@mail.gmail.com> References: <4864CC87.30406@gmail.com> <97391697688B44DBAF84C3196CE3D590@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3363@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D3365@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB023D336F@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807072042t67dce16fw9feffe51ff8dd80e@mail.gmail.com> Message-ID: <6037b70c0807072138y4f32393fsccb0db0ff06325c8@mail.gmail.com> 2008/7/7 Daniel Berger : > On Mon, Jul 7, 2008 at 8:59 PM, Heesob Park wrote: >> Hi, > > > >>> >>> The next major upgrade I have planned is to make our libraries more >>> Unicode friendly, which means lots of manual string handling via >>> multi_to_wide and so forth. The example that inspired me was >>> http://tinyurl.com/6e473w. >>> >> I can't find any example :) >> >>> Sound like a plan? >>> >> Please let me know your idea about unicode handling. > > File.size("C:\\Documents and Settings\\Art?ras") was the example. > > Although, come to think of it, maybe all we need to do is alter > win32-file-stat so that it uses wstat64() + multi_to_wide, and that > would probably solve a good number of the File class methods. Well, I tried this patch, but I'm still getting 3 test errors, but I'm having trouble nailing them down. The error indicates that get_file_type is failing, but I don't know why. ### Eclipse Workspace Patch 1.0 #P win32-file-stat Index: lib/win32/file/stat.rb =================================================================== RCS file: /var/cvs/win32utils/win32-file-stat/lib/win32/file/stat.rb,v retrieving revision 1.29 diff -u -r1.29 stat.rb --- lib/win32/file/stat.rb 2 Oct 2007 04:29:56 -0000 1.29 +++ lib/win32/file/stat.rb 8 Jul 2008 04:37:07 -0000 @@ -7,6 +7,7 @@ require 'windows/error' require 'windows/handle' require 'windows/volume' +require 'windows/unicode' require 'pp' class File::Stat @@ -19,9 +20,10 @@ include Windows::Error include Windows::Handle include Windows::Volume + include Windows::Unicode include Comparable - VERSION = '1.2.7' + VERSION = '1.2.8' # Defined in Ruby's win32.h. Not meant for public consumption. S_IWGRP = 0020 @@ -48,12 +50,13 @@ # the file after that point will not be reflected. # def initialize(file) - @file = file + @file = multi_to_wide(file, CP_UTF8) + @file = "\\\\?\\" + file unless PathIsRelativeW(@file) - @file_type = get_file_type(file) + @file_type = get_file_type(@file) @chardev = @file_type == FILE_TYPE_CHAR - case GetDriveType(file) + case GetDriveTypeW(@file) when DRIVE_REMOVABLE, DRIVE_CDROM, DRIVE_RAMDISK @blockdev = true else @@ -63,7 +66,7 @@ stat_buf = [0,0,0,0,0,0,0,0,0,0,0,0,0].pack('ISSssssIIQQQQ') # The stat64 function doesn't seem to like character devices - if stat64(file, stat_buf) != 0 + if wstat64(@file, stat_buf) != 0 raise ArgumentError, get_last_error unless @chardev end @@ -91,17 +94,17 @@ @mode = 33188 if @chardev - attr = GetFileAttributes(file) + attributes = GetFileAttributesW(@file) error_num = GetLastError() # Ignore errors caused by empty/open/used block devices. - if attr == INVALID_FILE_ATTRIBUTES + if attributes == INVALID_FILE_ATTRIBUTES unless error_num == ERROR_NOT_READY raise ArgumentError, get_last_error(error_num) end end - @blksize = get_blksize(file) + @blksize = get_blksize(@file) # This is a reasonable guess case @blksize @@ -113,19 +116,19 @@ @blocks = (@size.to_f / @blksize.to_f).ceil end - @readonly = attr & FILE_ATTRIBUTE_READONLY > 0 - @hidden = attr & FILE_ATTRIBUTE_HIDDEN > 0 - @system = attr & FILE_ATTRIBUTE_SYSTEM > 0 - @archive = attr & FILE_ATTRIBUTE_ARCHIVE > 0 - @directory = attr & FILE_ATTRIBUTE_DIRECTORY > 0 - @encrypted = attr & FILE_ATTRIBUTE_ENCRYPTED > 0 - @normal = attr & FILE_ATTRIBUTE_NORMAL > 0 - @temporary = attr & FILE_ATTRIBUTE_TEMPORARY > 0 - @sparse = attr & FILE_ATTRIBUTE_SPARSE_FILE > 0 - @reparse_point = attr & FILE_ATTRIBUTE_REPARSE_POINT > 0 - @compressed = attr & FILE_ATTRIBUTE_COMPRESSED > 0 - @offline = attr & FILE_ATTRIBUTE_OFFLINE > 0 - @indexed = attr & ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED > 0 + @readonly = attributes & FILE_ATTRIBUTE_READONLY > 0 + @hidden = attributes & FILE_ATTRIBUTE_HIDDEN > 0 + @system = attributes & FILE_ATTRIBUTE_SYSTEM > 0 + @archive = attributes & FILE_ATTRIBUTE_ARCHIVE > 0 + @directory = attributes & FILE_ATTRIBUTE_DIRECTORY > 0 + @encrypted = attributes & FILE_ATTRIBUTE_ENCRYPTED > 0 + @normal = attributes & FILE_ATTRIBUTE_NORMAL > 0 + @temporary = attributes & FILE_ATTRIBUTE_TEMPORARY > 0 + @sparse = attributes & FILE_ATTRIBUTE_SPARSE_FILE > 0 + @reparse_point = attributes & FILE_ATTRIBUTE_REPARSE_POINT > 0 + @compressed = attributes & FILE_ATTRIBUTE_COMPRESSED > 0 + @offline = attributes & FILE_ATTRIBUTE_OFFLINE > 0 + @indexed = attributes & ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED > 0 @executable = GetBinaryType(file, '') @regular = @file_type == FILE_TYPE_DISK @@ -536,17 +539,19 @@ free = [0].pack('L') total = [0].pack('L') + p file + # If there's a drive letter it must contain a trailing backslash. # The dup is necessary here because, for some odd reason, the function # appears to modify the argument passed in. - if PathStripToRoot(file.dup) + if PathStripToRootW(file.dup) file += "\\" unless file[-1].chr == "\\" else file = 0 # Default to root drive end # Don't check for an error here. Just default to nil. - if GetDiskFreeSpace(file, sectors, bytes, free, total) + if GetDiskFreeSpaceW(file, sectors, bytes, free, total) size = sectors.unpack('L').first * bytes.unpack('L').first end @@ -555,8 +560,8 @@ # Returns the file's type (as a numeric). # - def get_file_type(file) - handle = CreateFile( + def get_file_type(file) + handle = CreateFileW( file, 0, 0, Suggestions? Or is there a problem with the test suite itself perhaps? Regards, Dan From Daniel.Berger at qwest.com Tue Jul 8 15:38:00 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 8 Jul 2008 14:38:00 -0500 Subject: [Win32utils-devel] Some more win32-security: SID.create Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> Hi all, How does this look as a general approach to a SID.create method: # Creates and initializes def self.create(authority, *sub_authorities) if sub_authorities.length > 8 raise ArgumentError, 'maximum of 8 subauthorities allowed' end authorities = Array.new(8, 0) authorities.replace(sub_authorities) count = authorities.select{ |e| e > 0 }.size if count == 0 # Use InitializeSid() else # Use AllocateAndInitializeSid() end end Any help actually implementing this method would also be greatly appreciated, as my attempts were not working out so well. 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 Tue Jul 8 23:12:47 2008 From: phasis at gmail.com (Heesob Park) Date: Wed, 9 Jul 2008 12:12:47 +0900 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/7/9 Berger, Daniel : > Hi all, > > How does this look as a general approach to a SID.create method: > > # Creates and initializes > def self.create(authority, *sub_authorities) > if sub_authorities.length > 8 > raise ArgumentError, 'maximum of 8 subauthorities allowed' > end > > authorities = Array.new(8, 0) > authorities.replace(sub_authorities) > count = authorities.select{ |e| e > 0 }.size > > if count == 0 > # Use InitializeSid() > else > # Use AllocateAndInitializeSid() > end > end > > Any help actually implementing this method would also be greatly > appreciated, as my attempts were not working out so well. > Here is an working code: def self.create(authority, *sub_authorities) if sub_authorities.length > 8 raise ArgumentError, "maximum of 8 subauthorities allowed" end sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) if [0,1,2,3,5].include?(authority) auth = 0.chr * 5 + authority.chr bool = InitializeSid(sid, auth, sub_authorities.length+1) unless bool raise Error, get_last_error end sub_authorities.each_index do |i| value = [sub_authorities[i]].pack('L') auth_ptr = GetSidSubAuthority(sid, i) memcpy(auth_ptr,value,4) end end sid end Above code works with GetSidSubAuthority definition like this: API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') Regards, Park Heesob From djberg96 at gmail.com Wed Jul 9 00:11:59 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 8 Jul 2008 22:11:59 -0600 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> On Tue, Jul 8, 2008 at 9:12 PM, Heesob Park wrote: > Hi, > > 2008/7/9 Berger, Daniel : >> Hi all, >> >> How does this look as a general approach to a SID.create method: >> >> # Creates and initializes >> def self.create(authority, *sub_authorities) >> if sub_authorities.length > 8 >> raise ArgumentError, 'maximum of 8 subauthorities allowed' >> end >> >> authorities = Array.new(8, 0) >> authorities.replace(sub_authorities) >> count = authorities.select{ |e| e > 0 }.size >> >> if count == 0 >> # Use InitializeSid() >> else >> # Use AllocateAndInitializeSid() >> end >> end >> >> Any help actually implementing this method would also be greatly >> appreciated, as my attempts were not working out so well. >> > Here is an working code: > > def self.create(authority, *sub_authorities) > > if sub_authorities.length > 8 > raise ArgumentError, "maximum of 8 subauthorities allowed" > end > > sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) > > if [0,1,2,3,5].include?(authority) > auth = 0.chr * 5 + authority.chr > bool = InitializeSid(sid, auth, sub_authorities.length+1) > unless bool > raise Error, get_last_error > end > sub_authorities.each_index do |i| > value = [sub_authorities[i]].pack('L') > auth_ptr = GetSidSubAuthority(sid, i) > memcpy(auth_ptr,value,4) > end > end > sid > end > > > Above code works with GetSidSubAuthority definition like this: > API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') Excellent, thanks. I've modified GetSidSubAuthority() as you suggest, and made a few other functions that I had previously returning pointers return longs instead - easier to deal with. Your code gave me an idea, too. What do you think of modifying SID.new so that it accepts either an account name or a sid? Behind the scenes it just calls LookupAccountSid or LookupAccountName, depending on the content of the first argument. That would allow SID.create to return a full SID object. Here's a proposed implementation: def self.create(authority, *sub_authorities) # Code same as before except for the return value return self.new(sid) end def initialize(account, host=Socket.gethostname) sid = 0.chr * 28 sid_cb = [sid.size].pack('L') domain_buf = 0.chr * 80 domain_cch = [domain_buf.size].pack('L') sid_name_use = 0.chr * 4 # If the account includes non-alpha characters, assume it's a SID. if account =~ /\W+/ # Unicode concerns? bool = LookupAccountSid( host, [account].pack('p*').unpack('L')[0], sid, sid_cb, domain_buf, domain_cch, sid_name_use ) @sid = account @name = sid.strip else bool = LookupAccountName( host, account, sid, sid_cb, domain_buf, domain_cch, sid_name_use ) @sid = sid.strip @account = account end unless bool raise Error, get_last_error end @host = host @domain = domain_buf.strip @account_type = get_account_type(sid_name_use.unpack('L')[0]) sid end How does that look? Regards, Dan From phasis at gmail.com Wed Jul 9 00:35:50 2008 From: phasis at gmail.com (Heesob Park) Date: Wed, 9 Jul 2008 13:35:50 +0900 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> Message-ID: 2008/7/9 Daniel Berger : > On Tue, Jul 8, 2008 at 9:12 PM, Heesob Park wrote: >> Hi, >> >> 2008/7/9 Berger, Daniel : >>> Hi all, >>> >>> How does this look as a general approach to a SID.create method: >>> >>> # Creates and initializes >>> def self.create(authority, *sub_authorities) >>> if sub_authorities.length > 8 >>> raise ArgumentError, 'maximum of 8 subauthorities allowed' >>> end >>> >>> authorities = Array.new(8, 0) >>> authorities.replace(sub_authorities) >>> count = authorities.select{ |e| e > 0 }.size >>> >>> if count == 0 >>> # Use InitializeSid() >>> else >>> # Use AllocateAndInitializeSid() >>> end >>> end >>> >>> Any help actually implementing this method would also be greatly >>> appreciated, as my attempts were not working out so well. >>> >> Here is an working code: >> >> def self.create(authority, *sub_authorities) >> >> if sub_authorities.length > 8 >> raise ArgumentError, "maximum of 8 subauthorities allowed" >> end >> >> sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) >> >> if [0,1,2,3,5].include?(authority) >> auth = 0.chr * 5 + authority.chr >> bool = InitializeSid(sid, auth, sub_authorities.length+1) >> unless bool >> raise Error, get_last_error >> end >> sub_authorities.each_index do |i| >> value = [sub_authorities[i]].pack('L') >> auth_ptr = GetSidSubAuthority(sid, i) >> memcpy(auth_ptr,value,4) >> end >> end >> sid >> end >> >> >> Above code works with GetSidSubAuthority definition like this: >> API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') > > Excellent, thanks. I've modified GetSidSubAuthority() as you suggest, > and made a few other functions that I had previously returning > pointers return longs instead - easier to deal with. > > Your code gave me an idea, too. What do you think of modifying SID.new > so that it accepts either an account name or a sid? Behind the scenes > it just calls LookupAccountSid or LookupAccountName, depending on the > content of the first argument. That would allow SID.create to return a > full SID object. > > Here's a proposed implementation: > > def self.create(authority, *sub_authorities) > # Code same as before except for the return value > return self.new(sid) > end > > def initialize(account, host=Socket.gethostname) > sid = 0.chr * 28 > sid_cb = [sid.size].pack('L') > > domain_buf = 0.chr * 80 > domain_cch = [domain_buf.size].pack('L') > > sid_name_use = 0.chr * 4 > > # If the account includes non-alpha characters, assume it's a SID. > if account =~ /\W+/ # Unicode concerns? > bool = LookupAccountSid( > host, > [account].pack('p*').unpack('L')[0], > sid, > sid_cb, > domain_buf, > domain_cch, > sid_name_use > ) > > @sid = account > @name = sid.strip > else > bool = LookupAccountName( > host, > account, > sid, > sid_cb, > domain_buf, > domain_cch, > sid_name_use > ) > > @sid = sid.strip > @account = account > end > > unless bool > raise Error, get_last_error > end > > @host = host > @domain = domain_buf.strip > > @account_type = get_account_type(sid_name_use.unpack('L')[0]) > > sid > end > > How does that look? > That looks good. I think the SID detection code if account =~ /\W+/ can be something like if account[0] < 10 Regards, Park Heesob From djberg96 at gmail.com Wed Jul 9 09:13:20 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 9 Jul 2008 07:13:20 -0600 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> Message-ID: <6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com> On Tue, Jul 8, 2008 at 10:35 PM, Heesob Park wrote: > 2008/7/9 Daniel Berger : >> On Tue, Jul 8, 2008 at 9:12 PM, Heesob Park wrote: >>> Hi, >>> >>> 2008/7/9 Berger, Daniel : >>>> Hi all, >>>> >>>> How does this look as a general approach to a SID.create method: >>>> >>>> # Creates and initializes >>>> def self.create(authority, *sub_authorities) >>>> if sub_authorities.length > 8 >>>> raise ArgumentError, 'maximum of 8 subauthorities allowed' >>>> end >>>> >>>> authorities = Array.new(8, 0) >>>> authorities.replace(sub_authorities) >>>> count = authorities.select{ |e| e > 0 }.size >>>> >>>> if count == 0 >>>> # Use InitializeSid() >>>> else >>>> # Use AllocateAndInitializeSid() >>>> end >>>> end >>>> >>>> Any help actually implementing this method would also be greatly >>>> appreciated, as my attempts were not working out so well. >>>> >>> Here is an working code: >>> >>> def self.create(authority, *sub_authorities) >>> >>> if sub_authorities.length > 8 >>> raise ArgumentError, "maximum of 8 subauthorities allowed" >>> end >>> >>> sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) >>> >>> if [0,1,2,3,5].include?(authority) >>> auth = 0.chr * 5 + authority.chr >>> bool = InitializeSid(sid, auth, sub_authorities.length+1) >>> unless bool >>> raise Error, get_last_error >>> end >>> sub_authorities.each_index do |i| >>> value = [sub_authorities[i]].pack('L') >>> auth_ptr = GetSidSubAuthority(sid, i) >>> memcpy(auth_ptr,value,4) >>> end >>> end >>> sid >>> end >>> >>> >>> Above code works with GetSidSubAuthority definition like this: >>> API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') >> >> Excellent, thanks. I've modified GetSidSubAuthority() as you suggest, >> and made a few other functions that I had previously returning >> pointers return longs instead - easier to deal with. >> >> Your code gave me an idea, too. What do you think of modifying SID.new >> so that it accepts either an account name or a sid? Behind the scenes >> it just calls LookupAccountSid or LookupAccountName, depending on the >> content of the first argument. That would allow SID.create to return a >> full SID object. >> >> Here's a proposed implementation: >> >> def self.create(authority, *sub_authorities) >> # Code same as before except for the return value >> return self.new(sid) >> end >> >> def initialize(account, host=Socket.gethostname) >> sid = 0.chr * 28 >> sid_cb = [sid.size].pack('L') >> >> domain_buf = 0.chr * 80 >> domain_cch = [domain_buf.size].pack('L') >> >> sid_name_use = 0.chr * 4 >> >> # If the account includes non-alpha characters, assume it's a SID. >> if account =~ /\W+/ # Unicode concerns? >> bool = LookupAccountSid( >> host, >> [account].pack('p*').unpack('L')[0], >> sid, >> sid_cb, >> domain_buf, >> domain_cch, >> sid_name_use >> ) >> >> @sid = account >> @name = sid.strip >> else >> bool = LookupAccountName( >> host, >> account, >> sid, >> sid_cb, >> domain_buf, >> domain_cch, >> sid_name_use >> ) >> >> @sid = sid.strip >> @account = account >> end >> >> unless bool >> raise Error, get_last_error >> end >> >> @host = host >> @domain = domain_buf.strip >> >> @account_type = get_account_type(sid_name_use.unpack('L')[0]) >> >> sid >> end >> >> How does that look? >> > That looks good. > > I think the SID detection code > if account =~ /\W+/ > can be something like > if account[0] < 10 Yes, that will work better, thanks. Also, I wanted to ask about this bit: if [0,1,2,3,5].include?(authority) Why are we excluding SECURITY_NON_UNIQUE_AUTHORITY (4) and SECURITY_RESOURCE_MANAGER_AUTHORITY (9)? Thanks, Dan From phasis at gmail.com Wed Jul 9 09:26:49 2008 From: phasis at gmail.com (Park Heesob) Date: Wed, 9 Jul 2008 22:26:49 +0900 Subject: [Win32utils-devel] Some more win32-security: SID.create References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> <6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com> Message-ID: <3195F0F8697747DDBECAA545ABE27D47@mycomputer> ----- Original Message ----- From: "Daniel Berger" To: "Development and ideas for win32utils projects" Sent: Wednesday, July 09, 2008 10:13 PM Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > On Tue, Jul 8, 2008 at 10:35 PM, Heesob Park wrote: >> 2008/7/9 Daniel Berger : >>> On Tue, Jul 8, 2008 at 9:12 PM, Heesob Park wrote: >>>> Hi, >>>> >>>> 2008/7/9 Berger, Daniel : >>>>> Hi all, >>>>> >>>>> How does this look as a general approach to a SID.create method: >>>>> >>>>> # Creates and initializes >>>>> def self.create(authority, *sub_authorities) >>>>> if sub_authorities.length > 8 >>>>> raise ArgumentError, 'maximum of 8 subauthorities allowed' >>>>> end >>>>> >>>>> authorities = Array.new(8, 0) >>>>> authorities.replace(sub_authorities) >>>>> count = authorities.select{ |e| e > 0 }.size >>>>> >>>>> if count == 0 >>>>> # Use InitializeSid() >>>>> else >>>>> # Use AllocateAndInitializeSid() >>>>> end >>>>> end >>>>> >>>>> Any help actually implementing this method would also be greatly >>>>> appreciated, as my attempts were not working out so well. >>>>> >>>> Here is an working code: >>>> >>>> def self.create(authority, *sub_authorities) >>>> >>>> if sub_authorities.length > 8 >>>> raise ArgumentError, "maximum of 8 subauthorities allowed" >>>> end >>>> >>>> sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) >>>> >>>> if [0,1,2,3,5].include?(authority) >>>> auth = 0.chr * 5 + authority.chr >>>> bool = InitializeSid(sid, auth, sub_authorities.length+1) >>>> unless bool >>>> raise Error, get_last_error >>>> end >>>> sub_authorities.each_index do |i| >>>> value = [sub_authorities[i]].pack('L') >>>> auth_ptr = GetSidSubAuthority(sid, i) >>>> memcpy(auth_ptr,value,4) >>>> end >>>> end >>>> sid >>>> end >>>> >>>> >>>> Above code works with GetSidSubAuthority definition like this: >>>> API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') >>> >>> Excellent, thanks. I've modified GetSidSubAuthority() as you suggest, >>> and made a few other functions that I had previously returning >>> pointers return longs instead - easier to deal with. >>> >>> Your code gave me an idea, too. What do you think of modifying SID.new >>> so that it accepts either an account name or a sid? Behind the scenes >>> it just calls LookupAccountSid or LookupAccountName, depending on the >>> content of the first argument. That would allow SID.create to return a >>> full SID object. >>> > Yes, that will work better, thanks. > > Also, I wanted to ask about this bit: > > if [0,1,2,3,5].include?(authority) > > Why are we excluding SECURITY_NON_UNIQUE_AUTHORITY (4) and > SECURITY_RESOURCE_MANAGER_AUTHORITY (9)? > I have no idea about the excluding values. I just have ported it from the Visual C++ code :) Refer to http://support.microsoft.com/kb/276208/en-us Regards, Park Heesob From Daniel.Berger at qwest.com Wed Jul 9 18:00:15 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 9 Jul 2008 17:00:15 -0500 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: <3195F0F8697747DDBECAA545ABE27D47@mycomputer> References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com><6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com> <3195F0F8697747DDBECAA545ABE27D47@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3380@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, July 09, 2008 7:27 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > > > ----- Original Message ----- > From: "Daniel Berger" > To: "Development and ideas for win32utils projects" > > Sent: Wednesday, July 09, 2008 10:13 PM > Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > > > > On Tue, Jul 8, 2008 at 10:35 PM, Heesob Park > wrote: > >> 2008/7/9 Daniel Berger : > >>> On Tue, Jul 8, 2008 at 9:12 PM, Heesob Park > wrote: > >>>> Hi, > >>>> > >>>> 2008/7/9 Berger, Daniel : > >>>>> Hi all, > >>>>> > >>>>> How does this look as a general approach to a SID.create method: > >>>>> > >>>>> # Creates and initializes > >>>>> def self.create(authority, *sub_authorities) > >>>>> if sub_authorities.length > 8 > >>>>> raise ArgumentError, 'maximum of 8 subauthorities allowed' > >>>>> end > >>>>> > >>>>> authorities = Array.new(8, 0) > >>>>> authorities.replace(sub_authorities) > >>>>> count = authorities.select{ |e| e > 0 }.size > >>>>> > >>>>> if count == 0 > >>>>> # Use InitializeSid() > >>>>> else > >>>>> # Use AllocateAndInitializeSid() > >>>>> end > >>>>> end > >>>>> > >>>>> Any help actually implementing this method would also be greatly > >>>>> appreciated, as my attempts were not working out so well. > >>>>> > >>>> Here is an working code: > >>>> > >>>> def self.create(authority, *sub_authorities) > >>>> > >>>> if sub_authorities.length > 8 > >>>> raise ArgumentError, "maximum of 8 subauthorities allowed" > >>>> end > >>>> > >>>> sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) > >>>> > >>>> if [0,1,2,3,5].include?(authority) > >>>> auth = 0.chr * 5 + authority.chr > >>>> bool = InitializeSid(sid, auth, sub_authorities.length+1) > >>>> unless bool > >>>> raise Error, get_last_error > >>>> end > >>>> sub_authorities.each_index do |i| > >>>> value = [sub_authorities[i]].pack('L') > >>>> auth_ptr = GetSidSubAuthority(sid, i) > >>>> memcpy(auth_ptr,value,4) > >>>> end > >>>> end > >>>> sid > >>>> end > >>>> > >>>> > >>>> Above code works with GetSidSubAuthority definition like this: > >>>> API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') > >>> > >>> Excellent, thanks. I've modified GetSidSubAuthority() as > you suggest, > >>> and made a few other functions that I had previously returning > >>> pointers return longs instead - easier to deal with. > >>> > >>> Your code gave me an idea, too. What do you think of > modifying SID.new > >>> so that it accepts either an account name or a sid? > Behind the scenes > >>> it just calls LookupAccountSid or LookupAccountName, > depending on the > >>> content of the first argument. That would allow > SID.create to return a > >>> full SID object. > >>> > > > > Yes, that will work better, thanks. > > > > Also, I wanted to ask about this bit: > > > > if [0,1,2,3,5].include?(authority) > > > > Why are we excluding SECURITY_NON_UNIQUE_AUTHORITY (4) and > > SECURITY_RESOURCE_MANAGER_AUTHORITY (9)? > > > I have no idea about the excluding values. > I just have ported it from the Visual C++ code :) > Refer to http://support.microsoft.com/kb/276208/en-us Ok, but something's not right, because this bit of code doesn't seem to do anything: sub_authorities.each_index do |i| value = [sub_authorities[i]].pack('L') auth_ptr = GetSidSubAuthority(sid, i) memcpy(auth_ptr, value, 4) end I think part of the problem is that I changed the return type of GetSidSubAuthority to a long. But, regardless, I don't understand what that's supposed to do. I took a stab at trying to create a SID with a sub-authority with the following code, but it didn't seem to work. Any ideas? def self.create(authority, *sub_authorities) if sub_authorities.length > 8 raise ArgumentError, "maximum of 8 subauthorities allowed" end sid = 0.chr * GetSidLengthRequired(sub_authorities.length + 1) auth = 0.chr * 5 + authority.chr if sub_authorities.length == 0 unless InitializeSid(sid, auth, 1) raise Error, get_last_error end else array = Array.new(8, 0) array.replace(sub_authorities) bool = AllocateAndInitializeSid( auth, sub_authorities.select{ |e| e > 0 }.size, array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], sid ) unless bool raise Error, get_last_error end end self.new(sid) end 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 Jul 9 21:12:42 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 10 Jul 2008 10:12:42 +0900 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> <6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com> <3195F0F8697747DDBECAA545ABE27D47@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: 2008/7/10 Berger, Daniel : > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Wednesday, July 09, 2008 7:27 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Some more win32-security: SID.create >> >> >> ----- Original Message ----- >> From: "Daniel Berger" >> To: "Development and ideas for win32utils projects" >> >> Sent: Wednesday, July 09, 2008 10:13 PM >> Subject: Re: [Win32utils-devel] Some more win32-security: SID.create >> >> >> > On Tue, Jul 8, 2008 at 10:35 PM, Heesob Park >> wrote: >> >> 2008/7/9 Daniel Berger : >> >>> On Tue, Jul 8, 2008 at 9:12 PM, Heesob Park >> wrote: >> >>>> Hi, >> >>>> >> >>>> 2008/7/9 Berger, Daniel : >> >>>>> Hi all, >> >>>>> >> >>>>> How does this look as a general approach to a SID.create method: >> >>>>> >> >>>>> # Creates and initializes >> >>>>> def self.create(authority, *sub_authorities) >> >>>>> if sub_authorities.length > 8 >> >>>>> raise ArgumentError, 'maximum of 8 subauthorities allowed' >> >>>>> end >> >>>>> >> >>>>> authorities = Array.new(8, 0) >> >>>>> authorities.replace(sub_authorities) >> >>>>> count = authorities.select{ |e| e > 0 }.size >> >>>>> >> >>>>> if count == 0 >> >>>>> # Use InitializeSid() >> >>>>> else >> >>>>> # Use AllocateAndInitializeSid() >> >>>>> end >> >>>>> end >> >>>>> >> >>>>> Any help actually implementing this method would also be greatly >> >>>>> appreciated, as my attempts were not working out so well. >> >>>>> >> >>>> Here is an working code: >> >>>> >> >>>> def self.create(authority, *sub_authorities) >> >>>> >> >>>> if sub_authorities.length > 8 >> >>>> raise ArgumentError, "maximum of 8 subauthorities allowed" >> >>>> end >> >>>> >> >>>> sid = 0.chr * GetSidLengthRequired(sub_authorities.length+1) >> >>>> >> >>>> if [0,1,2,3,5].include?(authority) >> >>>> auth = 0.chr * 5 + authority.chr >> >>>> bool = InitializeSid(sid, auth, sub_authorities.length+1) >> >>>> unless bool >> >>>> raise Error, get_last_error >> >>>> end >> >>>> sub_authorities.each_index do |i| >> >>>> value = [sub_authorities[i]].pack('L') >> >>>> auth_ptr = GetSidSubAuthority(sid, i) >> >>>> memcpy(auth_ptr,value,4) >> >>>> end >> >>>> end >> >>>> sid >> >>>> end >> >>>> >> >>>> >> >>>> Above code works with GetSidSubAuthority definition like this: >> >>>> API.new('GetSidSubAuthority', 'PL', 'L', 'advapi32') >> >>> >> >>> Excellent, thanks. I've modified GetSidSubAuthority() as >> you suggest, >> >>> and made a few other functions that I had previously returning >> >>> pointers return longs instead - easier to deal with. >> >>> >> >>> Your code gave me an idea, too. What do you think of >> modifying SID.new >> >>> so that it accepts either an account name or a sid? >> Behind the scenes >> >>> it just calls LookupAccountSid or LookupAccountName, >> depending on the >> >>> content of the first argument. That would allow >> SID.create to return a >> >>> full SID object. >> >>> >> >> >> > Yes, that will work better, thanks. >> > >> > Also, I wanted to ask about this bit: >> > >> > if [0,1,2,3,5].include?(authority) >> > >> > Why are we excluding SECURITY_NON_UNIQUE_AUTHORITY (4) and >> > SECURITY_RESOURCE_MANAGER_AUTHORITY (9)? >> > >> I have no idea about the excluding values. >> I just have ported it from the Visual C++ code :) >> Refer to http://support.microsoft.com/kb/276208/en-us > > Ok, but something's not right, because this bit of code doesn't seem to > do anything: > > sub_authorities.each_index do |i| > value = [sub_authorities[i]].pack('L') > auth_ptr = GetSidSubAuthority(sid, i) > memcpy(auth_ptr, value, 4) > end > > I think part of the problem is that I changed the return type of > GetSidSubAuthority to a long. But, regardless, I don't understand what > that's supposed to do. > That is just ruby version of the following code: long j; for( j = 2; j <= lcAuths+1; j++) { DWORD dwValue = (DWORD)atol(pAuths[j]); PDWORD pdwSubAuth = GetSidSubAuthority( pLocalSid, (j-2)); *pdwSubAuth = dwValue; } Why do you think that did nothing? Regards, Park Heesob From djberg96 at gmail.com Thu Jul 10 23:55:08 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 10 Jul 2008 21:55:08 -0600 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> <6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com> <3195F0F8697747DDBECAA545ABE27D47@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <6037b70c0807102055w4d284ef3lc297f448cb29ed4a@mail.gmail.com> Hi, > That is just ruby version of the following code: > > long j; > for( j = 2; j <= lcAuths+1; j++) > { > DWORD dwValue = (DWORD)atol(pAuths[j]); > PDWORD pdwSubAuth = GetSidSubAuthority( pLocalSid, (j-2)); > *pdwSubAuth = dwValue; > } > > Why do you think that did nothing? I guess I misread it. Nevermind. :) I did remove the [0,1,2,3,5] loop, though. I do need some help with testing please. I've added some more tests in CVS, but I wasn't sure what a good way was to test SID.create with subauthorities. Any suggestions? Thanks, Dan From phasis at gmail.com Fri Jul 11 00:27:08 2008 From: phasis at gmail.com (Heesob Park) Date: Fri, 11 Jul 2008 13:27:08 +0900 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: <6037b70c0807102055w4d284ef3lc297f448cb29ed4a@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com> <6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com> <3195F0F8697747DDBECAA545ABE27D47@mycomputer> <7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM> <6037b70c0807102055w4d284ef3lc297f448cb29ed4a@mail.gmail.com> Message-ID: Hi, 2008/7/11 Daniel Berger : > Hi, > > > >> That is just ruby version of the following code: >> >> long j; >> for( j = 2; j <= lcAuths+1; j++) >> { >> DWORD dwValue = (DWORD)atol(pAuths[j]); >> PDWORD pdwSubAuth = GetSidSubAuthority( pLocalSid, (j-2)); >> *pdwSubAuth = dwValue; >> } >> >> Why do you think that did nothing? > > I guess I misread it. Nevermind. :) > > I did remove the [0,1,2,3,5] loop, though. > > I do need some help with testing please. I've added some more tests in > CVS, but I wasn't sure what a good way was to test SID.create with > subauthorities. Any suggestions? > I guess SID.create test with Well-known SIDs is possible. Refer to http://msdn.microsoft.com/en-us/library/aa379649(VS.85).aspx Regards, Park Heesob From Daniel.Berger at qwest.com Fri Jul 11 09:35:24 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Fri, 11 Jul 2008 08:35:24 -0500 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com><6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com><3195F0F8697747DDBECAA545ABE27D47@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807102055w4d284ef3lc297f448cb29ed4a@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3389@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: Thursday, July 10, 2008 10:27 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > > Hi, > > 2008/7/11 Daniel Berger : > > Hi, > > > > > > > >> That is just ruby version of the following code: > >> > >> long j; > >> for( j = 2; j <= lcAuths+1; j++) > >> { > >> DWORD dwValue = (DWORD)atol(pAuths[j]); > >> PDWORD pdwSubAuth = GetSidSubAuthority( > pLocalSid, (j-2)); > >> *pdwSubAuth = dwValue; > >> } > >> > >> Why do you think that did nothing? > > > > I guess I misread it. Nevermind. :) > > > > I did remove the [0,1,2,3,5] loop, though. > > > > I do need some help with testing please. I've added some > more tests in > > CVS, but I wasn't sure what a good way was to test SID.create with > > subauthorities. Any suggestions? > > > I guess SID.create test with Well-known SIDs is possible. > Refer to http://msdn.microsoft.com/en-us/library/aa379649(VS.85).aspx After adding some RID constants to Windows::Security (now in CVS) I tried this: include Win32 s = Security::SID.create( Security::SID::SECURITY_WORLD_SID_AUTHORITY, Security::SID::SECURITY_WORLD_RID ) p s But I get: C:\Documents and Settings\djberge\workspace\win32-security\lib\win32\security>ruby sid.rb sid.rb:151:in `initialize': No mapping between account names and security IDs was done. (Win32::Security::SID: :Error) from sid.rb:89:in `new' from sid.rb:89:in `create' from sid.rb:231 I suspect I don't understand the Windows security model as well as I should. Perhaps I should order this book: "Programming Windows Security" http://www.bookpool.com/sm/0201604426 It's a bit dated, but probably has everything I need. Does anyone have any opinion on this book? 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 Fri Jul 11 11:19:47 2008 From: phasis at gmail.com (Park Heesob) Date: Sat, 12 Jul 2008 00:19:47 +0900 Subject: [Win32utils-devel] Some more win32-security: SID.create References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com><6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com><3195F0F8697747DDBECAA545ABE27D47@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807102055w4d284ef3lc297f448cb29ed4a@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D3389@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <77ED34C40D424660BBE87E656830633F@mycomputer> Hi, ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Friday, July 11, 2008 10:35 PM Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Heesob Park >> Sent: Thursday, July 10, 2008 10:27 PM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Some more win32-security: SID.create >> >> Hi, >> >> 2008/7/11 Daniel Berger : >> > Hi, >> > >> > >> > >> >> That is just ruby version of the following code: >> >> >> >> long j; >> >> for( j = 2; j <= lcAuths+1; j++) >> >> { >> >> DWORD dwValue = (DWORD)atol(pAuths[j]); >> >> PDWORD pdwSubAuth = GetSidSubAuthority( >> pLocalSid, (j-2)); >> >> *pdwSubAuth = dwValue; >> >> } >> >> >> >> Why do you think that did nothing? >> > >> > I guess I misread it. Nevermind. :) >> > >> > I did remove the [0,1,2,3,5] loop, though. >> > >> > I do need some help with testing please. I've added some >> more tests in >> > CVS, but I wasn't sure what a good way was to test SID.create with >> > subauthorities. Any suggestions? >> > >> I guess SID.create test with Well-known SIDs is possible. >> Refer to http://msdn.microsoft.com/en-us/library/aa379649(VS.85).aspx > > After adding some RID constants to Windows::Security (now in CVS) I > tried this: > > include Win32 > > s = Security::SID.create( > Security::SID::SECURITY_WORLD_SID_AUTHORITY, > Security::SID::SECURITY_WORLD_RID > ) > > p s > > But I get: > > C:\Documents and > Settings\djberge\workspace\win32-security\lib\win32\security>ruby sid.rb > sid.rb:151:in `initialize': No mapping between account names and > security IDs was done. (Win32::Security::SID: > :Error) > from sid.rb:89:in `new' > from sid.rb:89:in `create' > from sid.rb:231 > I found the bug. The self.create method should be like this : def self.create(authority, *sub_authorities) if sub_authorities.length > 8 raise ArgumentError, "maximum of 8 subauthorities allowed" end sid = 0.chr * GetSidLengthRequired(sub_authorities.length) auth = 0.chr * 5 + authority.chr unless InitializeSid(sid, auth, sub_authorities.length) raise Error, get_last_error end sub_authorities.each_index do |i| value = [sub_authorities[i]].pack('L') auth_ptr = GetSidSubAuthority(sid, i) memcpy(auth_ptr, value, 4) end self.new(sid) end And here is a test code: sid = 0.chr * 12 sid_size = [12].pack('L') bool = CreateWellKnownSid(WinWorldSid,nil,sid,sid_size) unless bool puts get_last_error end s1 = Security::SID.new(sid) s2 = Security::SID.create( Security::SID::SECURITY_WORLD_SID_AUTHORITY, SECURITY_WORLD_RID ) p s1==s2 > I suspect I don't understand the Windows security model as well as I > should. Perhaps I should order this book: > > "Programming Windows Security" > > http://www.bookpool.com/sm/0201604426 > > It's a bit dated, but probably has everything I need. Does anyone have > any opinion on this book? > No comment :) Regards, Park Heesob From Daniel.Berger at qwest.com Fri Jul 11 13:32:42 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Fri, 11 Jul 2008 12:32:42 -0500 Subject: [Win32utils-devel] Some more win32-security: SID.create In-Reply-To: <77ED34C40D424660BBE87E656830633F@mycomputer> References: <7524A45A1A5B264FA4809E2156496CFB023D337B@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807082111k7f700ae6h565268811688c911@mail.gmail.com><6037b70c0807090613g8d17b4cv45e438d003689fe2@mail.gmail.com><3195F0F8697747DDBECAA545ABE27D47@mycomputer><7524A45A1A5B264FA4809E2156496CFB023D3380@ITOMAE2KM01.AD.QINTRA.COM><6037b70c0807102055w4d284ef3lc297f448cb29ed4a@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB023D3389@ITOMAE2KM01.AD.QINTRA.COM> <77ED34C40D424660BBE87E656830633F@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D338C@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, July 11, 2008 9:20 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > > Hi, > ----- Original Message ----- > From: "Berger, Daniel" > To: "Development and ideas for win32utils projects" > > Sent: Friday, July 11, 2008 10:35 PM > Subject: Re: [Win32utils-devel] Some more win32-security: SID.create > > > > > > > >> -----Original Message----- > >> From: win32utils-devel-bounces at rubyforge.org > >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > >> Heesob Park > >> Sent: Thursday, July 10, 2008 10:27 PM > >> To: Development and ideas for win32utils projects > >> Subject: Re: [Win32utils-devel] Some more win32-security: > SID.create > >> > >> Hi, > >> > >> 2008/7/11 Daniel Berger : > >> > Hi, > >> > > >> > > >> > > >> >> That is just ruby version of the following code: > >> >> > >> >> long j; > >> >> for( j = 2; j <= lcAuths+1; j++) > >> >> { > >> >> DWORD dwValue = (DWORD)atol(pAuths[j]); > >> >> PDWORD pdwSubAuth = GetSidSubAuthority( > >> pLocalSid, (j-2)); > >> >> *pdwSubAuth = dwValue; > >> >> } > >> >> > >> >> Why do you think that did nothing? > >> > > >> > I guess I misread it. Nevermind. :) > >> > > >> > I did remove the [0,1,2,3,5] loop, though. > >> > > >> > I do need some help with testing please. I've added some > >> more tests in > >> > CVS, but I wasn't sure what a good way was to test > SID.create with > >> > subauthorities. Any suggestions? > >> > > >> I guess SID.create test with Well-known SIDs is possible. > >> Refer to > http://msdn.microsoft.com/en-us/library/aa379649(VS.85).aspx > > > > After adding some RID constants to Windows::Security (now in CVS) I > > tried this: > > > > include Win32 > > > > s = Security::SID.create( > > Security::SID::SECURITY_WORLD_SID_AUTHORITY, > > Security::SID::SECURITY_WORLD_RID > > ) > > > > p s > > > > But I get: > > > > C:\Documents and > > > Settings\djberge\workspace\win32-security\lib\win32\security>r > uby sid.rb > > sid.rb:151:in `initialize': No mapping between account names and > > security IDs was done. (Win32::Security::SID: > > :Error) > > from sid.rb:89:in `new' > > from sid.rb:89:in `create' > > from sid.rb:231 > > > I found the bug. > The self.create method should be like this : > > def self.create(authority, *sub_authorities) > if sub_authorities.length > 8 > raise ArgumentError, "maximum of 8 > subauthorities allowed" > end > > sid = 0.chr * GetSidLengthRequired(sub_authorities.length) > > auth = 0.chr * 5 + authority.chr > > unless InitializeSid(sid, auth, sub_authorities.length) > raise Error, get_last_error > end > > sub_authorities.each_index do |i| > value = [sub_authorities[i]].pack('L') > auth_ptr = GetSidSubAuthority(sid, i) > memcpy(auth_ptr, value, 4) > end > > self.new(sid) > end > > And here is a test code: > > sid = 0.chr * 12 > sid_size = [12].pack('L') > bool = CreateWellKnownSid(WinWorldSid,nil,sid,sid_size) > unless bool > puts get_last_error > end > s1 = Security::SID.new(sid) > > s2 = Security::SID.create( > Security::SID::SECURITY_WORLD_SID_AUTHORITY, > SECURITY_WORLD_RID > ) > p s1==s2 Excellent, thanks! Fixed in CVS. > > > I suspect I don't understand the Windows security model as well as I > > should. Perhaps I should order this book: > > > > "Programming Windows Security" > > > > http://www.bookpool.com/sm/0201604426 > > > > It's a bit dated, but probably has everything I need. Does > anyone have > > any opinion on this book? > > > No comment :) I can get a used copy on Amazon for $5, so what the heck. :) 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 Sun Jul 13 08:37:31 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 13 Jul 2008 06:37:31 -0600 Subject: [Win32utils-devel] PathIsURL and frozen strings Message-ID: <4879F70B.9060201@gmail.com> Hi all, I may have brought this up a long time ago, but I've forgotten. Why does PathIsURL(path) fail if 'path' is frozen? require 'windows/path' include Windows::Path path = "file://C:\\Documents and Settings\\djberge" PathIsURL(path) # true path.freeze PathIsURL(path) # Boom! TypeError: can't modify frozen string from (eval):3:in `call' from (eval):3:in `PathIsURL' from (irb):9 Any ideas? I realize I can just dup the string, but I thought I'd ask. Thanks, Dan From phasis at gmail.com Sun Jul 13 09:22:27 2008 From: phasis at gmail.com (Park Heesob) Date: Sun, 13 Jul 2008 22:22:27 +0900 Subject: [Win32utils-devel] PathIsURL and frozen strings References: <4879F70B.9060201@gmail.com> Message-ID: <9A6022BFC76C474485ED8BF7E668D92F@mycomputer> Hi, ----- Original Message ----- From: "Daniel Berger" To: "win32utils-devel" Sent: Sunday, July 13, 2008 9:37 PM Subject: [Win32utils-devel] PathIsURL and frozen strings > Hi all, > > I may have brought this up a long time ago, but I've forgotten. Why does > PathIsURL(path) fail if 'path' is frozen? > > require 'windows/path' > include Windows::Path > > path = "file://C:\\Documents and Settings\\djberge" > PathIsURL(path) # true > > path.freeze > PathIsURL(path) # Boom! > > TypeError: can't modify frozen string > from (eval):3:in `call' > from (eval):3:in `PathIsURL' > from (irb):9 > > Any ideas? I realize I can just dup the string, but I thought I'd ask. > In the win32-api, the string type('P') denotes both input and output pointer parameter. Thus the string parameter can be modified and must not be frozen. In case of pure input string, you can define another parameter type and skip rb_str_modify(v_arg) (line #584 of win32/api.c) Regards, Park Heesob From djberg96 at gmail.com Sun Jul 13 10:32:18 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 13 Jul 2008 08:32:18 -0600 Subject: [Win32utils-devel] PathIsURL and frozen strings In-Reply-To: <9A6022BFC76C474485ED8BF7E668D92F@mycomputer> References: <4879F70B.9060201@gmail.com> <9A6022BFC76C474485ED8BF7E668D92F@mycomputer> Message-ID: <487A11F2.6040602@gmail.com> Park Heesob wrote: > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "win32utils-devel" > Sent: Sunday, July 13, 2008 9:37 PM > Subject: [Win32utils-devel] PathIsURL and frozen strings > > >> Hi all, >> >> I may have brought this up a long time ago, but I've forgotten. Why does >> PathIsURL(path) fail if 'path' is frozen? >> >> require 'windows/path' >> include Windows::Path >> >> path = "file://C:\\Documents and Settings\\djberge" >> PathIsURL(path) # true >> >> path.freeze >> PathIsURL(path) # Boom! >> >> TypeError: can't modify frozen string >> from (eval):3:in `call' >> from (eval):3:in `PathIsURL' >> from (irb):9 >> >> Any ideas? I realize I can just dup the string, but I thought I'd ask. >> > In the win32-api, the string type('P') denotes both input and output pointer > parameter. > Thus the string parameter can be modified and must not be frozen. > In case of pure input string, you can define another parameter type and skip > rb_str_modify(v_arg) (line #584 of win32/api.c) Ah, yes, thanks. I suppose we could add an "S" prototype for pure input strings, but I'm not sure the benefit outweighs the cost of adding yet another prototype. What do you think? Thanks, Dan From noreply at rubyforge.org Mon Jul 7 16:49:05 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 7 Jul 2008 16:49:05 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Support Requests-21110 ] Having problems creating junction on mounted network folder Message-ID: <20080707204905.DA9A918585A3@rubyforge.org> Support Requests item #21110, was opened at 2008-07-07 10:50 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=21110&group_id=85 Category: win32-dir Group: v1.0 (example) Status: Open Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Having problems creating junction on mounted network folder Initial Comment: Hey guys, I'm getting a permission denied error when trying to create a junction on a network folder that I have mounted.. I can stop the code right before the DeviceIoControl call (inside Dir.create_junction) and everything seems good (link has been created as a directory and filehandle is still open).. but then I get a: dir.rb:120:in `create_junction': DeviceIoControl() failed: Access is denied. (RuntimeError) from dir.rb:167 I'm using VERSION = '0.3.2' of dir.rb The code works fine on my local disk, so there is something different about the network permissions.. Do you guys have any advice? Thanks! -Blair BTW: I found that if you switch the order of the closing filehandle and removing directory it will remove the directory (which was going to be a link).. dir.rb: 116 unless bool error = 'DeviceIoControl() failed: ' + get_last_error CloseHandle(handle) RemoveDirectory(to) raise error end ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2008-07-07 13:49 Message: Hi, Hm, I'm not sure right off. Are you able to create a regular folder on the network folder without issue? Thanks, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=21110&group_id=85 From noreply at rubyforge.org Mon Jul 7 16:50:24 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 7 Jul 2008 16:50:24 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Support Requests-19349 ] Where do I find older version of win32-service for mongrel_service 0.3.4 Message-ID: <20080707205025.1C2F315B8002@rubyforge.org> Support Requests item #19349, was opened at 2008-04-07 12:25 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=19349&group_id=85 Category: win32-service Group: None Status: Open Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Where do I find older version of win32-service for mongrel_service 0.3.4 Initial Comment: I am trying to install the gem mongrel_service and it complains that it needs win32-service (>= 0.5.2, < 0.6.0) Where can I DL 0.5.x? I did not see it in CVS or on the web. Using gem -v 1.1.0 ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2008-07-07 13:50 Message: Hi, Is this still an issue? I'm afraid I don't know, but someone on the Mongrel mailing list probably knows. Luis Lavena probably knows as well. Regards, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=19349&group_id=85 From noreply at rubyforge.org Mon Jul 7 16:50:49 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 7 Jul 2008 16:50:49 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Support Requests-19349 ] Where do I find older version of win32-service for mongrel_service 0.3.4 Message-ID: <20080707205049.3A5E318585A7@rubyforge.org> Support Requests item #19349, was opened at 2008-04-07 12:25 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=19349&group_id=85 Category: win32-service Group: None >Status: Closed Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Where do I find older version of win32-service for mongrel_service 0.3.4 Initial Comment: I am trying to install the gem mongrel_service and it complains that it needs win32-service (>= 0.5.2, < 0.6.0) Where can I DL 0.5.x? I did not see it in CVS or on the web. Using gem -v 1.1.0 ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2008-07-07 13:50 Message: Hi, Is this still an issue? I'm afraid I don't know, but someone on the Mongrel mailing list probably knows. Luis Lavena probably knows as well. Regards, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=19349&group_id=85 From noreply at rubyforge.org Mon Jul 7 16:51:14 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 7 Jul 2008 16:51:14 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Support Requests-11344 ] Can't user win32-service inside of a Rails application Message-ID: <20080707205114.9589E18585A3@rubyforge.org> Support Requests item #11344, was opened at 2007-06-04 03:21 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=11344&group_id=85 Category: win32-service Group: None Status: Open Resolution: None Priority: 3 Submitted By: Roberto V. A. (robo) Assigned to: Nobody (None) Summary: Can't user win32-service inside of a Rails application Initial Comment: Hi, I'm trying to get win32-service to work on Rails. When I open up a console and do the following it works: require "win32/service" include Win32 @services = Service.services puts @services.first => => # If I do the same inside a Rails controller like this it dies: gem "win32-service" include Win32 class ServicesController < ApplicationController def index list render :action => "list" end def list # Enumerate over all services, inspecting each struct @services = Service.services end end The Error Message is as follows: NoMethodError in ServicesController#list undefined method `services' for Service:Module I tried to use gem "win32/service" but it is no better. Google didn't help me either. Any Suggestions? Thanks in Advance, Roberto ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2008-07-07 13:51 Message: Any luck with this? Dan ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2008-02-21 18:38 Message: Namespace issue perhaps? Don't include Win32 and try Win32::Service.services explicitly. Does that help? Regards, Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=11344&group_id=85 From noreply at rubyforge.org Fri Jul 18 17:48:17 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 18 Jul 2008 17:48:17 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-21272 ] File.basename bug smoked out by WEBrick, Rails Message-ID: <20080718214817.11F7615F800A@rubyforge.org> Bugs item #21272, was opened at 2008-07-18 14:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 Category: win32-file Group: Code Status: Open Resolution: None Priority: 5 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: File.basename bug smoked out by WEBrick, Rails Initial Comment: It looks like there's a bug in File.basename somewhere: C:\>ruby script\server => Booting WEBrick... => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2008-07-18 15:29:55] INFO WEBrick 1.3.1 [2008-07-18 15:29:55] INFO ruby 1.8.6 (2007-09-24) [i386-mswin32] [2008-07-18 15:29:55] INFO WEBrick::HTTPServer#start: pid=2036 port=3000 c:/ruby/lib/ruby/gems/1.8/gems/win32-file-0.5.4/lib/win32/file.rb:434: [BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. It was hard to track this down because adding print statemetns seemed to alter the behavior, but I did notice something like this: ??d???T??security.so e_support/d Regards, me ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 From noreply at rubyforge.org Fri Jul 18 18:01:44 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 18 Jul 2008 18:01:44 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-21272 ] File.basename bug smoked out by WEBrick, Rails Message-ID: <20080718220144.8E8831858283@rubyforge.org> Bugs item #21272, was opened at 2008-07-18 14:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 Category: win32-file Group: Code Status: Open Resolution: None Priority: 5 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: File.basename bug smoked out by WEBrick, Rails Initial Comment: It looks like there's a bug in File.basename somewhere: C:\>ruby script\server => Booting WEBrick... => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2008-07-18 15:29:55] INFO WEBrick 1.3.1 [2008-07-18 15:29:55] INFO ruby 1.8.6 (2007-09-24) [i386-mswin32] [2008-07-18 15:29:55] INFO WEBrick::HTTPServer#start: pid=2036 port=3000 c:/ruby/lib/ruby/gems/1.8/gems/win32-file-0.5.4/lib/win32/file.rb:434: [BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. It was hard to track this down because adding print statemetns seemed to alter the behavior, but I did notice something like this: ??d???T??security.so e_support/d Regards, me ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2008-07-18 15:01 Message: Quick update - it's line 436 in 0.5.5: file = file.split(0.chr).first ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 From noreply at rubyforge.org Fri Jul 18 18:25:57 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 18 Jul 2008 18:25:57 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-21272 ] File.basename bug smoked out by WEBrick, Rails Message-ID: <20080718222557.5B2AA185859F@rubyforge.org> Bugs item #21272, was opened at 2008-07-18 14:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 Category: win32-file Group: Code Status: Open Resolution: None Priority: 5 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: File.basename bug smoked out by WEBrick, Rails Initial Comment: It looks like there's a bug in File.basename somewhere: C:\>ruby script\server => Booting WEBrick... => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2008-07-18 15:29:55] INFO WEBrick 1.3.1 [2008-07-18 15:29:55] INFO ruby 1.8.6 (2007-09-24) [i386-mswin32] [2008-07-18 15:29:55] INFO WEBrick::HTTPServer#start: pid=2036 port=3000 c:/ruby/lib/ruby/gems/1.8/gems/win32-file-0.5.4/lib/win32/file.rb:434: [BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. It was hard to track this down because adding print statemetns seemed to alter the behavior, but I did notice something like this: ??d???T??security.so e_support/d Regards, me ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2008-07-18 15:25 Message: This error, which I pulled out of the debugger, may be related: c:/ruby/lib/ruby/gems/1.8/gems/win32-file-stat-1.2.7/lib/win32/file/stat.rb:576: `unknown error - T' (SystemCa llError) from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/filters.rb:684:in `process _without_session_management_support' from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/session_management.rb:114: in `process' from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/rescue.rb:18:in `process_w ith_exception' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:46:in `dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:136:in `failsafe_response' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:44:in `dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:113:in `handle_dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:79:in `service' from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' from c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' from c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' from c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' from c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:63:in `dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/servers/webrick.rb:59 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `req uire' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in `new _constants_in' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `req uire' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/server.rb:39 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from script/server:3 c:/ruby/lib/ruby/gems/1.8/gems/win32-file-stat-1.2.7/lib/win32/file/stat.rb:576: raise SystemCallEr ror, get_last_error(error_num) ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2008-07-18 15:01 Message: Quick update - it's line 436 in 0.5.5: file = file.split(0.chr).first ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 From noreply at rubyforge.org Sat Jul 19 14:20:56 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Sat, 19 Jul 2008 14:20:56 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-21275 ] Callback sometimes segfaults in test suite Message-ID: <20080719182058.84BD618585B8@rubyforge.org> Bugs item #21275, was opened at 2008-07-19 11:20 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21275&group_id=85 Category: win32-api Group: Test Suite Status: Open Resolution: None Priority: 3 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: Callback sometimes segfaults in test suite Initial Comment: Line 45 of test_win32_api_callback.rb sometimes segfaults: test_assert_nothing_raised{ @api_ew.call(@callback, 'UEDIT32') } >ruby -Iext test\test_win32_api_callback.rb Loaded suite test/test_win32_api_callback Started test/test_win32_api_callback.rb:45: [BUG] Segmentation fault ruby 1.8.6 (2008-03-03) [i386-mswin32_80] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Why is this happening? - me ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21275&group_id=85 From djberg96 at gmail.com Sat Jul 19 20:04:49 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 19 Jul 2008 18:04:49 -0600 Subject: [Win32utils-devel] PathIsURL and frozen strings In-Reply-To: <9A6022BFC76C474485ED8BF7E668D92F@mycomputer> References: <4879F70B.9060201@gmail.com> <9A6022BFC76C474485ED8BF7E668D92F@mycomputer> Message-ID: <48828121.5000000@gmail.com> Park Heesob wrote: > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "win32utils-devel" > Sent: Sunday, July 13, 2008 9:37 PM > Subject: [Win32utils-devel] PathIsURL and frozen strings > > >> Hi all, >> >> I may have brought this up a long time ago, but I've forgotten. Why does >> PathIsURL(path) fail if 'path' is frozen? >> >> require 'windows/path' >> include Windows::Path >> >> path = "file://C:\\Documents and Settings\\djberge" >> PathIsURL(path) # true >> >> path.freeze >> PathIsURL(path) # Boom! >> >> TypeError: can't modify frozen string >> from (eval):3:in `call' >> from (eval):3:in `PathIsURL' >> from (irb):9 >> >> Any ideas? I realize I can just dup the string, but I thought I'd ask. >> > In the win32-api, the string type('P') denotes both input and output pointer > parameter. > Thus the string parameter can be modified and must not be frozen. > In case of pure input string, you can define another parameter type and skip > rb_str_modify(v_arg) (line #584 of win32/api.c) After thinking about it some more I'm going to go ahead and add an 'S' prototype, which will be for const char* strings. My reasoning is as follows: It's a bit faster. About 25% in a strcpy benchmark I ran. It means we don't have to worry about buffers in some cases (or will, once I redefine the prototypes in windows-pr). It eliminates the issue I originally mentioned regarding frozen strings. I think it will simplify certain parts of a port for JRuby or IronRuby. I'll mark this as a major release, 1.2.0. Regards, Dan From noreply at rubyforge.org Sun Jul 20 07:49:10 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Sun, 20 Jul 2008 07:49:10 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-21275 ] Callback sometimes segfaults in test suite Message-ID: <20080720114911.034AA18581C4@rubyforge.org> Bugs item #21275, was opened at 2008-07-20 03:20 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21275&group_id=85 Category: win32-api Group: Test Suite Status: Open Resolution: None Priority: 3 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: Callback sometimes segfaults in test suite Initial Comment: Line 45 of test_win32_api_callback.rb sometimes segfaults: test_assert_nothing_raised{ @api_ew.call(@callback, 'UEDIT32') } >ruby -Iext test\test_win32_api_callback.rb Loaded suite test/test_win32_api_callback Started test/test_win32_api_callback.rb:45: [BUG] Segmentation fault ruby 1.8.6 (2008-03-03) [i386-mswin32_80] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Why is this happening? - me ---------------------------------------------------------------------- >Comment By: Park Heesob (phasis68) Date: 2008-07-20 20:49 Message: There seems need to reimplement callback facility. The current callback can handle only one method at a time. And it fails in a unit test sometimes as you mentioned. I will reinvent the wheel if you don't mind. :) Regards, Park Heesob ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21275&group_id=85 From phasis at gmail.com Sun Jul 20 22:49:25 2008 From: phasis at gmail.com (Heesob Park) Date: Mon, 21 Jul 2008 11:49:25 +0900 Subject: [Win32utils-devel] Patch for Callback [win32utils-Bugs-21275] Message-ID: Hi, Here is a patch for callback support: --- api.c.org 2008-07-21 11:30:55.000000000 +0900 +++ api.c 2008-07-21 11:29:49.000000000 +0900 @@ -470,16 +470,18 @@ DWORD params[1]; } PARAM; -static VALUE ActiveCallback; +static VALUE CallbackTable = Qnil; -DWORD CallbackFunction(PARAM param) +DWORD CallbackFunction(void* fptr,PARAM param) { VALUE v_proto, v_return, v_proc, v_retval; VALUE argv[16]; int i, argc; char *a_proto; char *a_return; + VALUE ActiveCallback; + ActiveCallback = rb_hash_aref(CallbackTable,INT2NUM((DWORD)fptr)); if(!NIL_P(ActiveCallback)){ v_proto = rb_iv_get(ActiveCallback, "@prototype"); a_proto = RSTRING(v_proto)->ptr; @@ -547,6 +549,43 @@ return 0; } +DWORD CallbackFunction1(PARAM param) +{ + return CallbackFunction(CallbackFunction1,param); +} +DWORD CallbackFunction2(PARAM param) +{ + return CallbackFunction(CallbackFunction2,param); +} +DWORD CallbackFunction3(PARAM param) +{ + return CallbackFunction(CallbackFunction3,param); +} +DWORD CallbackFunction4(PARAM param) +{ + return CallbackFunction(CallbackFunction4,param); +} +DWORD CallbackFunction5(PARAM param) +{ + return CallbackFunction(CallbackFunction5,param); +} +DWORD CallbackFunction6(PARAM param) +{ + return CallbackFunction(CallbackFunction6,param); +} +DWORD CallbackFunction7(PARAM param) +{ + return CallbackFunction(CallbackFunction7,param); +} +DWORD CallbackFunction8(PARAM param) +{ + return CallbackFunction(CallbackFunction8,param); +} + +static void *CallbackArray[] = {CallbackFunction1,CallbackFunction2, + CallbackFunction3,CallbackFunction4,CallbackFunction5,CallbackFunction6, + CallbackFunction7,CallbackFunction8}; + /* * call-seq: * Win32::API#call(arg1, arg2, ...) @@ -563,7 +602,7 @@ VALUE v_proto, v_args, v_arg, v_return; Win32API* ptr; unsigned long return_value; - int i = 0; + int i,j; struct{ unsigned long params[16]; @@ -618,8 +657,17 @@ } break; case _T_CALLBACK: - ActiveCallback = v_arg; - param.params[i] = (LPARAM)CallbackFunction; + if(CallbackTable==Qnil) CallbackTable = rb_hash_new(); + for(j=0;j<8;j++) { + if(rb_hash_aref(CallbackTable,INT2NUM((DWORD)CallbackArray[j]))==Qnil) { + param.params[i] = (LPARAM)CallbackArray[j]; + rb_hash_aset(CallbackTable,INT2NUM((DWORD)CallbackArray[j]),v_arg); + break; + } + if(j==7) { + rb_raise(rb_eArgError,"Callback function table overflow"); + } + } break; I'm not sure this will fix segfault in test suite, but it will fix multiple callback handling problem. Here is test code require 'win32/api' include Win32 api_ew = API.new('EnumWindows', 'KP', 'L', 'user32') api_gwt = API.new('GetWindowText', 'LPI', 'I', 'user32') callback1 = API::Callback.new('LP', 'I'){ |handle, param| buf = "\0" * 200 p "CALLBACK1" api_gwt.call(handle, buf, 200); buf.index(param).nil? ? true : false } callback2 = API::Callback.new('LP', 'I'){ |handle, param| buf = "\0" * 200 p "CALLBACK2" api_gwt.call(handle, buf, 200); buf.index(param).nil? ? true : false } a = Thread.new { api_ew.call(callback1, 'UEDIT32') } b = Thread.new { api_ew.call(callback2, 'UEDIT32') } a.join b.join Regards, Park Heesob From Daniel.Berger at qwest.com Mon Jul 21 10:21:45 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 21 Jul 2008 09:21:45 -0500 Subject: [Win32utils-devel] Patch for Callback [win32utils-Bugs-21275] In-Reply-To: References: Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D33B9@ITOMAE2KM01.AD.QINTRA.COM> Hi Park, > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Sunday, July 20, 2008 8:49 PM > To: Development and ideas for win32utils projects > Subject: [Win32utils-devel] Patch for Callback [win32utils-Bugs-21275] > > Hi, > > Here is a patch for callback support: > > --- api.c.org 2008-07-21 11:30:55.000000000 +0900 > +++ api.c 2008-07-21 11:29:49.000000000 +0900 > @@ -470,16 +470,18 @@ > DWORD params[1]; > } PARAM; > > -static VALUE ActiveCallback; > +static VALUE CallbackTable = Qnil; > > -DWORD CallbackFunction(PARAM param) > +DWORD CallbackFunction(void* fptr,PARAM param) > { > VALUE v_proto, v_return, v_proc, v_retval; > VALUE argv[16]; > int i, argc; > char *a_proto; > char *a_return; > + VALUE ActiveCallback; > > + ActiveCallback = > rb_hash_aref(CallbackTable,INT2NUM((DWORD)fptr)); > if(!NIL_P(ActiveCallback)){ > v_proto = rb_iv_get(ActiveCallback, "@prototype"); > a_proto = RSTRING(v_proto)->ptr; @@ -547,6 +549,43 @@ > return 0; > } > > +DWORD CallbackFunction1(PARAM param) > +{ > + return CallbackFunction(CallbackFunction1,param); > +} > +DWORD CallbackFunction2(PARAM param) > +{ > + return CallbackFunction(CallbackFunction2,param); > +} > +DWORD CallbackFunction3(PARAM param) > +{ > + return CallbackFunction(CallbackFunction3,param); > +} > +DWORD CallbackFunction4(PARAM param) > +{ > + return CallbackFunction(CallbackFunction4,param); > +} > +DWORD CallbackFunction5(PARAM param) > +{ > + return CallbackFunction(CallbackFunction5,param); > +} > +DWORD CallbackFunction6(PARAM param) > +{ > + return CallbackFunction(CallbackFunction6,param); > +} > +DWORD CallbackFunction7(PARAM param) > +{ > + return CallbackFunction(CallbackFunction7,param); > +} > +DWORD CallbackFunction8(PARAM param) > +{ > + return CallbackFunction(CallbackFunction8,param); > +} > + > +static void *CallbackArray[] = {CallbackFunction1,CallbackFunction2, > + > CallbackFunction3,CallbackFunction4,CallbackFunction5,Callback > Function6, > + CallbackFunction7,CallbackFunction8}; > + > /* > * call-seq: > * Win32::API#call(arg1, arg2, ...) > @@ -563,7 +602,7 @@ > VALUE v_proto, v_args, v_arg, v_return; > Win32API* ptr; > unsigned long return_value; > - int i = 0; > + int i,j; > > struct{ > unsigned long params[16]; > @@ -618,8 +657,17 @@ > } > break; > case _T_CALLBACK: > - ActiveCallback = v_arg; > - param.params[i] = (LPARAM)CallbackFunction; > + if(CallbackTable==Qnil) CallbackTable = > rb_hash_new(); > + for(j=0;j<8;j++) { > + > if(rb_hash_aref(CallbackTable,INT2NUM((DWORD)CallbackArray[j]))==Qnil) > { > + param.params[i] = (LPARAM)CallbackArray[j]; > + > rb_hash_aset(CallbackTable,INT2NUM((DWORD)CallbackArray[j]),v_arg); > + break; > + } > + if(j==7) { > + rb_raise(rb_eArgError,"Callback function table > overflow"); > + } > + } > break; Hi Park Thanks for this. However, I'm wondering if we have to hard code an 8 callback limit. Can't we dynamically add callbacks to the CallbackArray[] as needed? If we need to use a struct to store additional information, and store an array of those structs internally, that's fine. > I'm not sure this will fix segfault in test suite, but it > will fix multiple callback handling problem. > Here is test code > > require 'win32/api' > include Win32 > > api_ew = API.new('EnumWindows', 'KP', 'L', 'user32') > api_gwt = API.new('GetWindowText', 'LPI', 'I', 'user32') > > callback1 = API::Callback.new('LP', 'I'){ |handle, param| > buf = "\0" * 200 > p "CALLBACK1" > api_gwt.call(handle, buf, 200); > buf.index(param).nil? ? true : false > } > callback2 = API::Callback.new('LP', 'I'){ |handle, param| > buf = "\0" * 200 > p "CALLBACK2" > api_gwt.call(handle, buf, 200); > buf.index(param).nil? ? true : false > } > > a = Thread.new { > api_ew.call(callback1, 'UEDIT32') > } > b = Thread.new { > api_ew.call(callback2, 'UEDIT32') > } > a.join > b.join Thanks, I'll create some tests modelled on this. 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 Mon Jul 21 10:38:33 2008 From: phasis at gmail.com (Park Heesob) Date: Mon, 21 Jul 2008 23:38:33 +0900 Subject: [Win32utils-devel] Patch for Callback [win32utils-Bugs-21275] References: <7524A45A1A5B264FA4809E2156496CFB023D33B9@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Monday, July 21, 2008 11:21 PM Subject: Re: [Win32utils-devel] Patch for Callback [win32utils-Bugs-21275] > Hi Park, > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Heesob Park >> Sent: Sunday, July 20, 2008 8:49 PM >> To: Development and ideas for win32utils projects >> Subject: [Win32utils-devel] Patch for Callback [win32utils-Bugs-21275] >> >> Hi, >> >> Here is a patch for callback support: >> >> --- api.c.org 2008-07-21 11:30:55.000000000 +0900 >> +++ api.c 2008-07-21 11:29:49.000000000 +0900 >> @@ -470,16 +470,18 @@ >> DWORD params[1]; >> } PARAM; >> >> -static VALUE ActiveCallback; >> +static VALUE CallbackTable = Qnil; >> >> -DWORD CallbackFunction(PARAM param) >> +DWORD CallbackFunction(void* fptr,PARAM param) >> { >> VALUE v_proto, v_return, v_proc, v_retval; >> VALUE argv[16]; >> int i, argc; >> char *a_proto; >> char *a_return; >> + VALUE ActiveCallback; >> >> + ActiveCallback = >> rb_hash_aref(CallbackTable,INT2NUM((DWORD)fptr)); >> if(!NIL_P(ActiveCallback)){ >> v_proto = rb_iv_get(ActiveCallback, "@prototype"); >> a_proto = RSTRING(v_proto)->ptr; @@ -547,6 +549,43 @@ >> return 0; >> } >> >> +DWORD CallbackFunction1(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction1,param); >> +} >> +DWORD CallbackFunction2(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction2,param); >> +} >> +DWORD CallbackFunction3(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction3,param); >> +} >> +DWORD CallbackFunction4(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction4,param); >> +} >> +DWORD CallbackFunction5(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction5,param); >> +} >> +DWORD CallbackFunction6(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction6,param); >> +} >> +DWORD CallbackFunction7(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction7,param); >> +} >> +DWORD CallbackFunction8(PARAM param) >> +{ >> + return CallbackFunction(CallbackFunction8,param); >> +} >> + >> +static void *CallbackArray[] = {CallbackFunction1,CallbackFunction2, >> + >> CallbackFunction3,CallbackFunction4,CallbackFunction5,Callback >> Function6, >> + CallbackFunction7,CallbackFunction8}; >> + >> /* >> * call-seq: >> * Win32::API#call(arg1, arg2, ...) >> @@ -563,7 +602,7 @@ >> VALUE v_proto, v_args, v_arg, v_return; >> Win32API* ptr; >> unsigned long return_value; >> - int i = 0; >> + int i,j; >> >> struct{ >> unsigned long params[16]; >> @@ -618,8 +657,17 @@ >> } >> break; >> case _T_CALLBACK: >> - ActiveCallback = v_arg; >> - param.params[i] = (LPARAM)CallbackFunction; >> + if(CallbackTable==Qnil) CallbackTable = >> rb_hash_new(); >> + for(j=0;j<8;j++) { >> + >> if(rb_hash_aref(CallbackTable,INT2NUM((DWORD)CallbackArray[j]))==Qnil) >> { >> + param.params[i] = (LPARAM)CallbackArray[j]; >> + >> rb_hash_aset(CallbackTable,INT2NUM((DWORD)CallbackArray[j]),v_arg); >> + break; >> + } >> + if(j==7) { >> + rb_raise(rb_eArgError,"Callback function table >> overflow"); >> + } >> + } >> break; > > Hi Park > > Thanks for this. However, I'm wondering if we have to hard code an 8 > callback limit. Can't we dynamically add callbacks to the > CallbackArray[] as needed? If we need to use a struct to store > additional information, and store an array of those structs internally, > that's fine. > That is what I want to do. But that is not easy. Would you try it a little more? Regards, Park Heesob From djberg96 at gmail.com Tue Jul 22 23:44:42 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 22 Jul 2008 21:44:42 -0600 Subject: [Win32utils-devel] win32-api 1.2.0 Message-ID: <6037b70c0807222044oc186625y5b3f466986c07c6d@mail.gmail.com> Hi everyone, I don't know when I'll have time to work on the callback/thread issue for win32-api, so I decided to go ahead and release 1.2.0 tonight. We'll work out the callback issue for the next release. Regards, Dan From noreply at rubyforge.org Sun Jul 27 15:19:44 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Sun, 27 Jul 2008 15:19:44 -0400 (EDT) Subject: [Win32utils-devel] [ win32utils-Bugs-21272 ] File.basename bug smoked out by WEBrick, Rails Message-ID: <20080727191944.B198F1598076@rubyforge.org> Bugs item #21272, was opened at 2008-07-18 14:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 Category: win32-file Group: Code Status: Open Resolution: None Priority: 5 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: File.basename bug smoked out by WEBrick, Rails Initial Comment: It looks like there's a bug in File.basename somewhere: C:\>ruby script\server => Booting WEBrick... => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2008-07-18 15:29:55] INFO WEBrick 1.3.1 [2008-07-18 15:29:55] INFO ruby 1.8.6 (2007-09-24) [i386-mswin32] [2008-07-18 15:29:55] INFO WEBrick::HTTPServer#start: pid=2036 port=3000 c:/ruby/lib/ruby/gems/1.8/gems/win32-file-0.5.4/lib/win32/file.rb:434: [BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. It was hard to track this down because adding print statemetns seemed to alter the behavior, but I did notice something like this: ??d???T??security.so e_support/d Regards, me ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2008-07-27 12:19 Message: Not sure what's happening now. I tried Rails 2.1 with win32-file 0.5.5, windows-pr 0.9.0 and win32-file-stat 1.2.7. With some debug print statements added to win32-file-stat, I narrowed it down to: ERROR IN 'get_file_type' ON: C:\Documents and Settings\djberge\workspace\gym_tracker\config\routes.rb This is strange because I can definitely stat that file. Thread issue perhaps? Dan ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2008-07-18 15:25 Message: This error, which I pulled out of the debugger, may be related: c:/ruby/lib/ruby/gems/1.8/gems/win32-file-stat-1.2.7/lib/win32/file/stat.rb:576: `unknown error - T' (SystemCa llError) from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/filters.rb:684:in `process _without_session_management_support' from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/session_management.rb:114: in `process' from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/rescue.rb:18:in `process_w ith_exception' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:46:in `dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:136:in `failsafe_response' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:44:in `dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:113:in `handle_dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:79:in `service' from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' from c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' from c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' from c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' from c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' from c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:63:in `dispatch' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/servers/webrick.rb:59 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `req uire' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in `new _constants_in' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `req uire' from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/server.rb:39 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from script/server:3 c:/ruby/lib/ruby/gems/1.8/gems/win32-file-stat-1.2.7/lib/win32/file/stat.rb:576: raise SystemCallEr ror, get_last_error(error_num) ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2008-07-18 15:01 Message: Quick update - it's line 436 in 0.5.5: file = file.split(0.chr).first ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=21272&group_id=85 From djberg96 at gmail.com Sun Jul 27 18:02:30 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 27 Jul 2008 16:02:30 -0600 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue Message-ID: <488CF076.8010609@gmail.com> Hi all, Please take a look at RubyForge bug #21272: http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411 The easiest way to see this for yourself is to create a skeleton Rails app, add 'win32/file' to the config/environment.rb file, run "ruby script/server", and point your browser at http://localhost:3000. I've tried refactoring the get_file_type method in stat.rb like so: def get_file_type(file) begin handle = CreateFile( file, GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories nil ) error_num = GetLastError() # Ignore errors caused by open/empty/used block devices. We raise # a SystemCallError explicitly here in order to maintain # compatibility with the FileUtils module. if handle == INVALID_HANDLE_VALUE unless error_num == ERROR_NOT_READY raise SystemCallError, get_last_error(error_num) end end file_type = GetFileType(handle) error_num = GetLastError() if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR raise SystemCallError, get_last_error(error_num) end ensure CloseHandle(handle) end end But, that's still not fixing it. I've also tried wrapping it in a RUBY_CRITICAL block as well as an explicit wide version of CreateFile, along with a few different access flags, but I haven't had any luck yet so far. Any ideas? Thanks, Dan From phasis at gmail.com Sun Jul 27 22:50:21 2008 From: phasis at gmail.com (Heesob Park) Date: Mon, 28 Jul 2008 11:50:21 +0900 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue In-Reply-To: <488CF076.8010609@gmail.com> References: <488CF076.8010609@gmail.com> Message-ID: Hi, 2008/7/28 Daniel Berger : > Hi all, > > Please take a look at RubyForge bug #21272: > > http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411 > > The easiest way to see this for yourself is to create a skeleton Rails app, > add 'win32/file' to the config/environment.rb file, run "ruby > script/server", and point your browser at http://localhost:3000. > > I've tried refactoring the get_file_type method in stat.rb like so: > > def get_file_type(file) > begin > handle = CreateFile( > file, > GENERIC_READ, > FILE_SHARE_READ, > nil, > OPEN_EXISTING, > FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories > nil > ) > > error_num = GetLastError() > > # Ignore errors caused by open/empty/used block devices. We raise > # a SystemCallError explicitly here in order to maintain > # compatibility with the FileUtils module. > if handle == INVALID_HANDLE_VALUE > unless error_num == ERROR_NOT_READY > raise SystemCallError, get_last_error(error_num) > end > end > > file_type = GetFileType(handle) > error_num = GetLastError() > > if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR > raise SystemCallError, get_last_error(error_num) > end > ensure > CloseHandle(handle) > end > end > > But, that's still not fixing it. I've also tried wrapping it in a > RUBY_CRITICAL block as well as an explicit wide version of CreateFile, along > with a few different access flags, but I haven't had any luck yet so far. > > Any ideas? > I guess it is related with the Wide and Ansi API function detection problem. After modification of stat.rb #93 GetFileAttributes to GetFileAttributesA #558 CreateFile to CreateFileA works fine for me. Regards, Park Heesob From djberg96 at gmail.com Mon Jul 28 21:08:20 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 28 Jul 2008 19:08:20 -0600 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue In-Reply-To: References: <488CF076.8010609@gmail.com> Message-ID: <488E6D84.6030002@gmail.com> Heesob Park wrote: > Hi, > > 2008/7/28 Daniel Berger : >> Hi all, >> >> Please take a look at RubyForge bug #21272: >> >> http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411 >> >> The easiest way to see this for yourself is to create a skeleton Rails app, >> add 'win32/file' to the config/environment.rb file, run "ruby >> script/server", and point your browser at http://localhost:3000. >> >> I've tried refactoring the get_file_type method in stat.rb like so: >> >> def get_file_type(file) >> begin >> handle = CreateFile( >> file, >> GENERIC_READ, >> FILE_SHARE_READ, >> nil, >> OPEN_EXISTING, >> FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories >> nil >> ) >> >> error_num = GetLastError() >> >> # Ignore errors caused by open/empty/used block devices. We raise >> # a SystemCallError explicitly here in order to maintain >> # compatibility with the FileUtils module. >> if handle == INVALID_HANDLE_VALUE >> unless error_num == ERROR_NOT_READY >> raise SystemCallError, get_last_error(error_num) >> end >> end >> >> file_type = GetFileType(handle) >> error_num = GetLastError() >> >> if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR >> raise SystemCallError, get_last_error(error_num) >> end >> ensure >> CloseHandle(handle) >> end >> end >> >> But, that's still not fixing it. I've also tried wrapping it in a >> RUBY_CRITICAL block as well as an explicit wide version of CreateFile, along >> with a few different access flags, but I haven't had any luck yet so far. >> >> Any ideas? >> > I guess it is related with the Wide and Ansi API function detection problem. > > After modification of stat.rb > #93 GetFileAttributes to GetFileAttributesA > #558 CreateFile to CreateFileA > works fine for me. Yes, thanks. Also, there was some kind of bug in the multi_to_wide and wide_to_multi helper methods in Windows::Unicode. I've refactored those and updated win32-file-stat to use wide character functions internally. All tests pass now. I'll have to update win32-file next to use the wide character functions. I think there was one other bug (a bad error message somewhere) I need to fix, too. Regards, Dan From phasis at gmail.com Mon Jul 28 21:17:17 2008 From: phasis at gmail.com (Heesob Park) Date: Tue, 29 Jul 2008 10:17:17 +0900 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue In-Reply-To: <488E6D84.6030002@gmail.com> References: <488CF076.8010609@gmail.com> <488E6D84.6030002@gmail.com> Message-ID: Hi, 2008/7/29 Daniel Berger : > Heesob Park wrote: >> >> Hi, >> >> 2008/7/28 Daniel Berger : >>> >>> Hi all, >>> >>> Please take a look at RubyForge bug #21272: >>> >>> >>> http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411 >>> >>> The easiest way to see this for yourself is to create a skeleton Rails >>> app, >>> add 'win32/file' to the config/environment.rb file, run "ruby >>> script/server", and point your browser at http://localhost:3000. >>> >>> I've tried refactoring the get_file_type method in stat.rb like so: >>> >>> def get_file_type(file) >>> begin >>> handle = CreateFile( >>> file, >>> GENERIC_READ, >>> FILE_SHARE_READ, >>> nil, >>> OPEN_EXISTING, >>> FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories >>> nil >>> ) >>> >>> error_num = GetLastError() >>> >>> # Ignore errors caused by open/empty/used block devices. We raise >>> # a SystemCallError explicitly here in order to maintain >>> # compatibility with the FileUtils module. >>> if handle == INVALID_HANDLE_VALUE >>> unless error_num == ERROR_NOT_READY >>> raise SystemCallError, get_last_error(error_num) >>> end >>> end >>> >>> file_type = GetFileType(handle) >>> error_num = GetLastError() >>> >>> if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR >>> raise SystemCallError, get_last_error(error_num) >>> end >>> ensure >>> CloseHandle(handle) >>> end >>> end >>> >>> But, that's still not fixing it. I've also tried wrapping it in a >>> RUBY_CRITICAL block as well as an explicit wide version of CreateFile, >>> along >>> with a few different access flags, but I haven't had any luck yet so far. >>> >>> Any ideas? >>> >> I guess it is related with the Wide and Ansi API function detection >> problem. >> >> After modification of stat.rb >> #93 GetFileAttributes to GetFileAttributesA >> #558 CreateFile to CreateFileA >> works fine for me. > > Yes, thanks. Also, there was some kind of bug in the multi_to_wide and > wide_to_multi helper methods in Windows::Unicode. I've refactored those and > updated win32-file-stat to use wide character functions internally. All > tests pass now. > > I'll have to update win32-file next to use the wide character functions. I > think there was one other bug (a bad error message somewhere) I need to fix, > too. > That's the same problem. If you modify FormatMessage to FormatMessageA (#423 of error.rb), It works fine. Regards, Park Heesob From djberg96 at gmail.com Tue Jul 29 08:33:50 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 29 Jul 2008 06:33:50 -0600 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue In-Reply-To: References: <488CF076.8010609@gmail.com> <488E6D84.6030002@gmail.com> Message-ID: <488F0E2E.70800@gmail.com> Heesob Park wrote: > Hi, > > 2008/7/29 Daniel Berger : >> Heesob Park wrote: >>> Hi, >>> >>> 2008/7/28 Daniel Berger : >>>> Hi all, >>>> >>>> Please take a look at RubyForge bug #21272: >>>> >>>> >>>> http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411 >>>> >>>> The easiest way to see this for yourself is to create a skeleton Rails >>>> app, >>>> add 'win32/file' to the config/environment.rb file, run "ruby >>>> script/server", and point your browser at http://localhost:3000. >>>> >>>> I've tried refactoring the get_file_type method in stat.rb like so: >>>> >>>> def get_file_type(file) >>>> begin >>>> handle = CreateFile( >>>> file, >>>> GENERIC_READ, >>>> FILE_SHARE_READ, >>>> nil, >>>> OPEN_EXISTING, >>>> FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories >>>> nil >>>> ) >>>> >>>> error_num = GetLastError() >>>> >>>> # Ignore errors caused by open/empty/used block devices. We raise >>>> # a SystemCallError explicitly here in order to maintain >>>> # compatibility with the FileUtils module. >>>> if handle == INVALID_HANDLE_VALUE >>>> unless error_num == ERROR_NOT_READY >>>> raise SystemCallError, get_last_error(error_num) >>>> end >>>> end >>>> >>>> file_type = GetFileType(handle) >>>> error_num = GetLastError() >>>> >>>> if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR >>>> raise SystemCallError, get_last_error(error_num) >>>> end >>>> ensure >>>> CloseHandle(handle) >>>> end >>>> end >>>> >>>> But, that's still not fixing it. I've also tried wrapping it in a >>>> RUBY_CRITICAL block as well as an explicit wide version of CreateFile, >>>> along >>>> with a few different access flags, but I haven't had any luck yet so far. >>>> >>>> Any ideas? >>>> >>> I guess it is related with the Wide and Ansi API function detection >>> problem. >>> >>> After modification of stat.rb >>> #93 GetFileAttributes to GetFileAttributesA >>> #558 CreateFile to CreateFileA >>> works fine for me. >> Yes, thanks. Also, there was some kind of bug in the multi_to_wide and >> wide_to_multi helper methods in Windows::Unicode. I've refactored those and >> updated win32-file-stat to use wide character functions internally. All >> tests pass now. >> >> I'll have to update win32-file next to use the wide character functions. I >> think there was one other bug (a bad error message somewhere) I need to fix, >> too. >> > That's the same problem. > If you modify FormatMessage to FormatMessageA (#423 of error.rb), > It works fine. I guess all Windows error messages are in English anyway. Unless Vista changed things. :) Thanks, Dan From phasis at gmail.com Tue Jul 29 09:02:17 2008 From: phasis at gmail.com (Park Heesob) Date: Tue, 29 Jul 2008 22:02:17 +0900 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue References: <488CF076.8010609@gmail.com> <488E6D84.6030002@gmail.com> <488F0E2E.70800@gmail.com> Message-ID: ----- Original Message ----- From: "Daniel Berger" To: "Development and ideas for win32utils projects" Sent: Tuesday, July 29, 2008 9:33 PM Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue > Heesob Park wrote: >> Hi, >> >> 2008/7/29 Daniel Berger : >>> Heesob Park wrote: >>>> Hi, >>>> >>>> 2008/7/28 Daniel Berger : >>>>> Hi all, >>>>> >>>>> Please take a look at RubyForge bug #21272: >>>>> >>>>> >>>>> http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411 >>>>> >>>>> The easiest way to see this for yourself is to create a skeleton Rails >>>>> app, >>>>> add 'win32/file' to the config/environment.rb file, run "ruby >>>>> script/server", and point your browser at http://localhost:3000. >>>>> >>>>> I've tried refactoring the get_file_type method in stat.rb like so: >>>>> >>>>> def get_file_type(file) >>>>> begin >>>>> handle = CreateFile( >>>>> file, >>>>> GENERIC_READ, >>>>> FILE_SHARE_READ, >>>>> nil, >>>>> OPEN_EXISTING, >>>>> FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories >>>>> nil >>>>> ) >>>>> >>>>> error_num = GetLastError() >>>>> >>>>> # Ignore errors caused by open/empty/used block devices. We raise >>>>> # a SystemCallError explicitly here in order to maintain >>>>> # compatibility with the FileUtils module. >>>>> if handle == INVALID_HANDLE_VALUE >>>>> unless error_num == ERROR_NOT_READY >>>>> raise SystemCallError, get_last_error(error_num) >>>>> end >>>>> end >>>>> >>>>> file_type = GetFileType(handle) >>>>> error_num = GetLastError() >>>>> >>>>> if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR >>>>> raise SystemCallError, get_last_error(error_num) >>>>> end >>>>> ensure >>>>> CloseHandle(handle) >>>>> end >>>>> end >>>>> >>>>> But, that's still not fixing it. I've also tried wrapping it in a >>>>> RUBY_CRITICAL block as well as an explicit wide version of CreateFile, >>>>> along >>>>> with a few different access flags, but I haven't had any luck yet so >>>>> far. >>>>> >>>>> Any ideas? >>>>> >>>> I guess it is related with the Wide and Ansi API function detection >>>> problem. >>>> >>>> After modification of stat.rb >>>> #93 GetFileAttributes to GetFileAttributesA >>>> #558 CreateFile to CreateFileA >>>> works fine for me. >>> Yes, thanks. Also, there was some kind of bug in the multi_to_wide and >>> wide_to_multi helper methods in Windows::Unicode. I've refactored those >>> and >>> updated win32-file-stat to use wide character functions internally. All >>> tests pass now. >>> >>> I'll have to update win32-file next to use the wide character functions. >>> I >>> think there was one other bug (a bad error message somewhere) I need to >>> fix, >>> too. >>> >> That's the same problem. >> If you modify FormatMessage to FormatMessageA (#423 of error.rb), >> It works fine. > > I guess all Windows error messages are in English anyway. Unless Vista > changed things. :) > I guess you are correct only in the English version. In my Windows XP, the error messages are in Korean. :) Regards, Park Heesob From Daniel.Berger at qwest.com Tue Jul 29 09:57:03 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 29 Jul 2008 08:57:03 -0500 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue In-Reply-To: References: <488CF076.8010609@gmail.com> <488E6D84.6030002@gmail.com><488F0E2E.70800@gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D33F6@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: Tuesday, July 29, 2008 7:02 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue > >>> > >> That's the same problem. > >> If you modify FormatMessage to FormatMessageA (#423 of error.rb), > >> It works fine. > > > > I guess all Windows error messages are in English anyway. > Unless Vista > > changed things. :) > > > I guess you are correct only in the English version. > In my Windows XP, the error messages are in Korean. :) Oh? I didn't know that. FormatMessageA won't work for you then, will it? I changed get_last_error not too long ago so that I thought it would work either with -Ku or not. If you have a suggested refactoring, I'm listening. :) 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 Tue Jul 29 10:53:31 2008 From: phasis at gmail.com (Park Heesob) Date: Tue, 29 Jul 2008 23:53:31 +0900 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue References: <488CF076.8010609@gmail.com> <488E6D84.6030002@gmail.com><488F0E2E.70800@gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D33F6@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Tuesday, July 29, 2008 10:57 PM Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Tuesday, July 29, 2008 7:02 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue > > > >> >>> >> >> That's the same problem. >> >> If you modify FormatMessage to FormatMessageA (#423 of error.rb), >> >> It works fine. >> > >> > I guess all Windows error messages are in English anyway. >> Unless Vista >> > changed things. :) >> > >> I guess you are correct only in the English version. >> In my Windows XP, the error messages are in Korean. :) > > Oh? I didn't know that. > > FormatMessageA won't work for you then, will it? I changed > get_last_error not too long ago so that I thought it would work either > with -Ku or not. If you have a suggested refactoring, I'm listening. :) > As I mentioned before, FormatMessageA works for me. It returns the ansi character set (euckr aka ksc5601). I guess FormatMessageA should work for all languages. Regards, Park Heesob From djberg96 at gmail.com Wed Jul 30 09:46:44 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 30 Jul 2008 07:46:44 -0600 Subject: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue In-Reply-To: References: <488CF076.8010609@gmail.com> <488E6D84.6030002@gmail.com><488F0E2E.70800@gmail.com> <7524A45A1A5B264FA4809E2156496CFB023D33F6@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <489070C4.9000309@gmail.com> Park Heesob wrote: > ----- Original Message ----- > From: "Berger, Daniel" > To: "Development and ideas for win32utils projects" > > Sent: Tuesday, July 29, 2008 10:57 PM > Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue > > >>> -----Original Message----- >>> From: win32utils-devel-bounces at rubyforge.org >>> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >>> Park Heesob >>> Sent: Tuesday, July 29, 2008 7:02 AM >>> To: Development and ideas for win32utils projects >>> Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue >> >> >>>>> That's the same problem. >>>>> If you modify FormatMessage to FormatMessageA (#423 of error.rb), >>>>> It works fine. >>>> I guess all Windows error messages are in English anyway. >>> Unless Vista >>>> changed things. :) >>>> >>> I guess you are correct only in the English version. >>> In my Windows XP, the error messages are in Korean. :) >> Oh? I didn't know that. >> >> FormatMessageA won't work for you then, will it? I changed >> get_last_error not too long ago so that I thought it would work either >> with -Ku or not. If you have a suggested refactoring, I'm listening. :) >> > As I mentioned before, FormatMessageA works for me. > It returns the ansi character set (euckr aka ksc5601). > I guess FormatMessageA should work for all languages. Ok, I changed it to FormatMessageA, and released that change as part of windows-pr 0.9.1. Also, I released win32-file-stat 1.2.8 with the wide character support last night. Thanks! Dan