Skip to content

Commit

Permalink
Worked on format support
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jul 9, 2023
1 parent 1c853ae commit 99bc3b7
Show file tree
Hide file tree
Showing 36 changed files with 2,582 additions and 294 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -135,12 +135,14 @@ stamp-h[1-9]
/tests/scca_test_file_header
/tests/scca_test_file_information
/tests/scca_test_file_metrics
/tests/scca_test_filename_string
/tests/scca_test_filename_strings
/tests/scca_test_io_handle
/tests/scca_test_notify
/tests/scca_test_support
/tests/scca_test_tools_info_handle
/tests/scca_test_tools_output
/tests/scca_test_tools_path_string
/tests/scca_test_tools_signal
/tests/scca_test_volume_information
/tests/tmp*
Expand Down
13 changes: 13 additions & 0 deletions documentation/Windows Prefetch File (PF) format.asciidoc
Expand Up @@ -65,6 +65,7 @@ in the section entitled "GNU Free Documentation License".
| 0.0.18 | J.B. Metz | February 2020 | Cleaned up notes.
| 0.0.19 | J.B. Metz | September 2020 | Cleaned up notes.
| 0.0.20 | N. Suthar | July 2023 | Corrections and additional information regarding unknown "hash string" section.
| 0.0.21 | J.B. Metz | July 2023 | Additional information regarding encoding of filenames.
|===

:numbered:
Expand Down Expand Up @@ -237,6 +238,10 @@ The executable filename will store a maximum of 29 characters. Dependent on the
Windows version the unused bytes of the executable filename can contain remnant
data. Windows 8.1 seems to fill the unused bytes with 0-byte values.

[NOTE]
The filename is not strict UTF-16 since it allows for unpaired surrogates, such
as "U+d800" and "U+dc00".

==== Format version

[cols="1,5",options="header"]
Expand Down Expand Up @@ -557,6 +562,10 @@ The directory strings consists of:

A filename string is an UTF-16 little-endian strings with end-of-string character.

[NOTE]
A filename string is not strict UTF-16 since it allows for unpaired surrogates,
such as "U+d800" and "U+dc00".

[yellow-background]*Is the the array followed by alignment padding? If so what
is the size of the alignment,16-byte? Seen values ranging from 6 to 2 bytes.*

Expand Down Expand Up @@ -747,6 +756,10 @@ The value does not include the end-of-string character.
| 2 | ... | | Array of UTF-16 little-endian strings with end-of-string character
|===

[NOTE]
A directory string is not strict UTF-16 since it allows for unpaired surrogates,
such as "U+d800" and "U+dc00".

== [[calculating_prefetch_hash]]Calculating the prefetch hash

There are multiple known hashing functions to be used for prefetch filename
Expand Down
12 changes: 12 additions & 0 deletions include/libscca.h.in
Expand Up @@ -270,6 +270,7 @@ int libscca_file_get_format_version(
libscca_error_t **error );

/* Retrieves the size of a specific UTF-8 encoded executable filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -280,6 +281,7 @@ int libscca_file_get_utf8_executable_filename_size(
libscca_error_t **error );

/* Retrieves a specific UTF-8 encoded executable filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -291,6 +293,7 @@ int libscca_file_get_utf8_executable_filename(
libscca_error_t **error );

/* Retrieves the size of a specific UTF-16 encoded executable filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -301,6 +304,7 @@ int libscca_file_get_utf16_executable_filename_size(
libscca_error_t **error );

/* Retrieves a specific UTF-16 encoded executable filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down Expand Up @@ -372,6 +376,7 @@ int libscca_file_get_number_of_filenames(
libscca_error_t **error );

/* Retrieves the size of a specific UTF-8 encoded filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -383,6 +388,7 @@ int libscca_file_get_utf8_filename_size(
libscca_error_t **error );

/* Retrieves a specific UTF-8 encoded filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -395,6 +401,7 @@ int libscca_file_get_utf8_filename(
libscca_error_t **error );

/* Retrieves the size of a specific UTF-16 encoded filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -406,6 +413,7 @@ int libscca_file_get_utf16_filename_size(
libscca_error_t **error );

/* Retrieves a specific UTF-16 encoded filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down Expand Up @@ -449,6 +457,7 @@ int libscca_file_metrics_free(
libscca_error_t **error );

/* Retrieves the size of the UTF-8 encoded filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -459,6 +468,7 @@ int libscca_file_metrics_get_utf8_filename_size(
libscca_error_t **error );

/* Retrieves the UTF-8 encoded filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -470,6 +480,7 @@ int libscca_file_metrics_get_utf8_filename(
libscca_error_t **error );

/* Retrieves the size of the UTF-16 encoded filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -480,6 +491,7 @@ int libscca_file_metrics_get_utf16_filename_size(
libscca_error_t **error );

/* Retrieves the UTF-16 encoded filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down
1 change: 1 addition & 0 deletions libscca/Makefile.am
Expand Up @@ -34,6 +34,7 @@ libscca_la_SOURCES = \
libscca_file_header.c libscca_file_header.h \
libscca_file_information.c libscca_file_information.h \
libscca_file_metrics.c libscca_file_metrics.h \
libscca_filename_string.c libscca_filename_string.h \
libscca_filename_strings.c libscca_filename_strings.h \
libscca_io_handle.c libscca_io_handle.h \
libscca_libbfio.h \
Expand Down
96 changes: 24 additions & 72 deletions libscca/libscca_file.c
Expand Up @@ -1620,6 +1620,7 @@ int libscca_file_get_format_version(
}

/* Retrieves the size of a specific UTF-8 encoded executable filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -1644,30 +1645,16 @@ int libscca_file_get_utf8_executable_filename_size(
}
internal_file = (libscca_internal_file_t *) file;

if( internal_file->file_header == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: invalid internal file - missing file header.",
function );

return( -1 );
}
/* TODO add function to file header */
if( libuna_utf8_string_size_from_utf16_stream(
internal_file->file_header->executable_filename,
internal_file->file_header->executable_filename_size,
LIBUNA_ENDIAN_LITTLE,
if( libscca_file_header_get_utf8_executable_filename_size(
internal_file->file_header,
utf8_string_size,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to determine size of UTF-8 executable filename string.",
"%s: unable to retrieve UTF-8 executable filename size.",
function );

return( -1 );
Expand All @@ -1676,6 +1663,7 @@ int libscca_file_get_utf8_executable_filename_size(
}

/* Retrieves a specific UTF-8 encoded executable filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -1701,31 +1689,17 @@ int libscca_file_get_utf8_executable_filename(
}
internal_file = (libscca_internal_file_t *) file;

if( internal_file->file_header == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: invalid internal file - missing file header.",
function );

return( -1 );
}
/* TODO add function to file header */
if( libuna_utf8_string_copy_from_utf16_stream(
(libuna_utf8_character_t *) utf8_string,
if( libscca_file_header_get_utf8_executable_filename(
internal_file->file_header,
utf8_string,
utf8_string_size,
internal_file->file_header->executable_filename,
internal_file->file_header->executable_filename_size,
LIBUNA_ENDIAN_LITTLE,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_SET_FAILED,
"%s: unable to set UTF-8 executable filename string.",
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve UTF-8 executable filename.",
function );

return( -1 );
Expand All @@ -1734,6 +1708,7 @@ int libscca_file_get_utf8_executable_filename(
}

/* Retrieves the size of a specific UTF-16 encoded executable filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -1758,30 +1733,16 @@ int libscca_file_get_utf16_executable_filename_size(
}
internal_file = (libscca_internal_file_t *) file;

if( internal_file->file_header == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: invalid internal file - missing file header.",
function );

return( -1 );
}
/* TODO add function to file header */
if( libuna_utf16_string_size_from_utf16_stream(
internal_file->file_header->executable_filename,
internal_file->file_header->executable_filename_size,
LIBUNA_ENDIAN_LITTLE,
if( libscca_file_header_get_utf16_executable_filename_size(
internal_file->file_header,
utf16_string_size,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to determine size of UTF-16 executable filename string.",
"%s: unable to retrieve UTF-16 executable filename size.",
function );

return( -1 );
Expand All @@ -1790,6 +1751,7 @@ int libscca_file_get_utf16_executable_filename_size(
}

/* Retrieves a specific UTF-16 encoded executable filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand All @@ -1815,31 +1777,17 @@ int libscca_file_get_utf16_executable_filename(
}
internal_file = (libscca_internal_file_t *) file;

if( internal_file->file_header == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: invalid internal file - missing file header.",
function );

return( -1 );
}
/* TODO add function to file header */
if( libuna_utf16_string_copy_from_utf16_stream(
(libuna_utf16_character_t *) utf16_string,
if( libscca_file_header_get_utf16_executable_filename(
internal_file->file_header,
utf16_string,
utf16_string_size,
internal_file->file_header->executable_filename,
internal_file->file_header->executable_filename_size,
LIBUNA_ENDIAN_LITTLE,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_SET_FAILED,
"%s: unable to set UTF-16 executable filename string.",
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve UTF-16 executable filename.",
function );

return( -1 );
Expand Down Expand Up @@ -2164,6 +2112,7 @@ int libscca_file_get_number_of_filenames(
}

/* Retrieves the size of a specific UTF-8 encoded filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down Expand Up @@ -2209,6 +2158,7 @@ int libscca_file_get_utf8_filename_size(
}

/* Retrieves a specific UTF-8 encoded filename
* This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down Expand Up @@ -2256,6 +2206,7 @@ int libscca_file_get_utf8_filename(
}

/* Retrieves the size of a specific UTF-16 encoded filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The returned size includes the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down Expand Up @@ -2301,6 +2252,7 @@ int libscca_file_get_utf16_filename_size(
}

/* Retrieves a specific UTF-16 encoded filename
* This function uses UCS-2 (with surrogates) to support characters outside Unicode
* The size should include the end of string character
* Returns 1 if successful or -1 on error
*/
Expand Down

0 comments on commit 99bc3b7

Please sign in to comment.