This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 Action Scripts Using Alien
 Get Windows Major / Minor Version
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rob

USA
2615 Posts

Posted - 03/03/2012 :  09:56:39  Show Profile  Visit Rob's Homepage
Obviously, one could store the first portion of this script in StrokesPlus.lua to make these functions available to all scripts.

Bitwise operations taken from here: http://forum.us.runesofmagic.com/showthread.php?t=68772
------

local maxsize = 2^32
local floor = math.floor
local powtbl = { 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536,
131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216,
33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648 }
local xortbl = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, },
{ 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, },
{ 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13, },
{ 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12, },
{ 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11, },
{ 5, 4, 7, 6, 1, 0, 3, 2, 13, 12, 15, 14, 9, 8, 11, 10, },
{ 6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9, },
{ 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, },
{ 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, },
{ 9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3, 2, 5, 4, 7, 6, },
{10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5, },
{11, 10, 9, 8, 15, 14, 13, 12, 3, 2, 1, 0, 7, 6, 5, 4, },
{12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3, },
{13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2, },
{14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1, },
{15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, },
}

function bxor(a,b)
local res, mult = 0, 1
while a > 0 and b > 0 do
local a2, b2 = a % 16, b % 16
res = res + xortbl[a2+1][b2+1] * mult
a = (a-a2) / 16
b = (b-b2) / 16
mult = mult * 16
end
res = res + (a+b) * mult
return res
end

function band(a,b)
return ((a+b) - bxor(a,b))/2
end

function lsr(a,n)
if n < 1 then
return a -- 0 shifting does nothing, negative shifts are ignored
else
return (n > 31) and 0 or (floor(a / powtbl[n]) % maxsize)
end
end

local alien = alien.core
local mb = alien.load("kernel32.dll")
local GetVersion = mb.GetVersion
GetVersion:types{ ret = 'uint', abi = 'stdcall'}
local iVersion = GetVersion()

sVersion = band(band(iVersion,65535),255)
acMessageBox(sVersion,"Major Version",nil)

sVersion = band(lsr(band(iVersion,65535),8),255)
acMessageBox(sVersion,"Minor Version",nil)
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000