| 
 u = Win32API.new("kernel32", "GetModuleHandleA", "p", "l").call("user32")m = Win32API.new("kernel32", "GetProcAddress", "lp", "l").call(u, "MessageBoxA")func = [0x8B, 0x4C, 0x24, 0x04,         0x31, 0xC0, 0x50, 0x50, 0x51, 0x50, 0xB8].pack("C*") +       [m].pack("l") +       [0xFF, 0xD0, 0xC2, 0x04, 0x00].pack("C*")=begin  mov ecx, [esp+4] 参数 i.to_s  xor eax,eax  push eax  push eax  push ecx  push eax  mov eax,MessageBoxA  call eax  0,text,0,0  ret 4=endc = Win32API.new("kernel32", "CreateThread", "llppll", "v")for i in 0...5  c.call(0, 0, func, i.to_s, 0, 0)endloop{Graphics.update}
u = Win32API.new("kernel32", "GetModuleHandleA", "p", "l").call("user32") 
m = Win32API.new("kernel32", "GetProcAddress", "lp", "l").call(u, "MessageBoxA") 
func = [0x8B, 0x4C, 0x24, 0x04,  
        0x31, 0xC0, 0x50, 0x50, 0x51, 0x50, 0xB8].pack("C*") + 
       [m].pack("l") + 
       [0xFF, 0xD0, 0xC2, 0x04, 0x00].pack("C*") 
=begin 
  mov ecx, [esp+4] 参数 i.to_s 
  xor eax,eax 
  push eax 
  push eax 
  push ecx 
  push eax 
  mov eax,MessageBoxA 
  call eax  0,text,0,0 
  ret 4 
=end 
c = Win32API.new("kernel32", "CreateThread", "llppll", "v") 
for i in 0...5 
  c.call(0, 0, func, i.to_s, 0, 0) 
end 
loop{Graphics.update} 
道理还是一样的
 但是新线程的函数不能是ruby函数 因为机制不一样
 得先编译好
 汇编毕竟麻烦
 |