Skip to content

Commit

Permalink
Noted the difference in the two content lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArion committed Mar 10, 2024
1 parent 09bafd8 commit a5705ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions .github/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@ The Pattern for this type can be found [here](../ImHex-Patterns/NotepadTab.pat)
> - [1-16] `ul` Saved File Path Length
> - [~] `char16[~]` Saved File Path
> - UTF-16
> - [1-16] `ul` Tab Content Length
> - [1-16] `ul` Saved Tab Content Length
> - [2] `u8[2]` Possible Delimiter `05 01`
> - [1-16] `ul` FileTime `D2 EC E8 C2 D8 AF 9C ED 01`
> - Increments from Left to Right
Expand All @@ -34,8 34,7 @@ The Pattern for this type can be found [here](../ImHex-Patterns/NotepadTab.pat)
- [1-16] `ul` Selection Start Index
- [1-16] `ul` Selection End Index
- [4] `u8[4]` Possible Delimiter `01 00 00 00`
- [1-16] `ul` Tab Content Length
- Same as previous
- [1-16] `ul` Unsaved Tab Content Length
- [~] `char16[~]` Tab Content
- UTF-16
- [1] `bool` Unknown Bool `00 / 01`
Expand Down
17 changes: 9 additions & 8 deletions ImHex-Patterns/NotepadTab.hexpat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 29,7 @@ struct NotepadTab
{
ul SavedFilePathLength;
char16 SavedFilePath[SavedFilePathLength];
ul ContentLength1;
ul SavedContentLength;

u8 Unknown1[2]; // 05 01

Expand All @@ -48,23 48,24 @@ struct NotepadTab

u8 SelectionEndDelimiter[4]; // 01 00 00 00

ul ContentLength;
char16 Content[ContentLength];
ul CurrentContentLength;
char16 Content[CurrentContentLength];

// False on Saved File,
// True on unsaved file,
// False on unsaved file with chunks
bool Unknown3;
// True on saved file with unsaved content
bool HasUnsavedContent;

u8 CRC32[4];
UnsavedChunk Chunks[0];
};

fn VerifyLengths(ref NotepadTab tab)
fn CheckForUnsavedContent(ref NotepadTab tab)
{
if (tab.ContentLength1 != tab.ContentLength)
if (tab.SavedContentLength != tab.CurrentContentLength)
{
std::warning("Content Length Mismatch! Length 1 is {0} While Length 2 is {1}", tab.ContentLength1, tab.ContentLength);
std::print(std::format("You have some unsaved content! {0} bytes of unsaved content!", tab.CurrentContentLength - tab.SavedContentLength));
}
};

Expand Down Expand Up @@ -92,7 93,7 @@ if (tab.IsSaved)
std::time::EpochTime unixTime = std::time::filetime_to_unix(tab.FileTime);
std::print("Last Saved Unix Time is {0}",std::string::to_string(unixTime));

VerifyLengths(tab);
CheckForUnsavedContent(tab);

std::time::Time localTime = filetime_to_local(tab.FileTime);

Expand Down

0 comments on commit a5705ce

Please sign in to comment.