Win95下的注册表文件(User.dat,System.dat)文件格式说明 (转)[@more@]

windows registry files

agreement: ==========

the author of this document will not be responsible for any damage and/or license violation that may occur. the information within this document is provided "as is" without warranty of any kind... this information was "collected" during sleepless nights, and is not officially released by microsoft! it shall give you a peek at the windows(tm) internals to give you a chance to recover from corrupted data.

the author has nothing to do with microsoft, except that he uses their products...

if you don't agree with this, stop reading this document, and delete it at once!

history: ========

what is the registry? where did it came from? two questions, which i will try to answer here. the registry is a database (at least microsoft thinks so:) which contains configuration information about the system. it mainly is a memory dump which is saved to one or more files on the windows host drive. it is loaded every system-boot and remains resident until shutdown. since parts of it are not used during normal operation it will be swapped out very soon. the registry appeared with windows 3.?? (sorry, i can't remember any earlier version :-), where it was used for file associations and the "ole" functions (the conection between ole-id's and the applications). this is a critical information and since the registry has (almost) no checksum information (!), it sometimes gets corrupted. this is the main reason for this doc.

using windows 3.x, almost every configuration was done using good old ".ini"- files, which were readable but slow and limited in size (64k). in windows 95 (and nt), the registry was used instead of these files. so, to edit a particular setting, you would have to run the application which manages these settings. :( but what if this app won't start? ms included a tool named regedit in windows 3.?? and 95, and a regedt32 in windows NT. you can use these apps to edit all contents of the registry (in windows nt the registry supports security, as well as it provides the security for the whole system!)

an application can open a "key", write values (variables) to it and fill them with data. each key represents also a value called "default" and can contain any number of sub-keys. this will foRM a tree-structure as you can see at the left half of regedit. (note: regedit from windows 3.?? has to be started with /v or /y, i can't remember now)

where can i find the registry??? ================================

that differs for each windows-version:

version file(s) contents 3.1x reg.dat complete windows 3.?? registry

95 system.dat system-values (hkey_local_machine) user.dat user-values (hkey_users)

nt system32configsam sam-part of the registry (=nt security) system32configsoftware software-specific part (hkey_local_machinesoftware) system32configsystem system-specific part (hkey_local_machinesystem) profiles%username%ntuser.dat user-specific part (hkey_current_user{s-1-xxx...}) profiles%username%ntuser.man like ntuser.dat but a mandatory-profile

if you are using a roaming-profile with windows nt, ntuser.xxx can be on a.NETwork-share as well...

terms =====

the registry consists of the following elements:

hive: strating point of the structure. the name of an hive starts with the "hkey_"-prefix. can be seen as a "drive" in a file system.

hive name beschreibung 3.1 95 nt4 hkey_classes_root points to the "class" key in the "hkey_local_machine" hive, the only hive in windows 3.?? x x x

hkey_current_user information and settings valid for the currently logged in user. (points to the correct x x key under "hkey_users")

hkey_current_config settings for the currently active hardware profile. points to "hkey_local_machine x x controlcontrolsetxxx

hkey_users contains all currently active user settings. since nt is a single user system, there will be only one key (the s-id x x of the active user), and a ".defualt" key (the settings for the ctrl-alt-del environment)

hkey_localmachine all local settings x x

hkey_dyn_data as the name says, here you'll find x dynamic data (cpu-usage,...)

key: a key to the registry can be seen as a directory in a file system. value: can be seen as the registrys "file" data: is the actual setting, can be seen as the contents of a file

windows 3.x ===========

this registry is the easiest one. it consists of 3 blocks, which are not "signed" at all:

block position size header 0 32 bytes navigation-info 0x00000020 ??? data-block ??? ???

the "???" marked values can be read from the header.

header ======

offset size description 0x0000 8 byte ascii-text: "shcc3.10" 0x0008 d-word ? 0x000c d-word ? (always equal the d-word at 0x0008) 0x0010 d-word number of entrys in the navigation-block 0x0014 d-word offset of the data-block 0x0018 d-word size of the data-block 0x001c word ? 0x001e word ?

values marked "?" are not important for a read-access, and therefore unknown to me...

navigation-block ================

this is where chaos rules! it consists of two different, 8 byte long blocks:

* navigation-info-record, * text-info-record

the first record in the navigation block is a navigation info record.

navigation-info-record

offset size contents 0x00 word next key (same level) 0x02 word first sub-key (one level deeper) 0x04 word text-info-record key-namens 0x06 word text-info-record key-value (default)

the values are the locical number of the block inside the file:

offset=blocksize*blocknumber+headersize

since 2 of this values are constant:

offset=8*blocknumber+0x20

text-info-record ================

offset size contents 0x00 word ? 0x02 word number of references to this text 0x04 word text-length 0x06 word offset of the text-string inside the data-block

to get the text-offset inside the file you have to add this offset to the data-offset inside the header.

data-block ==========

the data-block only consists of a collection of text-strings. right in front of every text is a word which may or may not have a meaning. the offset in the text-info record points directly to the text, the text-size has to be defined in the text-info record too.

windows 95 ==========

the windows95-registry files:

inside the windows-directory (default: c:windows) are 2 files which are loaded to form the registry:

system.dat

and

user.dat

this files are mapped to the following hives:

hkey_local_machine in system.dat

and

hkey_users in user.dat

the file structure: ===================

both files have the same structure. each of them consists of 3 blocks where 1 of these blocks can be repeated. every block has a 4 byte long signature to help identify its contents.

id block-contents max. size creg header 32 bytes @ offset 0 rgkn directory information (tree-structure) ??? @ offset 32 rgdb the real data (values and data) max. 65535 bytes an offset ??

these blocks are "sticked together" with no space between them, but always a multiple of 16 in size.

the creg-block ==============

offset size inhalt 0x00000000 d-word ascii-"creg" = 0x47455243 0x00000008 d-word offset of 1st rgdb-block 0x00000010 d-word # of rgdb-blocks

all other values are not needed to read the registry...

the rgkn-block ==============

i assume that rgkn stands for registry-key-navigation. this block contains the information needed to built the tree-structure of the registry. this block will be larger then 65536 bytes (0xffff)!

all offset-values are relative to the rgkn-block!

offset size contents 0x00000000 d-word ascii-"rgkn" = 0x4e4b4752 0x00000004 d-word size of the rgkn-block in bytes 0x00000008 d-word rel. offset of the root-record 0x00000020 ???? tree-records (often the 1st record)

the tree-record ===============

the tree-record is a "complete" registry-key. it contains the "hash"-info for the real data stored in this key.

offset size contents 0x0000 d-word always 0 0x0004 d-word hash of the key-name 0x0008 d-word always -1 (0xffffffff) 0x000c d-word offset of the owner (parent)-records 0x0010 d-word offset of the 1st sub-sey record 0x0014 d-word offset of the next record in this level 0x0018 d-word id-number of the real key

the 1st entry in a "usual" registry file is a nul-entry with subkeys: the hive itself. it looks the same like other keys. even the id-number can be any value.

the "hash"-value is a value representing the key's name. windows will not search for the name, but for a matching hash-value. if it finds one, it will compare the actual string info, otherwise continue with the next key.

end of list-pointers are filled with -1 (0xffffffff)

the id-field has the following format:

bits 31..16: number of the corresponding rgdb-blocks bits 15..0: continuous number inside this rgdb-block.

the hash-method: ================

you are looking for the key: softwaremicrosoft

first you take the first part of the string and convert it to upper case

software

the "" is used as a seperator only and has no meaning here. next you initialize a d-word with 0 and add all ascii-values of the string which are smaller than 0x80 (128) to this d-word.

software = 0x0000026b

now you can start looking for this hash-value in the tree-record. if you want to modify key names, also modify the hash-values, since they cannot be found again (although they would be displayed in regedit)

the rgdb-block ==============

header:

offset size contents 0x0000 d-word ascii-"rgdb" = 0x42444752 0x0004 d-word size of this rgdb-block 0x0020 ???? rgdb records

rgdb-record (key-information) =============================

offset size contents 0x0000 d-word record length in bytes 0x0004 d-word id-number 0x0008 d-word ??? size ??? 0x000c word text length of key name 0x000e word number of values inside this key 0x0010 d-word always 0 0x0014 ???? key-name 0x???? ???? values

the first size (record length) can be used to find the next record. the second size value is only correct if the key has at least one value, otherwise it is a little lower.

the key-name is not 0-teRminated, its length is defined by the key- text length field. the values are stored as records.

value-record ============

offset size contents 0x0000 d-word type of data 0x0004 d-word always 0 0x0008 word length of value-name 0x000a word length of value-data 0x000c ???? value-name 0x???? ???? data

data-types ==========

value contents 0x00000001 regsz - 0-terminated string (sometimes without the 0!) 0x00000003 regbin - binary value (a simple data-block) 0x00000004 regdword - d-word (always 4 bytes in size)

windows nt (version 4.0) ========================

whoever thought that the registry of windows 95 and windows nt are similar will be surprised! they only look much the same, but have completely other structures! since the rgdb-blocks in the windows 95 registry are not larger than 0xffff, we can see that it is optimized for a 16-bit os... windows nt stores its registry in a page-oriented format with blocks of 4kb (4096 = 0x1000 bytes)

the windows nt registry has 2 different blocks, where one can occure many times...

the "regf"-block ================

"regf" is obviosly the abbreviation for "registry file". "regf" is the signature of the header-block which is always 4kb in size, although only the first 64 bytes seem to be used and a checksum is calculated over the first 0x200 bytes only!

offset size contents 0x00000000 d-word id: ascii-"regf" = 0x66676572 0x00000004 d-word ???? 0x00000008 d-word ???? always the same value as at 0x00000004 0x0000000c q-word last modify date in winnt date-format 0x00000014 d-word 1 0x00000018 d-word 3 0x0000001c d-word 0 0x00000020 d-word 1 0x00000024 d-word offset of 1st key record 0x00000028 d-word size of the data-blocks (filesize-4kb) 0x0000002c d-word 1 0x000001fc d-word sum of all d-words from 0x00000000 to 0x000001fb

i have analyzed more registry files (from multiple machines running nt 4.0 german version) and could not find an explanation for the values marked with ???? the rest of the first 4kb page is not important...

the "hbin"-block ================

i don't know what "hbin" stands for, but this block is always a multiple of 4kb in size.

inside these hbin-blocks the different records are placed. the memory- management looks like a c-compiler heap management to me...

hbin-header ===========

offset size contents 0x0000 d-word id: ascii-"hbin" = 0x6e696268 0x0004 d-word offset from the 1st hbin-block 0x0008 d-word offset to the next hbin-block 0x001c d-word block-size

the values in 0x0008 and 0x001c should be the same, so i don't know if they are correct or swapped...

from offset 0x0020 inside a hbin-block data is stored with the following format:

offset size contents 0x0000 d-word data-block size 0x0004 ???? data

if the size field is negative (bit 31 set), the corresponding block is free and has a size of -blocksize! the data is stored as one record per block. block size is a multiple of 4 and the last block reaches the next hbin-block, leaving no room.

records in the hbin-blocks ==========================

nk-record

the nk-record can be treated as a kombination of tree-record and key-record of the win 95 registry.

lf-record

the lf-record is the counterpart to the rgkn-record (the hash-function)

vk-record

the vk-record consists information to a single value.

sk-record

sk (? security key ?) is the acl of the registry.

value-lists

the value-lists contain information about which values are inside a sub-key and don't have a header.

datas

the datas of the registry are (like the value-list) stored without a header.

all offset-values are relative to the first hbin-block and point to the block- size field of the record-entry. to get the file offset, you have to add the header size (4kb) and the size field (4 bytes)...

the nk-record =============

offset size contents 0x0000 word id: ascii-"nk" = 0x6b6e 0x0002 word for the root-key: 0x2c, otherwise 0x20 0x0004 q-word write-date/time in windows nt notation 0x0010 d-word offset of owner/parent key 0x0014 d-word number of sub-keys 0x001c d-word offset of the sub-key lf-records 0x0024 d-word number of values 0x0028 d-word offset of the value-list 0x002c d-word offset of the sk-record 0x0030 d-word offset of the class-name 0x0044 d-word unused (data-trash) 0x0048 word name-length 0x004a word class-name length 0x004c ???? key-name

the value-list ==============

offset size contents 0x0000 d-word offset 1st value 0x0004 d-word offset 2nd value 0x???? d-word offset nth value

to determine the number of values, you have to look at the owner-nk-record!

der vk-record =============

offset size contents 0x0000 word id: ascii-"vk" = 0x6b76 0x0002 word name length 0x0004 d-word length of the data 0x0008 d-word offset of data 0x000c d-word type of value 0x0010 word flag 0x0012 word unused (data-trash) 0x0014 ???? name

if bit 0 of the flag-word is set, a name is present, otherwise the value has no name (=default) if the data-size is lower 5, the data-offset value is used to store the data itself!

the data-types ==============

wert beteutung 0x0001 regsz: character string (in unicode!) 0x0002 expandsz: string with "%var%" expanding (unicode!) 0x0003 regbin: raw-binary value 0x0004 regdword: dword 0x0007 regmultisz: multiple strings, seperated with 0 (unicode!)

the "lf"-record ===============

offset size contents 0x0000 word id: ascii-"lf" = 0x666c 0x0002 word number of keys 0x0004 ???? hash-records

hash-record ===========

offset size contents 0x0000 d-word offset of corresponding "nk"-record 0x0004 d-word ascii: the first 4 characters of the key-name, padded with 0's. case sensitiv!

keep in mind, that the value at 0x0004 is used for checking the data-consistency! if you change the key-name you have to change the hash-value too!

the "sk"-block ==============

(due to the complexity of the sam-info, not clear jet)

offset size contents 0x0000 word id: ascii-"sk" = 0x6b73 0x0002 word unused 0x0004 d-word offset of previous "sk"-record 0x0008 d-word offset of next "sk"-record 0x000c d-word usage-counter 0x0010 d-word size of "sk"-record in bytes ???? ???? ???? security and auditing settings... ????

the usage counter counts the number of references to this "sk"-record. you can use one "sk"-record for the entire registry!

windows nt date/time format ===========================

the time-format is a 64-bit integer which is incremented every 0,0000001 seconds by 1 (i don't know how accurate it realy is!) it starts with 0 at the 1st of january 1601 0:00! all values are stored in gmt time! the time-zone is important to get the real time!

common values for win95 and win-nt ==================================

offset values marking an "end of list", are either 0 or -1 (0xffffffff). if a value has no name (length=0, flag(bit 0)=0), it is treated as the "default" entry... if a value has no data (length=0), it is displayed as empty.

simplyfied win-3.?? registry: =============================

+-----------+ | next rec. |---+ +-----&gt +------------+ | first sub | | | | usage cnt. | | name | | +--&gt +------------+ | | length | | value | | | | next rec. | | | text |-------&gt +-------+ +-----------+ | | | name rec. |--+ +------------+ | xxxxx | +------------+ | | value rec. |--------&gt +------------+ +-------+ v | +------------+ | usage cnt. | +-----------+ | | length | | next rec. | | | text |-------&gt +-------+ | first sub |------+ +------------+ | xxxxx | | name | +-------+ | value | +-----------+

greatly simplyfied structure of the nt-registry: ================================================

+-------------------------------------------------------------------------+ v | +---------------+ +-------------&gt +-----------+ +------&gt +---------+ | | "nk" | | | lf-rec. | | | nk-rec. | | | id | | | # of keys | | | parent |---+ | date | | | 1st key |--+ | .... | | parent | | +-----------+ +---------+ | suk-keys |-------+ | values |---------------------&gt +----------+ | sk-rec. |---------------+ | 1. value |--&gt +----------+ | class |--+ | +----------+ | vk-rec. | +---------------+ | | | .... | v | | data |--&gt +-------+ +------------+ | +----------+ | xxxxx | | class name | | +-------+ +------------+ | v +---------+ +---------+ +-----&gt | next sk |---&gt | next sk |--+ | +---| prev sk |

--------------------------------------------------------------------------------

hope this helps.... (although it was "fun" for me to uncover this things, it took me several sleepless nights ;)

b.d.

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-988927/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-988927/

Win95下的注册表文件(User.dat,System.dat)文件格式说明 (转)相关推荐

  1. win7下的添加自定义右键功能 注册表文件

    直接按(windows微标+r)键盘,出来运行程序的窗口,输入regedit,如今注册表程序窗口后,进入如下路径,如果不存在就新建一个. HKEY_CLASSES_ROOT\*\shell *是一个路 ...

  2. DOS下操作注册表的部分命令

    1.导出注册表 格式:regedit /l:system /R:user /e filename.reg regpath 含义:/l system 指定system.dat文件的路径 :/R user ...

  3. cmd下修改注册表完全攻略

    cmd下修改注册表完全攻略 2005-5-10 17:27:00 信息来源:[url]www.juntuan.net[/url] regedit虽是gui下使用的东东 但其实是有未公开的参数的 可以在 ...

  4. [转载] 黑鹰完完全全学习注册表——剖析注册表文件体系

    需要用到的软件:系统注册表(regedit.exe) 内容: 1.Windows 98的物理文件构成 Windows 98注册表的物理文件构成比较简单,是由两个文件构成的: User.dat:特定的用 ...

  5. 命令编写注册表文件修改注册表项

    命令编写注册表文件修改注册表项 1.何谓REG文件 REG文件实际上是一种注册表脚本文件,双击REG文件即可将其中的数据导入到注册表中.利用REG文件我们可以直接对注册表进行任何修改操作,它对注册表的 ...

  6. win10进行系统还原 (可以还原注册表文件 还可以清除近期卸载不了的软件)

    我昨天为了给我爸刷机 就下了很多刷机软件 可能有病毒 但是某些杀毒软件检测不出来 但是而且这些软件昨天改了很多注册表的内容 我还是不放心 今天就想把那些软件卸载了 但是普通卸载方式卸载不了,所以通过系 ...

  7. mysql打开注册表命令_怎么打开注册表文件?

    打开注册表文件的方法:首先使用鼠标依次点击"开始"按钮->"运行"选项:然后在"运行"窗口中输入"regedit" ...

  8. Reg Organizer(注册表文件清理器) v8.30.2中文绿色便携版

    点击下载来源:Reg Organizer(注册表文件清理器) v8.30.2中文绿色便携版 Reg Organizer是一款高品质的注册表文件清理器工具,通过简单的清理和整理窗口注册表项以及卸载程序来 ...

  9. 编写注册表文件修改注册表项

    编写注册表文件修改注册表项 1.何谓REG文件 REG文件实际上是一种注册表脚本文件,双击REG文件即可将其中的数据导入到注册表中.利用REG文件我们可以直接对注册表进行任何修改操作,它对注册表的操作 ...

最新文章

  1. Tensorflow name_scope和variable_scope的用法
  2. java -d32_java11教程--JDK 10删除和不推荐的功能和选项-2
  3. 数学史上的哲学绝唱——无穷观与数学基础的争论
  4. phantomjs 抓取html,javascript – 如何使用PhantomJS获取网站的HTML源代码
  5. 简介I/O向量、sendv、writev
  6. 各大航空公司将加大海南春运期间运力投入
  7. C# 配置文件 自定義結點
  8. 微信小程序销毁某一注册函数_微信小程序 生命周期函数详解
  9. 怎么单选_第一届化妆品分类大赛丨用过的化妆刷、过期的口红…该怎么扔
  10. OpenCV读取RTSP视频流
  11. 基于AE+C#实现在TOCControl中实现指定图层删除
  12. php arrayfillkeys,PHP中的array_fill_keys()函数
  13. 计算机硬盘的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
  14. Python 基础 1加到100 求和
  15. Monte Carlo Approximations
  16. android属于数据库管理系统,详细谈谈Android系统中的SQLite数据库的应用
  17. 专访阿里巴巴元境王矛:打造研运一体化平台,去做开创性的事
  18. PS字体加粗的小方法、、
  19. 1934: [Shoi2007]Vote 善意的投票
  20. c++——vc++中的六种Runtime Library的类型

热门文章

  1. 2023兔年凯立德车载导航最新版
  2. 科学种草 | 破解小红书素人爆文的奥秘
  3. 使用Bert完成实体之间关系抽取
  4. MAC xmind破解版使用
  5. python 根据word生成ppt_python 生成 word、ppt 操作源码分享
  6. 简单粗暴地理解动态规划
  7. db2 数据库配置HADR+TSA添加集群节点
  8. CSS3动画帧数科学计算法http://tid.tenpay.com/?p=5983
  9. 《程序员升职记》2.繁忙的收发室
  10. 腾讯研究院夹缝中生存 35万元年薪难求才