Coverage Report

Created: 2026-12-01 07:31

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
101
{
43
101
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
44
101
  static char *function                              = "libfsntfs_reparse_point_attribute_get_tag";
45
101
  uint32_t attribute_type                            = 0;
46
47
101
  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
101
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
59
60
101
  if( libfsntfs_internal_attribute_get_type(
61
101
       internal_attribute,
62
101
       &attribute_type,
63
101
       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
101
  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
101
  if( libfsntfs_reparse_point_values_get_tag(
86
101
       (libfsntfs_reparse_point_values_t *) internal_attribute->value,
87
101
       tag,
88
101
       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
101
  return( 1 );
100
101
}
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
29
{
110
29
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
111
29
  static char *function                              = "libfsntfs_reparse_point_attribute_get_compression_method";
112
29
  uint32_t attribute_type                            = 0;
113
29
  int result                                         = 0;
114
115
29
  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
29
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
127
128
29
  if( libfsntfs_internal_attribute_get_type(
129
29
       internal_attribute,
130
29
       &attribute_type,
131
29
       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
29
  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
29
  result = libfsntfs_reparse_point_values_get_compression_method(
154
29
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
155
29
            compression_method,
156
29
            error );
157
158
29
  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
29
  return( result );
170
29
}
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
36
{
181
36
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
182
36
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_substitute_name_size";
183
36
  uint32_t attribute_type                            = 0;
184
36
  int result                                         = 0;
185
186
36
  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
36
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
198
199
36
  if( libfsntfs_internal_attribute_get_type(
200
36
       internal_attribute,
201
36
       &attribute_type,
202
36
       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
36
  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
36
  result = libfsntfs_reparse_point_values_get_utf8_substitute_name_size(
225
36
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
226
36
            utf8_string_size,
227
36
            error );
228
229
36
  if( result == -1 )
230
2
  {
231
2
    libcerror_error_set(
232
2
     error,
233
2
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
234
2
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
235
2
     "%s: unable to retrieve size of UTF-8 substitute name.",
236
2
     function );
237
238
2
    return( -1 );
239
2
  }
240
34
  return( result );
241
36
}
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
34
{
253
34
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
254
34
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_substitute_name";
255
34
  uint32_t attribute_type                            = 0;
256
34
  int result                                         = 0;
257
258
34
  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
34
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
270
271
34
  if( libfsntfs_internal_attribute_get_type(
272
34
       internal_attribute,
273
34
       &attribute_type,
274
34
       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
34
  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
34
  result = libfsntfs_reparse_point_values_get_utf8_substitute_name(
297
34
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
298
34
            utf8_string,
299
34
            utf8_string_size,
300
34
            error );
301
302
34
  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
34
  return( result );
314
34
}
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
34
{
325
34
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
326
34
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_substitute_name_size";
327
34
  uint32_t attribute_type                            = 0;
328
34
  int result                                         = 0;
329
330
34
  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
34
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
342
343
34
  if( libfsntfs_internal_attribute_get_type(
344
34
       internal_attribute,
345
34
       &attribute_type,
346
34
       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
34
  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
34
  result = libfsntfs_reparse_point_values_get_utf16_substitute_name_size(
369
34
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
370
34
            utf16_string_size,
371
34
            error );
372
373
34
  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
34
  return( result );
385
34
}
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
34
{
397
34
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
398
34
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_substitute_name";
399
34
  uint32_t attribute_type                            = 0;
400
34
  int result                                         = 0;
401
402
34
  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
34
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
414
415
34
  if( libfsntfs_internal_attribute_get_type(
416
34
       internal_attribute,
417
34
       &attribute_type,
418
34
       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
34
  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
34
  result = libfsntfs_reparse_point_values_get_utf16_substitute_name(
441
34
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
442
34
            utf16_string,
443
34
            utf16_string_size,
444
34
            error );
445
446
34
  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
34
  return( result );
458
34
}
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
28
{
469
28
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
470
28
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_print_name_size";
471
28
  uint32_t attribute_type                            = 0;
472
28
  int result                                         = 0;
473
474
28
  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
28
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
486
487
28
  if( libfsntfs_internal_attribute_get_type(
488
28
       internal_attribute,
489
28
       &attribute_type,
490
28
       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
28
  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
28
  result = libfsntfs_reparse_point_values_get_utf8_print_name_size(
513
28
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
514
28
            utf8_string_size,
515
28
            error );
516
517
28
  if( result == -1 )
518
1
  {
519
1
    libcerror_error_set(
520
1
     error,
521
1
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
522
1
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
523
1
     "%s: unable to retrieve size of UTF-8 print name.",
524
1
     function );
525
526
1
    return( -1 );
527
1
  }
528
27
  return( result );
529
28
}
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
27
{
541
27
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
542
27
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf8_print_name";
543
27
  uint32_t attribute_type                            = 0;
544
27
  int result                                         = 0;
545
546
27
  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
27
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
558
559
27
  if( libfsntfs_internal_attribute_get_type(
560
27
       internal_attribute,
561
27
       &attribute_type,
562
27
       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
27
  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
27
  result = libfsntfs_reparse_point_values_get_utf8_print_name(
585
27
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
586
27
            utf8_string,
587
27
            utf8_string_size,
588
27
            error );
589
590
27
  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
27
  return( result );
602
27
}
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
27
{
613
27
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
614
27
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_print_name_size";
615
27
  uint32_t attribute_type                            = 0;
616
27
  int result                                         = 0;
617
618
27
  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
27
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
630
631
27
  if( libfsntfs_internal_attribute_get_type(
632
27
       internal_attribute,
633
27
       &attribute_type,
634
27
       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
27
  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
27
  result = libfsntfs_reparse_point_values_get_utf16_print_name_size(
657
27
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
658
27
            utf16_string_size,
659
27
            error );
660
661
27
  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
27
  return( result );
673
27
}
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
27
{
685
27
  libfsntfs_internal_attribute_t *internal_attribute = NULL;
686
27
  static char *function                              = "libfsntfs_reparse_point_attribute_get_utf16_print_name";
687
27
  uint32_t attribute_type                            = 0;
688
27
  int result                                         = 0;
689
690
27
  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
27
  internal_attribute = (libfsntfs_internal_attribute_t *) attribute;
702
703
27
  if( libfsntfs_internal_attribute_get_type(
704
27
       internal_attribute,
705
27
       &attribute_type,
706
27
       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
27
  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
27
  result = libfsntfs_reparse_point_values_get_utf16_print_name(
729
27
            (libfsntfs_reparse_point_values_t *) internal_attribute->value,
730
27
            utf16_string,
731
27
            utf16_string_size,
732
27
            error );
733
734
27
  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
27
  return( result );
746
27
}
747