moteus/lua-winreg

Read 64 bit registry key from 32 bit interperetator.

Closed this issue · 5 comments

Hi!
Fix should be:

REGSAM reg_aux_getaccess(lua_State *L, int i){
	REGSAM acc = 0;
	if(lua_isnumber(L, i) || lua_isnoneornil(L, i)){
		acc = lua_optint(L, i, KEY_ALL_ACCESS);
	}else{
		const char * psz = lua_checkstring(L, i);
		for(;*psz;psz++){
			switch(*psz){
			case 'w': acc |= KEY_WRITE; break;
			case 'r': acc |= KEY_READ ; break;
			case 'a': acc |= KEY_ALL_ACCESS ; break;
			default : lua_error_invalid_option(L, i);
			}
		}
	}
	return acc **| KEY_WOW64_64KEY**;
}

May be just export all flags and allow end user use it?

Appendix: without KEY_WOW64_64KEY flag you will receive empty buffer in RegQueryValueExA when, for example, reading InstallDate from HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion on Windows 8 x64.

Export flags is good idea :)

This is 2 different keys. One for 32bit apps. and one for 64bit.
And I think it should be used by default. But you can pass any flags you whant.
Only problem winred does not export it. But you can just define them byself.

I think may be also export RegDisableReflectionKey and RegEnableReflectionKey.

https://msdn.microsoft.com/ru-ru/library/windows/desktop/ms724072(v=vs.85).aspx

Yes, it's better to export something like winreg_disable_redirection.