Coverage Report

Created: 2023-11-19 06:57

/src/libevtx/libevtx/libevtx_record.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Record functions
3
 *
4
 * Copyright (C) 2011-2023, Joachim Metz <joachim.metz@gmail.com>
5
 *
6
 * Refer to AUTHORS for acknowledgements.
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
#include <common.h>
23
#include <memory.h>
24
#include <types.h>
25
26
#include "libevtx_definitions.h"
27
#include "libevtx_io_handle.h"
28
#include "libevtx_libbfio.h"
29
#include "libevtx_libcerror.h"
30
#include "libevtx_record.h"
31
#include "libevtx_record_values.h"
32
33
/* Creates a record
34
 * Make sure the value record is referencing, is set to NULL
35
 * Returns 1 if successful or -1 on error
36
 */
37
int libevtx_record_initialize(
38
     libevtx_record_t **record,
39
     libevtx_io_handle_t *io_handle,
40
     libbfio_handle_t *file_io_handle,
41
     libevtx_record_values_t *record_values,
42
     uint8_t flags,
43
     libcerror_error_t **error )
44
55
{
45
55
  libevtx_internal_record_t *internal_record = NULL;
46
55
  static char *function                      = "libevtx_record_initialize";
47
48
55
  if( record == NULL )
49
0
  {
50
0
    libcerror_error_set(
51
0
     error,
52
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
53
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
54
0
     "%s: invalid record.",
55
0
     function );
56
57
0
    return( -1 );
58
0
  }
59
55
  if( *record != NULL )
60
0
  {
61
0
    libcerror_error_set(
62
0
     error,
63
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
64
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
65
0
     "%s: invalid record value already set.",
66
0
     function );
67
68
0
    return( -1 );
69
0
  }
70
55
  if( record_values == NULL )
71
0
  {
72
0
    libcerror_error_set(
73
0
     error,
74
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
75
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
76
0
     "%s: invalid record values.",
77
0
     function );
78
79
0
    return( -1 );
80
0
  }
81
55
  if( ( flags & ~( LIBEVTX_RECORD_FLAG_MANAGED_FILE_IO_HANDLE ) ) != 0 )
82
0
  {
83
0
    libcerror_error_set(
84
0
     error,
85
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
86
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
87
0
     "%s: unsupported flags: 0x%02" PRIx8 ".",
88
0
     function,
89
0
     flags );
90
91
0
    return( -1 );
92
0
  }
93
55
  internal_record = memory_allocate_structure(
94
55
                     libevtx_internal_record_t );
95
96
55
  if( internal_record == NULL )
97
0
  {
98
0
    libcerror_error_set(
99
0
     error,
100
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
101
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
102
0
     "%s: unable to create internal record.",
103
0
     function );
104
105
0
    goto on_error;
106
0
  }
107
55
  if( memory_set(
108
55
       internal_record,
109
55
       0,
110
55
       sizeof( libevtx_internal_record_t ) ) == NULL )
111
0
  {
112
0
    libcerror_error_set(
113
0
     error,
114
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
115
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
116
0
     "%s: unable to clear internal record.",
117
0
     function );
118
119
0
    memory_free(
120
0
     internal_record );
121
122
0
    return( -1 );
123
0
  }
124
55
  if( ( flags & LIBEVTX_RECORD_FLAG_MANAGED_FILE_IO_HANDLE ) == 0 )
125
55
  {
126
55
    internal_record->file_io_handle = file_io_handle;
127
55
  }
128
0
  else
129
0
  {
130
0
    if( libbfio_handle_clone(
131
0
         &( internal_record->file_io_handle ),
132
0
         file_io_handle,
133
0
         error ) != 1 )
134
0
    {
135
0
      libcerror_error_set(
136
0
       error,
137
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
138
0
       LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
139
0
       "%s: unable to copy file IO handle.",
140
0
       function );
141
142
0
      goto on_error;
143
0
    }
144
0
    if( libbfio_handle_set_open_on_demand(
145
0
         internal_record->file_io_handle,
146
0
         1,
147
0
         error ) != 1 )
148
0
    {
149
0
      libcerror_error_set(
150
0
       error,
151
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
152
0
       LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
153
0
       "%s: unable to set open on demand in file IO handle.",
154
0
       function );
155
156
0
      goto on_error;
157
0
    }
158
0
  }
159
55
  internal_record->io_handle     = io_handle;
160
55
  internal_record->record_values = record_values;
161
55
  internal_record->flags         = flags;
162
163
55
  *record = (libevtx_record_t *) internal_record;
164
165
55
  return( 1 );
166
167
0
on_error:
168
0
  if( internal_record != NULL )
169
0
  {
170
0
    if( ( flags & LIBEVTX_RECORD_FLAG_MANAGED_FILE_IO_HANDLE ) != 0 )
171
0
    {
172
0
      if( internal_record->file_io_handle != NULL )
173
0
      {
174
0
        libbfio_handle_free(
175
0
         &( internal_record->file_io_handle ),
176
0
         NULL );
177
0
      }
178
0
    }
179
0
    memory_free(
180
0
     internal_record );
181
0
  }
182
0
  return( -1 );
183
55
}
184
185
/* Frees a record
186
 * Returns 1 if successful or -1 on error
187
 */
188
int libevtx_record_free(
189
     libevtx_record_t **record,
190
     libcerror_error_t **error )
191
55
{
192
55
  libevtx_internal_record_t *internal_record = NULL;
193
55
  static char *function                      = "libevtx_record_free";
194
195
55
  if( record == NULL )
196
0
  {
197
0
    libcerror_error_set(
198
0
     error,
199
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
200
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
201
0
     "%s: invalid record.",
202
0
     function );
203
204
0
    return( -1 );
205
0
  }
206
55
  if( *record != NULL )
207
55
  {
208
55
    internal_record = (libevtx_internal_record_t *) *record;
209
55
    *record         = NULL;
210
211
    /* The io_handle and record_values references are freed elsewhere
212
     */
213
55
    if( ( internal_record->flags & LIBEVTX_RECORD_FLAG_MANAGED_FILE_IO_HANDLE ) != 0 )
214
0
    {
215
0
      if( internal_record->file_io_handle != NULL )
216
0
      {
217
0
        if( libbfio_handle_close(
218
0
             internal_record->file_io_handle,
219
0
             error ) != 0 )
220
0
        {
221
0
          libcerror_error_set(
222
0
           error,
223
0
           LIBCERROR_ERROR_DOMAIN_IO,
224
0
           LIBCERROR_IO_ERROR_CLOSE_FAILED,
225
0
           "%s: unable to close file IO handle.",
226
0
           function );
227
228
0
          return( -1 );
229
0
        }
230
0
        if( libbfio_handle_free(
231
0
             &( internal_record->file_io_handle ),
232
0
             error ) != 1 )
233
0
        {
234
0
          libcerror_error_set(
235
0
           error,
236
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
237
0
           LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
238
0
           "%s: unable to free file IO handle.",
239
0
           function );
240
241
0
          return( -1 );
242
0
        }
243
0
      }
244
0
    }
245
55
    memory_free(
246
55
     internal_record );
247
55
  }
248
55
  return( 1 );
249
55
}
250
251
/* Retrieves the offset
252
 * Returns 1 if successful or -1 on error
253
 */
254
int libevtx_record_get_offset(
255
     libevtx_record_t *record,
256
     off64_t *offset,
257
     libcerror_error_t **error )
258
0
{
259
0
  libevtx_internal_record_t *internal_record = NULL;
260
0
  static char *function                      = "libevtx_record_get_offset";
261
262
0
  if( record == NULL )
263
0
  {
264
0
    libcerror_error_set(
265
0
     error,
266
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
267
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
268
0
     "%s: invalid record.",
269
0
     function );
270
271
0
    return( -1 );
272
0
  }
273
0
  internal_record = (libevtx_internal_record_t *) record;
274
275
0
  if( internal_record->record_values == NULL )
276
0
  {
277
0
    libcerror_error_set(
278
0
     error,
279
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
280
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
281
0
     "%s: invalid record - missing record values.",
282
0
     function );
283
284
0
    return( -1 );
285
0
  }
286
0
  if( offset == NULL )
287
0
  {
288
0
    libcerror_error_set(
289
0
     error,
290
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
291
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
292
0
     "%s: invalid offset.",
293
0
     function );
294
295
0
    return( -1 );
296
0
  }
297
0
  *offset = internal_record->record_values->offset;
298
299
0
  return( 1 );
300
0
}
301
302
/* Retrieves the identifier (record number)
303
 * Returns 1 if successful or -1 on error
304
 */
305
int libevtx_record_get_identifier(
306
     libevtx_record_t *record,
307
     uint64_t *identifier,
308
     libcerror_error_t **error )
309
0
{
310
0
  libevtx_internal_record_t *internal_record = NULL;
311
0
  static char *function                      = "libevtx_record_get_identifier";
312
313
0
  if( record == NULL )
314
0
  {
315
0
    libcerror_error_set(
316
0
     error,
317
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
318
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
319
0
     "%s: invalid record.",
320
0
     function );
321
322
0
    return( -1 );
323
0
  }
324
0
  internal_record = (libevtx_internal_record_t *) record;
325
326
0
  if( internal_record->record_values == NULL )
327
0
  {
328
0
    libcerror_error_set(
329
0
     error,
330
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
331
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
332
0
     "%s: invalid record - missing record values.",
333
0
     function );
334
335
0
    return( -1 );
336
0
  }
337
0
  if( identifier == NULL )
338
0
  {
339
0
    libcerror_error_set(
340
0
     error,
341
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
342
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
343
0
     "%s: invalid identifier.",
344
0
     function );
345
346
0
    return( -1 );
347
0
  }
348
0
  *identifier = internal_record->record_values->identifier;
349
350
0
  return( 1 );
351
0
}
352
353
/* Retrieves the 64-bit FILETIME value containing the creation time from the binary XML
354
 * Returns 1 if successful or -1 on error
355
 */
356
int libevtx_record_get_creation_time(
357
     libevtx_record_t *record,
358
     uint64_t *filetime,
359
     libcerror_error_t **error )
360
0
{
361
0
  libevtx_internal_record_t *internal_record = NULL;
362
0
  static char *function                      = "libevtx_record_get_creation_time";
363
364
0
  if( record == NULL )
365
0
  {
366
0
    libcerror_error_set(
367
0
     error,
368
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
369
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
370
0
     "%s: invalid record.",
371
0
     function );
372
373
0
    return( -1 );
374
0
  }
375
0
  internal_record = (libevtx_internal_record_t *) record;
376
377
0
  if( libevtx_record_values_get_creation_time(
378
0
       internal_record->record_values,
379
0
       filetime,
380
0
       error ) != 1 )
381
0
  {
382
0
    libcerror_error_set(
383
0
     error,
384
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
385
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
386
0
     "%s: unable to retrieve creation time from record values.",
387
0
     function );
388
389
0
    return( -1 );
390
0
  }
391
0
  return( 1 );
392
0
}
393
394
/* Retrieves the 64-bit FILETIME value containing the written time from the event record header
395
 * Returns 1 if successful or -1 on error
396
 */
397
int libevtx_record_get_written_time(
398
     libevtx_record_t *record,
399
     uint64_t *filetime,
400
     libcerror_error_t **error )
401
0
{
402
0
  libevtx_internal_record_t *internal_record = NULL;
403
0
  static char *function                      = "libevtx_record_get_written_time";
404
405
0
  if( record == NULL )
406
0
  {
407
0
    libcerror_error_set(
408
0
     error,
409
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
410
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
411
0
     "%s: invalid record.",
412
0
     function );
413
414
0
    return( -1 );
415
0
  }
416
0
  internal_record = (libevtx_internal_record_t *) record;
417
418
0
  if( libevtx_record_values_get_written_time(
419
0
       internal_record->record_values,
420
0
       filetime,
421
0
       error ) != 1 )
422
0
  {
423
0
    libcerror_error_set(
424
0
     error,
425
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
426
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
427
0
     "%s: unable to retrieve written time from record values.",
428
0
     function );
429
430
0
    return( -1 );
431
0
  }
432
0
  return( 1 );
433
0
}
434
435
/* Retrieves the event identifier
436
 * Returns 1 if successful or -1 on error
437
 */
438
int libevtx_record_get_event_identifier(
439
     libevtx_record_t *record,
440
     uint32_t *event_identifier,
441
     libcerror_error_t **error )
442
0
{
443
0
  libevtx_internal_record_t *internal_record = NULL;
444
0
  static char *function                      = "libevtx_record_get_event_identifier";
445
446
0
  if( record == NULL )
447
0
  {
448
0
    libcerror_error_set(
449
0
     error,
450
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
451
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
452
0
     "%s: invalid record.",
453
0
     function );
454
455
0
    return( -1 );
456
0
  }
457
0
  internal_record = (libevtx_internal_record_t *) record;
458
459
0
  if( libevtx_record_values_get_event_identifier(
460
0
       internal_record->record_values,
461
0
       event_identifier,
462
0
       error ) != 1 )
463
0
  {
464
0
    libcerror_error_set(
465
0
     error,
466
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
467
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
468
0
     "%s: unable to retrieve event identifier from record values.",
469
0
     function );
470
471
0
    return( -1 );
472
0
  }
473
0
  return( 1 );
474
0
}
475
476
/* Retrieves the event identifier qualifiers
477
 * Returns 1 if successful, 0 if not available or -1 on error
478
 */
479
int libevtx_record_get_event_identifier_qualifiers(
480
     libevtx_record_t *record,
481
     uint32_t *event_identifier_qualifiers,
482
     libcerror_error_t **error )
483
0
{
484
0
  libevtx_internal_record_t *internal_record = NULL;
485
0
  static char *function                      = "libevtx_record_get_event_identifier_qualifiers";
486
0
  int result                                 = 0;
487
488
0
  if( record == NULL )
489
0
  {
490
0
    libcerror_error_set(
491
0
     error,
492
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
493
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
494
0
     "%s: invalid record.",
495
0
     function );
496
497
0
    return( -1 );
498
0
  }
499
0
  internal_record = (libevtx_internal_record_t *) record;
500
501
0
  result = libevtx_record_values_get_event_identifier_qualifiers(
502
0
            internal_record->record_values,
503
0
            event_identifier_qualifiers,
504
0
            error );
505
506
0
  if( result == -1 )
507
0
  {
508
0
    libcerror_error_set(
509
0
     error,
510
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
511
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
512
0
     "%s: unable to retrieve event identifier qualifiers from record values.",
513
0
     function );
514
515
0
    return( -1 );
516
0
  }
517
0
  return( result );
518
0
}
519
520
/* Retrieves the event version
521
 * Returns 1 if successful, 0 if not available or -1 on error
522
 */
523
int libevtx_record_get_event_version(
524
     libevtx_record_t *record,
525
     uint8_t *event_version,
526
     libcerror_error_t **error )
527
0
{
528
0
  libevtx_internal_record_t *internal_record = NULL;
529
0
  static char *function                      = "libevtx_record_get_event_version";
530
0
  int result                                 = 0;
531
532
0
  if( record == NULL )
533
0
  {
534
0
    libcerror_error_set(
535
0
     error,
536
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
537
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
538
0
     "%s: invalid record.",
539
0
     function );
540
541
0
    return( -1 );
542
0
  }
543
0
  internal_record = (libevtx_internal_record_t *) record;
544
545
0
  result = libevtx_record_values_get_event_version(
546
0
            internal_record->record_values,
547
0
            event_version,
548
0
            error );
549
550
0
  if( result == -1 )
551
0
  {
552
0
    libcerror_error_set(
553
0
     error,
554
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
555
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
556
0
     "%s: unable to retrieve event version from record values.",
557
0
     function );
558
559
0
    return( -1 );
560
0
  }
561
0
  return( result );
562
0
}
563
564
/* Retrieves the event level
565
 * Returns 1 if successful or -1 on error
566
 */
567
int libevtx_record_get_event_level(
568
     libevtx_record_t *record,
569
     uint8_t *event_level,
570
     libcerror_error_t **error )
571
0
{
572
0
  libevtx_internal_record_t *internal_record = NULL;
573
0
  static char *function                      = "libevtx_record_get_event_level";
574
575
0
  if( record == NULL )
576
0
  {
577
0
    libcerror_error_set(
578
0
     error,
579
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
580
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
581
0
     "%s: invalid record.",
582
0
     function );
583
584
0
    return( -1 );
585
0
  }
586
0
  internal_record = (libevtx_internal_record_t *) record;
587
588
0
  if( libevtx_record_values_get_event_level(
589
0
       internal_record->record_values,
590
0
       event_level,
591
0
       error ) != 1 )
592
0
  {
593
0
    libcerror_error_set(
594
0
     error,
595
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
596
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
597
0
     "%s: unable to retrieve event level from record values.",
598
0
     function );
599
600
0
    return( -1 );
601
0
  }
602
0
  return( 1 );
603
0
}
604
605
/* Retrieves the size of the UTF-8 encoded provider identifier
606
 * The returned size includes the end of string character
607
 * Returns 1 if successful, 0 if not available or -1 on error
608
 */
609
int libevtx_record_get_utf8_provider_identifier_size(
610
     libevtx_record_t *record,
611
     size_t *utf8_string_size,
612
     libcerror_error_t **error )
613
0
{
614
0
  libevtx_internal_record_t *internal_record = NULL;
615
0
  static char *function                      = "libevtx_record_get_utf8_provider_identifier_size";
616
0
  int result                                 = 0;
617
618
0
  if( record == NULL )
619
0
  {
620
0
    libcerror_error_set(
621
0
     error,
622
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
623
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
624
0
     "%s: invalid record.",
625
0
     function );
626
627
0
    return( -1 );
628
0
  }
629
0
  internal_record = (libevtx_internal_record_t *) record;
630
631
0
  result = libevtx_record_values_get_utf8_provider_identifier_size(
632
0
            internal_record->record_values,
633
0
            utf8_string_size,
634
0
            error );
635
636
0
  if( result == -1 )
637
0
  {
638
0
    libcerror_error_set(
639
0
     error,
640
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
641
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
642
0
     "%s: unable to retrieve UTF-8 string size of provider identifier.",
643
0
     function );
644
645
0
    return( -1 );
646
0
  }
647
0
  return( result );
648
0
}
649
650
/* Retrieves the UTF-8 encoded provider identifier
651
 * The size should include the end of string character
652
 * Returns 1 if successful, 0 if not available or -1 on error
653
 */
654
int libevtx_record_get_utf8_provider_identifier(
655
     libevtx_record_t *record,
656
     uint8_t *utf8_string,
657
     size_t utf8_string_size,
658
     libcerror_error_t **error )
659
0
{
660
0
  libevtx_internal_record_t *internal_record = NULL;
661
0
  static char *function                      = "libevtx_record_get_utf8_provider_identifier";
662
0
  int result                                 = 0;
663
664
0
  if( record == NULL )
665
0
  {
666
0
    libcerror_error_set(
667
0
     error,
668
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
669
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
670
0
     "%s: invalid record.",
671
0
     function );
672
673
0
    return( -1 );
674
0
  }
675
0
  internal_record = (libevtx_internal_record_t *) record;
676
677
0
  result = libevtx_record_values_get_utf8_provider_identifier(
678
0
            internal_record->record_values,
679
0
            utf8_string,
680
0
            utf8_string_size,
681
0
            error );
682
683
0
  if( result == -1 )
684
0
  {
685
0
    libcerror_error_set(
686
0
     error,
687
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
688
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
689
0
     "%s: unable to copy provider identifier to UTF-8 string.",
690
0
     function );
691
692
0
    return( -1 );
693
0
  }
694
0
  return( result );
695
0
}
696
697
/* Retrieves the size of the UTF-16 encoded provider identifier
698
 * The returned size includes the end of string character
699
 * Returns 1 if successful, 0 if not available or -1 on error
700
 */
701
int libevtx_record_get_utf16_provider_identifier_size(
702
     libevtx_record_t *record,
703
     size_t *utf16_string_size,
704
     libcerror_error_t **error )
705
0
{
706
0
  libevtx_internal_record_t *internal_record = NULL;
707
0
  static char *function                      = "libevtx_record_get_utf16_provider_identifier_size";
708
0
  int result                                 = 0;
709
710
0
  if( record == NULL )
711
0
  {
712
0
    libcerror_error_set(
713
0
     error,
714
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
715
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
716
0
     "%s: invalid record.",
717
0
     function );
718
719
0
    return( -1 );
720
0
  }
721
0
  internal_record = (libevtx_internal_record_t *) record;
722
723
0
  result = libevtx_record_values_get_utf16_provider_identifier_size(
724
0
            internal_record->record_values,
725
0
            utf16_string_size,
726
0
            error );
727
728
0
  if( result == -1 )
729
0
  {
730
0
    libcerror_error_set(
731
0
     error,
732
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
733
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
734
0
     "%s: unable to retrieve UTF-16 string size of provider identifier.",
735
0
     function );
736
737
0
    return( -1 );
738
0
  }
739
0
  return( result );
740
0
}
741
742
/* Retrieves the UTF-16 encoded provider identifier
743
 * The size should include the end of string character
744
 * Returns 1 if successful, 0 if not available or -1 on error
745
 */
746
int libevtx_record_get_utf16_provider_identifier(
747
     libevtx_record_t *record,
748
     uint16_t *utf16_string,
749
     size_t utf16_string_size,
750
     libcerror_error_t **error )
751
0
{
752
0
  libevtx_internal_record_t *internal_record = NULL;
753
0
  static char *function                      = "libevtx_record_get_utf16_provider_identifier";
754
0
  int result                                 = 0;
755
756
0
  if( record == NULL )
757
0
  {
758
0
    libcerror_error_set(
759
0
     error,
760
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
761
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
762
0
     "%s: invalid record.",
763
0
     function );
764
765
0
    return( -1 );
766
0
  }
767
0
  internal_record = (libevtx_internal_record_t *) record;
768
769
0
  result = libevtx_record_values_get_utf16_provider_identifier(
770
0
            internal_record->record_values,
771
0
            utf16_string,
772
0
            utf16_string_size,
773
0
            error );
774
775
0
  if( result == -1 )
776
0
  {
777
0
    libcerror_error_set(
778
0
     error,
779
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
780
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
781
0
     "%s: unable to copy provider identifier to UTF-16 string.",
782
0
     function );
783
784
0
    return( -1 );
785
0
  }
786
0
  return( result );
787
0
}
788
789
/* Retrieves the size of the UTF-8 encoded source name
790
 * The returned size includes the end of string character
791
 * Returns 1 if successful, 0 if not available or -1 on error
792
 */
793
int libevtx_record_get_utf8_source_name_size(
794
     libevtx_record_t *record,
795
     size_t *utf8_string_size,
796
     libcerror_error_t **error )
797
0
{
798
0
  libevtx_internal_record_t *internal_record = NULL;
799
0
  static char *function                      = "libevtx_record_get_utf8_source_name_size";
800
0
  int result                                 = 0;
801
802
0
  if( record == NULL )
803
0
  {
804
0
    libcerror_error_set(
805
0
     error,
806
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
807
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
808
0
     "%s: invalid record.",
809
0
     function );
810
811
0
    return( -1 );
812
0
  }
813
0
  internal_record = (libevtx_internal_record_t *) record;
814
815
0
  result = libevtx_record_values_get_utf8_source_name_size(
816
0
            internal_record->record_values,
817
0
            utf8_string_size,
818
0
            error );
819
820
0
  if( result == -1 )
821
0
  {
822
0
    libcerror_error_set(
823
0
     error,
824
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
825
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
826
0
     "%s: unable to retrieve UTF-8 string size of source name.",
827
0
     function );
828
829
0
    return( -1 );
830
0
  }
831
0
  return( result );
832
0
}
833
834
/* Retrieves the UTF-8 encoded source name
835
 * The size should include the end of string character
836
 * Returns 1 if successful, 0 if not available or -1 on error
837
 */
838
int libevtx_record_get_utf8_source_name(
839
     libevtx_record_t *record,
840
     uint8_t *utf8_string,
841
     size_t utf8_string_size,
842
     libcerror_error_t **error )
843
0
{
844
0
  libevtx_internal_record_t *internal_record = NULL;
845
0
  static char *function                      = "libevtx_record_get_utf8_source_name";
846
0
  int result                                 = 0;
847
848
0
  if( record == NULL )
849
0
  {
850
0
    libcerror_error_set(
851
0
     error,
852
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
853
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
854
0
     "%s: invalid record.",
855
0
     function );
856
857
0
    return( -1 );
858
0
  }
859
0
  internal_record = (libevtx_internal_record_t *) record;
860
861
0
  result = libevtx_record_values_get_utf8_source_name(
862
0
            internal_record->record_values,
863
0
            utf8_string,
864
0
            utf8_string_size,
865
0
            error );
866
867
0
  if( result == -1 )
868
0
  {
869
0
    libcerror_error_set(
870
0
     error,
871
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
872
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
873
0
     "%s: unable to copy source name to UTF-8 string.",
874
0
     function );
875
876
0
    return( -1 );
877
0
  }
878
0
  return( result );
879
0
}
880
881
/* Retrieves the size of the UTF-16 encoded source name
882
 * The returned size includes the end of string character
883
 * Returns 1 if successful, 0 if not available or -1 on error
884
 */
885
int libevtx_record_get_utf16_source_name_size(
886
     libevtx_record_t *record,
887
     size_t *utf16_string_size,
888
     libcerror_error_t **error )
889
0
{
890
0
  libevtx_internal_record_t *internal_record = NULL;
891
0
  static char *function                      = "libevtx_record_get_utf16_source_name_size";
892
0
  int result                                 = 0;
893
894
0
  if( record == NULL )
895
0
  {
896
0
    libcerror_error_set(
897
0
     error,
898
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
899
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
900
0
     "%s: invalid record.",
901
0
     function );
902
903
0
    return( -1 );
904
0
  }
905
0
  internal_record = (libevtx_internal_record_t *) record;
906
907
0
  result = libevtx_record_values_get_utf16_source_name_size(
908
0
            internal_record->record_values,
909
0
            utf16_string_size,
910
0
            error );
911
912
0
  if( result == -1 )
913
0
  {
914
0
    libcerror_error_set(
915
0
     error,
916
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
917
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
918
0
     "%s: unable to retrieve UTF-16 string size of source name.",
919
0
     function );
920
921
0
    return( -1 );
922
0
  }
923
0
  return( result );
924
0
}
925
926
/* Retrieves the UTF-16 encoded source name
927
 * The size should include the end of string character
928
 * Returns 1 if successful, 0 if not available or -1 on error
929
 */
930
int libevtx_record_get_utf16_source_name(
931
     libevtx_record_t *record,
932
     uint16_t *utf16_string,
933
     size_t utf16_string_size,
934
     libcerror_error_t **error )
935
0
{
936
0
  libevtx_internal_record_t *internal_record = NULL;
937
0
  static char *function                      = "libevtx_record_get_utf16_source_name";
938
0
  int result                                 = 0;
939
940
0
  if( record == NULL )
941
0
  {
942
0
    libcerror_error_set(
943
0
     error,
944
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
945
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
946
0
     "%s: invalid record.",
947
0
     function );
948
949
0
    return( -1 );
950
0
  }
951
0
  internal_record = (libevtx_internal_record_t *) record;
952
953
0
  result = libevtx_record_values_get_utf16_source_name(
954
0
            internal_record->record_values,
955
0
            utf16_string,
956
0
            utf16_string_size,
957
0
            error );
958
959
0
  if( result == -1 )
960
0
  {
961
0
    libcerror_error_set(
962
0
     error,
963
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
964
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
965
0
     "%s: unable to copy source name to UTF-16 string.",
966
0
     function );
967
968
0
    return( -1 );
969
0
  }
970
0
  return( result );
971
0
}
972
973
/* Retrieves the size of the UTF-8 encoded computer name
974
 * The returned size includes the end of string character
975
 * Returns 1 if successful, 0 if not available or -1 on error
976
 */
977
int libevtx_record_get_utf8_computer_name_size(
978
     libevtx_record_t *record,
979
     size_t *utf8_string_size,
980
     libcerror_error_t **error )
981
0
{
982
0
  libevtx_internal_record_t *internal_record = NULL;
983
0
  static char *function                      = "libevtx_record_get_utf8_computer_name_size";
984
0
  int result                                 = 0;
985
986
0
  if( record == NULL )
987
0
  {
988
0
    libcerror_error_set(
989
0
     error,
990
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
991
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
992
0
     "%s: invalid record.",
993
0
     function );
994
995
0
    return( -1 );
996
0
  }
997
0
  internal_record = (libevtx_internal_record_t *) record;
998
999
0
  result = libevtx_record_values_get_utf8_computer_name_size(
1000
0
            internal_record->record_values,
1001
0
            utf8_string_size,
1002
0
            error );
1003
1004
0
  if( result == -1 )
1005
0
  {
1006
0
    libcerror_error_set(
1007
0
     error,
1008
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1009
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1010
0
     "%s: unable to retrieve UTF-8 string size of computer name.",
1011
0
     function );
1012
1013
0
    return( -1 );
1014
0
  }
1015
0
  return( result );
1016
0
}
1017
1018
/* Retrieves the UTF-8 encoded computer name
1019
 * The size should include the end of string character
1020
 * Returns 1 if successful, 0 if not available or -1 on error
1021
 */
1022
int libevtx_record_get_utf8_computer_name(
1023
     libevtx_record_t *record,
1024
     uint8_t *utf8_string,
1025
     size_t utf8_string_size,
1026
     libcerror_error_t **error )
1027
0
{
1028
0
  libevtx_internal_record_t *internal_record = NULL;
1029
0
  static char *function                      = "libevtx_record_get_utf8_computer_name";
1030
0
  int result                                 = 0;
1031
1032
0
  if( record == NULL )
1033
0
  {
1034
0
    libcerror_error_set(
1035
0
     error,
1036
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1037
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1038
0
     "%s: invalid record.",
1039
0
     function );
1040
1041
0
    return( -1 );
1042
0
  }
1043
0
  internal_record = (libevtx_internal_record_t *) record;
1044
1045
0
  result = libevtx_record_values_get_utf8_computer_name(
1046
0
            internal_record->record_values,
1047
0
            utf8_string,
1048
0
            utf8_string_size,
1049
0
            error );
1050
1051
0
  if( result == -1 )
1052
0
  {
1053
0
    libcerror_error_set(
1054
0
     error,
1055
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1056
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1057
0
     "%s: unable to copy computer name to UTF-8 string.",
1058
0
     function );
1059
1060
0
    return( -1 );
1061
0
  }
1062
0
  return( result );
1063
0
}
1064
1065
/* Retrieves the size of the UTF-16 encoded computer name
1066
 * The returned size includes the end of string character
1067
 * Returns 1 if successful, 0 if not available or -1 on error
1068
 */
1069
int libevtx_record_get_utf16_computer_name_size(
1070
     libevtx_record_t *record,
1071
     size_t *utf16_string_size,
1072
     libcerror_error_t **error )
1073
0
{
1074
0
  libevtx_internal_record_t *internal_record = NULL;
1075
0
  static char *function                      = "libevtx_record_get_utf16_computer_name_size";
1076
0
  int result                                 = 0;
1077
1078
0
  if( record == NULL )
1079
0
  {
1080
0
    libcerror_error_set(
1081
0
     error,
1082
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1083
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1084
0
     "%s: invalid record.",
1085
0
     function );
1086
1087
0
    return( -1 );
1088
0
  }
1089
0
  internal_record = (libevtx_internal_record_t *) record;
1090
1091
0
  result = libevtx_record_values_get_utf16_computer_name_size(
1092
0
            internal_record->record_values,
1093
0
            utf16_string_size,
1094
0
            error );
1095
1096
0
  if( result == -1 )
1097
0
  {
1098
0
    libcerror_error_set(
1099
0
     error,
1100
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1101
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1102
0
     "%s: unable to retrieve UTF-16 string size of computer name.",
1103
0
     function );
1104
1105
0
    return( -1 );
1106
0
  }
1107
0
  return( result );
1108
0
}
1109
1110
/* Retrieves the UTF-16 encoded computer name
1111
 * The size should include the end of string character
1112
 * Returns 1 if successful, 0 if not available or -1 on error
1113
 */
1114
int libevtx_record_get_utf16_computer_name(
1115
     libevtx_record_t *record,
1116
     uint16_t *utf16_string,
1117
     size_t utf16_string_size,
1118
     libcerror_error_t **error )
1119
0
{
1120
0
  libevtx_internal_record_t *internal_record = NULL;
1121
0
  static char *function                      = "libevtx_record_get_utf16_computer_name";
1122
0
  int result                                 = 0;
1123
1124
0
  if( record == NULL )
1125
0
  {
1126
0
    libcerror_error_set(
1127
0
     error,
1128
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1129
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1130
0
     "%s: invalid record.",
1131
0
     function );
1132
1133
0
    return( -1 );
1134
0
  }
1135
0
  internal_record = (libevtx_internal_record_t *) record;
1136
1137
0
  result = libevtx_record_values_get_utf16_computer_name(
1138
0
            internal_record->record_values,
1139
0
            utf16_string,
1140
0
            utf16_string_size,
1141
0
            error );
1142
1143
0
  if( result == -1 )
1144
0
  {
1145
0
    libcerror_error_set(
1146
0
     error,
1147
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1148
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1149
0
     "%s: unable to copy computer name to UTF-16 string.",
1150
0
     function );
1151
1152
0
    return( -1 );
1153
0
  }
1154
0
  return( result );
1155
0
}
1156
1157
/* Retrieves the size of the UTF-8 encoded user security identifier
1158
 * The returned size includes the end of string character
1159
 * Returns 1 if successful, 0 if not available or -1 on error
1160
 */
1161
int libevtx_record_get_utf8_user_security_identifier_size(
1162
     libevtx_record_t *record,
1163
     size_t *utf8_string_size,
1164
     libcerror_error_t **error )
1165
0
{
1166
0
  libevtx_internal_record_t *internal_record = NULL;
1167
0
  static char *function                      = "libevtx_record_get_utf8_user_security_identifier_size";
1168
0
  int result                                 = 0;
1169
1170
0
  if( record == NULL )
1171
0
  {
1172
0
    libcerror_error_set(
1173
0
     error,
1174
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1175
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1176
0
     "%s: invalid record.",
1177
0
     function );
1178
1179
0
    return( -1 );
1180
0
  }
1181
0
  internal_record = (libevtx_internal_record_t *) record;
1182
1183
0
  result = libevtx_record_values_get_utf8_user_security_identifier_size(
1184
0
            internal_record->record_values,
1185
0
            utf8_string_size,
1186
0
            error );
1187
1188
0
  if( result == -1 )
1189
0
  {
1190
0
    libcerror_error_set(
1191
0
     error,
1192
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1193
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1194
0
     "%s: unable to retrieve UTF-8 string size of user security identifier.",
1195
0
     function );
1196
1197
0
    return( -1 );
1198
0
  }
1199
0
  return( result );
1200
0
}
1201
1202
/* Retrieves the UTF-8 encoded user security identifier
1203
 * The size should include the end of string character
1204
 * Returns 1 if successful, 0 if not available or -1 on error
1205
 */
1206
int libevtx_record_get_utf8_user_security_identifier(
1207
     libevtx_record_t *record,
1208
     uint8_t *utf8_string,
1209
     size_t utf8_string_size,
1210
     libcerror_error_t **error )
1211
0
{
1212
0
  libevtx_internal_record_t *internal_record = NULL;
1213
0
  static char *function                      = "libevtx_record_get_utf8_user_security_identifier";
1214
0
  int result                                 = 0;
1215
1216
0
  if( record == NULL )
1217
0
  {
1218
0
    libcerror_error_set(
1219
0
     error,
1220
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1221
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1222
0
     "%s: invalid record.",
1223
0
     function );
1224
1225
0
    return( -1 );
1226
0
  }
1227
0
  internal_record = (libevtx_internal_record_t *) record;
1228
1229
0
  result = libevtx_record_values_get_utf8_user_security_identifier(
1230
0
            internal_record->record_values,
1231
0
            utf8_string,
1232
0
            utf8_string_size,
1233
0
            error );
1234
1235
0
  if( result == -1 )
1236
0
  {
1237
0
    libcerror_error_set(
1238
0
     error,
1239
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1240
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1241
0
     "%s: unable to copy user security identifier to UTF-8 string.",
1242
0
     function );
1243
1244
0
    return( -1 );
1245
0
  }
1246
0
  return( result );
1247
0
}
1248
1249
/* Retrieves the size of the UTF-16 encoded user security identifier
1250
 * The returned size includes the end of string character
1251
 * Returns 1 if successful, 0 if not available or -1 on error
1252
 */
1253
int libevtx_record_get_utf16_user_security_identifier_size(
1254
     libevtx_record_t *record,
1255
     size_t *utf16_string_size,
1256
     libcerror_error_t **error )
1257
0
{
1258
0
  libevtx_internal_record_t *internal_record = NULL;
1259
0
  static char *function                      = "libevtx_record_get_utf16_user_security_identifier_size";
1260
0
  int result                                 = 0;
1261
1262
0
  if( record == NULL )
1263
0
  {
1264
0
    libcerror_error_set(
1265
0
     error,
1266
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1267
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1268
0
     "%s: invalid record.",
1269
0
     function );
1270
1271
0
    return( -1 );
1272
0
  }
1273
0
  internal_record = (libevtx_internal_record_t *) record;
1274
1275
0
  result = libevtx_record_values_get_utf16_user_security_identifier_size(
1276
0
            internal_record->record_values,
1277
0
            utf16_string_size,
1278
0
            error );
1279
1280
0
  if( result == -1 )
1281
0
  {
1282
0
    libcerror_error_set(
1283
0
     error,
1284
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1285
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1286
0
     "%s: unable to retrieve UTF-16 string size of user security identifier.",
1287
0
     function );
1288
1289
0
    return( -1 );
1290
0
  }
1291
0
  return( result );
1292
0
}
1293
1294
/* Retrieves the UTF-16 encoded user security identifier
1295
 * The size should include the end of string character
1296
 * Returns 1 if successful, 0 if not available or -1 on error
1297
 */
1298
int libevtx_record_get_utf16_user_security_identifier(
1299
     libevtx_record_t *record,
1300
     uint16_t *utf16_string,
1301
     size_t utf16_string_size,
1302
     libcerror_error_t **error )
1303
0
{
1304
0
  libevtx_internal_record_t *internal_record = NULL;
1305
0
  static char *function                      = "libevtx_record_get_utf16_user_security_identifier";
1306
0
  int result                                 = 0;
1307
1308
0
  if( record == NULL )
1309
0
  {
1310
0
    libcerror_error_set(
1311
0
     error,
1312
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1313
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1314
0
     "%s: invalid record.",
1315
0
     function );
1316
1317
0
    return( -1 );
1318
0
  }
1319
0
  internal_record = (libevtx_internal_record_t *) record;
1320
1321
0
  result = libevtx_record_values_get_utf16_user_security_identifier(
1322
0
            internal_record->record_values,
1323
0
            utf16_string,
1324
0
            utf16_string_size,
1325
0
            error );
1326
1327
0
  if( result == -1 )
1328
0
  {
1329
0
    libcerror_error_set(
1330
0
     error,
1331
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1332
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1333
0
     "%s: unable to copy user security identifier to UTF-16 string.",
1334
0
     function );
1335
1336
0
    return( -1 );
1337
0
  }
1338
0
  return( result );
1339
0
}
1340
1341
/* Parses the record data with a template definition
1342
 * This function needs to be called before accessing the strings otherwise
1343
 * the record data will be parsed without a template definition by default
1344
 * Returns 1 if successful, 0 if data could not be parsed or -1 on error
1345
 */
1346
int libevtx_record_parse_data_with_template_definition(
1347
     libevtx_record_t *record,
1348
     libevtx_template_definition_t *template_definition,
1349
     libcerror_error_t **error )
1350
0
{
1351
0
  libevtx_internal_record_t *internal_record = NULL;
1352
0
  static char *function                      = "libevtx_record_parse_data_with_template_definition";
1353
0
  int result                                 = 0;
1354
1355
0
  if( record == NULL )
1356
0
  {
1357
0
    libcerror_error_set(
1358
0
     error,
1359
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1360
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1361
0
     "%s: invalid record.",
1362
0
     function );
1363
1364
0
    return( -1 );
1365
0
  }
1366
0
  internal_record = (libevtx_internal_record_t *) record;
1367
1368
0
  if( template_definition == NULL )
1369
0
  {
1370
0
    libcerror_error_set(
1371
0
     error,
1372
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1373
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1374
0
     "%s: invalid template definition.",
1375
0
     function );
1376
1377
0
    return( -1 );
1378
0
  }
1379
0
  result = libevtx_record_values_parse_data(
1380
0
            internal_record->record_values,
1381
0
            internal_record->io_handle,
1382
0
            (libevtx_internal_template_definition_t *) template_definition,
1383
0
            error );
1384
1385
0
  if( result == -1 )
1386
0
  {
1387
0
    libcerror_error_set(
1388
0
     error,
1389
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1390
0
     LIBCERROR_RUNTIME_ERROR_GENERIC,
1391
0
     "%s: unable to parse data.",
1392
0
     function );
1393
1394
0
    return( -1 );
1395
0
  }
1396
0
  return( result );
1397
0
}
1398
1399
/* Retrieves the number of strings
1400
 * Returns 1 if successful or -1 on error
1401
 */
1402
int libevtx_record_get_number_of_strings(
1403
     libevtx_record_t *record,
1404
     int *number_of_strings,
1405
     libcerror_error_t **error )
1406
0
{
1407
0
  libevtx_internal_record_t *internal_record = NULL;
1408
0
  static char *function                      = "libevtx_record_get_number_of_strings";
1409
1410
0
  if( record == NULL )
1411
0
  {
1412
0
    libcerror_error_set(
1413
0
     error,
1414
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1415
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1416
0
     "%s: invalid record.",
1417
0
     function );
1418
1419
0
    return( -1 );
1420
0
  }
1421
0
  internal_record = (libevtx_internal_record_t *) record;
1422
1423
0
  if( libevtx_record_values_get_number_of_strings(
1424
0
       internal_record->record_values,
1425
0
       internal_record->io_handle,
1426
0
       number_of_strings,
1427
0
       error ) != 1 )
1428
0
  {
1429
0
    libcerror_error_set(
1430
0
     error,
1431
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1432
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1433
0
     "%s: unable to retrieve number of strings.",
1434
0
     function );
1435
1436
0
    return( -1 );
1437
0
  }
1438
0
  return( 1 );
1439
0
}
1440
1441
/* Retrieves the size of a specific UTF-8 encoded string
1442
 * The returned size includes the end of string character
1443
 * Returns 1 if successful or -1 on error
1444
 */
1445
int libevtx_record_get_utf8_string_size(
1446
     libevtx_record_t *record,
1447
     int string_index,
1448
     size_t *utf8_string_size,
1449
     libcerror_error_t **error )
1450
0
{
1451
0
  libevtx_internal_record_t *internal_record = NULL;
1452
0
  static char *function                      = "libevtx_record_get_utf8_string_size";
1453
1454
0
  if( record == NULL )
1455
0
  {
1456
0
    libcerror_error_set(
1457
0
     error,
1458
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1459
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1460
0
     "%s: invalid record.",
1461
0
     function );
1462
1463
0
    return( -1 );
1464
0
  }
1465
0
  internal_record = (libevtx_internal_record_t *) record;
1466
1467
0
  if( libevtx_record_values_get_utf8_string_size(
1468
0
       internal_record->record_values,
1469
0
       internal_record->io_handle,
1470
0
       string_index,
1471
0
       utf8_string_size,
1472
0
       error ) != 1 )
1473
0
  {
1474
0
    libcerror_error_set(
1475
0
     error,
1476
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1477
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1478
0
     "%s: unable to retrieve size of UTF-8 string: %d.",
1479
0
     function,
1480
0
     string_index );
1481
1482
0
    return( -1 );
1483
0
  }
1484
0
  return( 1 );
1485
0
}
1486
1487
/* Retrieves a specific UTF-8 encoded string
1488
 * The size should include the end of string character
1489
 * Returns 1 if successful or -1 on error
1490
 */
1491
int libevtx_record_get_utf8_string(
1492
     libevtx_record_t *record,
1493
     int string_index,
1494
     uint8_t *utf8_string,
1495
     size_t utf8_string_size,
1496
     libcerror_error_t **error )
1497
0
{
1498
0
  libevtx_internal_record_t *internal_record = NULL;
1499
0
  static char *function                      = "libevtx_record_get_utf8_string";
1500
1501
0
  if( record == NULL )
1502
0
  {
1503
0
    libcerror_error_set(
1504
0
     error,
1505
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1506
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1507
0
     "%s: invalid record.",
1508
0
     function );
1509
1510
0
    return( -1 );
1511
0
  }
1512
0
  internal_record = (libevtx_internal_record_t *) record;
1513
1514
0
  if( libevtx_record_values_get_utf8_string(
1515
0
       internal_record->record_values,
1516
0
       internal_record->io_handle,
1517
0
       string_index,
1518
0
       utf8_string,
1519
0
       utf8_string_size,
1520
0
       error ) != 1 )
1521
0
  {
1522
0
    libcerror_error_set(
1523
0
     error,
1524
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1525
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1526
0
     "%s: unable to retrieve UTF-8 string: %d.",
1527
0
     function,
1528
0
     string_index );
1529
1530
0
    return( -1 );
1531
0
  }
1532
0
  return( 1 );
1533
0
}
1534
1535
/* Retrieves the size of a specific UTF-16 encoded string
1536
 * The returned size includes the end of string character
1537
 * Returns 1 if successful or -1 on error
1538
 */
1539
int libevtx_record_get_utf16_string_size(
1540
     libevtx_record_t *record,
1541
     int string_index,
1542
     size_t *utf16_string_size,
1543
     libcerror_error_t **error )
1544
0
{
1545
0
  libevtx_internal_record_t *internal_record = NULL;
1546
0
  static char *function                      = "libevtx_record_get_utf16_string_size";
1547
1548
0
  if( record == NULL )
1549
0
  {
1550
0
    libcerror_error_set(
1551
0
     error,
1552
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1553
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1554
0
     "%s: invalid record.",
1555
0
     function );
1556
1557
0
    return( -1 );
1558
0
  }
1559
0
  internal_record = (libevtx_internal_record_t *) record;
1560
1561
0
  if( libevtx_record_values_get_utf16_string_size(
1562
0
       internal_record->record_values,
1563
0
       internal_record->io_handle,
1564
0
       string_index,
1565
0
       utf16_string_size,
1566
0
       error ) != 1 )
1567
0
  {
1568
0
    libcerror_error_set(
1569
0
     error,
1570
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1571
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1572
0
     "%s: unable to retrieve size of UTF-16 string: %d.",
1573
0
     function,
1574
0
     string_index );
1575
1576
0
    return( -1 );
1577
0
  }
1578
0
  return( 1 );
1579
0
}
1580
1581
/* Retrieves a specific UTF-16 encoded string
1582
 * The size should include the end of string character
1583
 * Returns 1 if successful or -1 on error
1584
 */
1585
int libevtx_record_get_utf16_string(
1586
     libevtx_record_t *record,
1587
     int string_index,
1588
     uint16_t *utf16_string,
1589
     size_t utf16_string_size,
1590
     libcerror_error_t **error )
1591
0
{
1592
0
  libevtx_internal_record_t *internal_record = NULL;
1593
0
  static char *function                      = "libevtx_record_get_utf16_string";
1594
1595
0
  if( record == NULL )
1596
0
  {
1597
0
    libcerror_error_set(
1598
0
     error,
1599
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1600
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1601
0
     "%s: invalid record.",
1602
0
     function );
1603
1604
0
    return( -1 );
1605
0
  }
1606
0
  internal_record = (libevtx_internal_record_t *) record;
1607
1608
0
  if( libevtx_record_values_get_utf16_string(
1609
0
       internal_record->record_values,
1610
0
       internal_record->io_handle,
1611
0
       string_index,
1612
0
       utf16_string,
1613
0
       utf16_string_size,
1614
0
       error ) != 1 )
1615
0
  {
1616
0
    libcerror_error_set(
1617
0
     error,
1618
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1619
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1620
0
     "%s: unable to retrieve UTF-16 string: %d.",
1621
0
     function,
1622
0
     string_index );
1623
1624
0
    return( -1 );
1625
0
  }
1626
0
  return( 1 );
1627
0
}
1628
1629
/* Retrieves the size of the data
1630
 * Returns 1 if successful, 0 if not available or -1 on error
1631
 */
1632
int libevtx_record_get_data_size(
1633
     libevtx_record_t *record,
1634
     size_t *data_size,
1635
     libcerror_error_t **error )
1636
0
{
1637
0
  libevtx_internal_record_t *internal_record = NULL;
1638
0
  static char *function                      = "libevtx_record_get_data_size";
1639
0
  int result                                 = 0;
1640
1641
0
  if( record == NULL )
1642
0
  {
1643
0
    libcerror_error_set(
1644
0
     error,
1645
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1646
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1647
0
     "%s: invalid record.",
1648
0
     function );
1649
1650
0
    return( -1 );
1651
0
  }
1652
0
  internal_record = (libevtx_internal_record_t *) record;
1653
1654
0
  result = libevtx_record_values_get_data_size(
1655
0
            internal_record->record_values,
1656
0
            internal_record->io_handle,
1657
0
            data_size,
1658
0
            error );
1659
1660
0
  if( result == -1 )
1661
0
  {
1662
0
    libcerror_error_set(
1663
0
     error,
1664
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1665
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1666
0
     "%s: unable to retrieve data size.",
1667
0
     function );
1668
1669
0
    return( -1 );
1670
0
  }
1671
0
  return( result );
1672
0
}
1673
1674
/* Retrieves the data
1675
 * Returns 1 if successful, 0 if not available or -1 on error
1676
 */
1677
int libevtx_record_get_data(
1678
     libevtx_record_t *record,
1679
     uint8_t *data,
1680
     size_t data_size,
1681
     libcerror_error_t **error )
1682
0
{
1683
0
  libevtx_internal_record_t *internal_record = NULL;
1684
0
  static char *function                      = "libevtx_record_get_data";
1685
0
  int result                                 = 0;
1686
1687
0
  if( record == NULL )
1688
0
  {
1689
0
    libcerror_error_set(
1690
0
     error,
1691
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1692
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1693
0
     "%s: invalid record.",
1694
0
     function );
1695
1696
0
    return( -1 );
1697
0
  }
1698
0
  internal_record = (libevtx_internal_record_t *) record;
1699
1700
0
  result = libevtx_record_values_get_data(
1701
0
            internal_record->record_values,
1702
0
            internal_record->io_handle,
1703
0
            data,
1704
0
            data_size,
1705
0
            error );
1706
1707
0
  if( result == -1 )
1708
0
  {
1709
0
    libcerror_error_set(
1710
0
     error,
1711
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1712
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1713
0
     "%s: unable to retrieve data.",
1714
0
     function );
1715
1716
0
    return( -1 );
1717
0
  }
1718
0
  return( result );
1719
0
}
1720
1721
/* Retrieves the size of the UTF-8 encoded XML string
1722
 * The returned size includes the end of string character
1723
 * Returns 1 if successful or -1 on error
1724
 */
1725
int libevtx_record_get_utf8_xml_string_size(
1726
     libevtx_record_t *record,
1727
     size_t *utf8_string_size,
1728
     libcerror_error_t **error )
1729
0
{
1730
0
  libevtx_internal_record_t *internal_record = NULL;
1731
0
  static char *function                      = "libevtx_record_get_utf8_xml_string_size";
1732
1733
0
  if( record == NULL )
1734
0
  {
1735
0
    libcerror_error_set(
1736
0
     error,
1737
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1738
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1739
0
     "%s: invalid record.",
1740
0
     function );
1741
1742
0
    return( -1 );
1743
0
  }
1744
0
  internal_record = (libevtx_internal_record_t *) record;
1745
1746
0
  if( libevtx_record_values_get_utf8_xml_string_size(
1747
0
       internal_record->record_values,
1748
0
       utf8_string_size,
1749
0
       error ) != 1 )
1750
0
  {
1751
0
    libcerror_error_set(
1752
0
     error,
1753
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1754
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1755
0
     "%s: unable to retrieve UTF-8 string size of event XML.",
1756
0
     function );
1757
1758
0
    return( -1 );
1759
0
  }
1760
0
  return( 1 );
1761
0
}
1762
1763
/* Retrieves the UTF-8 encoded XML string
1764
 * The size should include the end of string character
1765
 * Returns 1 if successful or -1 on error
1766
 */
1767
int libevtx_record_get_utf8_xml_string(
1768
     libevtx_record_t *record,
1769
     uint8_t *utf8_string,
1770
     size_t utf8_string_size,
1771
     libcerror_error_t **error )
1772
0
{
1773
0
  libevtx_internal_record_t *internal_record = NULL;
1774
0
  static char *function                      = "libevtx_record_get_utf8_xml_string";
1775
1776
0
  if( record == NULL )
1777
0
  {
1778
0
    libcerror_error_set(
1779
0
     error,
1780
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1781
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1782
0
     "%s: invalid record.",
1783
0
     function );
1784
1785
0
    return( -1 );
1786
0
  }
1787
0
  internal_record = (libevtx_internal_record_t *) record;
1788
1789
0
  if( libevtx_record_values_get_utf8_xml_string(
1790
0
       internal_record->record_values,
1791
0
       utf8_string,
1792
0
       utf8_string_size,
1793
0
       error ) != 1 )
1794
0
  {
1795
0
    libcerror_error_set(
1796
0
     error,
1797
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1798
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1799
0
     "%s: unable to copy event XML to UTF-8 string.",
1800
0
     function );
1801
1802
0
    return( -1 );
1803
0
  }
1804
0
  return( 1 );
1805
0
}
1806
1807
/* Retrieves the size of the UTF-16 encoded XML string
1808
 * The returned size includes the end of string character
1809
 * Returns 1 if successful or -1 on error
1810
 */
1811
int libevtx_record_get_utf16_xml_string_size(
1812
     libevtx_record_t *record,
1813
     size_t *utf16_string_size,
1814
     libcerror_error_t **error )
1815
0
{
1816
0
  libevtx_internal_record_t *internal_record = NULL;
1817
0
  static char *function                      = "libevtx_record_get_utf16_xml_string_size";
1818
1819
0
  if( record == NULL )
1820
0
  {
1821
0
    libcerror_error_set(
1822
0
     error,
1823
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1824
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1825
0
     "%s: invalid record.",
1826
0
     function );
1827
1828
0
    return( -1 );
1829
0
  }
1830
0
  internal_record = (libevtx_internal_record_t *) record;
1831
1832
0
  if( libevtx_record_values_get_utf16_xml_string_size(
1833
0
       internal_record->record_values,
1834
0
       utf16_string_size,
1835
0
       error ) != 1 )
1836
0
  {
1837
0
    libcerror_error_set(
1838
0
     error,
1839
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1840
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1841
0
     "%s: unable to retrieve UTF-16 string size of event XML.",
1842
0
     function );
1843
1844
0
    return( -1 );
1845
0
  }
1846
0
  return( 1 );
1847
0
}
1848
1849
/* Retrieves the UTF-16 encoded XML string
1850
 * The size should include the end of string character
1851
 * Returns 1 if successful or -1 on error
1852
 */
1853
int libevtx_record_get_utf16_xml_string(
1854
     libevtx_record_t *record,
1855
     uint16_t *utf16_string,
1856
     size_t utf16_string_size,
1857
     libcerror_error_t **error )
1858
0
{
1859
0
  libevtx_internal_record_t *internal_record = NULL;
1860
0
  static char *function                      = "libevtx_record_get_utf16_xml_string";
1861
1862
0
  if( record == NULL )
1863
0
  {
1864
0
    libcerror_error_set(
1865
0
     error,
1866
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1867
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1868
0
     "%s: invalid record.",
1869
0
     function );
1870
1871
0
    return( -1 );
1872
0
  }
1873
0
  internal_record = (libevtx_internal_record_t *) record;
1874
1875
0
  if( libevtx_record_values_get_utf16_xml_string(
1876
0
       internal_record->record_values,
1877
0
       utf16_string,
1878
0
       utf16_string_size,
1879
0
       error ) != 1 )
1880
0
  {
1881
0
    libcerror_error_set(
1882
0
     error,
1883
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1884
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1885
0
     "%s: unable to copy event XML to UTF-16 string.",
1886
0
     function );
1887
1888
0
    return( -1 );
1889
0
  }
1890
0
  return( 1 );
1891
0
}
1892