[#365153] synchronize a "mocked" clock in a distributed system — Chuck Remes <cremes.devlist@...>

I've been banging on a problem for a few days now and don't feel any closer to solving it. I'm hoping some of the big brains on the ruby ML can shed some light. Following are a few paragraphs with a brief system overview before I state the problem. I apologize in advance for this question being only tangentially related to Ruby the language. :)

13 messages 2010/07/01
[#365164] Re: [Q] synchronize a "mocked" clock in a distributed system — Tony Arcieri <tony.arcieri@...> 2010/07/01

On Thu, Jul 1, 2010 at 3:10 PM, Chuck Remes <cremes.devlist@mac.com> wrote:

[#365214] RubyGoLightly Progress Report — Eleanor McHugh <eleanor@...>

I seem to have been missing in action for the best part of six months so =

14 messages 2010/07/02

[#365320] Why am I not getting the expected output? — Abder-rahman Ali <abder.rahman.ali@...>

I have the following code: http://pastie.org/1032525, but always getting

11 messages 2010/07/06

[#365351] best way to make .rb into an executable for linux? — David Ainley <wrinkliez@...>

I have a pretty basic .rb script that I would like to turn into an

11 messages 2010/07/06

[#365374] Hashes don't allow preceding commas by design? — Iain Barnett <iainspeed@...>

This is the output from irb that shows ruby 1.9.1 doesn't like hash =

12 messages 2010/07/07

[#365413] What is meant by those lines of code in this script? — Abder-rahman Ali <abder.rahman.ali@...>

I came across the following script from "Why's poignant guide to Ruby".

9 messages 2010/07/07

[#365504] FIRST PROGRAMMING PROBLEM Array — Francisco Martinez <calabazag@...>

Hi...I'm trying to solve a very simple exercise but this is one of my

12 messages 2010/07/09

[#365513] what about allowing to specify, which end belongs to which start? — Jan Lelis <prog@...>

Hi Ruby mailing list,

24 messages 2010/07/09
[#365541] Re: what about allowing to specify, which end belongs to which start? — Caleb Clausen <vikkous@...> 2010/07/10

On 7/9/10, Jan Lelis <prog@janlelis.de> wrote:

[#365548] Re: what about allowing to specify, which end belongs to which start? — Robert Klemme <shortcutter@...> 2010/07/11

On 10.07.2010 17:54, Caleb Clausen wrote:

[#365551] Re: what about allowing to specify, which end belongs to which start? — Caleb Clausen <vikkous@...> 2010/07/11

On 7/11/10, Robert Klemme <shortcutter@googlemail.com> wrote:

[#365555] Re: what about allowing to specify, which end belongs to which start? — Robert Klemme <shortcutter@...> 2010/07/11

On 11.07.2010 13:32, Caleb Clausen wrote:

[#365574] Re: what about allowing to specify, which end belongs to which start? — Caleb Clausen <vikkous@...> 2010/07/11

On 7/11/10, Robert Klemme <shortcutter@googlemail.com> wrote:

[#365570] How to pass a hash as a param to a method called through eval? — Alex Stahl <astahl@...5.com>

Hi Folks - I've got a data-driven app I'm building, and I'd like to be

14 messages 2010/07/11

[#365615] Try Ruby is back online. — andrew mcelroy <sophrinix@...>

Greetings,

10 messages 2010/07/12

[#365721] Ruby garabage collector — Abder-Rahman Ali <abder.rahman.ali@...>

In the "Why's poignant guide to Ruby" book, it states the following:

22 messages 2010/07/13

[#365752] What does this do? — Abder-Rahman Ali <abder.rahman.ali@...>

I have this portion of code from "Why's poignant guide to Ruby" book.

12 messages 2010/07/13

[#365828] click a javascript dialog window in Firefox — Mario Ruiz <tcblues@...>

Hi,

9 messages 2010/07/14

[#365844] Return nothing when looking outside the bounds of 2D array? — Shawn W_ <shawnw@...>

I have a 2D Array. I have written a method

22 messages 2010/07/14
[#365850] Re: Return nothing when looking outside the bounds of 2D array? — w_a_x_man <w_a_x_man@...> 2010/07/14

On Jul 14, 3:56=A0pm, Shawn W_ <sha...@internode.on.net> wrote:

[#365853] Re: Return nothing when looking outside the bounds of 2D array? — Shawn W_ <shawnw@...> 2010/07/15

Thx. Don't quite understand that code. I tried plugging in some nils but

[#365869] Re: Return nothing when looking outside the bounds of 2D array? — Shawn W_ <shawnw@...> 2010/07/15

A better way to describe it.

[#365871] Re: Return nothing when looking outside the bounds of 2D array? — Dave Howell <groups.2009a@...> 2010/07/15

I was going to suggest using the 'case' statement instead of all those =

[#365938] Re: Return nothing when looking outside the bounds of 2D array? — Shawn W_ <shawnw@...> 2010/07/16

Okay, just found out that...

[#365944] Re: Return nothing when looking outside the bounds of 2D array? — Martin DeMello <martindemello@...> 2010/07/16

On Fri, Jul 16, 2010 at 11:11 AM, Shawn W_ <shawnw@internode.on.net> wrote:

[#365847] Ruby best practice for "always on" app/service? — yermej <yermej@...>

I'm building an app that will essentially be a web service client. It

10 messages 2010/07/14

[#365988] client-side Ruby on iPad/iPhone? — Jeff Pritchard <jp@...>

I've seen jRuby and IronRuby, and really want to use them since i really

12 messages 2010/07/17

[#366015] ruby abstraction — "James O'Brien" <jeob32@...>

Hi,

17 messages 2010/07/18

[#366053] LoadError: no such file to load -- tk — Rich Leblanc <rl001@...>

I'm trying to install Ruby on a 64 bit Windows 7 machine following this

46 messages 2010/07/19
[#366063] Re: LoadError: no such file to load -- tk — Roger Pack <rogerpack2005@...> 2010/07/19

[#366082] Re: LoadError: no such file to load -- tk — Rich Leblanc <rl001@...> 2010/07/19

Roger Pack wrote:

[#366085] Re: LoadError: no such file to load -- tk — Eric Christopherson <echristopherson@...> 2010/07/19

On Mon, Jul 19, 2010 at 3:26 PM, Rich Leblanc <rl001@pacbell.net> wrote:

[#366086] Re: LoadError: no such file to load -- tk — Rich Leblanc <rl001@...> 2010/07/20

Eric Christopherson wrote:

[#366135] Re: LoadError: no such file to load -- tk — Roger Pack <rogerpack2005@...> 2010/07/20

[#366140] Re: LoadError: no such file to load -- tk — Rich Leblanc <rl001@...> 2010/07/20

Roger Pack wrote:

[#366147] Re: LoadError: no such file to load -- tk — Roger Pack <rogerpack2005@...> 2010/07/20

Rich Leblanc wrote:

[#366153] Re: LoadError: no such file to load -- tk — Rich Leblanc <rl001@...> 2010/07/20

Roger Pack wrote:

[#366179] Re: LoadError: no such file to load -- tk — Rich Leblanc <rl001@...> 2010/07/21

Rich Leblanc wrote:

[#366115] Count occurences of vars in array — Vitaliy Yanchuk <fuksito@...>

Hello, everyone.

18 messages 2010/07/20
[#366116] Re: Count occurences of vars in array — Jean-Julien Fleck <jeanjulien.fleck@...> 2010/07/20

Hello,

[#366120] Re: Count occurences of vars in array — Vitaliy Yanchuk <fuksito@...> 2010/07/20

Jean-Julien Fleck, thanks.

[#366152] Can't get ruby 1.9 to work after install on OSX — Musdev Musdev <devrubygem@...>

Hello

12 messages 2010/07/20

[#366196] how to make "gem install rmagick" work? — Jian Lin <blueskybreeze@...>

I wanted to install rmagick on Win7 but it can't install:

10 messages 2010/07/21

[#366226] Text to Binary — Umm Whyshouldisay <kipthemudkip@...>

Hi! I'm new to the forums. I'm also a bit new to Ruby. I already know

13 messages 2010/07/21

[#366254] finding last line in a file — Ted Flethuseo <flethuseo@...>

Hi everyone,

15 messages 2010/07/22
[#366256] Re: finding last line in a file — Urabe Shyouhei <shyouhei@...> 2010/07/22

Take a look at the doc for File.readline.

[#366257] Re: finding last line in a file — Urabe Shyouhei <shyouhei@...> 2010/07/22

(2010/07/22 14:08), Urabe Shyouhei wrote:

[#366319] Typical Ruby (non-rails) project structure. — Carl Jenkins <carljenkins@...>

What is/are the best-practice(s) for a Ruby project structure?

18 messages 2010/07/22

[#366418] Ruby books designed especially for beginngers — Kaye Ng <sbstn26@...>

Hey experts, i need your advice.

12 messages 2010/07/24

[#366611] Which Ruby is in use? — Hassan Schroeder <hassan.schroeder@...>

Is there a way to tell from within a program which executable is being

23 messages 2010/07/27
[#366614] Re: Which Ruby is in use? — "Joseph E. Savard" <joseph.savard@...> 2010/07/27

[#366617] Re: Which Ruby is in use? — Hassan Schroeder <hassan.schroeder@...> 2010/07/27

On Tue, Jul 27, 2010 at 2:20 PM, Joseph E. Savard

[#366620] Re: Which Ruby is in use? — Joel VanderWerf <joelvanderwerf@...> 2010/07/27

Hassan Schroeder wrote:

[#366622] Re: Which Ruby is in use? — Hassan Schroeder <hassan.schroeder@...> 2010/07/27

On Tue, Jul 27, 2010 at 3:10 PM, Joel VanderWerf

[#366624] Re: Which Ruby is in use? — Joel VanderWerf <joelvanderwerf@...> 2010/07/27

Hassan Schroeder wrote:

[#366625] Re: Which Ruby is in use? — Hassan Schroeder <hassan.schroeder@...> 2010/07/27

On Tue, Jul 27, 2010 at 3:52 PM, Joel VanderWerf

[#366626] Re: Which Ruby is in use? — Joel VanderWerf <joelvanderwerf@...> 2010/07/27

Hassan Schroeder wrote:

[#366629] tool to compare DB schema against DDL file — Fabian Marin <fmg134s@...>

First of all any feedback from you guys will be of tremendous help.

14 messages 2010/07/28

[#366727] my script just read one line? — Junhui Liao <junhui.liao@...>

Dear all,

19 messages 2010/07/29
[#366729] Re: my script just read one line? — Jes俍 Gabriel y Gal疣 <jgabrielygalan@...> 2010/07/29

On Thu, Jul 29, 2010 at 1:43 PM, Junhui Liao <junhui.liao@uclouvain.be> wro=

[#366766] Re: my script just read one line? — Junhui Liao <junhui.liao@...> 2010/07/29

Dear Jes炭s Gabriel y Gal叩n and all,

[#366774] Re: my script just read one line? — Jes俍 Gabriel y Gal疣 <jgabrielygalan@...> 2010/07/30

On Fri, Jul 30, 2010 at 1:58 AM, Junhui Liao <junhui.liao@uclouvain.be> wro=

[#366784] Re: my script just read one line? — Junhui Liao <junhui.liao@...> 2010/07/30

[#366786] Re: my script just read one line? — Jes俍 Gabriel y Gal疣 <jgabrielygalan@...> 2010/07/30

On Fri, Jul 30, 2010 at 2:18 PM, Junhui Liao <junhui.liao@uclouvain.be> wro=

[#366792] Re: my script just read one line? — Junhui Liao <junhui.liao@...> 2010/07/30

Dear Jes炭s Gabriel y Gal叩n,

[#366755] .any?{} Behavior — John Sikora <john.sikora@...>

I find the following behavior interesting (so interesting that I

28 messages 2010/07/29
[#366797] Re: [].all?{} and [].any?{} Behavior — Rick DeNatale <rick.denatale@...> 2010/07/30

On Thu, Jul 29, 2010 at 5:27 PM, John Sikora <john.sikora@xtera.com> wrote:

[#366809] Re: [].all?{} and [].any?{} Behavior — Josh Cheek <josh.cheek@...> 2010/07/30

On Fri, Jul 30, 2010 at 10:49 AM, Rick DeNatale <rick.denatale@gmail.com>wrote:

[#366837] Mocking a method with a block — Fernando Guillen <fguillen.mail@...>

Hi people,

12 messages 2010/07/31

Re: Help: How to pass a struct as a pointer to Win32API?

From: 李晶 <thyrlian@...>
Date: 2010-07-27 09:46:19 UTC
List: ruby-talk #366569
Hi Park,

I tried both, with VirtualAllocEx and WriteProcessMemory part and without.
The problem now is that I can not unpack lv_item after sendmessage.  Error
prompted: in "unpack": non associated pointer.  I guess I can simply try to
unpack pszText, i.e. 5th element of lv_item, but i don't know the length?

BTW, from your code: lv_item[20,4], could you plz explain why it's 20?  Wha=
t
I understand is there are only 15 elements.  And what's more, according to
MSDN, the LVITEM struct has only 14 elements.  Correct me if I'm wrong.
Thanks.

Here attached both snippets.  Thanks for your patient answer.

Regards and Thanks,
Jing Li

2010/7/27 Heesob Park <phasis@gmail.com>

> Hi,
>
> 2010/7/27 =E6=9D=8E=E6=99=B6 <thyrlian@gmail.com>:
> > Hi Park,
> >
> > Thanks for your answer, and I've tried your code, everything is fine bu=
t
> > nothing is retrieved for item or subitem.
> >
> > So the result will be like this:
> >  -
> >  -
> >  -
> > which should be "#{item} - #{subitem}"
> >
> > Could you plz tell me what's wrong?  Meanwhile I will investigate on
> this.
> >
> > BTW, does it matter if I remove VirtualAllocEx and WriteProcessMemory
> part?
> > Since I mentioned it's not a pop-up.
> >
> > Thanks a lot.
> >
> Did you tried the whole code with VirtualAllocEx and WriteProcessMemory?
>
> What's your code?
>
> If you want to remove VirtualAllocEx and WriteProcessMemory part,
>
> lv_item[20,4] =3D [_item].pack('L')
> should be
> lv_item[20,4] =3D [item].pack('p')
>
> lv_item[20,4] =3D [_subitem].pack('L')
> should be
> lv_item[20,4] =3D [subitem].pack('p')
>
>
> Regards,
> Park Heesob
>
>

Attachments (3)

with.rb (2.65 KB, text/x-ruby)
require 'Win32API'

findwin = Win32API.new('user32', 'FindWindow', 'PP', 'L')
getdlg = Win32API.new('user32', 'GetDlgItem', 'LL', 'L')
sendmsg = Win32API.new('user32', 'SendMessage', 'LLLP', 'L')
getWindowThreadProcessId = Win32API.new('user32', 'GetWindowThreadProcessId', 'LP', 'L')
openProcess = Win32API.new('kernel32', 'OpenProcess', 'LIL', 'L')
virtualAllocEx = Win32API.new('kernel32', 'VirtualAllocEx', 'LPLLL', 'L')
virtualFreeEx = Win32API.new('kernel32', 'VirtualFreeEx', 'LLLL', 'L')
writeProcessMemory = Win32API.new('kernel32', 'WriteProcessMemory','LLPLP', 'I')
readProcessMemory = Win32API.new('kernel32', 'ReadProcessMemory', 'LLPLP', 'I')

PROCESS_VM_OPERATION = 0x08
PROCESS_VM_READ = 0x10
PROCESS_VM_WRITE = 0x20
PROCESS_QUERY_INFORMATION = 0x400
MEM_COMMIT = 0x1000
MEM_RELEASE = 0x8000
PAGE_READWRITE = 0x04
LVM_FIRST = 0x1000
LVM_GETITEMCOUNT = (LVM_FIRST + 4)
LVM_GETITEMTEXT = (LVM_FIRST + 45)
SIZE_OF_LVITEM = 60

resultslist = 0x00390EF4
count = sendmsg.call(resultslist, LVM_GETITEMCOUNT, 0, nil)
puts "Count of items = #{count}"

header = getdlg.call(resultslist, 0)
puts header.to_s(16).upcase

lv_item = [0, 0, 0, 0, 0, nil, 512, 0, 0,0,0,0,0,0,0]
lv_item = lv_item.pack("LiiLLpiiLiiLLLL")
pid = 0.chr*4
getWindowThreadProcessId.call(resultslist, pid)
pid = pid.unpack('L').first
process = openProcess.call(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION,0,pid)
_lvi=virtualAllocEx.call(process, nil, SIZE_OF_LVITEM,MEM_COMMIT,PAGE_READWRITE)
_item=virtualAllocEx.call(process, nil, 512, MEM_COMMIT,PAGE_READWRITE)
_subitem=virtualAllocEx.call(process, nil, 512, MEM_COMMIT,PAGE_READWRITE)

for i in 0..count
 lv_item[8,4] = [0].pack('L')
 item = 0.chr * 512
 lv_item[20,4] = [_item].pack('L')
 writeProcessMemory.call(process, _lvi, lv_item, SIZE_OF_LVITEM, nil)
 sendmsg.call(resultslist, LVM_GETITEMTEXT, i, _lvi)

 subitem = 0.chr * 512
 lv_item[8,4] = [1].pack('L')
 lv_item[20,4] = [_subitem].pack('L')
 writeProcessMemory.call(process, _lvi, lv_item, SIZE_OF_LVITEM, nil)
 sendmsg.call(resultslist, LVM_GETITEMTEXT, i, _lvi)

 readProcessMemory.call(process, _item, item, 512, nil)
 readProcessMemory.call(process, _item, subitem, 512, nil)
 item = item.strip!
 subitem = subitem.strip!
 puts "#{item} - #{subitem}"
end

virtualFreeEx.call(process, _lvi, 0, MEM_RELEASE)
virtualFreeEx.call(process, _item, 0, MEM_RELEASE)
virtualFreeEx.call(process, _subitem, 0, MEM_RELEASE)

puts "====================="
sendmsg.call(resultslist, LVM_GETITEMTEXT, 1, lv_item)
puts lv_item.inspect
# puts lv_item.unpack("LiiLLpiiLiiLLLL").inspect  #Error in "unpack": non associated pointer
without.rb (1.27 KB, text/x-ruby)
require 'Win32API'

findwin = Win32API.new('user32', 'FindWindow', 'PP', 'L')
getdlg = Win32API.new('user32', 'GetDlgItem', 'LL', 'L')
sendmsg = Win32API.new('user32', 'SendMessage', 'LLLP', 'L')

LVM_FIRST = 0x1000
LVM_GETITEMCOUNT = (LVM_FIRST + 4)
LVM_GETITEMTEXT = (LVM_FIRST + 45)

resultslist = 0x00390EF4
count = sendmsg.call(resultslist, LVM_GETITEMCOUNT, 0, nil)
puts "Count of items = #{count}"

header = getdlg.call(resultslist, 0)
puts header.to_s(16).upcase

lv_item = [0, 0, 0, 0, 0, nil, 512, 0, 0,0,0,0,0,0,0]
lv_item = lv_item.pack("LiiLLpiiLiiLLLL")

for i in 0..count
 lv_item[8,4] = [0].pack('L')
 item = 0.chr * 512
 lv_item[20,4] = [item].pack('p')

 subitem = 0.chr * 512
 lv_item[8,4] = [1].pack('L')
 lv_item[20,4] = [subitem].pack('p')
sendmsg.call(resultslist, LVM_GETITEMTEXT, i, lv_item)
 item = item.strip!
 subitem = subitem.strip!
 puts "#{item} - #{subitem}"
end

puts "====================="
sendmsg.call(resultslist, LVM_GETITEMTEXT, 1, lv_item)
puts lv_item.inspect
# puts lv_item.unpack("LiiLLpiiLiiLLLL").inspect  #Error in "unpack": non associated pointer
#puts "\310\335\221\002\000\002".unpack("p") #The pointer address I get?  I don't know if this is right, but "non associated pointer" if I try to directly unpack it
without.png (3.63 KB)
without.png

In This Thread

Prev Next