Any ideas? ---------- Forwarded message ---------- From: Christian Kerth <christian.ke... at dynamicmedia.at> Date: Dec 5, 8:28 am Subject: win32/process problem To: comp.lang.ruby I have an application that consists of serveral independent parts. I want to use the Windows Process API to spawn the different processes. e.g. require ''rubygems'' require ''win32/process'' x = Process.create(:app_name => "rubyw learnbase_server.rb") puts x.process_id puts a process id, but i get the error: [BUG] Segmentation fault. Not even x = Process.create(:app_name => "notepad") works. It starts notepad, but i get the same error. -- Posted viahttp://www.ruby-forum.com/.
Hi, 2007/12/6, Daniel Berger <djberg96 at gmail.com>:> > Any ideas? > > > ---------- Forwarded message ---------- > From: Christian Kerth <christian.ke... at dynamicmedia.at> > Date: Dec 5, 8:28 am > Subject: win32/process problem > To: comp.lang.ruby > > > I have an application that consists of serveral independent parts. > > I want to use the Windows Process API to spawn the different > processes. > > e.g. > > require ''rubygems'' > require ''win32/process'' > > x = Process.create(:app_name => "rubyw learnbase_server.rb") > > puts x.process_id > > puts a process id, but i get the error: [BUG] Segmentation fault. > > Not even x = Process.create(:app_name => "notepad") works. It starts > notepad, but i get the same error.We need more information. What is the OS, Ruby version and win32-process version? What result of "p x" ? x = Process.create(:app_name => "notepad") p x Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071206/e53b4b8d/attachment-0001.html
2007/12/6, Daniel Berger <djberg96 at gmail.com>:> > Any ideas? > > > ---------- Forwarded message ---------- > From: Christian Kerth <christian.ke... at dynamicmedia.at> > Date: Dec 5, 8:28 am > Subject: win32/process problem > To: comp.lang.ruby > > > I have an application that consists of serveral independent parts. > > I want to use the Windows Process API to spawn the different > processes. > > e.g. > > require ''rubygems'' > require ''win32/process'' > > x = Process.create(:app_name => "rubyw learnbase_server.rb") > > puts x.process_id > > puts a process id, but i get the error: [BUG] Segmentation fault. > > Not even x = Process.create(:app_name => "notepad") works. It starts > notepad, but i get the same error. > -- > Posted viahttp://www.ruby-forum.com/.Though it is doubtful whether this is the cause or not, Insert flowing two lines before ProcessInfo.new (line #409 of process.rb) might be helpful. CloseHandle(procinfo[8,4].unpack(''L'').first) CloseHandle(procinfo[12,4].unpack(''L'').first) Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071206/0e9c07f7/attachment.html
Heesob Park wrote: <snip>> Though it is doubtful whether this is the cause or not, > Insert flowing two lines before ProcessInfo.new (line #409 of > process.rb) might be helpful. > > CloseHandle(procinfo[8,4].unpack(''L'').first) > CloseHandle(procinfo[12,4].unpack(''L'').first)I''m somewhat afraid to do that, because I can''t be sure other people aren''t using the process handle afterwards. At the very least I should document that, however. Hmm, let me mull it over. The good news is that his problem was fixed after upgrading the gem. Thanks, Dan
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Daniel Berger > Sent: Thursday, December 06, 2007 5:18 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Fwd: win32/process problem > > Heesob Park wrote: > > <snip> > > > Though it is doubtful whether this is the cause or not, > Insert flowing > > two lines before ProcessInfo.new (line #409 of > > process.rb) might be helpful. > > > > CloseHandle(procinfo[8,4].unpack(''L'').first) > > CloseHandle(procinfo[12,4].unpack(''L'').first) > > I''m somewhat afraid to do that, because I can''t be sure other > people aren''t using the process handle afterwards. > > At the very least I should document that, however. Hmm, let > me mull it over.Ok, what if we add a "close_handles" option to Process.create? If set to true (the default), we''ll close the handles automatically before returning from the method. Users could explicitly set it to false if they want to keep the handles open. Seem reasonable? 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.
Hi, 2007/12/7, Berger, Daniel <Daniel.Berger at qwest.com>:> > -----Original Message----- > > From: win32utils-devel-bounces at rubyforge.org > > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > > Daniel Berger > > Sent: Thursday, December 06, 2007 5:18 AM > > To: Development and ideas for win32utils projects > > Subject: Re: [Win32utils-devel] Fwd: win32/process problem > > > > Heesob Park wrote: > > > > <snip> > > > > > Though it is doubtful whether this is the cause or not, > > Insert flowing > > > two lines before ProcessInfo.new (line #409 of > > > process.rb) might be helpful. > > > > > > CloseHandle(procinfo[8,4].unpack(''L'').first) > > > CloseHandle(procinfo[12,4].unpack(''L'').first) > > > > I''m somewhat afraid to do that, because I can''t be sure other > > people aren''t using the process handle afterwards. > > > > At the very least I should document that, however. Hmm, let > > me mull it over. > > Ok, what if we add a "close_handles" option to Process.create? If set to > true (the default), we''ll close the handles automatically before > returning from the method. Users could explicitly set it to false if > they want to keep the handles open. > > Seem reasonable?Yes, it seems reasonable. BTW, how about your thought about supporting Process.create as a different user with CreateProcessWithLoginW API ?> DanRegards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071207/ab172b70/attachment.html
Heesob Park wrote:> Hi, > > 2007/12/7, Berger, Daniel <Daniel.Berger at qwest.com > <mailto:Daniel.Berger at qwest.com>>: > > > -----Original Message----- > > From: win32utils-devel-bounces at rubyforge.org > <mailto:win32utils-devel-bounces at rubyforge.org> > > [mailto:win32utils-devel-bounces at rubyforge.org > <mailto:win32utils-devel-bounces at rubyforge.org>] On Behalf Of > > Daniel Berger > > Sent: Thursday, December 06, 2007 5:18 AM > > To: Development and ideas for win32utils projects > > Subject: Re: [Win32utils-devel] Fwd: win32/process problem > > > > Heesob Park wrote: > > > > <snip> > > > > > Though it is doubtful whether this is the cause or not, > > Insert flowing > > > two lines before ProcessInfo.new (line #409 of > > > process.rb) might be helpful. > > > > > > CloseHandle(procinfo[8,4].unpack(''L'').first) > > > CloseHandle(procinfo[12,4].unpack(''L'').first) > > > > I''m somewhat afraid to do that, because I can''t be sure other > > people aren''t using the process handle afterwards. > > > > At the very least I should document that, however. Hmm, let > > me mull it over. > > Ok, what if we add a "close_handles" option to Process.create? If set to > true (the default), we''ll close the handles automatically before > returning from the method. Users could explicitly set it to false if > they want to keep the handles open. > > Seem reasonable? > > > Yes, it seems reasonable. > > BTW, how about your thought about supporting Process.create as > a different user with CreateProcessWithLoginW API ?I think it''s a good idea. Let''s add a "with_logon" option as well. If set, it will call CreateProcessWithLoginW behind the scenes. Any chance I could get you to patch win32-eventlog to handle the other message files so I can work on this instead this weekend? BTW, I''ve made a couple minor commits since 0.4.6, so you''ll want to grab the latest from CVS (there were some bugs in a few error messages). Thanks, Dan
Hi, ----- Original Message ----- From: "Daniel Berger" <djberg96 at gmail.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Friday, December 07, 2007 11:24 AM Subject: Re: [Win32utils-devel] Fwd: win32/process problem> Heesob Park wrote: >> Hi, >> >> 2007/12/7, Berger, Daniel <Daniel.Berger at qwest.com >> <mailto:Daniel.Berger at qwest.com>>: >> >> > -----Original Message----- >> > From: win32utils-devel-bounces at rubyforge.org >> <mailto:win32utils-devel-bounces at rubyforge.org> >> > [mailto:win32utils-devel-bounces at rubyforge.org >> <mailto:win32utils-devel-bounces at rubyforge.org>] On Behalf Of >> > Daniel Berger >> > Sent: Thursday, December 06, 2007 5:18 AM >> > To: Development and ideas for win32utils projects >> > Subject: Re: [Win32utils-devel] Fwd: win32/process problem >> > >> > Heesob Park wrote: >> > >> > <snip> >> > >> > > Though it is doubtful whether this is the cause or not, >> > Insert flowing >> > > two lines before ProcessInfo.new (line #409 of >> > > process.rb) might be helpful. >> > > >> > > CloseHandle(procinfo[8,4].unpack(''L'').first) >> > > CloseHandle(procinfo[12,4].unpack(''L'').first) >> > >> > I''m somewhat afraid to do that, because I can''t be sure other >> > people aren''t using the process handle afterwards. >> > >> > At the very least I should document that, however. Hmm, let >> > me mull it over. >> >> Ok, what if we add a "close_handles" option to Process.create? If set to >> true (the default), we''ll close the handles automatically before >> returning from the method. Users could explicitly set it to false if >> they want to keep the handles open. >> >> Seem reasonable? >> >> >> Yes, it seems reasonable. >> >> BTW, how about your thought about supporting Process.create as >> a different user with CreateProcessWithLoginW API ? > > I think it''s a good idea. Let''s add a "with_logon" option as well. If > set, it will call CreateProcessWithLoginW behind the scenes. > > Any chance I could get you to patch win32-eventlog to handle the other > message files so I can work on this instead this weekend? BTW, I''ve made > a couple minor commits since 0.4.6, so you''ll want to grab the latest > from CVS (there were some bugs in a few error messages). >First of all, I implemented the ParameterMessage formatting routine. You can test it with the botp_sample_dmpi_security_log_2007_nov_27.evt file attached a few days ago. Here is get_description method code: def get_description(rec, event_source, lkey) str = rec[rec[36,4].unpack(''L'')[0] .. -1] num = rec[26,2].unpack(''S'')[0] # NumStrings hkey = [0].pack(''L'') key = BASE_KEY + "#{@source}\\#{event_source}" buf = 0.chr * 8192 va_list0 = (num == 0) ? [] : str.unpack(''Z*'' * num) if RegOpenKeyEx(lkey, key, 0, KEY_READ, hkey) == 0 value = ''ParameterMessageFile'' file = 0.chr * MAX_SIZE hkey = hkey.unpack(''L'')[0] size = [file.length].pack(''L'') if RegQueryValueEx(hkey, value, 0, 0, file, size) == 0 file = file.nstrip exe = 0.chr * MAX_SIZE ExpandEnvironmentStrings(file, exe, exe.size) exe = exe.nstrip va_list = va_list0.map{|v| va = v v.scan(/%%(\d+)/).uniq.each {|x| exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, hmodule, x.first.to_i, 0, buf, buf.size, v ) FreeLibrary(hmodule) break if buf.nstrip != "" end } va = va.gsub("%%#{x.first}",buf.nstrip) } va } end value = ''EventMessageFile'' file = 0.chr * MAX_SIZE size = [file.length].pack(''L'') if RegQueryValueEx(hkey, value, 0, 0, file, size) == 0 file = file.nstrip exe = 0.chr * MAX_SIZE ExpandEnvironmentStrings(file, exe, exe.size) exe = exe.nstrip # Try to retrieve message *without* expanding the inserts yet exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) event_id = rec[20,4].unpack(''L'')[0] if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, hmodule, event_id, 0, buf, buf.size, nil ) FreeLibrary(hmodule) break if buf.nstrip != "" # All messages read end } # Determine higest %n insert number max_insert = [num,buf.nstrip.scan(/%(\d+)/).map{|x|x[0].to_i}.max].compact.max # Insert dummy strings for not provided by caller */ ((num+1)..(max_insert)).each {|x|va_list.push("%#{x}")} if va_list.length== 0 va_list_ptr = 0.chr * 4 else va_list_ptr = va_list.map{ |x| [x + 0.chr].pack(''P'').unpack(''L'')[0] }.pack(''L*'') end exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) event_id = rec[20,4].unpack(''L'')[0] if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, hmodule, event_id, 0, buf, buf.size, va_list_ptr ) FreeLibrary(hmodule) break if buf.nstrip != "" # All messages read end } end RegCloseKey(hkey) end [va_list0, buf.strip] end Regards, Park Heesob
Hi, Park Heesob wrote: <snip>> First of all, I implemented the ParameterMessage formatting routine. > You can test it with the botp_sample_dmpi_security_log_2007_nov_27.evt file attached a few days ago. > Here is get_description method code:I tried your code but I got this error when I tried to read the Application log: eventlog.rb:846:in `get_description'': undefined method `length'' for nil:NilClass (NoMethodError) I haven''t dug further yet. Regards, Dan
Whoops, forgot to include the line that fails: if va_list.length == 0 So, for some reason va_list isn''t set. Dan
Hi, 2007/12/9, Daniel Berger <djberg96 at gmail.com>:> > Whoops, forgot to include the line that fails: > > if va_list.length == 0 > > So, for some reason va_list isn''t set. > > DanDid you modified my code? I did''nt use va_list.length. but I had omitted initializing va_list . Here is the corrent code: def get_description(rec, event_source, lkey) str = rec[rec[36,4].unpack(''L'')[0] .. -1] num = rec[26,2].unpack(''S'')[0] # NumStrings hkey = [0].pack(''L'') key = BASE_KEY + "#{@source}\\#{event_source}" buf = 0.chr * 8192 va_list = va_list0 = (num == 0) ? [] : str.unpack(''Z*'' * num) if RegOpenKeyEx(lkey, key, 0, KEY_READ, hkey) == 0 value = ''ParameterMessageFile'' file = 0.chr * MAX_SIZE hkey = hkey.unpack(''L'')[0] size = [file.length].pack(''L'') if RegQueryValueEx(hkey, value, 0, 0, file, size) == 0 file = file.nstrip exe = 0.chr * MAX_SIZE ExpandEnvironmentStrings(file, exe, exe.size) exe = exe.nstrip va_list = va_list0.map{|v| va = v v.scan(/%%(\d+)/).uniq.each {|x| exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, hmodule, x.first.to_i, 0, buf, buf.size, v ) FreeLibrary(hmodule) break if buf.nstrip != "" end } va = va.gsub("%%#{x.first}",buf.nstrip) } va } end value = ''EventMessageFile'' file = 0.chr * MAX_SIZE size = [file.length].pack(''L'') if RegQueryValueEx(hkey, value, 0, 0, file, size) == 0 file = file.nstrip exe = 0.chr * MAX_SIZE ExpandEnvironmentStrings(file, exe, exe.size) exe = exe.nstrip # Try to retrieve message *without* expanding the inserts yet exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) event_id = rec[20,4].unpack(''L'')[0] if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, hmodule, event_id, 0, buf, buf.size, nil ) FreeLibrary(hmodule) break if buf.nstrip != "" # All messages read end } # Determine higest %n insert number max_insert = [num,buf.nstrip.scan (/%(\d+)/).map{|x|x[0].to_i}.max].compact.max # Insert dummy strings for not provided by caller */ ((num+1)..(max_insert)).each {|x|va_list.push("%#{x}")} if num == 0 va_list_ptr = 0.chr * 4 else va_list_ptr = va_list.map{ |x| [x + 0.chr].pack(''P'').unpack(''L'')[0] }.pack(''L*'') end exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) event_id = rec[20,4].unpack(''L'')[0] if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, hmodule, event_id, 0, buf, buf.size, va_list_ptr ) FreeLibrary(hmodule) break if buf.nstrip != "" # All messages read end } end RegCloseKey(hkey) end [va_list0, buf.strip] end Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071209/dd959694/attachment-0001.html
2007/12/7, Daniel Berger <djberg96 at gmail.com>:> > Heesob Park wrote: > > Hi, > > > > 2007/12/7, Berger, Daniel <Daniel.Berger at qwest.com > > <mailto:Daniel.Berger at qwest.com>>: > > > > > -----Original Message----- > > > From: win32utils-devel-bounces at rubyforge.org > > <mailto:win32utils-devel-bounces at rubyforge.org> > > > [mailto:win32utils-devel-bounces at rubyforge.org > > <mailto:win32utils-devel-bounces at rubyforge.org>] On Behalf Of > > > Daniel Berger > > > Sent: Thursday, December 06, 2007 5:18 AM > > > To: Development and ideas for win32utils projects > > > Subject: Re: [Win32utils-devel] Fwd: win32/process problem > > > > > > Heesob Park wrote: > > > > > > <snip> > > > > > > > Though it is doubtful whether this is the cause or not, > > > Insert flowing > > > > two lines before ProcessInfo.new (line #409 of > > > > process.rb) might be helpful. > > > > > > > > CloseHandle(procinfo[8,4].unpack(''L'').first) > > > > CloseHandle(procinfo[12,4].unpack(''L'').first) > > > > > > I''m somewhat afraid to do that, because I can''t be sure other > > > people aren''t using the process handle afterwards. > > > > > > At the very least I should document that, however. Hmm, let > > > me mull it over. > > > > Ok, what if we add a "close_handles" option to Process.create? If > set to > > true (the default), we''ll close the handles automatically before > > returning from the method. Users could explicitly set it to false if > > they want to keep the handles open. > > > > Seem reasonable? > > > > > > Yes, it seems reasonable. > > > > BTW, how about your thought about supporting Process.create as > > a different user with CreateProcessWithLoginW API ? > > I think it''s a good idea. Let''s add a "with_logon" option as well. If > set, it will call CreateProcessWithLoginW behind the scenes.Here is the snippet for CreateProcessWithLogonW if hash[''user''].nil? bool = CreateProcess( nil, # App name hash[''app_name''], # Command line process_security, # Process attributes thread_security, # Thread attributes hash[''inherit''], # Inherit handles? hash[''creation_flags''], # Creation flags env, # Environment hash[''cwd''], # Working directory startinfo, # Startup Info procinfo # Process Info ) else logon_flags = 0x1 # LOGON_WITH_PROFILE bool = CreateProcessWithLogonW( multi_to_wide(hash[''user'']), # User name multi_to_wide(hash[''domain'']), # Domain name multi_to_wide(hash[''password'']), # Password logon_flags, # Logon flags nil, # App name multi_to_wide(hash[''app_name'']), # Command line hash[''creation_flags''], # Creation flags env, # Environment multi_to_wide(hash[''cwd'']), # Working directory startinfo, # Startup Info procinfo # Process Info ) end CreateProcessWithLogonW is defined as API.new(''CreateProcessWithLogonW'', ''PPPLPPLLPPP'', ''B'', ''advapi32'') and called like this x = Process.create(:app_name => "notepad",:user=>''user'',:password=>''pass'') Regards, Park Heeosb -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071209/42ad8bef/attachment.html
Heesob Park wrote:> Hi, > > 2007/12/9, Daniel Berger <djberg96 at gmail.com <mailto:djberg96 at gmail.com>>: > > Whoops, forgot to include the line that fails: > > if va_list.length == 0 > > So, for some reason va_list isn''t set. > > Dan > > > Did you modified my code? > I did''nt use va_list.length. but I had omitted initializing va_list . > Here is the corrent code:<snip> Ok, there''s good news and bad news. First the good news - this definitely picks up some descriptions we were missing before (specifically Winlogon events). Awesome. But there''s some bad news. I sent the eventlog descriptions to a file using the original code and your code and found some discrepancies using diff. First, now I''m seeing literal parameter strings where I would expect data. For example: Security Configuration (OFF = 0 and ON = 1): - Network Administration of Transactions = 0, - Network Clients = 0, - Inbound Distributed Transactions using Native MSDTC Protocol = 0, - Outbound Distributed Transactions using Native MSDTC Protocol = 0, - Transaction Internet Protocol (TIP) = 0, - XA Transactions = 0 + Network Administration of Transactions = %1, + Network Clients = %2, + Inbound Distributed Transactions using Native MSDTC Protocol = %3, + Outbound Distributed Transactions using Native MSDTC Protocol = %4, + Transaction Internet Protocol (TIP) = %5, + XA Transactions = %6 Second, in rare cases I''m seeing some junk characters in the description: -Product: Nero 7 Ultra Edition -- Installation completed successfully. +`???`??? Nero 7 Ultra Edition -- Installation completed successfully. Last (and least), it looks it''s picking up blank lines at the end. Nothing serious but it didn''t do that before: -The Windows Installer initiated a system restart to complete or continue the configuration of ''''. +The Windows Installer initiated a system restart to complete or continue the configuration of ''''. + I''ve attached my (zipped) application so you can play with it. Regards, Dan -------------- next part -------------- A non-text attachment was scrubbed... Name: dan_app.zip Type: application/x-zip-compressed Size: 44212 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20071208/8b143417/attachment-0001.bin
2007/12/9, Daniel Berger <djberg96 at gmail.com>:> > Heesob Park wrote: > > Hi, > > > > 2007/12/9, Daniel Berger <djberg96 at gmail.com <mailto:djberg96 at gmail.com > >>: > > > > Whoops, forgot to include the line that fails: > > > > if va_list.length == 0 > > > > So, for some reason va_list isn''t set. > > > > Dan > > > > > > Did you modified my code? > > I did''nt use va_list.length. but I had omitted initializing va_list . > > Here is the corrent code: > > <snip> > > Ok, there''s good news and bad news. First the good news - this > definitely picks up some descriptions we were missing before > (specifically Winlogon events). Awesome. > > But there''s some bad news. I sent the eventlog descriptions to a file > using the original code and your code and found some discrepancies using > diff. > > First, now I''m seeing literal parameter strings where I would expect > data. For example: > > Security Configuration (OFF = 0 and ON = 1): > - Network Administration of Transactions = 0, > - Network Clients = 0, > - Inbound Distributed Transactions using Native MSDTC Protocol = 0, > - Outbound Distributed Transactions using Native MSDTC Protocol = 0, > - Transaction Internet Protocol (TIP) = 0, > - XA Transactions = 0 > + Network Administration of Transactions = %1, > + Network Clients = %2, > + Inbound Distributed Transactions using Native MSDTC Protocol = %3, > + Outbound Distributed Transactions using Native MSDTC Protocol = %4, > + Transaction Internet Protocol (TIP) = %5, > + XA Transactions = %6 > > Second, in rare cases I''m seeing some junk characters in the description: > > -Product: Nero 7 Ultra Edition -- Installation completed successfully. > +`???`??? Nero 7 Ultra Edition -- Installation completed successfully. > > Last (and least), it looks it''s picking up blank lines at the end. > Nothing serious but it didn''t do that before: > > -The Windows Installer initiated a system restart to complete or > continue the configuration of ''''. > +The Windows Installer initiated a system restart to complete or > continue the configuration of ''''. > + > > I''ve attached my (zipped) application so you can play with it. > > Regards, > > DanOk, I saw it. Reinitializing buf after the first formatting like this works fine for me: # Try to retrieve message *without* expanding the inserts yet exe.split('';'').each{ |file| hmodule = LoadLibraryEx(file, 0, DONT_RESOLVE_DLL_REFERENCES) event_id = rec[20,4].unpack(''L'')[0] if hmodule != 0 FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, hmodule, event_id, 0, buf, buf.size, nil ) FreeLibrary(hmodule) break if buf.nstrip != "" # All messages read end } buf = 0.chr * 8192 # Reinitialize buf Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071209/d6e45eb8/attachment.html
Heesob Park wrote: <snip>> Ok, I saw it. > Reinitializing buf after the first formatting like this works fine for me: > > # Try to retrieve message *without* expanding the inserts > yet > exe.split('';'').each{ |file| > hmodule = LoadLibraryEx(file, 0, > DONT_RESOLVE_DLL_REFERENCES) > event_id = rec[20,4].unpack(''L'')[0] > if hmodule != 0 > FormatMessage( > FORMAT_MESSAGE_FROM_HMODULE | > FORMAT_MESSAGE_IGNORE_INSERTS, > hmodule, > event_id, > 0, > buf, > buf.size, > nil > ) > > FreeLibrary(hmodule) > break if buf.nstrip != "" # All messages read > end > } > > buf = 0.chr * 8192 # Reinitialize bufExcellent, that worked, thanks! I''ll put out 0.4.7 tonight. Regards, Dan
Heesob Park wrote: <snip>> > BTW, how about your thought about supporting Process.create as > > a different user with CreateProcessWithLoginW API ? > > I think it''s a good idea. Let''s add a "with_logon" option as well. If > set, it will call CreateProcessWithLoginW behind the scenes. > > > Here is the snippet for CreateProcessWithLogonW > > if hash[''user''].nil? > bool = CreateProcess( > nil, # App name > hash[''app_name''], # Command line > process_security, # Process attributes > thread_security, # Thread attributes > hash[''inherit''], # Inherit handles? > hash[''creation_flags''], # Creation flags > env, # Environment > hash[''cwd''], # Working directory > startinfo, # Startup Info > procinfo # Process Info > ) > else > logon_flags = 0x1 # LOGON_WITH_PROFILE > bool = CreateProcessWithLogonW( > multi_to_wide(hash[''user'']), # User name > multi_to_wide(hash[''domain'']), # Domain name > multi_to_wide(hash[''password'']), # Password > logon_flags, # Logon flags > nil, # App name > multi_to_wide(hash[''app_name'']), # Command line > hash[''creation_flags''], # Creation flags > env, # Environment > multi_to_wide(hash[''cwd'']), # Working directory > startinfo, # Startup Info > procinfo # Process Info > ) > > end > > CreateProcessWithLogonW is defined as > API.new(''CreateProcessWithLogonW'', ''PPPLPPLLPPP'', ''B'', ''advapi32'') > and called like this > x = Process.create(:app_name => "notepad",:user=>''user'',:password=>''pass'')I modified what you provided slightly and committed to CVS. I had to make an adjustment to wide_to_multi and multi_to_wide in the Windows::Unicode module so that they return nil if the argument is nil instead of segfaulting. After I made those changes I tried this: struct = Process.create( :app_name => ''notepad.exe'', :creation_flags => Process::DETACHED_PROCESS, :process_inherit => false, :thread_inherit => true, :cwd => "C:\\", :inherit => true, :environment => "SYSTEMROOT=#{ENV[''SYSTEMROOT'']};PATH=C:\\", :with_logon => ''some_local_account'', :domain => ''MYDOMAIN'', :password => ''xxxx'' ) p struct However, I couldn''t make this work. I always get a "parameter is incorrect" error. I know I''ve got the right logon and password. The domain my local domain, which the Sys::Admin library confirms. Any ideas? You may want to take a look at multi_to_wide just to make sure I didn''t break it, btw. Regards, Dan
Hi, 2007/12/11, Daniel Berger <djberg96 at gmail.com>:> Heesob Park wrote: > > <snip> > > I modified what you provided slightly and committed to CVS. I had to > make an adjustment to wide_to_multi and multi_to_wide in the > Windows::Unicode module so that they return nil if the argument is nil > instead of segfaulting. > > After I made those changes I tried this: > > struct = Process.create( > :app_name => ''notepad.exe'', > :creation_flags => Process::DETACHED_PROCESS, > :process_inherit => false, > :thread_inherit => true, > :cwd => "C:\\", > :inherit => true, > :environment => "SYSTEMROOT=#{ENV[''SYSTEMROOT'']};PATH=C:\\", > :with_logon => ''some_local_account'', > :domain => ''MYDOMAIN'', > :password => ''xxxx'' > ) > > p structThe creation flag is not correct. It must be combination of following constant: CREATE_DEFAULT_ERROR_MODE 0x04000000 CREATE_NEW_CONSOLE 0x00000010 CREATE_NEW_PROCESS_GROUP 0x00000200 CREATE_SEPARATE_WOW_VDM 0x00000800 CREATE_SUSPENDED 0x00000004 CREATE_UNICODE_ENVIRONMENT 0x00000400 EXTENDED_STARTUPINFO_PRESENT 0x00080000 After modify the env to unicode and set create_flag to CREATE_UNICODE_ENVIRONMENT like this if hash[''with_logon''] logon = multi_to_wide(hash[''with_logon'']) domain = multi_to_wide(hash[''domain'']) app = multi_to_wide(hash[''app_name'']) cwd = multi_to_wide(hash[''cwd'']) passwd = multi_to_wide(hash[''password'']) if hash[''environment''] env = hash[''environment''].split(File::PATH_SEPARATOR) << 0.chr env = env.map{|x|multi_to_wide(x)} env = [env.join("\0\0")].pack(''p*'').unpack(''L'').first else env = nil end hash[''creation_flags''] |= CREATE_UNICODE_ENVIRONMENT # 0x00000400 bool = CreateProcessWithLogonW( logon, # User domain, # Domain passwd, # Password LOGON_WITH_PROFILE, # Logon flags nil, # App name app, # Command line hash[''creation_flags''], # Creation flags env, # Environment cwd, # Working directory startinfo, # Startup Info procinfo # Process Info ) else And call like this struct = Process.create( :app_name => ''notepad.exe'', :creation_flags => CREATE_NEW_CONSOLE, # 0x00000010 :process_inherit => false, :thread_inherit => true, :cwd => "C:\\", :inherit => true, :environment => "SYSTEMROOT=#{ENV[''SYSTEMROOT'']};PATH=C:\\", :with_logon => ''some_local_account'', :domain => ''MYDOMAIN'', :password => ''xxxx'' ) work fine for me.> However, I couldn''t make this work. I always get a "parameter is > incorrect" error. I know I''ve got the right logon and password. The > domain my local domain, which the Sys::Admin library confirms. > > Any ideas? You may want to take a look at multi_to_wide just to make > sure I didn''t break it, btw. > > Regards, > > DanRegards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071211/e1a04f58/attachment-0001.html
Heesob Park wrote:> Hi, > > 2007/12/11, Daniel Berger <djberg96 at gmail.com <mailto:djberg96 at gmail.com>>: > > Heesob Park wrote: > > <snip> > > I modified what you provided slightly and committed to CVS. I had to > make an adjustment to wide_to_multi and multi_to_wide in the > Windows::Unicode module so that they return nil if the argument is nil > instead of segfaulting. > > After I made those changes I tried this: > > struct = Process.create( > :app_name => ''notepad.exe'', > :creation_flags => Process::DETACHED_PROCESS, > :process_inherit => false, > :thread_inherit => true, > :cwd => "C:\\", > :inherit => true, > :environment => "SYSTEMROOT=#{ENV[''SYSTEMROOT'']};PATH=C:\\", > :with_logon => ''some_local_account'', > :domain => ''MYDOMAIN'', > :password => ''xxxx'' > ) > > p struct > > > The creation flag is not correct. > It must be combination of following constant: > > CREATE_DEFAULT_ERROR_MODE > 0x04000000 > > CREATE_NEW_CONSOLE > 0x00000010 > > CREATE_NEW_PROCESS_GROUP > 0x00000200 > > CREATE_SEPARATE_WOW_VDM > 0x00000800 > > CREATE_SUSPENDED > 0x00000004 > > CREATE_UNICODE_ENVIRONMENT > 0x00000400 > > EXTENDED_STARTUPINFO_PRESENT > 0x00080000 > > After modify the env to unicode and set create_flag to > CREATE_UNICODE_ENVIRONMENT like this > > > if hash[''with_logon''] > logon = multi_to_wide(hash[''with_logon'']) > domain = multi_to_wide(hash[''domain'']) > app = multi_to_wide(hash[''app_name'']) > cwd = multi_to_wide(hash[''cwd'']) > passwd = multi_to_wide(hash[''password'']) > if hash[''environment''] > env = hash[''environment''].split(File::PATH_SEPARATOR) << 0.chr > env = env.map{|x|multi_to_wide(x)} > env = [env.join("\0\0")].pack(''p*'').unpack(''L'').first > else > env = nil > end > hash[''creation_flags''] |= CREATE_UNICODE_ENVIRONMENT # 0x00000400 > > bool = CreateProcessWithLogonW( > logon, # User > domain, # Domain > passwd, # Password > LOGON_WITH_PROFILE, # Logon flags > nil, # App name > app, # Command line > hash[''creation_flags''], # Creation flags > env, # Environment > cwd, # Working directory > startinfo, # Startup Info > procinfo # Process Info > ) > else > > And call like this > > struct = Process.create( > :app_name => ''notepad.exe'', > :creation_flags => CREATE_NEW_CONSOLE, # 0x00000010 > :process_inherit => false, > :thread_inherit => true, > :cwd => "C:\\", > :inherit => true, > :environment => "SYSTEMROOT=#{ENV[''SYSTEMROOT'']};PATH=C:\\", > :with_logon => ''some_local_account'', > :domain => ''MYDOMAIN'', > :password => ''xxxx'' > ) > > work fine for me.Ok, I made the changes you suggested (in slightly different places, but you''ll see the changes), but I still couldn''t make it work. It could just be me, though. Please check out the latest from CVS and see if it works for you. Thanks, Dan Please checkout the lates
Hi, 2007/12/11, Daniel Berger <djberg96 at gmail.com>:> > Heesob Park wrote: > > Hi, > > > > 2007/12/11, Daniel Berger <djberg96 at gmail.com <mailto:djberg96 at gmail.com > >>: > > > > Heesob Park wrote: > > > > <snip> > > > > Ok, I made the changes you suggested (in slightly different places, but > you''ll see the changes), but I still couldn''t make it work. It could > just be me, though. > > Please check out the latest from CVS and see if it works for you.Thanks,> > DanThe lastest CVS code works fine on my WinXP Prof. What''s your result? any error message? or just nothing? Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071211/d2601a38/attachment.html
Heesob Park wrote:> Hi, > > 2007/12/11, Daniel Berger <djberg96 at gmail.com <mailto:djberg96 at gmail.com>>: > > Heesob Park wrote: > > Hi, > > > > 2007/12/11, Daniel Berger < djberg96 at gmail.com > <mailto:djberg96 at gmail.com> <mailto:djberg96 at gmail.com > <mailto:djberg96 at gmail.com>>>: > > > > Heesob Park wrote: > > > > <snip> > > > > Ok, I made the changes you suggested (in slightly different places, but > you''ll see the changes), but I still couldn''t make it work. It could > just be me, though. > > Please check out the latest from CVS and see if it works for you. > > > Thanks, > > Dan > > > The lastest CVS code works fine on my WinXP Prof. > > What''s your result? any error message? or just nothing?I tried this on WinXP Home: struct = Process.create( :app_name => "notepad.exe", :with_logon => ''foo'', :password => ''xxxx'', :domain => ''MYDOMAIN'' ) (Note that I didn''t set the flags explicitly - the docs say the CREATE_DEFAULT_ERROR_MODE, CREATE_NEW_CONSOLE, and CREATE_NEW_PROCESS_GROUP flags are enabled by default). The result was: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.: CreateProcess() failed: (Process::Error) That error is junk - the number (1058) must just happen to match a service error. Maybe it''s a Home vs Pro issue? Or maybe I''m just doing something wrong. Regards, Dan
2007/12/12, Daniel Berger <djberg96 at gmail.com>:> > Heesob Park wrote: > > Hi, > > > > 2007/12/11, Daniel Berger <djberg96 at gmail.com <mailto:djberg96 at gmail.com > >>: > > > > Heesob Park wrote: > > > Hi, > > > > > > 2007/12/11, Daniel Berger < djberg96 at gmail.com > > <mailto:djberg96 at gmail.com> <mailto:djberg96 at gmail.com > > <mailto:djberg96 at gmail.com>>>: > > > > > > Heesob Park wrote: > > > > > > <snip> > > > > > > > Ok, I made the changes you suggested (in slightly different places, > but > > you''ll see the changes), but I still couldn''t make it work. It could > > just be me, though. > > > > Please check out the latest from CVS and see if it works for you. > > > > > > Thanks, > > > > Dan > > > > > > The lastest CVS code works fine on my WinXP Prof. > > > > What''s your result? any error message? or just nothing? > > I tried this on WinXP Home: > > struct = Process.create( > :app_name => "notepad.exe", > :with_logon => ''foo'', > :password => ''xxxx'', > :domain => ''MYDOMAIN'' > ) > > (Note that I didn''t set the flags explicitly - the docs say the > CREATE_DEFAULT_ERROR_MODE, CREATE_NEW_CONSOLE, and > CREATE_NEW_PROCESS_GROUP flags are enabled by default). > > The result was: > > The service cannot be started, either because it is disabled or because > it has no enabled devices associated with it.: CreateProcess() failed: > (Process::Error) > > That error is junk - the number (1058) must just happen to match a > service error. > > Maybe it''s a Home vs Pro issue? Or maybe I''m just doing something wrong.That''s strange. On my WinXP Home, your test code works fine also. What result wtih another domain like "." or nil? It works same with whatever domain even with nil in my case. Regards,> > DanRegards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071212/ccbfb660/attachment.html
Heesob Park wrote: <snip>> > What''s your result? any error message? or just nothing? > > I tried this on WinXP Home: > > struct = Process.create( > :app_name => "notepad.exe", > :with_logon => ''foo'', > :password => ''xxxx'', > :domain => ''MYDOMAIN'' > ) > > (Note that I didn''t set the flags explicitly - the docs say the > CREATE_DEFAULT_ERROR_MODE, CREATE_NEW_CONSOLE, and > CREATE_NEW_PROCESS_GROUP flags are enabled by default). > > The result was: > > The service cannot be started, either because it is disabled or because > it has no enabled devices associated with it.: CreateProcess() failed: > (Process::Error) > > That error is junk - the number (1058) must just happen to match a > service error. > > Maybe it''s a Home vs Pro issue? Or maybe I''m just doing something wrong. > > > That''s strange. On my WinXP Home, your test code works fine also. > What result wtih another domain like "." or nil? > It works same with whatever domain even with nil in my case.I can only guess that I''ve shut off some service that this function requires, but I don''t see anything documented. Ah, well. If you say it works, then I''ll release it. :) Thanks, Dan