Skip to content

Commit

Permalink
Added support for channel name
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed May 4, 2024
1 parent 2c25f80 commit d028b4f
Show file tree
Hide file tree
Showing 11 changed files with 1,021 additions and 28 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ([2.71])

AC_INIT(
[libevtx],
[20240427],
[20240504],
[joachim.metz@gmail.com])

AC_CONFIG_SRCDIR(
Expand Down
73 changes: 73 additions & 0 deletions evtxtools/export_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,79 @@ int export_handle_export_record_text(
"Source name\t\t\t: %" PRIs_SYSTEM "\n",
source_name );
}
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
result = libevtx_record_get_utf16_channel_name_size(
record,
&value_string_size,
error );
#else
result = libevtx_record_get_utf8_channel_name_size(
record,
&value_string_size,
error );
#endif
if( result == -1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve channel name size.",
function );

goto on_error;
}
if( ( result != 0 )
&& ( value_string_size > 0 ) )
{
value_string = system_string_allocate(
value_string_size );

if( value_string == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_MEMORY,
LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
"%s: unable to create value string.",
function );

goto on_error;
}
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
result = libevtx_record_get_utf16_channel_name(
record,
(uint16_t *) value_string,
value_string_size,
error );
#else
result = libevtx_record_get_utf8_channel_name(
record,
(uint8_t *) value_string,
value_string_size,
error );
#endif
if( result != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve channel name.",
function );

goto on_error;
}
fprintf(
export_handle->notify_stream,
"Channel name\t\t\t: %" PRIs_SYSTEM "\n",
value_string );

memory_free(
value_string );

value_string = NULL;
}
/* TODO category ? */

if( libevtx_record_get_event_identifier(
Expand Down
42 changes: 42 additions & 0 deletions include/libevtx.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,48 @@ int libevtx_record_get_utf16_source_name(
size_t utf16_string_size,
libevtx_error_t **error );

/* Retrieves the size of the UTF-8 encoded channel name
* The returned size includes the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
LIBEVTX_EXTERN \
int libevtx_record_get_utf8_channel_name_size(
libevtx_record_t *record,
size_t *utf8_string_size,
libevtx_error_t **error );

/* Retrieves the UTF-8 encoded channel name
* The size should include the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
LIBEVTX_EXTERN \
int libevtx_record_get_utf8_channel_name(
libevtx_record_t *record,
uint8_t *utf8_string,
size_t utf8_string_size,
libevtx_error_t **error );

/* Retrieves the size of the UTF-16 encoded channel name
* The returned size includes the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
LIBEVTX_EXTERN \
int libevtx_record_get_utf16_channel_name_size(
libevtx_record_t *record,
size_t *utf16_string_size,
libevtx_error_t **error );

/* Retrieves the UTF-16 encoded channel name
* The size should include the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
LIBEVTX_EXTERN \
int libevtx_record_get_utf16_channel_name(
libevtx_record_t *record,
uint16_t *utf16_string,
size_t utf16_string_size,
libevtx_error_t **error );

/* Retrieves the size of the UTF-8 encoded computer name
* The returned size includes the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
Expand Down
184 changes: 184 additions & 0 deletions libevtx/libevtx_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,190 @@ int libevtx_record_get_utf16_source_name(
return( result );
}

/* Retrieves the size of the UTF-8 encoded channel name
* The returned size includes the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
int libevtx_record_get_utf8_channel_name_size(
libevtx_record_t *record,
size_t *utf8_string_size,
libcerror_error_t **error )
{
libevtx_internal_record_t *internal_record = NULL;
static char *function = "libevtx_record_get_utf8_channel_name_size";
int result = 0;

if( record == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid record.",
function );

return( -1 );
}
internal_record = (libevtx_internal_record_t *) record;

result = libevtx_record_values_get_utf8_channel_name_size(
internal_record->record_values,
utf8_string_size,
error );

if( result == -1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve UTF-8 string size of channel name.",
function );

return( -1 );
}
return( result );
}

/* Retrieves the UTF-8 encoded channel name
* The size should include the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
int libevtx_record_get_utf8_channel_name(
libevtx_record_t *record,
uint8_t *utf8_string,
size_t utf8_string_size,
libcerror_error_t **error )
{
libevtx_internal_record_t *internal_record = NULL;
static char *function = "libevtx_record_get_utf8_channel_name";
int result = 0;

if( record == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid record.",
function );

return( -1 );
}
internal_record = (libevtx_internal_record_t *) record;

result = libevtx_record_values_get_utf8_channel_name(
internal_record->record_values,
utf8_string,
utf8_string_size,
error );

if( result == -1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
"%s: unable to copy channel name to UTF-8 string.",
function );

return( -1 );
}
return( result );
}

/* Retrieves the size of the UTF-16 encoded channel name
* The returned size includes the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
int libevtx_record_get_utf16_channel_name_size(
libevtx_record_t *record,
size_t *utf16_string_size,
libcerror_error_t **error )
{
libevtx_internal_record_t *internal_record = NULL;
static char *function = "libevtx_record_get_utf16_channel_name_size";
int result = 0;

if( record == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid record.",
function );

return( -1 );
}
internal_record = (libevtx_internal_record_t *) record;

result = libevtx_record_values_get_utf16_channel_name_size(
internal_record->record_values,
utf16_string_size,
error );

if( result == -1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve UTF-16 string size of channel name.",
function );

return( -1 );
}
return( result );
}

/* Retrieves the UTF-16 encoded channel name
* The size should include the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
*/
int libevtx_record_get_utf16_channel_name(
libevtx_record_t *record,
uint16_t *utf16_string,
size_t utf16_string_size,
libcerror_error_t **error )
{
libevtx_internal_record_t *internal_record = NULL;
static char *function = "libevtx_record_get_utf16_channel_name";
int result = 0;

if( record == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid record.",
function );

return( -1 );
}
internal_record = (libevtx_internal_record_t *) record;

result = libevtx_record_values_get_utf16_channel_name(
internal_record->record_values,
utf16_string,
utf16_string_size,
error );

if( result == -1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
"%s: unable to copy channel name to UTF-16 string.",
function );

return( -1 );
}
return( result );
}

/* Retrieves the size of the UTF-8 encoded computer name
* The returned size includes the end of string character
* Returns 1 if successful, 0 if not available or -1 on error
Expand Down
26 changes: 26 additions & 0 deletions libevtx/libevtx_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,32 @@ int libevtx_record_get_utf16_source_name(
size_t utf16_string_size,
libcerror_error_t **error );

LIBEVTX_EXTERN \
int libevtx_record_get_utf8_channel_name_size(
libevtx_record_t *record,
size_t *utf8_string_size,
libcerror_error_t **error );

LIBEVTX_EXTERN \
int libevtx_record_get_utf8_channel_name(
libevtx_record_t *record,
uint8_t *utf8_string,
size_t utf8_string_size,
libcerror_error_t **error );

LIBEVTX_EXTERN \
int libevtx_record_get_utf16_channel_name_size(
libevtx_record_t *record,
size_t *utf16_string_size,
libcerror_error_t **error );

LIBEVTX_EXTERN \
int libevtx_record_get_utf16_channel_name(
libevtx_record_t *record,
uint16_t *utf16_string,
size_t utf16_string_size,
libcerror_error_t **error );

LIBEVTX_EXTERN \
int libevtx_record_get_utf8_computer_name_size(
libevtx_record_t *record,
Expand Down
Loading

0 comments on commit d028b4f

Please sign in to comment.