Coverage Report

Created: 2026-05-24 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libfsntfs/libfsntfs/libfsntfs_reparse_point_attribute.c
Line
Count
Source
1
/*
2
 * Reparse point attribute ($REPARSE_POINT) functions
3
 *
4
 * Copyright (C) 2010-2026, 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 "libfsntfs_attribute.h"
27
#include "libfsntfs_definitions.h"
28
#include "libfsntfs_libcerror.h"
29
#include "libfsntfs_libcthreads.h"
30
#include "libfsntfs_reparse_point_attribute.h"
31
#include "libfsntfs_reparse_point_values.h"
32
#include "libfsntfs_types.h"
33
34
/* Retrieves the tag
35
 * The tag is a combination of the type and flags
36
 * Returns 1 if successful or -1 on error
37
 */
38
int libfsntfs_reparse_point_attribute_get_tag(
39
     libfsntfs_attribute_t *attribute,
40
     uint32_t *tag,
41
     libcerror_error_t **error )
42
0
{
43
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
44
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_tag";
45
0
  uint32_t attribute_type                            = 0;
46
47
0
  if( attribute == NULL )
48
0
  {
49
0
    libcerror_error_set(
50
0
     error,
51
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
52
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
53
0
     "%s: invalid attribute.",
54
0
     function );
55
56
0
    return( -1 );
57
0
  }
58
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
59
60
0
  if( libfsntfs_internal_attribute_get_type(
61
0
       internal_attribute,
62
0
       &attribute_type,
63
0
       error ) != 1 )
64
0
  {
65
0
    libcerror_error_set(
66
0
     error,
67
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
68
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
69
0
     "%s: unable to retrieve attribute type.",
70
0
     function );
71
72
0
    return( -1 );
73
0
  }
74
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
75
0
  {
76
0
    libcerror_error_set(
77
0
     error,
78
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
79
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
80
0
     "%s: unsupported attribute type.",
81
0
     function );
82
83
0
    return( -1 );
84
0
  }
85
0
  if( libfsntfs_reparse_point_values_get_tag(
86
0
       (libfsntfs_reparse_point_values_t *) internal_attribute->value,
87
0
       tag,
88
0
       error ) != 1 )
89
0
  {
90
0
    libcerror_error_set(
91
0
     error,
92
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
93
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
94
0
     "%s: unable to retrieve compression method.",
95
0
     function );
96
97
0
    return( -1 );
98
0
  }
99
0
  return( 1 );
100
0
}
101
102
/* Retrieves the Windows Overlay Filter (WOF) compression_method
103
 * Returns 1 if successful, 0 if not available or -1 on error
104
 */
105
int libfsntfs_reparse_point_attribute_get_compression_method(
106
     libfsntfs_attribute_t *attribute,
107
     uint32_t *compression_method,
108
     libcerror_error_t **error )
109
0
{
110
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
111
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_compression_method";
112
0
  uint32_t attribute_type                            = 0;
113
0
  int result                                         = 0;
114
115
0
  if( attribute == NULL )
116
0
  {
117
0
    libcerror_error_set(
118
0
     error,
119
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
120
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
121
0
     "%s: invalid attribute.",
122
0
     function );
123
124
0
    return( -1 );
125
0
  }
126
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
127
128
0
  if( libfsntfs_internal_attribute_get_type(
129
0
       internal_attribute,
130
0
       &attribute_type,
131
0
       error ) != 1 )
132
0
  {
133
0
    libcerror_error_set(
134
0
     error,
135
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
136
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
137
0
     "%s: unable to retrieve attribute type.",
138
0
     function );
139
140
0
    return( -1 );
141
0
  }
142
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
143
0
  {
144
0
    libcerror_error_set(
145
0
     error,
146
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
147
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
148
0
     "%s: unsupported attribute type.",
149
0
     function );
150
151
0
    return( -1 );
152
0
  }
153
0
  result = libfsntfs_reparse_point_values_get_compression_method(
154
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
155
0
            compression_method,
156
0
            error );
157
158
0
  if( result == -1 )
159
0
  {
160
0
    libcerror_error_set(
161
0
     error,
162
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
163
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
164
0
     "%s: unable to retrieve compression method.",
165
0
     function );
166
167
0
    return( -1 );
168
0
  }
169
0
  return( result );
170
0
}
171
172
/* Retrieves the size of the UTF-8 encoded substitute name
173
 * The returned size includes the end of string character
174
 * Returns 1 if successful, 0 if not available or -1 on error
175
 */
176
int libfsntfs_reparse_point_attribute_get_utf8_substitute_name_size(
177
     libfsntfs_attribute_t *attribute,
178
     size_t *utf8_string_size,
179
     libcerror_error_t **error )
180
0
{
181
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
182
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_substitute_name_size";
183
0
  uint32_t attribute_type                            = 0;
184
0
  int result                                         = 0;
185
186
0
  if( attribute == NULL )
187
0
  {
188
0
    libcerror_error_set(
189
0
     error,
190
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
191
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
192
0
     "%s: invalid attribute.",
193
0
     function );
194
195
0
    return( -1 );
196
0
  }
197
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
198
199
0
  if( libfsntfs_internal_attribute_get_type(
200
0
       internal_attribute,
201
0
       &attribute_type,
202
0
       error ) != 1 )
203
0
  {
204
0
    libcerror_error_set(
205
0
     error,
206
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
207
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
208
0
     "%s: unable to retrieve attribute type.",
209
0
     function );
210
211
0
    return( -1 );
212
0
  }
213
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
214
0
  {
215
0
    libcerror_error_set(
216
0
     error,
217
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
218
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
219
0
     "%s: unsupported attribute type.",
220
0
     function );
221
222
0
    return( -1 );
223
0
  }
224
0
  result = libfsntfs_reparse_point_values_get_utf8_substitute_name_size(
225
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
226
0
            utf8_string_size,
227
0
            error );
228
229
0
  if( result == -1 )
230
0
  {
231
0
    libcerror_error_set(
232
0
     error,
233
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
234
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
235
0
     "%s: unable to retrieve size of UTF-8 substitute name.",
236
0
     function );
237
238
0
    return( -1 );
239
0
  }
240
0
  return( result );
241
0
}
242
243
/* Retrieves the UTF-8 encoded substitute name
244
 * The size should include the end of string character
245
 * Returns 1 if successful, 0 if not available or -1 on error
246
 */
247
int libfsntfs_reparse_point_attribute_get_utf8_substitute_name(
248
     libfsntfs_attribute_t *attribute,
249
     uint8_t *utf8_string,
250
     size_t utf8_string_size,
251
     libcerror_error_t **error )
252
0
{
253
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
254
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_substitute_name";
255
0
  uint32_t attribute_type                            = 0;
256
0
  int result                                         = 0;
257
258
0
  if( attribute == NULL )
259
0
  {
260
0
    libcerror_error_set(
261
0
     error,
262
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
263
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
264
0
     "%s: invalid attribute.",
265
0
     function );
266
267
0
    return( -1 );
268
0
  }
269
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
270
271
0
  if( libfsntfs_internal_attribute_get_type(
272
0
       internal_attribute,
273
0
       &attribute_type,
274
0
       error ) != 1 )
275
0
  {
276
0
    libcerror_error_set(
277
0
     error,
278
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
279
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
280
0
     "%s: unable to retrieve attribute type.",
281
0
     function );
282
283
0
    return( -1 );
284
0
  }
285
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
286
0
  {
287
0
    libcerror_error_set(
288
0
     error,
289
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
290
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
291
0
     "%s: unsupported attribute type.",
292
0
     function );
293
294
0
    return( -1 );
295
0
  }
296
0
  result = libfsntfs_reparse_point_values_get_utf8_substitute_name(
297
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
298
0
            utf8_string,
299
0
            utf8_string_size,
300
0
            error );
301
302
0
  if( result == -1 )
303
0
  {
304
0
    libcerror_error_set(
305
0
     error,
306
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
307
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
308
0
     "%s: unable to retrieve UTF-8 substitute name.",
309
0
     function );
310
311
0
    return( -1 );
312
0
  }
313
0
  return( result );
314
0
}
315
316
/* Retrieves the size of the UTF-16 encoded substitute name
317
 * The returned size includes the end of string character
318
 * Returns 1 if successful, 0 if not available or -1 on error
319
 */
320
int libfsntfs_reparse_point_attribute_get_utf16_substitute_name_size(
321
     libfsntfs_attribute_t *attribute,
322
     size_t *utf16_string_size,
323
     libcerror_error_t **error )
324
0
{
325
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
326
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_substitute_name_size";
327
0
  uint32_t attribute_type                            = 0;
328
0
  int result                                         = 0;
329
330
0
  if( attribute == NULL )
331
0
  {
332
0
    libcerror_error_set(
333
0
     error,
334
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
335
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
336
0
     "%s: invalid attribute.",
337
0
     function );
338
339
0
    return( -1 );
340
0
  }
341
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
342
343
0
  if( libfsntfs_internal_attribute_get_type(
344
0
       internal_attribute,
345
0
       &attribute_type,
346
0
       error ) != 1 )
347
0
  {
348
0
    libcerror_error_set(
349
0
     error,
350
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
351
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
352
0
     "%s: unable to retrieve attribute type.",
353
0
     function );
354
355
0
    return( -1 );
356
0
  }
357
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
358
0
  {
359
0
    libcerror_error_set(
360
0
     error,
361
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
362
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
363
0
     "%s: unsupported attribute type.",
364
0
     function );
365
366
0
    return( -1 );
367
0
  }
368
0
  result = libfsntfs_reparse_point_values_get_utf16_substitute_name_size(
369
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
370
0
            utf16_string_size,
371
0
            error );
372
373
0
  if( result == -1 )
374
0
  {
375
0
    libcerror_error_set(
376
0
     error,
377
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
378
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
379
0
     "%s: unable to retrieve size of UTF-16 substitute name.",
380
0
     function );
381
382
0
    return( -1 );
383
0
  }
384
0
  return( result );
385
0
}
386
387
/* Retrieves the UTF-16 encoded substitute name
388
 * The size should include the end of string character
389
 * Returns 1 if successful, 0 if not available or -1 on error
390
 */
391
int libfsntfs_reparse_point_attribute_get_utf16_substitute_name(
392
     libfsntfs_attribute_t *attribute,
393
     uint16_t *utf16_string,
394
     size_t utf16_string_size,
395
     libcerror_error_t **error )
396
0
{
397
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
398
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_substitute_name";
399
0
  uint32_t attribute_type                            = 0;
400
0
  int result                                         = 0;
401
402
0
  if( attribute == NULL )
403
0
  {
404
0
    libcerror_error_set(
405
0
     error,
406
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
407
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
408
0
     "%s: invalid attribute.",
409
0
     function );
410
411
0
    return( -1 );
412
0
  }
413
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
414
415
0
  if( libfsntfs_internal_attribute_get_type(
416
0
       internal_attribute,
417
0
       &attribute_type,
418
0
       error ) != 1 )
419
0
  {
420
0
    libcerror_error_set(
421
0
     error,
422
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
423
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
424
0
     "%s: unable to retrieve attribute type.",
425
0
     function );
426
427
0
    return( -1 );
428
0
  }
429
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
430
0
  {
431
0
    libcerror_error_set(
432
0
     error,
433
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
434
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
435
0
     "%s: unsupported attribute type.",
436
0
     function );
437
438
0
    return( -1 );
439
0
  }
440
0
  result = libfsntfs_reparse_point_values_get_utf16_substitute_name(
441
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
442
0
            utf16_string,
443
0
            utf16_string_size,
444
0
            error );
445
446
0
  if( result == -1 )
447
0
  {
448
0
    libcerror_error_set(
449
0
     error,
450
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
451
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
452
0
     "%s: unable to retrieve UTF-16 substitute name.",
453
0
     function );
454
455
0
    return( -1 );
456
0
  }
457
0
  return( result );
458
0
}
459
460
/* Retrieves the size of the UTF-8 encoded print name
461
 * The returned size includes the end of string character
462
 * Returns 1 if successful, 0 if not available or -1 on error
463
 */
464
int libfsntfs_reparse_point_attribute_get_utf8_print_name_size(
465
     libfsntfs_attribute_t *attribute,
466
     size_t *utf8_string_size,
467
     libcerror_error_t **error )
468
0
{
469
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
470
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_print_name_size";
471
0
  uint32_t attribute_type                            = 0;
472
0
  int result                                         = 0;
473
474
0
  if( attribute == NULL )
475
0
  {
476
0
    libcerror_error_set(
477
0
     error,
478
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
479
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
480
0
     "%s: invalid attribute.",
481
0
     function );
482
483
0
    return( -1 );
484
0
  }
485
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
486
487
0
  if( libfsntfs_internal_attribute_get_type(
488
0
       internal_attribute,
489
0
       &attribute_type,
490
0
       error ) != 1 )
491
0
  {
492
0
    libcerror_error_set(
493
0
     error,
494
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
495
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
496
0
     "%s: unable to retrieve attribute type.",
497
0
     function );
498
499
0
    return( -1 );
500
0
  }
501
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
502
0
  {
503
0
    libcerror_error_set(
504
0
     error,
505
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
506
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
507
0
     "%s: unsupported attribute type.",
508
0
     function );
509
510
0
    return( -1 );
511
0
  }
512
0
  result = libfsntfs_reparse_point_values_get_utf8_print_name_size(
513
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
514
0
            utf8_string_size,
515
0
            error );
516
517
0
  if( result == -1 )
518
0
  {
519
0
    libcerror_error_set(
520
0
     error,
521
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
522
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
523
0
     "%s: unable to retrieve size of UTF-8 print name.",
524
0
     function );
525
526
0
    return( -1 );
527
0
  }
528
0
  return( result );
529
0
}
530
531
/* Retrieves the UTF-8 encoded print name
532
 * The size should include the end of string character
533
 * Returns 1 if successful, 0 if not available or -1 on error
534
 */
535
int libfsntfs_reparse_point_attribute_get_utf8_print_name(
536
     libfsntfs_attribute_t *attribute,
537
     uint8_t *utf8_string,
538
     size_t utf8_string_size,
539
     libcerror_error_t **error )
540
0
{
541
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
542
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_print_name";
543
0
  uint32_t attribute_type                            = 0;
544
0
  int result                                         = 0;
545
546
0
  if( attribute == NULL )
547
0
  {
548
0
    libcerror_error_set(
549
0
     error,
550
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
551
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
552
0
     "%s: invalid attribute.",
553
0
     function );
554
555
0
    return( -1 );
556
0
  }
557
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
558
559
0
  if( libfsntfs_internal_attribute_get_type(
560
0
       internal_attribute,
561
0
       &attribute_type,
562
0
       error ) != 1 )
563
0
  {
564
0
    libcerror_error_set(
565
0
     error,
566
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
567
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
568
0
     "%s: unable to retrieve attribute type.",
569
0
     function );
570
571
0
    return( -1 );
572
0
  }
573
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
574
0
  {
575
0
    libcerror_error_set(
576
0
     error,
577
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
578
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
579
0
     "%s: unsupported attribute type.",
580
0
     function );
581
582
0
    return( -1 );
583
0
  }
584
0
  result = libfsntfs_reparse_point_values_get_utf8_print_name(
585
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
586
0
            utf8_string,
587
0
            utf8_string_size,
588
0
            error );
589
590
0
  if( result == -1 )
591
0
  {
592
0
    libcerror_error_set(
593
0
     error,
594
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
595
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
596
0
     "%s: unable to retrieve UTF-8 print name.",
597
0
     function );
598
599
0
    return( -1 );
600
0
  }
601
0
  return( result );
602
0
}
603
604
/* Retrieves the size of the UTF-16 encoded print name
605
 * The returned size includes the end of string character
606
 * Returns 1 if successful, 0 if not available or -1 on error
607
 */
608
int libfsntfs_reparse_point_attribute_get_utf16_print_name_size(
609
     libfsntfs_attribute_t *attribute,
610
     size_t *utf16_string_size,
611
     libcerror_error_t **error )
612
0
{
613
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
614
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_print_name_size";
615
0
  uint32_t attribute_type                            = 0;
616
0
  int result                                         = 0;
617
618
0
  if( attribute == 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 attribute.",
625
0
     function );
626
627
0
    return( -1 );
628
0
  }
629
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
630
631
0
  if( libfsntfs_internal_attribute_get_type(
632
0
       internal_attribute,
633
0
       &attribute_type,
634
0
       error ) != 1 )
635
0
  {
636
0
    libcerror_error_set(
637
0
     error,
638
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
639
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
640
0
     "%s: unable to retrieve attribute type.",
641
0
     function );
642
643
0
    return( -1 );
644
0
  }
645
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
646
0
  {
647
0
    libcerror_error_set(
648
0
     error,
649
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
650
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
651
0
     "%s: unsupported attribute type.",
652
0
     function );
653
654
0
    return( -1 );
655
0
  }
656
0
  result = libfsntfs_reparse_point_values_get_utf16_print_name_size(
657
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
658
0
            utf16_string_size,
659
0
            error );
660
661
0
  if( result == -1 )
662
0
  {
663
0
    libcerror_error_set(
664
0
     error,
665
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
666
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
667
0
     "%s: unable to retrieve size of UTF-16 print name.",
668
0
     function );
669
670
0
    return( -1 );
671
0
  }
672
0
  return( result );
673
0
}
674
675
/* Retrieves the UTF-16 encoded print name
676
 * The size should include the end of string character
677
 * Returns 1 if successful, 0 if not available or -1 on error
678
 */
679
int libfsntfs_reparse_point_attribute_get_utf16_print_name(
680
     libfsntfs_attribute_t *attribute,
681
     uint16_t *utf16_string,
682
     size_t utf16_string_size,
683
     libcerror_error_t **error )
684
0
{
685
0
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
686
0
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_print_name";
687
0
  uint32_t attribute_type                            = 0;
688
0
  int result                                         = 0;
689
690
0
  if( attribute == NULL )
691
0
  {
692
0
    libcerror_error_set(
693
0
     error,
694
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
695
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
696
0
     "%s: invalid attribute.",
697
0
     function );
698
699
0
    return( -1 );
700
0
  }
701
0
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
702
703
0
  if( libfsntfs_internal_attribute_get_type(
704
0
       internal_attribute,
705
0
       &attribute_type,
706
0
       error ) != 1 )
707
0
  {
708
0
    libcerror_error_set(
709
0
     error,
710
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
711
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
712
0
     "%s: unable to retrieve attribute type.",
713
0
     function );
714
715
0
    return( -1 );
716
0
  }
717
0
  if( attribute_type != LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT )
718
0
  {
719
0
    libcerror_error_set(
720
0
     error,
721
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
722
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
723
0
     "%s: unsupported attribute type.",
724
0
     function );
725
726
0
    return( -1 );
727
0
  }
728
0
  result = libfsntfs_reparse_point_values_get_utf16_print_name(
729
0
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
730
0
            utf16_string,
731
0
            utf16_string_size,
732
0
            error );
733
734
0
  if( result == -1 )
735
0
  {
736
0
    libcerror_error_set(
737
0
     error,
738
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
739
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
740
0
     "%s: unable to retrieve UTF-16 print name.",
741
0
     function );
742
743
0
    return( -1 );
744
0
  }
745
0
  return( result );
746
0
}
747