Registry File (User.dat, System.dat) file format description

zhaozj2021-02-08  507

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 IS

Provided "As IS" without warranty of any kind ...

THIS Information WAS "Collected" During Sleepless Nights, and is not

Officially release 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 T

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 uncle

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 is 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 Edit A

Particular Setting, you would have to run the application Which manages these

Settings :( But what if this app won't start? ms inclined 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 contact

Any Number of Sub-Keys. this will form a tree-structure as you can see at

The Left Half of Reedit. (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 completion windows 3. ?? registry

95 System.dat System-Values ​​(HKEY_LOCAL_MACHINE)

User.dat user-value (HKEY_USERS)

Nt System32 / Config / Sam Sam-Part of The Registry (= NT Security)

System32 / config / Software Software-Specific Part

(HKEY_LOCAL_MACHINE / SOFTWARE)

System 32 / config / system system-specific part, the SYSTEM-SPECIG / SPART

(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-Profileif you are use 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_CLASS_ROOT POINTS to the "Class" Key in

The "HKEY_LOCAL_MACHINE" HIVE,

The only hive in windows 3. ?? 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 search, 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 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-names

0x06 Word Text-Info-Record Key-Value (Default)

The Values ​​Are The Locical Number of The Block Inside File:

Offset = blocksize * blocknumber headersize

Since 2 of this Values ​​Are Constant:

OFFSET = 8 * block 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 theData-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 file:

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 used.

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 ??

Thase 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 NEDED TO BUILT The Tree-structure of the registry. this

Block Will Be Larger Then 65536 Bytes (0xfff)!

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 (Offen 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 (0xfffffffff)

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 "haveh" -value is a value representing the key's name. Windows Will Not 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 (0xfffffffff)

The ID-field HAS The FOLLOWING FORMAT:

BITS 31..16: Number of the corresponding rgdb-blocksbits 15..0: Continuous Number Inside 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 buy as a seperator only and has no meaning here.

Next you initialize a d-word with 0 and add all ascii-value 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-value, Since they

Cannot Be Found Again (Althought the 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 limited.

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 it 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 calculate 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-block (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 value in 0x0008 and 0x001c Should Be The Same, SO I don't know

IF the isy is the correct or swapped ...

From offset 0x0020 Inside a hbin-block data is stored with the folowing

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-block

=========================== 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 Theowner-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" -tribord

================

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" -trib

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 buy for checking the

Data-consisten! 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 counented the number of reason. To this

"SK" -record. You can use one "SK" -trib 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 acid it 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 (0xfffffffff).

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. | | | | - ------------ | XXXXX |

------------ | | Value Rec. | --------> ---------- ------ -

v | ---------- | Usage CNT. |

--------- | | Length |

| NEXT REC. | | | TEXT | -------> -------

| first sub | ------ ------------ | XXXXX |

| Name | -------

| Value |

---------

Great 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.

转载请注明原文地址:https://www.9cbs.com/read-223.html

New Post(0)