分享
 
 
 

Win95下的注册表文件(User.dat,System.dat)文件格式说明

王朝system·作者佚名  2006-12-17
窄屏简体版  字體: |||超大  

Win95下的注册表文件(User.dat,System.dat)文件格式说明

Win95下的注册表文件(User.dat,System.dat)文件格式说明 Windows registry files

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

the author of this document will not be responsible for any damage and/orlicense violation that may occur. the information within this document isprovided "as is" without warranty of any kind...this information was "collected" during sleepless nights, and is notofficially 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 theirproducts...

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

history:========

what is the registry? where did it came from? two questions, which i will try toanswer 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 windowshost drive. it is loaded every system-boot and remains resident untilshutdown. 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) nochecksum information (!), it sometimes gets corrupted. this is the mainreason 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 aparticular setting, you would have to run the application which manages thesesettings. :( but what if this app won't start? ms included a tool namedregedit in windows 3.?? and 95, and a regedt32 in windows nt. you can usethese apps to edit all contents of the registry (in windows nt the registrysupports 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 themwith data. each key represents also a value called "default" and can containany number of sub-keys. this will form a tree-structure as you can see atthe left half of regedit. (note: regedit from windows 3.?? has to be startedwith /v or /y, i can't remember now)

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

that differs for each windows-version:

version file(s) contents3.1x reg.dat complete windows 3.?? registry

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

nt system32\config\sam sam-part of the registry (=nt security) system32\config\software software-specific part (hkey_local_machine\software) system32\config\system system-specific part (hkey_local_machine\system) 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 ona 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 nt4hkey_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 control\controlsetxxx

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 sizeheader 0 32 bytesnavigation-info 0x00000020 ???data-block ??? ???

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

header======

offset size description0x0000 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-block0x0014 d-word offset of the data-block0x0018 d-word size of the data-block0x001c word ?0x001e word ?

values marked "?" are not important for a read-access, and therefore unknownto 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 contents0x00 word next key (same level)0x02 word first sub-key (one level deeper)0x04 word text-info-record key-namens0x06 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 contents0x00 word ?0x02 word number of references to this text0x04 word text-length0x06 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 thedata-offset inside the header.

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

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

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

the windows95-registry files:

inside the windows-directory (default: c:\windows) are 2 files which areloaded 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 where1 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 32rgdb the real data (values and data) max. 65535 bytes an offset ??

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

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

offset size inhalt0x00000000 d-word ascii-"creg" = 0x474552430x00000008 d-word offset of 1st rgdb-block0x00000010 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 containsthe information needed to built the tree-structure of the registry. thisblock will be larger then 65536 bytes (0xffff)!

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

offset size contents0x00000000 d-word ascii-"rgkn" = 0x4e4b47520x00000004 d-word size of the rgkn-block in bytes0x00000008 d-word rel. offset of the root-record0x00000020 ???? tree-records (often the 1st record)

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

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

offset size contents0x0000 d-word always 00x0004 d-word hash of the key-name0x0008 d-word always -1 (0xffffffff)0x000c d-word offset of the owner (parent)-records0x0010 d-word offset of the 1st sub-sey record0x0014 d-word offset of the next record in this level0x0018 d-word id-number of the real key

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

the "hash"-value is a value representing the key's name. windows will notsearch for the name, but for a matching hash-value. if it finds one, itwill 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: software\microsoft

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 stringwhich 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 theycannot be found again (although they would be displayed in regedit)

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

header:

offset size contents0x0000 d-word ascii-"rgdb" = 0x424447520x0004 d-word size of this rgdb-block0x0020 ???? rgdb records

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

offset size contents0x0000 d-word record length in bytes0x0004 d-word id-number0x0008 d-word ??? size ???0x000c word text length of key name0x000e word number of values inside this key0x0010 d-word always 00x0014 ???? key-name0x???? ???? 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============

offsetsizecontents0x0000d-wordtype of data0x0004d-wordalways 00x0008wordlength of value-name0x000awordlength of value-data0x000c????value-name0x????????data

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

valuecontents0x00000001regsz - 0-terminated string (sometimes without the 0!)0x00000003regbin - binary value (a simple data-block)0x00000004regdword - d-word (always 4 bytes in size)

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

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

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

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 onlythe first 64 bytes seem to be used and a checksum is calculated overthe first 0x200 bytes only!

offsetsizecontents0x00000000d-wordid: ascii-"regf" = 0x666765720x00000004d-word????0x00000008d-word???? always the same value as at 0x000000040x0000000cq-wordlast modify date in winnt date-format0x00000014d-word10x00000018d-word30x0000001cd-word00x00000020d-word10x00000024d-wordoffset of 1st key record0x00000028d-wordsize of the data-blocks (filesize-4kb)0x0000002cd-word10x000001fcd-wordsum of all d-words from 0x00000000 to 0x000001fb

i have analyzed more registry files (from multiple machines runningnt 4.0 german version) and could not find an explanation for the valuesmarked 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===========

offsetsizecontents0x0000d-wordid: ascii-"hbin" = 0x6e6962680x0004d-wordoffset from the 1st hbin-block0x0008d-wordoffset to the next hbin-block0x001cd-wordblock-size

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

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

offsetsizecontents0x0000d-worddata-block size0x0004????data

if the size field is negative (bit 31 set), the corresponding blockis free and has a size of -blocksize!the data is stored as one record per block. block size is a multipleof 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 asub-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 addthe header size (4kb) and the size field (4 bytes)...

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

offsetsizecontents0x0000wordid: ascii-"nk" = 0x6b6e0x0002wordfor the root-key: 0x2c, otherwise 0x200x0004q-wordwrite-date/time in windows nt notation0x0010d-wordoffset of owner/parent key0x0014d-wordnumber of sub-keys0x001cd-wordoffset of the sub-key lf-records0x0024d-wordnumber of values0x0028d-wordoffset of the value-list0x002cd-wordoffset of the sk-record0x0030d-wordoffset of the class-name0x0044d-wordunused (data-trash)0x0048wordname-length0x004awordclass-name length0x004c????key-name

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

offsetsizecontents0x0000d-wordoffset 1st value0x0004d-wordoffset 2nd value0x????d-wordoffset nth value

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

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

offsetsizecontents0x0000wordid: ascii-"vk" = 0x6b760x0002wordname length0x0004d-wordlength of the data0x0008d-wordoffset of data0x000cd-wordtype of value0x0010wordflag0x0012wordunused (data-trash)0x0014????name

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

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

wertbeteutung0x0001regsz: character string (in unicode!)0x0002expandsz: string with "%var%" expanding (unicode!)0x0003regbin:raw-binary value0x0004regdword:dword0x0007regmultisz:multiple strings, seperated with 0(unicode!)

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

offsetsizecontents0x0000wordid: ascii-"lf" = 0x666c0x0002wordnumber of keys0x0004????hash-records

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

offsetsizecontents0x0000d-wordoffset of corresponding "nk"-record0x0004d-wordascii: 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 thedata-consistency! if you change the key-name you have to change thehash-value too!

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

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

offsetsizecontents0x0000wordid: ascii-"sk" = 0x6b730x0002wordunused0x0004d-wordoffset of previous "sk"-record0x0008d-wordoffset of next "sk"-record0x000cd-wordusage-counter0x0010d-wordsize 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 every0,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 arestored in gmt time! the time-zone is important to get the realtime!

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. |---++----->+------------+| first sub | ||| usage cnt. || name || +-->+------------+|| length || value || || next rec. ||| text |------->+-------++-----------+| || name rec. |--++------------+| xxxxx | +------------+ || value rec. |-------->+------------++-------+ v |+------------+| usage cnt. |+-----------+ || length || next rec. | || text |------->+-------+| first sub |------++------------+| xxxxx || name |+-------+| value |+-----------+

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

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

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

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

b.d.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有