Coverage Report

Created: 2024-10-02 06:58

/src/liblnk/liblnk/liblnk_distributed_link_tracker_properties.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Distributed link tracker properties functions
3
 *
4
 * Copyright (C) 2009-2024, 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 <byte_stream.h>
24
#include <memory.h>
25
#include <types.h>
26
27
#include "liblnk_data_block.h"
28
#include "liblnk_debug.h"
29
#include "liblnk_distributed_link_tracker_properties.h"
30
#include "liblnk_libcerror.h"
31
#include "liblnk_libcnotify.h"
32
#include "liblnk_libfguid.h"
33
#include "liblnk_libfwsi.h"
34
#include "liblnk_libuna.h"
35
36
#include "lnk_data_blocks.h"
37
38
/* Creates distributed link tracker properties
39
 * Make sure the value distributed_link_tracker_properties is referencing, is set to NULL
40
 * Returns 1 if successful or -1 on error
41
 */
42
int liblnk_distributed_link_tracker_properties_initialize(
43
     liblnk_distributed_link_tracker_properties_t **distributed_link_tracker_properties,
44
     libcerror_error_t **error )
45
547
{
46
547
  static char *function = "liblnk_distributed_link_tracker_properties_initialize";
47
48
547
  if( distributed_link_tracker_properties == 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 distributed link tracker properties.",
55
0
     function );
56
57
0
    return( -1 );
58
0
  }
59
547
  if( *distributed_link_tracker_properties != 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 distributed link tracker properties value already set.",
66
0
     function );
67
68
0
    return( -1 );
69
0
  }
70
547
  *distributed_link_tracker_properties = memory_allocate_structure(
71
547
                                          liblnk_distributed_link_tracker_properties_t );
72
73
547
  if( *distributed_link_tracker_properties == NULL )
74
0
  {
75
0
    libcerror_error_set(
76
0
     error,
77
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
78
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
79
0
     "%s: unable to create distributed link tracker properties.",
80
0
     function );
81
82
0
    goto on_error;
83
0
  }
84
547
  if( memory_set(
85
547
       *distributed_link_tracker_properties,
86
547
       0,
87
547
       sizeof( liblnk_distributed_link_tracker_properties_t ) ) == NULL )
88
0
  {
89
0
    libcerror_error_set(
90
0
     error,
91
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
92
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
93
0
     "%s: unable to clear distributed link tracker properties.",
94
0
     function );
95
96
0
    goto on_error;
97
0
  }
98
547
  return( 1 );
99
100
0
on_error:
101
0
  if( *distributed_link_tracker_properties != NULL )
102
0
  {
103
0
    memory_free(
104
0
     *distributed_link_tracker_properties );
105
106
0
    *distributed_link_tracker_properties = NULL;
107
0
  }
108
0
  return( -1 );
109
547
}
110
111
/* Frees distributed link tracker properties
112
 * Returns 1 if successful or -1 on error
113
 */
114
int liblnk_distributed_link_tracker_properties_free(
115
     liblnk_distributed_link_tracker_properties_t **distributed_link_tracker_properties,
116
     libcerror_error_t **error )
117
547
{
118
547
  static char *function = "liblnk_distributed_link_tracker_properties_free";
119
120
547
  if( distributed_link_tracker_properties == NULL )
121
0
  {
122
0
    libcerror_error_set(
123
0
     error,
124
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
125
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
126
0
     "%s: invalid distributed link tracker properties.",
127
0
     function );
128
129
0
    return( -1 );
130
0
  }
131
547
  if( *distributed_link_tracker_properties != NULL )
132
547
  {
133
547
    memory_free(
134
547
     *distributed_link_tracker_properties );
135
136
547
    *distributed_link_tracker_properties = NULL;
137
547
  }
138
547
  return( 1 );
139
547
}
140
141
/* Reads distributed link tracker properties
142
 * Returns the number of bytes read if successful or -1 on error
143
 */
144
int liblnk_distributed_link_tracker_properties_read(
145
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
146
     liblnk_data_block_t *data_block,
147
     int ascii_codepage,
148
     libcerror_error_t **error )
149
547
{
150
547
  liblnk_internal_data_block_t *internal_data_block                                              = NULL;
151
547
  lnk_data_block_distributed_link_tracker_properties_t *distributed_link_tracker_properties_data = NULL;
152
547
  static char *function                                                                          = "liblnk_distributed_link_tracker_properties_read";
153
547
  uint32_t data_size                                                                             = 0;
154
547
  uint32_t data_version                                                                          = 0;
155
156
547
  if( distributed_link_tracker_properties == NULL )
157
0
  {
158
0
    libcerror_error_set(
159
0
     error,
160
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
161
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
162
0
     "%s: invalid distributed link tracker properties.",
163
0
     function );
164
165
0
    return( -1 );
166
0
  }
167
547
  if( data_block == NULL )
168
0
  {
169
0
    libcerror_error_set(
170
0
     error,
171
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
172
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
173
0
     "%s: invalid data block.",
174
0
     function );
175
176
0
    return( -1 );
177
0
  }
178
547
  internal_data_block = (liblnk_internal_data_block_t *) data_block;
179
180
547
  if( internal_data_block->data == NULL )
181
0
  {
182
0
    libcerror_error_set(
183
0
     error,
184
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
185
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
186
0
     "%s: invalid data block - missing data.",
187
0
     function );
188
189
0
    return( -1 );
190
0
  }
191
547
  if( internal_data_block->data_size < sizeof( lnk_data_block_distributed_link_tracker_properties_t ) )
192
23
  {
193
23
    libcerror_error_set(
194
23
     error,
195
23
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
196
23
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
197
23
     "%s: invalid data block - data size too small.",
198
23
     function );
199
200
23
    return( -1 );
201
23
  }
202
524
  distributed_link_tracker_properties_data = (lnk_data_block_distributed_link_tracker_properties_t *) internal_data_block->data;
203
204
524
  byte_stream_copy_to_uint32_little_endian(
205
524
   distributed_link_tracker_properties_data->data_size,
206
524
   data_size );
207
208
524
  byte_stream_copy_to_uint32_little_endian(
209
524
   distributed_link_tracker_properties_data->data_version,
210
524
   data_version );
211
212
524
  if( data_version != 0 )
213
46
  {
214
46
    libcerror_error_set(
215
46
     error,
216
46
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
217
46
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
218
46
     "%s: unsupported data version: %" PRIu32 ".",
219
46
     function,
220
46
     data_version );
221
222
46
    return( -1 );
223
46
  }
224
/* TODO check if data size matches data block size */
225
478
  if( data_size < 88 )
226
5
  {
227
5
    libcerror_error_set(
228
5
     error,
229
5
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
230
5
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
231
5
     "%s: unsupported data size: %" PRIu32 ".",
232
5
     function,
233
5
     data_size );
234
235
5
    return( -1 );
236
5
  }
237
473
  if( memory_copy(
238
473
       distributed_link_tracker_properties->machine_identifier_string,
239
473
       distributed_link_tracker_properties_data->machine_identifier_string,
240
473
       16 ) == NULL )
241
0
  {
242
0
    libcerror_error_set(
243
0
     error,
244
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
245
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
246
0
     "%s: unable to copy machine identifier string.",
247
0
     function );
248
249
0
    return( -1 );
250
0
  }
251
473
  if( memory_copy(
252
473
       distributed_link_tracker_properties->droid_volume_identifier,
253
473
       distributed_link_tracker_properties_data->droid_volume_identifier,
254
473
       16 ) == NULL )
255
0
  {
256
0
    libcerror_error_set(
257
0
     error,
258
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
259
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
260
0
     "%s: unable to copy droid volume identifier.",
261
0
     function );
262
263
0
    return( -1 );
264
0
  }
265
473
  if( memory_copy(
266
473
       distributed_link_tracker_properties->droid_file_identifier,
267
473
       distributed_link_tracker_properties_data->droid_file_identifier,
268
473
       16 ) == NULL )
269
0
  {
270
0
    libcerror_error_set(
271
0
     error,
272
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
273
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
274
0
     "%s: unable to copy droid file identifier.",
275
0
     function );
276
277
0
    return( -1 );
278
0
  }
279
473
  if( memory_copy(
280
473
       distributed_link_tracker_properties->birth_droid_volume_identifier,
281
473
       distributed_link_tracker_properties_data->birth_droid_volume_identifier,
282
473
       16 ) == NULL )
283
0
  {
284
0
    libcerror_error_set(
285
0
     error,
286
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
287
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
288
0
     "%s: unable to copy birth droid volume identifier.",
289
0
     function );
290
291
0
    return( -1 );
292
0
  }
293
473
  if( memory_copy(
294
473
       distributed_link_tracker_properties->birth_droid_file_identifier,
295
473
       distributed_link_tracker_properties_data->birth_droid_file_identifier,
296
473
       16 ) == NULL )
297
0
  {
298
0
    libcerror_error_set(
299
0
     error,
300
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
301
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
302
0
     "%s: unable to copy birth droid file identifier.",
303
0
     function );
304
305
0
    return( -1 );
306
0
  }
307
#if defined( HAVE_DEBUG_OUTPUT )
308
  if( libcnotify_verbose != 0 )
309
  {
310
    libcnotify_printf(
311
     "%s: data size\t\t\t: %" PRIu32 "\n",
312
     function,
313
     data_size );
314
315
    libcnotify_printf(
316
     "%s: data version\t\t\t: %" PRIu32 "\n",
317
     function,
318
     data_version );
319
320
    libcnotify_printf(
321
     "%s: machine identifier string data:\n",
322
     function );
323
    libcnotify_print_data(
324
     distributed_link_tracker_properties_data->machine_identifier_string,
325
     16,
326
     0 );
327
328
    if( liblnk_debug_print_string_value(
329
         function,
330
         "machine identifier string\t",
331
         distributed_link_tracker_properties_data->machine_identifier_string,
332
         16,
333
         ascii_codepage,
334
         error ) != 1 )
335
    {
336
      libcerror_error_set(
337
       error,
338
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
339
       LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
340
       "%s: unable to print string value.",
341
       function );
342
343
      return( -1 );
344
    }
345
    if( liblnk_debug_print_guid_value(
346
         function,
347
         "droid volume identifier\t",
348
         distributed_link_tracker_properties->droid_volume_identifier,
349
         16,
350
         LIBFGUID_ENDIAN_LITTLE,
351
         LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE,
352
         error ) != 1 )
353
    {
354
      libcerror_error_set(
355
       error,
356
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
357
       LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
358
       "%s: unable to print GUID value.",
359
       function );
360
361
      return( -1 );
362
    }
363
    if( liblnk_debug_print_guid_value(
364
         function,
365
         "droid file identifier\t\t",
366
         distributed_link_tracker_properties->droid_file_identifier,
367
         16,
368
         LIBFGUID_ENDIAN_LITTLE,
369
         LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE,
370
         error ) != 1 )
371
    {
372
      libcerror_error_set(
373
       error,
374
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
375
       LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
376
       "%s: unable to print GUID value.",
377
       function );
378
379
      return( -1 );
380
    }
381
    if( liblnk_debug_print_guid_value(
382
         function,
383
         "birth droid volume identifier\t",
384
         distributed_link_tracker_properties->birth_droid_volume_identifier,
385
         16,
386
         LIBFGUID_ENDIAN_LITTLE,
387
         LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE,
388
         error ) != 1 )
389
    {
390
      libcerror_error_set(
391
       error,
392
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
393
       LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
394
       "%s: unable to print GUID value.",
395
       function );
396
397
      return( -1 );
398
    }
399
    if( liblnk_debug_print_guid_value(
400
         function,
401
         "birth droid file identifier\t",
402
         distributed_link_tracker_properties->birth_droid_file_identifier,
403
         16,
404
         LIBFGUID_ENDIAN_LITTLE,
405
         LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE,
406
         error ) != 1 )
407
    {
408
      libcerror_error_set(
409
       error,
410
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
411
       LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
412
       "%s: unable to print GUID value.",
413
       function );
414
415
      return( -1 );
416
    }
417
    libcnotify_printf(
418
     "\n" );
419
  }
420
#endif
421
#if defined( HAVE_DEBUG_OUTPUT )
422
  if( libcnotify_verbose != 0 )
423
  {
424
    if( internal_data_block->data_size > sizeof( lnk_data_block_distributed_link_tracker_properties_t ) )
425
    {
426
      libcnotify_printf(
427
       "%s: trailing data:\n",
428
       function );
429
      libcnotify_print_data(
430
       &( internal_data_block->data[ sizeof( lnk_data_block_distributed_link_tracker_properties_t ) ] ),
431
       internal_data_block->data_size - sizeof( lnk_data_block_distributed_link_tracker_properties_t ),
432
       0 );
433
    }
434
  }
435
#endif
436
473
  return( 1 );
437
473
}
438
439
/* Retrieves the size of the UTF-8 encoded machine identifier
440
 * The size includes the end of string character
441
 * Returns 1 if successful or -1 on error
442
 */
443
int liblnk_distributed_link_tracker_properties_get_utf8_machine_identifier_size(
444
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
445
     size_t *utf8_string_size,
446
     int ascii_codepage,
447
     libcerror_error_t **error )
448
0
{
449
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_utf8_machine_identifier_size";
450
451
0
  if( distributed_link_tracker_properties == NULL )
452
0
  {
453
0
    libcerror_error_set(
454
0
     error,
455
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
456
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
457
0
     "%s: invalid distributed link tracker properties.",
458
0
     function );
459
460
0
    return( -1 );
461
0
  }
462
0
  if( libuna_utf8_string_size_from_byte_stream(
463
0
       distributed_link_tracker_properties->machine_identifier_string,
464
0
       16,
465
0
       ascii_codepage,
466
0
       utf8_string_size,
467
0
       error ) != 1 )
468
0
  {
469
0
    libcerror_error_set(
470
0
     error,
471
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
472
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
473
0
     "%s: unable to retrieve UTF-8 machine identifier string size.",
474
0
     function );
475
476
0
    return( -1 );
477
0
  }
478
0
  return( 1 );
479
0
}
480
481
/* Retrieves the UTF-8 encoded machine identifier
482
 * The size should include the end of string character
483
 * Returns 1 if successful or -1 on error
484
 */
485
int liblnk_distributed_link_tracker_properties_get_utf8_machine_identifier(
486
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
487
     uint8_t *utf8_string,
488
     size_t utf8_string_size,
489
     int ascii_codepage,
490
     libcerror_error_t **error )
491
0
{
492
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_utf8_machine_identifier";
493
494
0
  if( distributed_link_tracker_properties == NULL )
495
0
  {
496
0
    libcerror_error_set(
497
0
     error,
498
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
499
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
500
0
     "%s: invalid distributed link tracker properties.",
501
0
     function );
502
503
0
    return( -1 );
504
0
  }
505
0
  if( libuna_utf8_string_copy_from_byte_stream(
506
0
       utf8_string,
507
0
       utf8_string_size,
508
0
       distributed_link_tracker_properties->machine_identifier_string,
509
0
       16,
510
0
       ascii_codepage,
511
0
       error ) != 1 )
512
0
  {
513
0
    libcerror_error_set(
514
0
     error,
515
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
516
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
517
0
     "%s: unable to retrieve UTF-8 machine identifier string.",
518
0
     function );
519
520
0
    return( -1 );
521
0
  }
522
0
  return( 1 );
523
0
}
524
525
/* Retrieves the size of the UTF-16 encoded machine identifier
526
 * The size includes the end of string character
527
 * Returns 1 if successful or -1 on error
528
 */
529
int liblnk_distributed_link_tracker_properties_get_utf16_machine_identifier_size(
530
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
531
     size_t *utf16_string_size,
532
     int ascii_codepage,
533
     libcerror_error_t **error )
534
0
{
535
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_utf16_machine_identifier_size";
536
537
0
  if( distributed_link_tracker_properties == NULL )
538
0
  {
539
0
    libcerror_error_set(
540
0
     error,
541
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
542
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
543
0
     "%s: invalid distributed link tracker properties.",
544
0
     function );
545
546
0
    return( -1 );
547
0
  }
548
0
  if( libuna_utf16_string_size_from_byte_stream(
549
0
       distributed_link_tracker_properties->machine_identifier_string,
550
0
       16,
551
0
       ascii_codepage,
552
0
       utf16_string_size,
553
0
       error ) != 1 )
554
0
  {
555
0
    libcerror_error_set(
556
0
     error,
557
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
558
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
559
0
     "%s: unable to retrieve UTF-16 machine identifier string size.",
560
0
     function );
561
562
0
    return( -1 );
563
0
  }
564
0
  return( 1 );
565
0
}
566
567
/* Retrieves the UTF-16 encoded machine identifier
568
 * The size should include the end of string character
569
 * Returns 1 if successful or -1 on error
570
 */
571
int liblnk_distributed_link_tracker_properties_get_utf16_machine_identifier(
572
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
573
     uint16_t *utf16_string,
574
     size_t utf16_string_size,
575
     int ascii_codepage,
576
     libcerror_error_t **error )
577
0
{
578
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_utf16_machine_identifier";
579
580
0
  if( distributed_link_tracker_properties == NULL )
581
0
  {
582
0
    libcerror_error_set(
583
0
     error,
584
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
585
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
586
0
     "%s: invalid distributed link tracker properties.",
587
0
     function );
588
589
0
    return( -1 );
590
0
  }
591
0
  if( libuna_utf16_string_copy_from_byte_stream(
592
0
       utf16_string,
593
0
       utf16_string_size,
594
0
       distributed_link_tracker_properties->machine_identifier_string,
595
0
       16,
596
0
       ascii_codepage,
597
0
       error ) != 1 )
598
0
  {
599
0
    libcerror_error_set(
600
0
     error,
601
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
602
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
603
0
     "%s: unable to retrieve UTF-16 machine identifier string.",
604
0
     function );
605
606
0
    return( -1 );
607
0
  }
608
0
  return( 1 );
609
0
}
610
611
/* Retrieves the droid volume identifier
612
 * The identifier is a GUID stored in little-endian and is 16 bytes of size
613
 * Returns 1 if successful or -1 on error
614
 */
615
int liblnk_distributed_link_tracker_properties_get_droid_volume_identifier(
616
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
617
     uint8_t *guid_data,
618
     size_t guid_data_size,
619
     libcerror_error_t **error )
620
0
{
621
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_droid_volume_identifier";
622
623
0
  if( distributed_link_tracker_properties == NULL )
624
0
  {
625
0
    libcerror_error_set(
626
0
     error,
627
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
628
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
629
0
     "%s: invalid distributed link tracker properties.",
630
0
     function );
631
632
0
    return( -1 );
633
0
  }
634
0
  if( guid_data == NULL )
635
0
  {
636
0
    libcerror_error_set(
637
0
     error,
638
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
639
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
640
0
     "%s: invalid GUID data.",
641
0
     function );
642
643
0
    return( -1 );
644
0
  }
645
0
  if( ( guid_data_size < 16 )
646
0
   || ( guid_data_size > (size_t) SSIZE_MAX ) )
647
0
  {
648
0
    libcerror_error_set(
649
0
     error,
650
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
651
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
652
0
     "%s: GUID data size value out of bounds.",
653
0
     function );
654
655
0
    return( -1 );
656
0
  }
657
0
  if( memory_copy(
658
0
       guid_data,
659
0
       distributed_link_tracker_properties->droid_volume_identifier,
660
0
       16 ) == NULL )
661
0
  {
662
0
    libcerror_error_set(
663
0
     error,
664
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
665
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
666
0
     "%s: unable to copy droid volume identifier.",
667
0
     function );
668
669
0
    return( -1 );
670
0
  }
671
0
  return( 1 );
672
0
}
673
674
/* Retrieves the droid file identifier
675
 * The identifier is a GUID stored in little-endian and is 16 bytes of size
676
 * Returns 1 if successful or -1 on error
677
 */
678
int liblnk_distributed_link_tracker_properties_get_droid_file_identifier(
679
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
680
     uint8_t *guid_data,
681
     size_t guid_data_size,
682
     libcerror_error_t **error )
683
0
{
684
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_droid_file_identifier";
685
686
0
  if( distributed_link_tracker_properties == NULL )
687
0
  {
688
0
    libcerror_error_set(
689
0
     error,
690
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
691
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
692
0
     "%s: invalid distributed link tracker properties.",
693
0
     function );
694
695
0
    return( -1 );
696
0
  }
697
0
  if( guid_data == NULL )
698
0
  {
699
0
    libcerror_error_set(
700
0
     error,
701
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
702
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
703
0
     "%s: invalid GUID data.",
704
0
     function );
705
706
0
    return( -1 );
707
0
  }
708
0
  if( ( guid_data_size < 16 )
709
0
   || ( guid_data_size > (size_t) SSIZE_MAX ) )
710
0
  {
711
0
    libcerror_error_set(
712
0
     error,
713
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
714
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
715
0
     "%s: GUID data size value out of bounds.",
716
0
     function );
717
718
0
    return( -1 );
719
0
  }
720
0
  if( memory_copy(
721
0
       guid_data,
722
0
       distributed_link_tracker_properties->droid_file_identifier,
723
0
       16 ) == NULL )
724
0
  {
725
0
    libcerror_error_set(
726
0
     error,
727
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
728
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
729
0
     "%s: unable to copy droid file identifier.",
730
0
     function );
731
732
0
    return( -1 );
733
0
  }
734
0
  return( 1 );
735
0
}
736
737
/* Retrieves the birth droid volume identifier
738
 * The identifier is a GUID stored in little-endian and is 16 bytes of size
739
 * Returns 1 if successful or -1 on error
740
 */
741
int liblnk_distributed_link_tracker_properties_get_birth_droid_volume_identifier(
742
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
743
     uint8_t *guid_data,
744
     size_t guid_data_size,
745
     libcerror_error_t **error )
746
0
{
747
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_birth_droid_volume_identifier";
748
749
0
  if( distributed_link_tracker_properties == NULL )
750
0
  {
751
0
    libcerror_error_set(
752
0
     error,
753
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
754
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
755
0
     "%s: invalid distributed link tracker properties.",
756
0
     function );
757
758
0
    return( -1 );
759
0
  }
760
0
  if( guid_data == NULL )
761
0
  {
762
0
    libcerror_error_set(
763
0
     error,
764
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
765
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
766
0
     "%s: invalid GUID data.",
767
0
     function );
768
769
0
    return( -1 );
770
0
  }
771
0
  if( ( guid_data_size < 16 )
772
0
   || ( guid_data_size > (size_t) SSIZE_MAX ) )
773
0
  {
774
0
    libcerror_error_set(
775
0
     error,
776
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
777
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
778
0
     "%s: GUID data size value out of bounds.",
779
0
     function );
780
781
0
    return( -1 );
782
0
  }
783
0
  if( memory_copy(
784
0
       guid_data,
785
0
       distributed_link_tracker_properties->birth_droid_volume_identifier,
786
0
       16 ) == NULL )
787
0
  {
788
0
    libcerror_error_set(
789
0
     error,
790
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
791
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
792
0
     "%s: unable to copy birth droid volume identifier.",
793
0
     function );
794
795
0
    return( -1 );
796
0
  }
797
0
  return( 1 );
798
0
}
799
800
/* Retrieves the birth droid file identifier
801
 * The identifier is a GUID stored in little-endian and is 16 bytes of size
802
 * Returns 1 if successful or -1 on error
803
 */
804
int liblnk_distributed_link_tracker_properties_get_birth_droid_file_identifier(
805
     liblnk_distributed_link_tracker_properties_t *distributed_link_tracker_properties,
806
     uint8_t *guid_data,
807
     size_t guid_data_size,
808
     libcerror_error_t **error )
809
0
{
810
0
  static char *function = "liblnk_distributed_link_tracker_properties_get_birth_droid_file_identifier";
811
812
0
  if( distributed_link_tracker_properties == NULL )
813
0
  {
814
0
    libcerror_error_set(
815
0
     error,
816
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
817
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
818
0
     "%s: invalid distributed link tracker properties.",
819
0
     function );
820
821
0
    return( -1 );
822
0
  }
823
0
  if( guid_data == NULL )
824
0
  {
825
0
    libcerror_error_set(
826
0
     error,
827
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
828
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
829
0
     "%s: invalid GUID data.",
830
0
     function );
831
832
0
    return( -1 );
833
0
  }
834
0
  if( ( guid_data_size < 16 )
835
0
   || ( guid_data_size > (size_t) SSIZE_MAX ) )
836
0
  {
837
0
    libcerror_error_set(
838
0
     error,
839
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
840
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
841
0
     "%s: GUID data size value out of bounds.",
842
0
     function );
843
844
0
    return( -1 );
845
0
  }
846
0
  if( memory_copy(
847
0
       guid_data,
848
0
       distributed_link_tracker_properties->birth_droid_file_identifier,
849
0
       16 ) == NULL )
850
0
  {
851
0
    libcerror_error_set(
852
0
     error,
853
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
854
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
855
0
     "%s: unable to copy birth droid file identifier.",
856
0
     function );
857
858
0
    return( -1 );
859
0
  }
860
0
  return( 1 );
861
0
}
862