From phasis at gmail.com Mon Dec 1 00:18:27 2008 From: phasis at gmail.com (Heesob Park) Date: Mon, 1 Dec 2008 14:18:27 +0900 Subject: [Win32utils-devel] [Fwd: [ruby-core:20176] Unable to build from source on Vista, VC++ 9] In-Reply-To: <493369D6.2070903@gmail.com> References: <49334E9F.8050301@gmail.com> <4933570C.8030902@gmail.com> <493369D6.2070903@gmail.com> Message-ID: 2008/12/1 Daniel Berger : > Heesob Park wrote: >> >>> >> The __asm inline assembler is not supported in 64bit compiler. > > Ah, thanks. Do we absolutely have to have this bit of assembler code to > begin with? I don't really know assembler so I don't know what that code is > needed for. > That assembly code gets/sets the SEH(Structured Exception Handling) stack list for the 32bit Intel CPU. Refer to http://www.microsoft.com/msj/0197/Exception/Exception.aspx. But in 64bit CPU, the SEH is not stack based but table based. So SEH is not compatible with 32 bit. Refer to http://www.woodmann.com/forum/showthread.php?t=11636 Regards, Park Heesob From djberg96 at gmail.com Mon Dec 1 00:52:46 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 30 Nov 2008 22:52:46 -0700 Subject: [Win32utils-devel] [ruby-core:20183] Re: Unable to build from source on Vista, VC++ 9 In-Reply-To: <20081201034611.4C422E0B2C@mail.bc9.jp> References: <49329987.8040806@gmail.com> <20081201034611.4C422E0B2C@mail.bc9.jp> Message-ID: <49337BAE.80106@gmail.com> Nobuyoshi Nakada wrote: > Hi, > > At Sun, 30 Nov 2008 22:42:36 +0900, > Daniel Berger wrote in [ruby-core:20176]: >> eval.c(9839) : fatal error C1189: #error : unsupported platform >> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio >> 9.0\VC\BIN\amd64\cl.EXE"' : return code '0x2' >> Stop. > > VC seems to define _M_AMD64 on amd64 instead of _M_IX86, but > I'm not sure about AMD64 instruction set and if Windows on it > saves the exception list in the same place. Do you have any > idea? As Park Heesob brought up on win32utils-devel, SEH on 64-bit Windows is table based instead of stack based. From MSDN: "One of the constraints for the x64 compiler is to have no inline assembler support. This means that functions that cannot be written in C or C++ will either have to be written as subroutines or as intrinsic functions supported by the compiler. Certain functions are performance sensitive while others are not. Performance-sensitive functions should be implemented as intrinsic functions. In general, this will be the same list of intrinsic functions implemented for ALPHA and the Itanium but will include x64 specific functions as well." http://msdn.microsoft.com/en-us/library/wbk4z78b.aspx So, I guess we must compile in 32-bit mode on Windows. :( Regards, Dan From djberg96 at gmail.com Mon Dec 1 01:02:37 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 30 Nov 2008 23:02:37 -0700 Subject: [Win32utils-devel] [Fwd: [ruby-core:20176] Unable to build from source on Vista, VC++ 9] In-Reply-To: References: <49334E9F.8050301@gmail.com> <4933570C.8030902@gmail.com> <493369D6.2070903@gmail.com> Message-ID: <49337DFD.4000705@gmail.com> Heesob Park wrote: > 2008/12/1 Daniel Berger : >> Heesob Park wrote: >>> The __asm inline assembler is not supported in 64bit compiler. >> Ah, thanks. Do we absolutely have to have this bit of assembler code to >> begin with? I don't really know assembler so I don't know what that code is >> needed for. >> > That assembly code gets/sets the SEH(Structured Exception Handling) > stack list for the 32bit Intel CPU. > Refer to http://www.microsoft.com/msj/0197/Exception/Exception.aspx. > > But in 64bit CPU, the SEH is not stack based but table based. So SEH > is not compatible with 32 bit. > Refer to http://www.woodmann.com/forum/showthread.php?t=11636 That second link is unreachable for me. I'm not sure what's up, but the MSDN site had some documentation, too: http://msdn.microsoft.com/en-us/library/wbk4z78b.aspx I guess the question is whether or not there's some way we can deal with that eval.c code with a simple patch, or if it will take a major overhaul. Regards, Dan From Daniel.Berger at qwest.com Mon Dec 1 12:06:39 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 1 Dec 2008 11:06:39 -0600 Subject: [Win32utils-devel] Code formatting with VS 2008? Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514ED7@ITOMAE2KM01.AD.QINTRA.COM> Hi everyone, I see that Visual Studio 2008 Pro has the ability to auto-format code. Does anyone know if there's a way to auto-format pre-ansi C code to ANSI C? I couldn't find anything, but there's so many options in VS I wasn't sure. 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 Dec 1 21:59:19 2008 From: phasis at gmail.com (Heesob Park) Date: Tue, 2 Dec 2008 11:59:19 +0900 Subject: [Win32utils-devel] Code formatting with VS 2008? In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514ED7@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514ED7@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/12/2 Berger, Daniel : > Hi everyone, > > I see that Visual Studio 2008 Pro has the ability to auto-format code. > Does anyone know if there's a way to auto-format pre-ansi C code to ANSI > C? I couldn't find anything, but there's so many options in VS I wasn't > sure. > I doubt VS can convert pre-ansi C to ANSI c. But protoize can do it. protoize is an optional part of GCC Refer to http://gcc.gnu.org/onlinedocs/gcc/Running-Protoize.html Regards, Park Heesob From djberg96 at gmail.com Mon Dec 1 23:16:31 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 01 Dec 2008 21:16:31 -0700 Subject: [Win32utils-devel] Favorite COM book? Message-ID: <4934B69F.6030009@gmail.com> Hi everyone, Does anyone have a favorite OLE/COM/Automation/Whatever programming book? I'm thinking of picking one up. Thanks, Dan From waynev at gmail.com Mon Dec 1 23:35:37 2008 From: waynev at gmail.com (Wayne Vucenic) Date: Mon, 1 Dec 2008 20:35:37 -0800 Subject: [Win32utils-devel] Favorite COM book? In-Reply-To: <4934B69F.6030009@gmail.com> References: <4934B69F.6030009@gmail.com> Message-ID: <88c9ce410812012035i10a72b65oa0a4fb275503e2c7@mail.gmail.com> Hi Dan, Back when I was working with COM, my favorite source of information was Richard Grimes' books. For example, "Professional ATL COM Programming" (WROX Press). At the time (6+ years ago) IMHO, ATL was the best way to make serious use of COM. I don't know if things have changed since then. Also Don Box's "Essential COM" was the best book I had that covered the nitty-gritty technical details about what was really going on. Then again, at the time I was doing all of this in C++, which may not be the approach you're taking. Hope this helps, Wayne On Mon, Dec 1, 2008 at 8:16 PM, Daniel Berger wrote: > Hi everyone, > > Does anyone have a favorite OLE/COM/Automation/Whatever programming book? > I'm thinking of picking one up. > > Thanks, > > Dan > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From waynev at gmail.com Tue Dec 2 16:10:18 2008 From: waynev at gmail.com (Wayne Vucenic) Date: Tue, 2 Dec 2008 13:10:18 -0800 Subject: [Win32utils-devel] Favorite COM book? In-Reply-To: <88c9ce410812012035i10a72b65oa0a4fb275503e2c7@mail.gmail.com> References: <4934B69F.6030009@gmail.com> <88c9ce410812012035i10a72b65oa0a4fb275503e2c7@mail.gmail.com> Message-ID: <88c9ce410812021310j6ee5c6bdr3335c1c91ff0afdf@mail.gmail.com> Hi Dan, I realize you said you were interested in one book and here I'm recommending yet another. I like "Understanding Active X and OLE: A guide for developers and managers" by David Chappell. It's mostly language neutral, and I thought he did an excellent job of providing enough technical details to keep developers happy together with good overviews which are more likely to appeal to managers. Now that I give a little more thought to what you are likely to be interested in regarding COM/ActiveX/etc., I think this would be a better book for you than either of the two I mentioned earlier. I should point out that I haven't kept up with new COM books for 5+ years, so there may be newer books that I would prefer to the above. Then again COM doesn't seem to be nearly the hot topic for books that it was 5 years ago. Best regards, Wayne On Mon, Dec 1, 2008 at 8:35 PM, Wayne Vucenic wrote: > Hi Dan, > > Back when I was working with COM, my favorite source of information was > Richard Grimes' books. For example, "Professional ATL COM Programming" (WROX > Press). At the time (6+ years ago) IMHO, ATL was the best way to make > serious use of COM. I don't know if things have changed since then. > > Also Don Box's "Essential COM" was the best book I had that covered the > nitty-gritty technical details about what was really going on. > > Then again, at the time I was doing all of this in C++, which may not be > the approach you're taking. > > Hope this helps, > > Wayne > > On Mon, Dec 1, 2008 at 8:16 PM, Daniel Berger wrote: > >> Hi everyone, >> >> Does anyone have a favorite OLE/COM/Automation/Whatever programming book? >> I'm thinking of picking one up. >> >> Thanks, >> >> Dan >> _______________________________________________ >> win32utils-devel mailing list >> win32utils-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/win32utils-devel >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From djberg96 at gmail.com Wed Dec 3 20:56:24 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 03 Dec 2008 18:56:24 -0700 Subject: [Win32utils-devel] Get current process owner (sid) Message-ID: <493738C8.6020201@gmail.com> Hi, I'm close, but what I've got doesn't quite match what Win32::Security::SID.new returns: require 'windows/file' require 'windows/handle' require 'windows/error' require 'windows/security' require 'windows/process' include Windows::File include Windows::Handle include Windows::Error include Windows::Security include Windows::Process token = 0.chr * 4 unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token) raise error, get_last_error end token = token.unpack('V')[0] rlength = 0.chr * 4 tu = 0.chr * 512 # TokenUser bool = GetTokenInformation( token, TokenUser, tu, tu.size, rlength ) unless bool raise get_last_error end p tu.strip Looks like the first 8 bytes are unwanted. Are these the attributes? If so, why are they the first 8 bytes instead of the last 8? I guess I'm confused about how to properly unroll a SID_AND_ATTRIBUTES struct. Regards, Dan From phasis at gmail.com Wed Dec 3 21:28:21 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 4 Dec 2008 11:28:21 +0900 Subject: [Win32utils-devel] Get current process owner (sid) In-Reply-To: <493738C8.6020201@gmail.com> References: <493738C8.6020201@gmail.com> Message-ID: Hi, 2008/12/4 Daniel Berger : > Hi, > > I'm close, but what I've got doesn't quite match what > Win32::Security::SID.new returns: > > require 'windows/file' > require 'windows/handle' > require 'windows/error' > require 'windows/security' > require 'windows/process' > > include Windows::File > include Windows::Handle > include Windows::Error > include Windows::Security > include Windows::Process > > token = 0.chr * 4 > > unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token) > raise error, get_last_error > end > > token = token.unpack('V')[0] > rlength = 0.chr * 4 > tu = 0.chr * 512 # TokenUser > > bool = GetTokenInformation( > token, > TokenUser, > tu, > tu.size, > rlength > ) > > unless bool > raise get_last_error > end > > p tu.strip > > Looks like the first 8 bytes are unwanted. Are these the attributes? If so, > why are they the first 8 bytes instead of the last 8? I guess I'm confused > about how to properly unroll a SID_AND_ATTRIBUTES struct. > According to the document, the first 4bytes is the pointer of SID and the second 4bytes are attributes. In my test with the above code, [tu].pack('P').unpack('L').first is 50436232 tu[0,4].unpack('L').first is 50436240 rlength.unpack('L').first is 36 The SID is at 50436240 and equal to address of tu[8] Thus the actual SID is tu[8,(36-8)] Regards, Park Heesob From djberg96 at gmail.com Fri Dec 12 23:02:04 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 12 Dec 2008 21:02:04 -0700 Subject: [Win32utils-devel] Time windows volume was mounted? Message-ID: <494333BC.6020607@gmail.com> Hi all, Does Windows store the time a particular volume was mounted? Is there an equivalent to mnt_time from mntent.h? I suppose it's probably the same as the boot time for hard disks, but I thought I'd ask. Regards, Dan From djberg96 at gmail.com Wed Dec 17 23:53:05 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 17 Dec 2008 21:53:05 -0700 Subject: [Win32utils-devel] win32-security 0.1.0 released Message-ID: <4949D731.5020408@gmail.com> Hi all, Just a quick note to let you know that I've pushed out the first release of win32-security. For now I've only included the SID wrapper because I'm still unsure of the interface for the other stuff just yet. Besides, I wanted to get _something_ out there now so people can take a look now while I'm thinking over the other stuff. http://raa.ruby-lang.org/project/win32-security/ Regards, Dan From djberg96 at gmail.com Fri Dec 19 08:13:05 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 19 Dec 2008 06:13:05 -0700 Subject: [Win32utils-devel] Fwd: [ANN] win32-security 0.1.0 In-Reply-To: <8C943B94-B343-4C48-A0A4-E17802FCDC58@gmail.com> References: <4949D886.2090402@gmail.com> <494A633C.30508@gmail.com> <6037b70c0812180959q251f69f1lbcd4870d0901a956@mail.gmail.com> <8C943B94-B343-4C48-A0A4-E17802FCDC58@gmail.com> Message-ID: <6037b70c0812190513l6bc04457n4764f2d0bd4b68e6@mail.gmail.com> Hi, These were some suggestions from Clifford Heath regarding win32-security and Windows security in general. Regards, Dan PS - I'll be on vacation until Jan, 2009. Merry Christmas and Happy New Year everyone! ---------- Forwarded message ---------- From: Clifford Heath Date: Fri, Dec 19, 2008 at 12:34 AM Subject: Re: [ANN] win32-security 0.1.0 To: Daniel Berger On 19/12/2008, at 4:59 AM, Daniel Berger wrote: > > Please take a look at the CVS repo. Ok, making notes as I read through it now. I think the hardest thing with the Microsoft APIs is getting an understanding of what's going on under the covers, so I'll comment on the C++ API I created. Most of what I write is about our implementation rather than your prototype. I note that you aren't (yet?) targeting a NTSD (SecurityDescriptor) yet. This is a good thing to have, it contains the owner, group, DACL and SACL - each of which is optional depending on LDAP server options set before the LDAP query is made. The owner and group are just SIDs, the DACL (Discretionary ACL) is what you normally look at, and the SACL or System ACL is for audit (secret police) type features, normally visible only to domain admins. If you want to read a DACL over LDAP, you need an NTSD parser - and preferably the ability to set the LDAP server options that say not to retrieve the SACL, otherwise you get nothing when not domain admin. SIDs. The SID is made up of: version, top authority, and a number of subAuthorities. The SID as you retrieve it over LDAP will *always* contain slots for 12 sub-auths, so its important to use the count provided, not believe the size. I forget whether it's important to encode all 12 (zero-padded) when composing an LDAP command. The SubAuthorities are encoded as 32-bit RIDs, relative IDs. I found it was useful to provide a "SID Difference" string conversion, so you can pass a Domain SID and a domain name to a SID, and the returned string contains -RID - nice when printing messages containing SIDs. I also provided constant SIDs for: Null = S-1-0-0 World = S-1-1-0 CreatorOwner = S-1-3-0 CreatorGroup = S-1-3-1 AuthenticatedUsers = S-1-5-11 SYSTEM = S-1-5-18 BuiltinAdministrators = S-1-5-32-0x220 (or S-1-5-32-544) BuiltinUsers = S-1-5-32-0x221 (or S-1-5-32-545) EnterpriseDomainControllers (S-1-5-9) I also provided a constant RID for the DomainControllers group and there are others of these. BTW, a new AD domain database is created by merely cloning and tweaking a template one, but the fixed values are defined in Microsoft documentation so should be stable. The need for all these reflect my focus on ActiveDirectory, but they (and probably others I didn't need!) have constant values, they're nice to have. They also probably obviate the need for your SidType enumeration. The "domain the SID is on" is just the SID with the last RID removed, but you probably knew that. You should provided accessors for get/set using the string form and by cloning a SID and adding or removing a RID. A subset operator is useful (use case-equality === like Class.=== does. Make sure your SID has a hash method - SIDs are useful as hash keys. I don't get why you have any reference to hostnames in the SID class. You need a domain and a host lookup that returns SIDs for those names, and that is done using an LDAP query - or call a system DLL to do it for you... but it's less reliable and slower... preferable to do the lookup yourself I believe. The ADSI DLL is an utter crock of shit collected from all the worst corners of Microsoft, is slow, buggy and feature-lacking. Much better to just do what it does and completely ignore it. In general, the conversions between SIDs and machine & account names is *not* a security thing, its a user-identity thing that we layered under a Directory::Binding aspect. ACLs. We needed extreme performance in the C version, so implemented iterator methods over the NTSD, rather than walking the whole ACL to build the ACL and all ACEs as separate structures. In Ruby, I suspect walking is better/easier. ACEs. You have most of the same stuff we had - except you forgot the SID! My ACE had the following methods: type() (allow, deny, audit, alarm - the last two are used in SACLs) basicType() (I forget what this did that was different) isAllow() isDeny() flags() mask() (32 bit mask with most of the obvious things like read, write, etc) size() - in bytes, used during unpacking. who() - returns a SID objectGUID() inheritedGUID() - both for ACEs that include such, like custom access rights (we were interested in the ApplyGroupPolicy right). describe() = like ACE#to_s, useful for inspect. flags&0x1 indicates there's an object type GUID. flags()&0x2 indicates there's a inherited object type GUID. You should have constants for all the mask() values - there are a lot and not all are compatible with the others. Also, although you can look up the GUIDs using LDAP queries on the schemaContainer, they're constants, and a little LDAP program to dump them and generate Ruby versions to include wouldn't go amiss. Good luck, and happy Xmas. Clifford Heath, Data Constellation. From djberg96 at gmail.com Sun Dec 21 02:53:56 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 21 Dec 2008 02:53:56 -0500 Subject: [Win32utils-devel] Code formatting with VS 2008? In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB04514ED7@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <6037b70c0812202353v603bbdb3y99e62adad0573a04@mail.gmail.com> On Mon, Dec 1, 2008 at 9:59 PM, Heesob Park wrote: > Hi, > > 2008/12/2 Berger, Daniel : >> Hi everyone, >> >> I see that Visual Studio 2008 Pro has the ability to auto-format code. >> Does anyone know if there's a way to auto-format pre-ansi C code to ANSI >> C? I couldn't find anything, but there's so many options in VS I wasn't >> sure. >> > I doubt VS can convert pre-ansi C to ANSI c. > > But protoize can do it. > > protoize is an optional part of GCC > > Refer to http://gcc.gnu.org/onlinedocs/gcc/Running-Protoize.html Interesting, thanks. Regards, Dan From noreply at rubyforge.org Fri Dec 26 21:48:50 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Dec 2008 21:48:50 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Bugs-23356 ] $?.exitstatus is not set properly Message-ID: <20081227024850.B599618585AB@rubyforge.org> Bugs item #23356, was opened at 2008-12-27 03:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=23356&group_id=85 Category: win32-open3 Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Roman Zawada (zwadar) Assigned to: Nobody (None) Summary: $?.exitstatus is not set properly Initial Comment: Hi, this simple code require "win32/open3" Open3.popen3("svn info") do |stdin, stdout, stderr| puts stdout.read puts stderr.read end puts "OPEN3: "+ $?.exitstatus.to_s system("svn info") puts "SYSTEM: "+ $?.exitstatus.to_s results in following output svn: '.' is not a working copy OPEN3: 0 SYSTEM: 1 Existatuses "generated" by open3 and sytem should be the same. In this case "1", but I'can get from open3 somthing else than 0, so I assume there is a bug. Tested on 1.8.6 (vesion from One click installer) and 1.8.7 under WinXP. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=23356&group_id=85 From noreply at rubyforge.org Mon Dec 29 08:23:59 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 29 Dec 2008 08:23:59 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Support Requests-22149 ] open3 and daemon Message-ID: <20081229132359.249081858283@rubyforge.org> Support Requests item #22149, was opened at 2008-09-24 15:18 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=22149&group_id=85 Category: win32-service Group: None Status: Open Resolution: None Priority: 3 Submitted By: Florian D?tsch (der_flo) Assigned to: Nobody (None) Summary: open3 and daemon Initial Comment: open3 blocks in combination with a daemon. here is the example-code: ################################################################################ require 'win32/open3' require 'win32/daemon' include Win32 ################################################################################ COMPUTER_NAME = 'test' LOGFILE = 'C:\test.txt' PSLOGGEDON_EXE = 'D:\pstools\psloggedon.exe' ################################################################################ class Daemon def service_main while running? # User ermitteln users = [] i, o, e = Open3.popen3("#{PSLOGGEDON_EXE} -l \\#{COMPUTER_NAME}") i.close e.close o.readlines.each do |line| m = /^DOMAINNAME\(.*)$/.match line users << m[1] if m end o.close txt = "#{Time.new.strftime('%d.%m.%Y %H:%M')} - #{users.join(',')}" File.open(LOGFILE, 'a') { |file| file.puts txt } sleep 1 * 60 end end def service_stop exit! end end ################################################################################ Daemon.mainloop ################################################################################ The service/daemon looks for logged in users on a specific host and logs it to a file. The tool psloggedon (http://technet.microsoft.com/de-de/sysinternals/bb897545.aspx ) When not using a service and calling the open3-stuff directly everything is ok. But when starting as a service the psloggedon.exe does not exit. I don't know why and debugging is quite hard. Any ideas? Thanks, der flo ---------------------------------------------------------------------- Comment By: Grzegorz Marsza?ek (graf0) Date: 2008-12-29 13:23 Message: Hello! Maybe problem is that STDIN, STDOUT and STDERR are redirected to NULL when your code runs as service? Just guessing... ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=22149&group_id=85 From noreply at rubyforge.org Wed Dec 31 05:15:00 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Dec 2008 05:15:00 -0500 (EST) Subject: [Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2 Message-ID: <20081231101500.68DDC18585B5@rubyforge.org> Support Requests item #23395, was opened at 2008-12-31 05:15 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=23395&group_id=85 Category: win32-api Group: None Status: Open Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: EnumChildWindows and EnumWindowsProc with win32-api-1.2.2 Initial Comment: My program doesn't work normally with win32-api-1.2.2. There was no problem with win32-api-1.2.0. At EnumChildWindows.call(), lparam in EnumWindowsProc is not correct. # my program require 'win32/api' class SimpleWindow GetWindowText = Win32::API.new('GetWindowText', 'LPI', 'I', 'user32') GetClassName = Win32::API.new('GetClassName', 'LPI', 'I', 'user32') EnumWindows = Win32::API.new('EnumWindows', 'KL', 'L', 'user32') EnumChildWindows = Win32::API.new('EnumChildWindows', 'LKL', 'L', 'user32') EnumWindowsProc = Win32::API::Callback.new('LL', 'I') {|hwnd, lparam| begin block = ObjectSpace._id2ref(lparam) if block.respond_to? :call block.call(SimpleWindow.new(hwnd)) == :break ? 0 : 1 else 0 end rescue warn $! 0 end } TMP = ("\0" * 256).freeze def self.each(&block) EnumWindows.call(EnumWindowsProc, block.__id__) end def initialize(hwnd) @hwnd = hwnd end def each(&block) EnumChildWindows.call(@hwnd, EnumWindowsProc, block.__id__) end def caption tmp = TMP.dup GetWindowText.call(@hwnd, tmp, tmp.size-1) tmp.rstrip end def class_name tmp = TMP.dup len = GetClassName.call(@hwnd, tmp, tmp.size-1) tmp.rstrip end end p Win32::API::VERSION SimpleWindow.each {|win| if win.class_name == 'Shell_TrayWnd' win.each {|cwin| p [cwin.caption, cwin.class_name] } next :break end } ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=23395&group_id=85 From djberg96 at gmail.com Wed Dec 31 06:08:32 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 31 Dec 2008 04:08:32 -0700 Subject: [Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2 In-Reply-To: <20081231101500.68DDC18585B5@rubyforge.org> References: <20081231101500.68DDC18585B5@rubyforge.org> Message-ID: <495B52B0.8060009@gmail.com> Hi, > My program doesn't work normally with win32-api-1.2.2. > There was no problem with win32-api-1.2.0. Yep, he's right. With 1.2.0 I get this: c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.0" ["", "TrayNotifyWnd"] ["4:03 AM", "TrayClockWClass"] ["", "SysPager"] ["Notification Area", "ToolbarWindow32"] ["", "SysPager"] ["System Control Area", "ToolbarWindow32"] ["", "Button"] ["", "ReBarWindow32"] ["Quick Launch", "ToolbarWindow32"] ["Running Applications", "MSTaskSwWClass"] ["Running Applications", "ToolbarWindow32"] With 1.2.2 I get this: c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.2" 0x1ca2b8 is not id value Any ideas? Regards, Dan From phasis at gmail.com Wed Dec 31 09:36:59 2008 From: phasis at gmail.com (Park Heesob) Date: Wed, 31 Dec 2008 23:36:59 +0900 Subject: [Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2 References: <20081231101500.68DDC18585B5@rubyforge.org> <495B52B0.8060009@gmail.com> Message-ID: <4084FF13626D4643814C79663C8401D6@mycomputer> Hi, ----- Original Message ----- From: "Daniel Berger" To: "Development and ideas for win32utils projects" Sent: Wednesday, December 31, 2008 8:08 PM Subject: Re: [Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2 > Hi, > >> My program doesn't work normally with win32-api-1.2.2. >> There was no problem with win32-api-1.2.0. > > > > Yep, he's right. With 1.2.0 I get this: > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb > "1.2.0" > ["", "TrayNotifyWnd"] > ["4:03 AM", "TrayClockWClass"] > ["", "SysPager"] > ["Notification Area", "ToolbarWindow32"] > ["", "SysPager"] > ["System Control Area", "ToolbarWindow32"] > ["", "Button"] > ["", "ReBarWindow32"] > ["Quick Launch", "ToolbarWindow32"] > ["Running Applications", "MSTaskSwWClass"] > ["Running Applications", "ToolbarWindow32"] > > With 1.2.2 I get this: > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb > "1.2.2" > 0x1ca2b8 is not id value > > Any ideas? > Sorry. It is a bug due to my modification of callback support. Here is the patch for api.c ============================================== @@ -671,6 +671,7 @@ Win32API* ptr; unsigned long return_value; int i = 0; + int len; struct{ unsigned long params[20]; @@ -695,8 +696,8 @@ ); } } - - for(i = 0; i < RARRAY(v_proto)->len; i++){ + len = RARRAY(v_proto)->len; + for(i = 0; i < len; i++){ v_arg = RARRAY(v_args)->ptr[i]; /* Convert nil to NULL. Otherwise convert as appropriate. */ ================================================== Happy New Year! Regards, Park Heesob From Daniel.Berger at qwest.com Wed Dec 31 12:24:19 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 31 Dec 2008 11:24:19 -0600 Subject: [Win32utils-devel] [ win32utils-Support Requests-23395] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2 In-Reply-To: <4084FF13626D4643814C79663C8401D6@mycomputer> References: <20081231101500.68DDC18585B5@rubyforge.org><495B52B0.8060009@gmail.com> <4084FF13626D4643814C79663C8401D6@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514F35@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, December 31, 2008 7:37 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] [ win32utils-Support > Requests-23395] EnumChildWindows and EnumWindowsProc with > win32-api-1.2.2 > > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "Development and ideas for win32utils projects" > > Sent: Wednesday, December 31, 2008 8:08 PM > Subject: Re: [Win32utils-devel] [ win32utils-Support > Requests-23395 ] EnumChildWindows and EnumWindowsProc with > win32-api-1.2.2 > > > > Hi, > > > >> My program doesn't work normally with win32-api-1.2.2. > >> There was no problem with win32-api-1.2.0. > > > > > > > > Yep, he's right. With 1.2.0 I get this: > > > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.0" > > ["", "TrayNotifyWnd"] > > ["4:03 AM", "TrayClockWClass"] > > ["", "SysPager"] > > ["Notification Area", "ToolbarWindow32"] ["", "SysPager"] ["System > > Control Area", "ToolbarWindow32"] ["", "Button"] ["", > "ReBarWindow32"] > > ["Quick Launch", "ToolbarWindow32"] ["Running Applications", > > "MSTaskSwWClass"] ["Running Applications", "ToolbarWindow32"] > > > > With 1.2.2 I get this: > > > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.2" > > 0x1ca2b8 is not id value > > > > Any ideas? > > > Sorry. It is a bug due to my modification of callback support. > Here is the patch for api.c > ============================================== > @@ -671,6 +671,7 @@ > Win32API* ptr; > unsigned long return_value; > int i = 0; > + int len; > > struct{ > unsigned long params[20]; > @@ -695,8 +696,8 @@ > ); > } > } > - > - for(i = 0; i < RARRAY(v_proto)->len; i++){ > + len = RARRAY(v_proto)->len; > + for(i = 0; i < len; i++){ > v_arg = RARRAY(v_args)->ptr[i]; > > /* Convert nil to NULL. Otherwise convert as > appropriate. */ ================================================== > > Happy New Year! Yep, that worked, thanks. Committed to CVS. Happy New Year to you, too! 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.