Windows注册表--32位和64位程序写注册表位置

本文探讨了在Windows环境下,使用RegCreateKeyEx+KEY_WOW64_64KEY在HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Paths下写入时遇到的问题。通过分析注册表重定向和反射机制,揭示了为何在特定情况下,写入操作不会如预期般仅影响非wow6432node部分。

前言

最近遇到个关于注册表的神奇的事情,当使用RegCreateKeyEx+KEY_WOW64_64KEY在win7环境下写HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\123.exe时,发现结果没有达到预期:在wow6432node下没有该项。

解决思路

1、测试自己使用RegCreateKeyEx+KEY_WOW64_64KEY是否错误:即用该函数写HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\APP1\123.exe,发现结果达到预期:在wow6432node下面没有该项。

2、百度搜索App Paths注册表项的作用

3、问老大,发现有点懵,然后决定从最基础的了解,即windows是怎么玩注册表的?接着就解决了我的问题。

正文

1、注册表知识点

参考文章:https://www.onthink.com/2014/07/06/32bit-64bit-registry/

msdn的解释:
重定向:https://docs.microsoft.com/zh-cn/windows/win32/winprog64/registry-redirector?redirectedfrom=MSDN

反射:https://docs.microsoft.com/zh-cn/windows/win32/winprog64/registry-reflection?redirectedfrom=MSDN

注册表项采用何种方式供32位和64位使用:

https://docs.microsoft.com/zh-cn/windows/win32/winprog64/shared-registry-keys

KeyWindows 7 and Windows Server 2008 R2Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP
HKEY_LOCAL_MACHINESharedShared
** SOFTWARE**RedirectedRedirected
** Classes**SharedRedirected and reflected
** Appid**SharedRedirected and reflected with one exception: the DllSurrogate and DllSurrogateExecutable registry values are not reflected if their value is an empty string.
** CLSID**RedirectedRedirected and reflected only for CLSIDs that do not specify InprocServer32 or InprocHandler32.
** DirectShow**RedirectedRedirected and reflected
** HCP**SharedShared
** Interface**RedirectedRedirected and reflected
** Media Type**RedirectedRedirected and reflected
** MediaFoundation**RedirectedRedirected and reflected
** Clients**SharedRedirected
** Microsoft**\COM3SharedRedirected and reflected
** Microsoft**\Cryptography\Calais\CurrentSharedShared
** Microsoft**\Cryptography\Calais\ReadersSharedShared
** Microsoft**\Cryptography\ServicesSharedShared
** Microsoft**\CTF\SystemSharedSharedShared
** Microsoft**\CTF\TIPSharedShared
** Microsoft**\DFSSharedShared
** Microsoft**\Driver SigningSharedShared
** Microsoft**\EnterpriseCertificatesSharedShared
** Microsoft**\EventSystemSharedRedirected and reflected
** Microsoft**\MSMQSharedShared
** Microsoft**\Non-Driver SigningSharedShared
** Microsoft**\Notepad\DefaultFontsSharedRedirected
** Microsoft**\OLESharedRedirected and reflected
** Microsoft**\RASSharedShared
** Microsoft**\RPCSharedRedirected and reflected
** Microsoft**\SOFTWARE\Microsoft\Shared Tools\MSInfoSharedShared
** Microsoft**\SystemCertificatesSharedShared
** Microsoft**\TermServLicensingSharedShared
** Microsoft**\TransactionServerSharedShared
** Microsoft**\Windows\CurrentVersion\App PathsSharedRedirected
** Microsoft**\Windows\CurrentVersion\Control Panel\Cursors\SchemesSharedShared
** Microsoft**\Windows\CurrentVersion\Explorer\AutoplayHandlersSharedRedirected
** Microsoft**\Windows\CurrentVersion\Explorer\DriveIconsSharedRedirected
** Microsoft**\Windows\CurrentVersion\Explorer\KindMapSharedRedirected
** Microsoft**\Windows\CurrentVersion\Group PolicySharedShared
** Microsoft**\Windows\CurrentVersion\PoliciesSharedShared
** Microsoft**\Windows\CurrentVersion\PreviewHandlersSharedRedirected
** Microsoft**\Windows\CurrentVersion\SetupSharedShared
** Microsoft**\Windows\CurrentVersion\Telephony\LocationsSharedShared
** Microsoft**\Windows NT\CurrentVersion\ConsoleSharedRedirected
** Microsoft**\Windows NT\CurrentVersion\FontDpiSharedShared
** Microsoft**\Windows NT\CurrentVersion\FontLinkSharedRedirected
** Microsoft**\Windows NT\CurrentVersion\FontMapperSharedShared
** Microsoft**\Windows NT\CurrentVersion\FontsSharedShared
** Microsoft**\Windows NT\CurrentVersion\FontSubstitutesSharedShared
** Microsoft**\Windows NT\CurrentVersion\Gre_InitializeSharedRedirected
** Microsoft**\Windows NT\CurrentVersion\Image File Execution OptionsSharedRedirected
** Microsoft**\Windows NT\CurrentVersion\Language PackSharedRedirected
** Microsoft**\Windows NT\CurrentVersion\NetworkCardsSharedShared
** Microsoft**\Windows NT\CurrentVersion\PerflibSharedShared
** Microsoft**\Windows NT\CurrentVersion\PortsSharedShared
** Microsoft**\Windows NT\CurrentVersion\PrintSharedShared
** Microsoft**\Windows NT\CurrentVersion\ProfileListSharedShared
** Microsoft**\Windows NT\CurrentVersion\Time ZonesSharedShared
** Policies**SharedShared
** RegisteredApplications**SharedSharedWindows Server 2003 and Windows XP: This key was added in Windows Vista.
HKEY_CURRENT_USERSharedShared
** SOFTWARE**SharedShared
** Classes**SharedRedirected and reflected
** Appid**SharedRedirected and reflected with one exception: the DllSurrogate and DllSurrogateExecutable registry values are not reflected if their value is an empty string.
** CLSID**RedirectedRedirected and reflected
** DirectShow**RedirectedRedirected and reflected
** Interface**RedirectedRedirected and reflected
** Media Type**RedirectedRedirected and reflected
** MediaFoundation**RedirectedRedirected and reflected

2、问题的原因

由上述可知,HKLM\** Microsoft**\Windows\CurrentVersion\App Paths在Win7下是采用注册表共享方式,因此用RegCreateKeyEx+KEY_WOW64_64KEY写也不能达到只写在非wow6432node下。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值