Page 1 of 2 12>
Topic Options
#192923 - 2009-03-16 06:35 PM shell regedit on 64 bit OS
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
Question. On 64 bit operating systems:

I need to get an entry under HKLM\Software\Product\etc

However, when you run the following command SHELL "regedit /s update.reg", the registry setting gets redirected to HKLM\Software\Wow6432Node\Product\etc.

This particular software needs the registry entry under HKLM\Software\Product\etc. But what's strange is that when you double click on the *.reg file directly, it goes to the place specified in the reg file. Is there some swtic or something in Kixtart to make it go to the specified place?

Thanks,

Jeff

Top
#192924 - 2009-03-16 07:36 PM Re: shell regedit on 64 bit OS [Re: jeff_eisenberg]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Yes - read the Readme file that comes with the Kix32 zip file.. ;\)

It's a SetOption() parameter that turns off file and registry WOW redirection.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192928 - 2009-03-16 08:43 PM Re: shell regedit on 64 bit OS [Re: Glenn Barnas]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
Got it.

So it looks like the command:

SETOPTION("Wow64FileRedirection","off")

Has a conflict with the EnumProcess fuction below. When you add the SETOPTION to turn off Wow64FileRedirection the EnumProcess function produces the following popup error.

Windows - Unable To Locate Component:
Exception Processing message c0000135 Parameters 7c7df5f8

Any ideas?

---------------------------
FUNCTION EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id, $getobject, $
if not $computer $computer=@wksta endif
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
select
case val($exe)>0
$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For each $Process in $GetObject
if $terminate $=$Process.Terminate endif
$EnumProcess = $Process.name
next
$GetObject=''
case vartype($exe)=8
$ExecQuery="select * from Win32_Process where Name='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For each $Process in $GetObject
if $terminate $=$Process.Terminate endif
$id=$Process.ProcessId
$EnumProcess = "$Id" + "|" + "$EnumProcess"
Next
$EnumProcess=left($EnumProcess,len($EnumProcess)-1)
$GetObject=''
case 1
exit 1
endselect
ENDFUNCTION

Top
#192934 - 2009-03-17 08:55 AM Re: shell regedit on 64 bit OS [Re: jeff_eisenberg]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you don't show how you call the udf, nor you bothered to use code-tags.

follow some etiquette and we might be able to help with your issue.
_________________________
!

download KiXnet

Top
#192967 - 2009-03-18 07:18 AM Re: shell regedit on 64 bit OS [Re: Lonkero]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
I'm really sorry about not following the proper etiquette. I'm new to this. What do you mean by code tags? Do you mean tabs. I tried to put in tabs for clarity, but when you submit the message the tab spaces disappear.

Here is the script I am running along with how I call the UDF. I tested it with only the code below and it give the same error so I know it's something below and not any of the other code in my script.

----------------------------
SETOPTION("Wow64FileRedirection","off")
CALL "ENUMPROCESS.kix"
$STICK=EnumProcess("stick.exe")
IF $STICK = 0
RUN "C:\Program Files\Stick\Stick.exe"
ENDIF

Here is the function
----------------------------------
FUNCTION EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id, $getobject, $
if not $computer $computer=@wksta endif
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
select
case val($exe)>0
$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For each $Process in $GetObject
if $terminate $=$Process.Terminate endif
$EnumProcess = $Process.name
next
$GetObject=''
case vartype($exe)=8
$ExecQuery="select * from Win32_Process where Name='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For each $Process in $GetObject
if $terminate $=$Process.Terminate endif
$id=$Process.ProcessId
$EnumProcess = "$Id" + "|" + "$EnumProcess"
Next
$EnumProcess=left($EnumProcess,len($EnumProcess)-1)
$GetObject=''
case 1
exit 1
endselect
ENDFUNCTION

Top
#192968 - 2009-03-18 08:56 AM Re: shell regedit on 64 bit OS [Re: jeff_eisenberg]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
To use the UBB code tags simply type [ code ] without the spaces at the beginning of your script and [ /code ] again without the spaces at the end. All of your formatting will be preserved.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#192969 - 2009-03-18 09:37 AM Re: shell regedit on 64 bit OS [Re: Gargoyle]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
Why thank you very much:
It seems that the error occurs during the "select * from Win32_Process" part of the function. This is running on a 64 bit OS.

-------------------------------
script:
 Code:
SETOPTION("Wow64FileRedirection","off")
CALL "ENUMPROCESS.kix"
$STICK=EnumProcess("stick.exe")
IF $STICK = 0
       RUN "C:\Program Files\Stick\Stick.exe"
ENDIF

-------------------------------
Function:

 Code:
FUNCTION EnumProcess($exe, optional $terminate, optional $Computer)
	Dim $winmgmts, $ExecQuery, $Process, $id, $getobject, $
	if not $computer $computer=@wksta endif
	$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
	select
		case val($exe)>0
			$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
			$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
			For each $Process in $GetObject
				if $terminate $=$Process.Terminate endif
				$EnumProcess = $Process.name
				next
		$GetObject=''
		case vartype($exe)=8
			$ExecQuery="select * from Win32_Process where Name='$exe'"
			$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
			For each $Process in $GetObject
				if $terminate $=$Process.Terminate endif
				$id=$Process.ProcessId
				$EnumProcess = "$Id" + "|" + "$EnumProcess"
				Next
			$EnumProcess=left($EnumProcess,len($EnumProcess)-1)
			$GetObject=''
		case 1
			exit 1
	endselect
ENDFUNCTION

Top
#192971 - 2009-03-18 01:51 PM Re: shell regedit on 64 bit OS [Re: jeff_eisenberg]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I honestly haven't spent the time to understand the 64bit redirects, but I can tell you I am seeing the same problem on VistaX64. If you change the WOW64FileRedirection to On, enumprocess works as expected.
Top
#192972 - 2009-03-18 03:38 PM Re: shell regedit on 64 bit OS [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I think this may be a bug. Can someone verify my findings?

Using the following code;
 Code:
? @kix
? iif(@onwow64,"64","32") + "bit"
? "Wow64FileRedirection=" + SETOPTION("Wow64FileRedirection")

;$rc=SETOPTION("Wow64FileRedirection","off")
$PID=EnumProcess("calc.exe")
? "PID=" + $Pid


Results:
 Code:
4.61 Beta 1
64bit
Wow64FileRedirection=OFF
PID=3952


Works as expected. However, just uncommenting the Wow64FileRedirection line, which should be doing nothing, as it is already OFF, breaks Enumprocess resulting in the following:

 Code:
4.61 Beta 1
64bit
Wow64FileRedirection=OFFselect * from Win32_Process where Name='calc.exe'
PID=


Tested with 4.53, 4.60, and 4.61b1 with the same results.

Top
#192974 - 2009-03-18 03:41 PM Re: shell regedit on 64 bit OS [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
I can check it this evening on Vista X64 and 2K8 X64.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192977 - 2009-03-18 03:55 PM Re: shell regedit on 64 bit OS [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
The more I look at this, the more I think Setoption is returning the wrong value. Wouldn't FileRedirection be on by default under x64? And turning the redirection on causes the script to work.
Top
#192978 - 2009-03-18 04:42 PM Re: shell regedit on 64 bit OS [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
It should be on by default.

Maybe your "Easter egg" is cracked? ;\) Or is there other code ahead of this that isn't shown?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192979 - 2009-03-18 04:42 PM Re: shell regedit on 64 bit OS [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Interesting reading/investigation. I think I found something of some use.

A brief history.
 Quote:
In 64-bit (x64) Windows operating system, including Windows Vista, Microsoft implements a feature called File System Redirector on WOW64 (Windows-32-on-Windows-64 that runs 32-bit programs without modifications) subsystem layer for 32-bit programs or DLL (dynamic link libraries) which provides a WOW64 sandbox for registry calls and some file system calls. The filesystem redirection forces 32-bit application attempts to be installed into or accessed from %windir%\System32, been intercepted and get redirected or re-pointed to %windir%\SysWOW64 instead.

The reason for the Filesystem Redirector is that in x64 edition of Windows OS, %windir%\System32 directory is reserved for 64-bit applications. However, most DLL implements Windows API has the same file names and paths that were not changed when porting to 64-bit. As there cannot be two 32-bit and 64-bit DLLs with same name and same path exist on the same system at the same time, so File System Redirector automatically isolates and makes 32-bit applications or non-64-bit aware programs use a different directory as their System32 directory, which is %windir%\SysWOW64 folder. It’s also as a way to avoid incompatibility issue to prevent a 32-bit binary from accidentally accessing data from a 64-bit binary.


Starting with Vista x64 Microsoft introduced a virtual directory for 32 bit apps to access the "REAL" system32 directory. Its called SYSNATIVE. You can't see it from explorer, but 32 bit apps (kixtart) can use it. Interestingly, you can make a directory called SYSNATIVE in the Windows directory, and then you can see the magic of the Virtual/Redirect at work within 32 bit apps, 64bit apps just see it as an empty directory.

I think the value of this with Kixtart is, you can use it without having to turn on or off file redirection globally.



Top
#192982 - 2009-03-18 04:47 PM Re: shell regedit on 64 bit OS [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
@Glenn

If on is default... setoption is returning the wrong value either way.

 Code:
$RC=SETOPTION("Wow64FileRedirection","on")
? $RC


OFF

Top
#192983 - 2009-03-18 04:52 PM Re: shell regedit on 64 bit OS [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
That looks correct, Allen - at least syntactically. SetOption used in that manner returns the PRIOR setting so you can easily revert to what it was.

I do agree, however, that it doesn't appear to be On as a default in that situation. I don't have access to any x64 gear here, but have plenty at home and my office. I can do some additional testing.

Very cool "discovery" of SYSNATIVE! Can't wait to give that a try.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192991 - 2009-03-19 12:04 AM Re: shell regedit on 64 bit OS [Re: Glenn Barnas]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
Thanks guys. This is an XP 64 bit OS I'm having the problem on.

jeff.

Top
#192992 - 2009-03-19 12:12 AM Re: shell regedit on 64 bit OS [Re: jeff_eisenberg]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Did you try turning FileRedirects back on?
Top
#192993 - 2009-03-19 03:07 AM Re: shell regedit on 64 bit OS [Re: Allen]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
Yes. On seems to be the default.

When the FileRedirects is on (or not defined), the reg file I run via the script, puts the registry entry in to the "Wow6432Node" of the registry which is not the setting in the reg file.

When the FileRedirects is on (or not defined), the EnumProcess function I use works fine.

When the FileRedirects is off, the reg file I run puts the registry entry in the correct portion of the registry so the "redirect" seems to be off and working how I would like it to... But I get the error with the EnumProcess funcion pop up window:

Windows Unable to Locate Component
Exception Processing Message: C0000135 Parameters 7c7df5f8 7c7df5f8 7c7df5f8 7c7df5f8

Also in the kixtart window you see:
Select * from win_32process where name = 'XXXX.exe"

Jeff

Top
#192994 - 2009-03-19 03:29 AM Re: shell regedit on 64 bit OS [Re: jeff_eisenberg]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Well the good news is, you can turn it on and off as needed. The bad news is you will have to keep up with it. ;\)


Top
#193015 - 2009-03-19 08:56 PM Re: shell regedit on 64 bit OS [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Correct. You should be able to alter it's state before you run that portion of the script and when that portion is done switch it back.
Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1003 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.126 seconds in which 0.077 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org