PDA

View Full Version : 64 Bit x64 IA64 some handy functions


Eagle
08-23-2007, 02:22 PM
These may help in getting some specific IR runtime 'actions' or other
functionality to behave in your APPS - as usual fully test before Market

Global Functions: -- place in Global Functions scripting Window

--sProcArch
function GetCPUArch()

--to return(formatted string) the Operating system Architecture type

local sArch = "x86";
local sREnvKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
local Arch = String.Lower(Registry.GetValue(3, sREnvKey, "PROCESSOR_ARCHITECTURE", false));
if (Arch == "amd64") then
sArch = "x64";
elseif (Arch == "ia64") then
sArch = "IA64";
end
return sArch;
end
--eProcArch


--sWOW64 DIS-EN
function DisableWow64ReDirect()

--to disable the wow64 file system redirection of your APP(the IR 32bit 'runtime.exe')

if(not bWow64Disabled)then
local sr = DLL.CallFunction(_WindowsFolder.."\\SysWOW64\\kernel32.dll", "Wow64DisableWow64FsRedirection", "\""..Application.GetWndHandle().."\"", 1, 1);
bWow64Disabled = true; --global
end
end
function EnableWow64ReDirect()

--to restore\re-enable the wow64 file system redirection of your APP(the IR 32bit 'runtime.exe')

if(bWow64Disabled)then
local sr = DLL.CallFunction(_WindowsFolder.."\\SysWOW64\\kernel32.dll", "Wow64RevertWow64FsRedirection", "\""..Application.GetWndHandle().."\"", 1, 1);
bWow64Disabled = nil; --global
end
end
--eWOW64 DIS-EN


some example calls-uses:

--example Os Architecture:

Os_Arc = GetCPUArch(); -- Global to APP - to get the Operating system Architecture -string (x86,x64,IA64)

--one suggested method:
local bIS64Bit = System.Is64BitOS(); --could make this global to APP
if bIS64Bit then
Os_Arc = GetCPUArch(); --(wow64 influences on 32bit applications)
else
Os_Arc = "x86";
end


if (Os_Arc == "IA64") then

-- is ia64 type OS (wow64 influences on 32bit applications)

--do something here
Dialog.Message("System Architecture", Os_Arc);

elseif (Os_Arc == "x64") then

-- is x64 type OS (wow64 influences on 32bit applications)

--do something here
Dialog.Message("System Architecture", Os_Arc);

elseif (Os_Arc == "x86") then

--is 32 bit Os

-- do something here
Dialog.Message("System Architecture", Os_Arc);

end



--example using File System Redirection control ONLY if confirmed 64bit OS

local bIS64Bit = System.Is64BitOS();
if (bIS64Bit) then

DisableWow64ReDirect(); --call to disable wow64 fs redirection(if not) for the IR 32bit 'runtime.exe'
--you now have access to 64 bit system resources(based on 'wow64' OS functionality)

--perform required action-s here, when completed reccommend revert\re-enable immeditaley--

EnableWow64ReDirect(); --call to revert\re-enable wow64 fs redirection(if not) for the IR 32bit 'runtime.exe'
--you no longer have access to 64 bit system resources(based on 'wow64' OS functionality)

end

hth

Eagle
08-25-2007, 09:49 PM
when using the WOW64 FS dis-en functions:
* the key is to maintain the stability of the runtime *

Very important to have the above in mind when performing
any 64bit oriented system access - actions

some things to keep in mind too:

* IR Lan.actions do not work if FS is Disabled
* Test Web connection does not Work if FS is Disabled
* Web object functionality misbehaves if FS is Disabled

fwiw

jassing
08-30-2007, 08:05 PM
Eagle: might want to check out this registry key:

HKEY_LOCAL_MACHINE, "hardware\\DESCRIPTION\\system\\centralprocessor\\"..x

where x is 0 ... 1 ... 2 etc.

seems to be a better reg to get cpu type.

Eagle
08-31-2007, 07:05 AM
Josh, the above function was intended only to return Os Architecture,
are you saying that it is failing in some way ? If it is could you expand...

Yeah, for actual CPU 'friendly name' - description string, speed etc,
I posted a func on the forum some ways back.

the cpu 'friendly name' can be searched for "x86", "AMD64", "Itanium",
however the 'Environment key is more in line with msdn docs, to id OS Arch:
x86 or
"AMD64" covers Both:
AMD cpus (like opteron and later) x64 and
Intel EMT64 supported(non itanium) x64 processors.

or: "IA64" for intel Itanium type cpu's

lemme know as mentioned if failing to ID the Architecture.
(anyone else having issues , please post here tks )

jassing
08-31-2007, 08:27 AM
didn't mean to imply that anything was wrong with your code...
just to point out an option for identifing the arch in use -- the 1st word of identifier value is usually a lot more accurate than AMD when it's really intel 64bit....

Eagle
08-31-2007, 10:32 AM
Sure, if you want-need that additional information :yes