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