Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » [FEATURE] Accessing to Alternate Win Registry View (patch included)
[FEATURE] Accessing to Alternate Win Registry View (patch included) [message #46574] Thu, 02 June 2016 16:46 Go to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
Hi,

in a Win64 OS, the registry is divided in tow part.

by default, a binary compiled 64 bit, accees only to the 64 part of the rgistry
and a binary compiled 32 bit, accees only to the 32 part of the rgistry.

in order to accees to the 64 part, a 32 binary shall specify the key KEY_WOW64_64KEY.
in order to accees to the 32 part, a 64 binary shall specify the key KEY_WOW64_32KEY.

U++ now has this functions:
String GetWinRegString(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
int    GetWinRegInt(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
bool   SetWinRegString(const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
bool   SetWinRegExpandString(const String& string, const char *value, const char *path, HKEY base_key);
bool   SetWinRegInt(int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
void   DeleteWinReg(const String& key, HKEY base = HKEY_LOCAL_MACHINE);



my proposal is to:

1 - Add a new dword argument to this funcions, with default value set to zero (0).

String GetWinRegString(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
int    GetWinRegInt(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
bool   SetWinRegString(const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
bool   SetWinRegExpandString(const String& string, const char *value, const char *path, HKEY base_key, dword wow = 0);
bool   SetWinRegInt(int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
void   DeleteWinReg(const String& key, HKEY base = HKEY_LOCAL_MACHINE, dword wow = 0);



this is backware compatible.

2 - in the functions bodys:
- GetWinRegString/GetWinRegInt : replace
KEY_READ
by
KEY_READ | wow 


- SetWinRegString/SetWinRegExpandString/SetWinRegInt: replace
KEY_ALL_ACCESS
by
KEY_ALL_ACCESS | wow 


- DeleteWinReg :
replace
KEY_READ
by
KEY_READ | wow 

AND replace
RegDeleteKey(base, key);

by
          if(wow)
              RegDeleteKeyEx(base, key, wow, 0);
          else
              RegDeleteKey(base, key);
     


3 - Next, add a set of function to acees to specific part of the registry

3.1 : accees to the others part (the 32 part for 64 bin, or the 64 part for the 32 bin):
- define this macro WOW :
#ifdef CPU_64
#define WOW KEY_WOW64_32KEY
#else
#define WOW KEY_WOW64_64KEY
#endif


- Add the new functions,
String GetWinRegStringWOW ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return GetWinRegString ( value, path, base_key, WOW );
}

int    GetWinRegIntWOW ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return GetWinRegInt ( value, path, base_key, WOW );
}

bool   SetWinRegStringWOW ( const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return SetWinRegString ( string, value, path, base_key, WOW );
}

bool   SetWinRegExpandStringWOW ( const String& string, const char *value, const char *path, HKEY base_key ){
	return SetWinRegExpandString ( string, value, path, base_key, WOW );
}

bool   SetWinRegIntWOW ( int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return SetWinRegInt ( string, value, path, base_key, WOW );
}

void   DeleteWinRegWOW ( const String& key, HKEY base = HKEY_LOCAL_MACHINE ){
	DeleteWinReg ( key, base, WOW );
}




3.2 : functions to accees to specific part:

64 bits:
String GetWinRegStringWOW64 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return GetWinRegString ( value, path, base_key, KEY_WOW64_64KEY );
}

int    GetWinRegIntWOW64 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return GetWinRegInt ( value, path, base_key, KEY_WOW64_64KEY );
}

bool   SetWinRegStringWOW64 ( const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return SetWinRegString ( string, value, path, base_key, KEY_WOW64_64KEY );
}

bool   SetWinRegExpandStringWOW64 ( const String& string, const char *value, const char *path, HKEY base_key ){
	return SetWinRegExpandString ( string, value, path, base_key, KEY_WOW64_64KEY );
}

bool   SetWinRegIntWOW64 ( int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return SetWinRegInt ( string, value, path, base_key, KEY_WOW64_64KEY );
}

void   DeleteWinRegWOW64 ( const String& key, HKEY base = HKEY_LOCAL_MACHINE ){
	DeleteWinReg ( key, base, KEY_WOW64_64KEY );
}

and 32 bits:

String GetWinRegStringWOW32 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return GetWinRegString ( value, path, base_key, KEY_WOW64_32KEY );
}

int    GetWinRegIntWOW32 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return GetWinRegInt ( value, path, base_key, KEY_WOW64_32KEY );
}

bool   SetWinRegStringWOW32 ( const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return SetWinRegString ( string, value, path, base_key, KEY_WOW64_32KEY );
}

bool   SetWinRegExpandStringWOW32 ( const String& string, const char *value, const char *path, HKEY base_key ){
	return SetWinRegExpandString ( string, value, path, base_key, KEY_WOW64_32KEY );
}

bool   SetWinRegIntWOW32 ( int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
	return SetWinRegInt ( string, value, path, base_key, KEY_WOW64_32KEY );
}

void   DeleteWinRegWOW32 ( const String& key, HKEY base = HKEY_LOCAL_MACHINE ){
	DeleteWinReg ( key, base, KEY_WOW64_32KEY );
}



regards
omari.

[Updated on: Thu, 02 June 2016 19:08]

Report message to a moderator

Re: [FEATURE] Accessing to Alternate Win Registry View (patch included) [message #46627 is a reply to message #46574] Thu, 16 June 2016 08:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I think part 3.1 is not really necessary.

What about adding just single parameter to all function, which will be 0 by default and gets | with access?
Re: [FEATURE] Accessing to Alternate Win Registry View (patch included) [message #46628 is a reply to message #46627] Thu, 16 June 2016 10:38 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
I am agree with you, the part 3. is not necessary.

regards
omari.
Re: [FEATURE] Accessing to Alternate Win Registry View (patch included) [message #46639 is a reply to message #46628] Mon, 20 June 2016 11:04 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Applied (simple variant - adding wow parameter).

Thanks,

Mirek
Previous Topic: [FIXED] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
Next Topic: Nightly packages compilation error
Goto Forum:
  


Current Time: Thu Mar 28 21:37:35 CET 2024

Total time taken to generate the page: 0.00860 seconds