moteus / lua-winreg

Lua binary module to Access Microsoft(R) Windows(R) Registry
8 stars 5 forks source link

Read 64 bit registry key from 32 bit interperetator. #1

Closed ghost closed 7 years ago

ghost commented 7 years ago

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**;
}
moteus commented 7 years ago

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

ghost commented 7 years ago

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 :)

moteus commented 7 years ago

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.

moteus commented 7 years ago

I think may be also export RegDisableReflectionKey and RegEnableReflectionKey.

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

ghost commented 7 years ago

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