Skip to content

Repository files navigation

Notepad State Library

Microsoft Windows 11's version of Windows Notepad supports multiple tabs and many other features. This repository serves to record and document my research and efforts in reverse engineering the format of the tabstate and windowstate files and understand their behavior. The result of which is a C# library and toolset that provides the ability to parse and manipulate the tabstate, windowstate, and settings files.

The following are planned:

This library and its tools could be useful in forensic investigations or even in the toolbox for a red/purple team.

Note

This repository grew out of two previous repositories of research and code that have been kept for posterity.

https://github.com/ogmini/Notepad-Tabstate-Buffer
https://github.com/ogmini/Notepad-Windowstate-Buffer

Usage

Warning

Prior to using the library or any of the tools, you should have an understanding of the tabstate, windowstate, and settings files. I try to keep this README updated with research that I am documenting on my blog.

Information Section

Library

I have not released compiled DLLs. You can find the source code at https://github.com/ogmini/Notepad-State-Library/tree/main/NotepadStateLibrary/NotepadStateLibrary and compile it.

Documentation WIP

Pattern Files

Binary Templates for 010 Editor and Pattern Files for ImHex have been submitted to their respective repositories and should be available for use. They can also be found in this repository at https://github.com/ogmini/Notepad-State-Library/tree/main/PatternFiles.

Parser

There are two versions of the parser and their differences are detailed below.

WindowsNotepadParser.exe will check the default locations for Tabstate and Windowstate files and generate CSV files which can be viewed in tools such as Timeline Explorer or Excel. GIFs will also be generated for any detected Unsaved Buffer Chunks to visualize the changes of the content over time.

WindowsNotepadParser-minimal.exe will not generate GIFs for any Unsaved Buffer Chunks.

Running WindowsNotepadParser.exe --help will display flag options.

 -t, --tabstatelocation Tab State Folder Location. Default value is the system location.
-w, --windowstatelocation Window State Folder Location. Default value is the system location.
-o, --outputlocation Output Folder Location for CSV files. Default location is same folder as program.
--help Display this help screen.
--version Display version information.

Examples

The following arguments would look at D:\tabstatefolder for tab state files and D:\windowstatefolder for window state fles. The csv files will be output to D:\results. WindowsNotepadParser.exe -t D:\tabstatefolder -w D:\windowstatefolder -o D:\results

The following arguments will parse the default system location for the current user and output the csv files to D:\results.
WindowsNotepadParser.exe -o D:\results

Information

The information below has been tested/validated on the following configurations:

Windows BuildWindows Notepad Version
Windows 11 23H2 OS Build 22635.3566 (Beta Release Branch)11.2402.22.0
Windows 11 23H2 OS Build 22631.3527 (Stable Release Branch)11.2402.22.0
Windows 11 23H2 OS Build 22631.3737 (Stable Release Branch)11.2404.10.0
Windows 11 23H2 OS Build 22631.4317 (Stable Release Branch)11.2407.9.0
Windows 11 23H2 OS Build 22631.4317 (Stable Release Branch)11.2408.12.0
Windows 11 23H2 OS Build 22631.4460 (Stable Release Branch)11.2409.9.0
Windows 11 24H2 OS Build 26100.4652 (Stable Release Branch)11.2504.62.0
Windows 11 25H2 OS Build 26200.6899 (Stable Release Branch)11.2507.26.0

Tabstate

Note

Location of Files %localappdata%\Packages\Microsoft.WindowsNotepad_8wekyb3d8bbwe\LocalState\TabState

Relevant Files *.bin*.0.bin*.1.bin

The tabstate files store information about the open tabs and their contents in Windows Notepad. The filenames are GUIDs and there are three types of *.bin files:

  • File Tab
    • These tabs have been saved to disk or have been opened from a file on disk.
    • These tabs can be in a Saved or Unsaved condition.
      • Unsaved condition is visually denoted by a dot to the right of the Tab name. Dot
    • They have a TypeFlag of 1.
  • No File Tab
    • These tabs have not been saved to disk and have not been opened from a file on disk. They only exist in the *.bin files.
    • These tabs can be in a New or Reopened condition.
      • Reopened condition is visually denoted by a dot to the right of the Tab name. Dot
    • They have a TypeFlag of 0.
  • State File
    • These are the *.0.bin and *.1.bin files and store extra information about the related matching GUID *.bin.
    • These files do not always exist and this behavior will be expanded upon in the Behavior section.
    • They have a TypeFlag of 10 or 11.

Integrity of the file is validated with CRC32 calculated and stored for the preceding bytes.

I've created a Notepad-Tabstate.bt for 010 Editor and a Notepad-Tabstate.hexpat for ImHex to assist in examining these files.

File Format

File Tab
NameTypeNotesSaved Condition
Signature / Magic Bytes2 bytes[0x4E, 0x50] "NP"
Sequence NumberuLEB128Always 0
TypeFlaguLEB128Equal to 1
FilePathLengthuLEB128Length of the FilePath in bytes
FilePathUTF-16LE (Variable Length)FilePath string with length determined from FilePathLength
SavedFileContentLengthuLEB128Size in bytes of the text file saved on diskWill be 0 if all changes have been saved to the file
EncodingType1 byte1 = ANSI / 2 = UTF16LE / 3 = UTF16BE / 4 = UTF8BOM / 5 = UTF8
CarriageReturnType1 byte1 = Windows CRLF / 2 = Macintosh CR / 3 = Unix LF
TimestampuLEB12818-digit Win32 FILETIMEWill be 0 if all changes have been saved to the file
FileHash32 bytesSHA256 Hash of the text file saved on diskWill be 0 if all changes have been saved to the file
❓Unknown2 bytes[0x00, 0x01]
SelectionStartIndexuLEB128Start position of text selection
SelectionEndIndexuLEB128End position of text selection
Configuration Block
ContentLengthuLEB128Length of the Content in bytesWill be 0 if all changes have been saved to the file
ContentUTF-16LE (Variable Length)Text Content with length determined from ContentLengthWill not exist if all changes have been saved to the file
Unsaved1 byteUnsaved flagWill be 0 since the file has been saved
CRC324 bytesCRC32 Check
Unsaved Buffer ChunksWill exist if any changes to the file are unsavedWill not exist if all changes been saved to the file
No File Tab
NameTypeNotesNew Condition
Signature / Magic Bytes2 bytes[0x4E, 0x50] "NP"
Sequence NumberuLEB128Always 0
TypeFlaguLEB128Equal to 0
❓Unknown1 byte[0x01]
SelectionStartIndexuLEB128Start position of text selection
SelectionEndIndexuLEB128End position of text selection
Configuration Block
ContentLengthuLEB128Length of the Content in bytesWill be 0
ContentUTF-16LE (Variable Length)Text Content with length determined from ContentLengthWill not exist
Unsaved1 byteUnsaved flagWill be 0
CRC324 bytesCRC32 Check
Unsaved Buffer ChunksValues will exist for changes until they are flushed to Content when Windows Notepad is closed
State File
NameTypeNotes
Signature / Magic Bytes2 bytes[0x4E, 0x50] "NP"
Sequence NumberuLEB128Increments and highest number signifies the active state file
TypeFlaguLEB12810 = No File Tab State / 11 = File Tab State
❓Unknown1 byte[0x00]
BinSizeuLEB128Size in bytes of the associated *.bin file
SelectionStartIndexuLEB128Start position of text selection
SelectionEndIndexuLEB128End position of text selection
Configuration Block
CRC324 bytesCRC32 Check
Configuration Block
NameTypeNotes
WordWrap1 byteWordWrap flag
RightToLeft1 byteRightToLeft flag
ShowUnicode1 byteShowUnicode flag
MoreOptionsuLEB128Number of More Options in bytes that follow
More Options Block
More Options Block
NameTypeNotes
❓Unknown1 byteSpellcheck/Autocorrect? Do not seem to be flags. These were added to the file format when Spellcheck/Autocorrect feature was added
❓Unknown1 byteSpellcheck/Autocorrect? Do not seem to be flags. These were added to the file format when Spellcheck/Autocorrect feature was added
Formatting1 byte1 = Unformatted / 2 = Markdown Formatted / 3 = Markdown Syntax
Unsaved Buffer Chunk

Note, these will not exist for a Markdown Formatted tab. https://ogmini.github.io/2025/06/28/Windows-Notepad-Markdown-Support.html

NameTypeNotes
Cursor PositionuLEB128Cursor Position of where Deletion/Addition/Insertion begins. Insertion is signified by both a Deletion Action and Addition Action
Deletion ActionuLEB128Number of Characters deleted
Addition ActionuLEB128Number of Characters added
Added CharactersUTF-16LE (Variable Length)Characters added with length determined from Addition Action
CRC324 bytesCRC32 Check of Unsaved Buffer Chunk

Windowstate

Note

Location of Files %localappdata%\Packages\Microsoft.WindowsNotepad_8wekyb3d8bbwe\LocalState\WindowState

Relevant Files *.0.bin*.1.bin

The windowstate files store information about opened windows of Windows Notepad and files are created for each opened window. Information is stored about:

  • Number of tabs
  • Order of tabs
  • Active tab
  • Window size
  • Window position

Integrity of the file is validated with CRC32 calculated and stored for the preceding bytes.

I've created a Notepad-WindowState.bt for 010 Editor and a Notepad-WindowState.hexpat for ImHex to assist in examining these files.

File Format

NameTypeNotes
Signature / Magic Bytes2 bytes[0x4E, 0x50] "NP"
Sequence NumberuLEB128
BytesToCRCuLEB128Number of bytes to the CRC Check
❓Unknown1 byte[0x00]
NumberTabsuLEB128Number of Tabs in Notepad
GUID Chunks16 bytes (Variable Number of Chunks)GUID for each tab in view order that refer to the filename of the matching Tabstate file
ActiveTabuLEB128Number of Active Tab in Notepad. 0 based index.
TopLeftCoords_XuINT32
TopLeftCoords_YuINT32
BottomRightCoords_XuINT32
BottomRightCoords_YuINT32
WindowSize_WidthuINT32
WindowSize_HeightuINT32
❓Unknown1 byte[0x00]
CRC324 bytesCRC32 Check
Slack SpaceVariable

Slack Space

It appears that the windowstate files will never reduce in size. More testing is required to validate this or to discover what actions will cause them to be deleted or cleared out.

There is a potential to recover complete or partial GUIDs from the slack space that can be tied back to past Tabstate files. These deleted files could possibly be recovered and examined. As Tabs are opened and closed, the slack space will get more and more convoluted and disarrayed as records are overwritten as the GUID Chunks section changes in size. Manual parsing is suggested and there is no guarantee of being able to recover anything of use.

Approaches

Warning

The approaches make heavy assumptions. As Tabs are opened and closed, the slack space will get more and more convoluted and disarrayed. Manual parsing is suggested and there is no guarantee of being able to recover anything of use.

WIP

Settings

Note

Location of Files %localappdata%\Packages\Microsoft.WindowsNotepad_8wekyb3d8bbwe\Settings

Relevant Files settings.dat

The settings files store application wide settings and defaults. The settings.dat file is an application hive which can be opened with Registry Editor and other tools which can handle registry files. I've also updated the RegistryHive.bt for 010 Editor. If a key doesn't exist that option hasn't been changed from the default or set. Research has already been published on this file format and a list of links can be found here

Rewrite

WIP

Rewrite is the AI integration into Windows Notepad.

Please see the following blog links:
https://ogmini.github.io/2025/03/08/Windows-Notepad-Rewrite.html
https://ogmini.github.io/2025/03/14/Windows-Notepad-Rewrite-Part-2.html
https://ogmini.github.io/2025/03/16/Windows-Notepad-Rewrite-Part-3.html
https://ogmini.github.io/2025/03/18/Windows-Notepad-Rewrite-Part-4.html
https://ogmini.github.io/2025/03/19/Windows-Notepad-Rewrite-Part-5.html

Useful Links / Information

Application Hives

Windows Store App Settings

Manipulating Windows Store App Settings

UWP App Data Storage

REGF Format

Registry Format

File Format

TypeHexDescription
0x5f5e10404 E1 F5 05uINT32
0x5f5e10505 E1 F5 05uINT32
0x5f5e10b0B E1 F5 05byte (bool)
0x5f5e10c0C E1 F5 05string (NULL Terminated)

Last 8 bytes of the value for each key is the 18-digit Win32 FILETIME Timestamp for the setting change.

KeyNameTypeNotes
AutoCorrect0x5f5e10b0 = Off / 1 = On
FindMatchCase0x5f5e10b0 = Off / 1 = On. Default is 0.
FindString0x5f5e10cStores the last string searched by find.
FindWrapAround0x5f5e10b0 = Off / 1 = On. Default is 1.
FirstCowriterClick0x5f5e10b
FirstSignIn0x5f5e10b
FontFamily0x5f5e10cString
FontSize0x5f5e104
FontStyle0x5f5e10cString
FormattingEnabled0x5f5e10bMarkdown Enabled
FormattingFREFirstLoad0x5f5e10bUnknown
GhostFile0x5f5e10b0 = Open in a new window / 1 = Open content from a previous session
LocalizedFontFamily0x5f5e10cString
LocalizedFontStyle0x5f5e10cString
OpenFile0x5f5e1040 = New Tab / 1 = New Window
PrivacyTeachingTip0x5f5e10b
RecentFiles0x5f5e10cCSV array. List is in descending order with the most recently closed file at the top.
RecentFilesEnabled0x5f5e10b0 = Off / 1 = On
RecentFilesFirstLoad0x5f5e10b0 = Off / 1 = On
ReplaceString0x5f5e10cStores the last string that was the replacement.
RewriteEnabled0x5f5e10b0 = Off / 1 = On
RewriteTeachingtip0x5f5e10b0 = Off / 1 = On
SpellCheckState0x5f5e10cJSON: {"Enabled":false,"FileExtensionsOverrides":[[".md",true],[".ass",true],[".lic",true],[".srt",true],[".lrc",true],[".txt",true]]}
StatusBarShown0x5f5e10b0 = Off / 1 = On
TeachingTipCheckCount0x5f5e105Unknown
TeachingTipExplicitClose0x5f5e10bUnknown
TeachingTipVersion0x5f5e105Unknown
Theme0x5f5e1040 = System / 1 = Light / 2 = Dark
WebAccountId0x5f5e10cUnknown
WebAccountType0x5f5e104
WindowPositionBottom0x5f5e104
WindowPositionHeight0x5f5e104
WindowPositionLeft0x5f5e104
WindowPositionRight0x5f5e104
WindowPositionTop0x5f5e104
WindowPositionWidth0x5f5e104
WordWrap0x5f5e10b0 = Off / 1 = On

Behavior

Timestamp for the File Tab for Tabstate files will be set to 0 when the file is saved to disk. It will have a valid value when the first change is made to the contents of the file. Any successive changes before saving the file will not result in the Timestamp being updated. This behavior persists over opening/closing Windows Notepad. In short, the Timestamp for the File Tab indicates when changes were started to be made on the file and that they have not yet been saved to disk.

The timestamps associated with each key in the application hive show us when those Settings were last changed.

The sequence number is used to tell which *.0.bin or *.1.bin is active as updates alternate between the two. The file with the highest sequence number is the active one and are relevant to both State Files and Windowstate files.

The presence of State Files can tell us a bit about the usage pattern of Windows Notepad. For a File Tab with no changes, the State Files are only created when Windows Notepad is closed. They are subsequently deleted when the File Tab is made active. The sequence number for the State Files will never increment and the *.1.bin file will be empty.

For a File Tab or No File Tab with unsaved changes, the State Files are only created when Windows Notepad is closed and no Unsaved Buffer Chunks were flushed. They are subsequently deleted when new changes are made or the file has been saved. The sequence number for the State Files will increment everytime Windows Notepad is closed and is indicative of many cycles of opening and closing Windows Notepad while in the unsaved and flushed state.

While Windows Notepad is open the File Tab and No File Tab can have Unsaved Buffer Chunks of changes that haven't been flushed. The Unsaved Buffer Chunks can be used to playback the changes to the text similar to a keylogger. Once Windows Notepad is closed or the file is saved, the Unsaved Buffer Chunks are flushed into the content.

Opening a Tab adds another Tab GUID Chunk to the collection of Chunks and updates the number of bytes to the CRC32 in the Windowstate file. Any existing slack space in the file will get overwritten up to the end of the new CRC32.

Closing a tab deletes the relevant Tab GUID Chunk from the collection of Chunks and updates the number of bytes to the CRC32. Slack space after the CRC32 may result from closing tabs. The files appear to never get smaller.

The following actions will cause an update of the sequence number in the Windowstate files:

  • Resizing window
  • Moving window
  • Reordering/moving tabs
  • Closing tab(s)
    • Closing multiple tabs at once results in one action
  • Opening tab(s)

Creating a new Windows Notepad window by dragging a tab outside of the original window will spawn new Windowstate files. As you close each extra window, it will prompt you to save any files in that window and the corresponding Windowstate files will be deleted. When the last window of Windows Notepad is closed, the final Windowstate files will not be deleted. Only the Windowstate files for the last closed Windows Notepad is kept.

Acknowledgements

In random order:

jlogsdonNordGaren
JohnHammondJustArion
joost-jdaddycocoaman

About

C# Library and research notes for Windows 11 Notepad State Files

Topics

Resources

Stars

32 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages