Hi,
I want to read some hardware values from the windows registry using the tsysinfo class.
There are no problems when I access to the system as "Administrator" but it read nothing when I access as "Guest".
The strange is that as "Guest" I can read those informations without problems.
Any ideas ?
I made a self-contained sample that show the problem at www.softwarexp.co.uk/beta/sample.prg
Try to execute this app with an "Administrator" account and then on a "Guest" account. You will see that with the "Guest" account it return nothing.
Thanks in advance.
Regards,
Marco Turco
Problems to read the windows registry with a Guest access
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
Hello!
TSysInfo is using TReg32 and there is a problem in
New() method:
As you can see, KEY_ALL_ACCESS is used, but you don't have such rights
when running guest or limited user. This class should be enhanced
to support KEY_READ:
http://www.deez.info/sengelha/blog/2006 ... a-changes/
Fixing "LUA bugs"
Security Tools for Windows applications
http://nonadmin.editme.com/KnownProblems
http://homepage.mac.com/corrp/windows/LUA/homesite.html
Regards, Roman
TSysInfo is using TReg32 and there is a problem in
New() method:
Code: Select all
#ifdef __CLIPPER__
::nError = RegOpenKeyEx( nKey, cRegKey,, KEY_ALL_ACCESS, @nHandle )
#else
::nError = RegOpenKeyExA( nKey, cRegKey,, KEY_ALL_ACCESS, @nHandle )
#endif
when running guest or limited user. This class should be enhanced
to support KEY_READ:
http://www.deez.info/sengelha/blog/2006 ... a-changes/
Same useful links regarding LUA (and UAC):Here is how to perform some common development tasks while working in a least-privileged environment:
- Need to read from a HKEY_LOCAL_MACHINE key in the registry? Use RegOpenKeyEx() (not RegOpenKey()) and request KEY_READ (not KEY_ALL_ACCESS) privileges.
- Need to save per-user data which will roam with the user (i.e. may be replicated to the network)? Get the path to the Application Data\ folder by either retrieving the value of the environment variable %APPDATA% or calling SHGetFolderPath() with the parameter CSIDL_APPDATA. The recommended directory in which to store files appears to be %APPDATA%\<Vendor>\<Product>\, e.g. %APPDATA%\Microsoft\Office\.
- Need to save per-user data which will not roam with the user (e.g. a web browser cache)? Call SHGetFolderPath() with the parameter CSIDL_LOCAL_APPDATA.
- Need to save per-machine data (e.g. machine-wide game high scores)? Use %ALLUSERSPROFILE% or SHGetFolderPath() with the parameter CSIDL_COMMON_APPDATA.
- Need a place to store a temporary file? Use %TEMP% or GetTempPath(). GetTempFileName() may also be useful.
Fixing "LUA bugs"
Security Tools for Windows applications
http://nonadmin.editme.com/KnownProblems
http://homepage.mac.com/corrp/windows/LUA/homesite.html
Regards, Roman
© I'm not patented!
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Roman,
Thanks for the info. This may seem the right code to use in source\classes\reg32.prg:
Thanks for the info. This may seem the right code to use in source\classes\reg32.prg:
Code: Select all
#define ERROR_SUCCESS 0
...
#ifdef __CLIPPER__
::nError = RegOpenKeyEx( nKey, cRegKey,, KEY_ALL_ACCESS, @nHandle )
if ::nError != ERROR_SUCCESS
::nError = RegOpenKeyEx( nKey, cRegKey,, KEY_READ, @nHandle )
endif
#else
::nError = RegOpenKeyExA( nKey, cRegKey,, KEY_ALL_ACCESS, @nHandle )
if ::nError != ERROR_SUCCESS
::nError = RegOpenKeyExA( nKey, cRegKey,, KEY_READ, @nHandle )
endif
#endif
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact: