Coverage Report

Created: 2025-07-04 07:01

/src/libwrc/libwrc/libwrc_mui_resource.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * MUI resource functions
3
 *
4
 * Copyright (C) 2011-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 <narrow_string.h>
26
#include <system_string.h>
27
#include <types.h>
28
#include <wide_string.h>
29
30
#include "libwrc_debug.h"
31
#include "libwrc_definitions.h"
32
#include "libwrc_libcerror.h"
33
#include "libwrc_libcnotify.h"
34
#include "libwrc_libuna.h"
35
#include "libwrc_mui_resource.h"
36
37
#include "wrc_mui_resource.h"
38
39
uint8_t libwrc_mui_resource_signature[ 4 ] = { 0xcd, 0xfe, 0xcd, 0xfe };
40
41
/* Creates a MUI resource
42
 * Make sure the value mui_resource is referencing, is set to NULL
43
 * Returns 1 if successful or -1 on error
44
 */
45
int libwrc_mui_resource_initialize(
46
     libwrc_mui_resource_t **mui_resource,
47
     libcerror_error_t **error )
48
919
{
49
919
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
50
919
  static char *function                                 = "libwrc_mui_resource_initialize";
51
52
919
  if( mui_resource == NULL )
53
0
  {
54
0
    libcerror_error_set(
55
0
     error,
56
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
57
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
58
0
     "%s: invalid MUI resource.",
59
0
     function );
60
61
0
    return( -1 );
62
0
  }
63
919
  if( *mui_resource != NULL )
64
0
  {
65
0
    libcerror_error_set(
66
0
     error,
67
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
68
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
69
0
     "%s: invalid MUI resource value already set.",
70
0
     function );
71
72
0
    return( -1 );
73
0
  }
74
919
  internal_mui_resource = memory_allocate_structure(
75
919
                           libwrc_internal_mui_resource_t );
76
77
919
  if( internal_mui_resource == NULL )
78
0
  {
79
0
    libcerror_error_set(
80
0
     error,
81
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
82
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
83
0
     "%s: unable to create MUI resource.",
84
0
     function );
85
86
0
    goto on_error;
87
0
  }
88
919
  if( memory_set(
89
919
       internal_mui_resource,
90
919
       0,
91
919
       sizeof( libwrc_internal_mui_resource_t ) ) == NULL )
92
0
  {
93
0
    libcerror_error_set(
94
0
     error,
95
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
96
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
97
0
     "%s: unable to clear MUI resource.",
98
0
     function );
99
100
0
    goto on_error;
101
0
  }
102
919
  *mui_resource = (libwrc_mui_resource_t *) internal_mui_resource;
103
104
919
  return( 1 );
105
106
0
on_error:
107
0
  if( internal_mui_resource != NULL )
108
0
  {
109
0
    memory_free(
110
0
     internal_mui_resource );
111
0
  }
112
0
  return( -1 );
113
919
}
114
115
/* Frees a MUI resource
116
 * Returns 1 if successful or -1 on error
117
 */
118
int libwrc_mui_resource_free(
119
     libwrc_mui_resource_t **mui_resource,
120
     libcerror_error_t **error )
121
919
{
122
919
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
123
919
  static char *function                                 = "libwrc_mui_resource_free";
124
125
919
  if( mui_resource == NULL )
126
0
  {
127
0
    libcerror_error_set(
128
0
     error,
129
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
130
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
131
0
     "%s: invalid MUI resource.",
132
0
     function );
133
134
0
    return( -1 );
135
0
  }
136
919
  if( *mui_resource != NULL )
137
919
  {
138
919
    internal_mui_resource = (libwrc_internal_mui_resource_t *) *mui_resource;
139
919
    *mui_resource         = NULL;
140
141
919
    if( internal_mui_resource->main_name != NULL )
142
19
    {
143
19
      memory_free(
144
19
       internal_mui_resource->main_name );
145
19
    }
146
919
    if( internal_mui_resource->mui_name != NULL )
147
51
    {
148
51
      memory_free(
149
51
       internal_mui_resource->mui_name );
150
51
    }
151
919
    if( internal_mui_resource->language != NULL )
152
126
    {
153
126
      memory_free(
154
126
       internal_mui_resource->language );
155
126
    }
156
919
    if( internal_mui_resource->fallback_language != NULL )
157
126
    {
158
126
      memory_free(
159
126
       internal_mui_resource->fallback_language );
160
126
    }
161
919
    memory_free(
162
919
     internal_mui_resource );
163
919
  }
164
919
  return( 1 );
165
919
}
166
167
/* Reads the MUI resource
168
 * Returns 1 if successful or -1 on error
169
 */
170
int libwrc_mui_resource_read(
171
     libwrc_mui_resource_t *mui_resource,
172
     const uint8_t *data,
173
     size_t data_size,
174
     libcerror_error_t **error )
175
919
{
176
919
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
177
919
  static char *function                                 = "libwrc_mui_resource_read";
178
919
  size_t data_offset                                    = 0;
179
919
  uint32_t mui_resource_data_size                       = 0;
180
919
  uint32_t value_data_offset                            = 0;
181
919
  uint32_t value_data_size                              = 0;
182
183
#if defined( HAVE_DEBUG_OUTPUT )
184
  system_character_t *value_string                      = NULL;
185
  size_t value_string_size                              = 0;
186
  uint32_t value_32bit                                  = 0;
187
  int result                                            = 0;
188
#endif
189
190
919
  if( mui_resource == NULL )
191
0
  {
192
0
    libcerror_error_set(
193
0
     error,
194
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
195
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
196
0
     "%s: invalid MUI resource.",
197
0
     function );
198
199
0
    return( -1 );
200
0
  }
201
919
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
202
203
919
  if( internal_mui_resource->main_name != NULL )
204
0
  {
205
0
    libcerror_error_set(
206
0
     error,
207
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
208
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
209
0
     "%s: invalid MUI resource - main name value already set.",
210
0
     function );
211
212
0
    return( -1 );
213
0
  }
214
919
  if( internal_mui_resource->mui_name != NULL )
215
0
  {
216
0
    libcerror_error_set(
217
0
     error,
218
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
219
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
220
0
     "%s: invalid MUI resource - MUI name value already set.",
221
0
     function );
222
223
0
    return( -1 );
224
0
  }
225
919
  if( internal_mui_resource->language != NULL )
226
0
  {
227
0
    libcerror_error_set(
228
0
     error,
229
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
230
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
231
0
     "%s: invalid MUI resource - language value already set.",
232
0
     function );
233
234
0
    return( -1 );
235
0
  }
236
919
  if( internal_mui_resource->fallback_language != NULL )
237
0
  {
238
0
    libcerror_error_set(
239
0
     error,
240
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
241
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
242
0
     "%s: invalid MUI resource - fallback language value already set.",
243
0
     function );
244
245
0
    return( -1 );
246
0
  }
247
919
  if( data == 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 data.",
254
0
     function );
255
256
0
    return( -1 );
257
0
  }
258
919
  if( ( data_size < sizeof( wrc_mui_header_t ) )
259
919
   || ( data_size > (size_t) SSIZE_MAX ) )
260
13
  {
261
13
    libcerror_error_set(
262
13
     error,
263
13
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
264
13
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
265
13
     "%s: invalid data size value out of bounds.",
266
13
     function );
267
268
13
    return( -1 );
269
13
  }
270
#if defined( HAVE_DEBUG_OUTPUT )
271
  if( libcnotify_verbose != 0 )
272
  {
273
    libcnotify_printf(
274
     "%s: data:\n",
275
     function );
276
    libcnotify_print_data(
277
     data,
278
     data_size,
279
     0 );
280
  }
281
#endif
282
906
  if( memory_compare(
283
906
       ( (wrc_mui_header_t *) data )->signature,
284
906
       libwrc_mui_resource_signature,
285
906
       4 ) != 0 )
286
46
  {
287
46
    libcerror_error_set(
288
46
     error,
289
46
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
290
46
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
291
46
     "%s: unsupported signature.",
292
46
     function );
293
294
46
    goto on_error;
295
46
  }
296
860
  byte_stream_copy_to_uint32_little_endian(
297
860
   ( (wrc_mui_header_t *) data )->size,
298
860
   mui_resource_data_size );
299
300
860
  byte_stream_copy_to_uint32_little_endian(
301
860
   ( (wrc_mui_header_t *) data )->file_type,
302
860
   internal_mui_resource->file_type );
303
304
#if defined( HAVE_DEBUG_OUTPUT )
305
  if( libcnotify_verbose != 0 )
306
  {
307
    byte_stream_copy_to_uint32_little_endian(
308
     ( (wrc_mui_header_t *) data )->signature,
309
     value_32bit );
310
    libcnotify_printf(
311
     "%s: signature\t\t\t\t\t: 0x%08" PRIx32 "\n",
312
     function,
313
     value_32bit );
314
315
    libcnotify_printf(
316
     "%s: size\t\t\t\t\t\t: %" PRIu32 "\n",
317
     function,
318
     mui_resource_data_size );
319
320
    byte_stream_copy_to_uint32_little_endian(
321
     ( (wrc_mui_header_t *) data )->version,
322
     value_32bit );
323
    libcnotify_printf(
324
     "%s: version\t\t\t\t\t: %" PRIu32 ".%" PRIu32 "\n",
325
     function,
326
     value_32bit >> 16,
327
     value_32bit & 0x0000ffffUL );
328
329
    byte_stream_copy_to_uint32_little_endian(
330
     ( (wrc_mui_header_t *) data )->unknown1,
331
     value_32bit );
332
    libcnotify_printf(
333
     "%s: unknown1\t\t\t\t\t: 0x%08" PRIx32 "\n",
334
     function,
335
     value_32bit );
336
337
    libcnotify_printf(
338
     "%s: file type\t\t\t\t\t: 0x%08" PRIx32 "\n",
339
     function,
340
     internal_mui_resource->file_type );
341
342
    byte_stream_copy_to_uint32_little_endian(
343
     ( (wrc_mui_header_t *) data )->system_attributes,
344
     value_32bit );
345
    libcnotify_printf(
346
     "%s: system attributes\t\t\t\t: 0x%08" PRIx32 "\n",
347
     function,
348
     value_32bit );
349
350
    byte_stream_copy_to_uint32_little_endian(
351
     ( (wrc_mui_header_t *) data )->ultimate_fallback_location,
352
     value_32bit );
353
    libcnotify_printf(
354
     "%s: ultimate fallback location\t\t\t: 0x%08" PRIx32 "\n",
355
     function,
356
     value_32bit );
357
358
    libcnotify_printf(
359
     "%s: service checksum:\n",
360
     function );
361
    libcnotify_print_data(
362
     ( (wrc_mui_header_t *) data )->service_checksum,
363
     16,
364
     0 );
365
366
    libcnotify_printf(
367
     "%s: checksum:\n",
368
     function );
369
    libcnotify_print_data(
370
     ( (wrc_mui_header_t *) data )->checksum,
371
     16,
372
     0 );
373
374
    libcnotify_printf(
375
     "%s: unknown2:\n",
376
     function );
377
    libcnotify_print_data(
378
     ( (wrc_mui_header_t *) data )->unknown2,
379
     24,
380
     0 );
381
  }
382
#endif /* defined( HAVE_DEBUG_OUTPUT ) */
383
384
860
  if( (size_t) mui_resource_data_size > data_size )
385
44
  {
386
44
    libcerror_error_set(
387
44
     error,
388
44
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
389
44
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
390
44
     "%s: invalid MUI resource data size value out of bounds.",
391
44
     function );
392
393
44
    goto on_error;
394
44
  }
395
816
  data_offset = sizeof( wrc_mui_header_t );
396
397
816
  if( data_offset > ( data_size - 8 ) )
398
7
  {
399
7
    libcerror_error_set(
400
7
     error,
401
7
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
402
7
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
403
7
     "%s: invalid data size value too small.",
404
7
     function );
405
406
7
    goto on_error;
407
7
  }
408
809
  byte_stream_copy_to_uint32_little_endian(
409
809
   &( data[ data_offset ] ),
410
809
   value_data_offset );
411
412
809
  byte_stream_copy_to_uint32_little_endian(
413
809
   &( data[ data_offset + 4 ] ),
414
809
   value_data_size );
415
416
#if defined( HAVE_DEBUG_OUTPUT )
417
  if( libcnotify_verbose != 0 )
418
  {
419
    libcnotify_printf(
420
     "%s: main name type data offset\t\t\t: 0x%08" PRIx32 "\n",
421
     function,
422
     value_data_offset );
423
424
    libcnotify_printf(
425
     "%s: main name type data size\t\t\t: %" PRIu32 "\n",
426
     function,
427
     value_data_size );
428
  }
429
#endif
430
809
  data_offset += 8;
431
432
809
  if( value_data_size > 0 )
433
174
  {
434
174
    if( ( (size_t) value_data_offset < 0x84 )
435
174
     || ( (size_t) value_data_offset >= data_size ) )
436
75
    {
437
75
      libcerror_error_set(
438
75
       error,
439
75
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
440
75
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
441
75
       "%s: invalid value data offset value out of bounds.",
442
75
       function );
443
444
75
      goto on_error;
445
75
    }
446
99
    if( ( value_data_size == 0 )
447
99
     || ( value_data_size > (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE )
448
99
     || ( value_data_size > ( data_size - value_data_offset ) ) )
449
44
    {
450
44
      libcerror_error_set(
451
44
       error,
452
44
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
453
44
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
454
44
       "%s: invalid value data size value out of bounds.",
455
44
       function );
456
457
44
      goto on_error;
458
44
    }
459
#if defined( HAVE_DEBUG_OUTPUT )
460
    if( libcnotify_verbose != 0 )
461
    {
462
      libcnotify_printf(
463
       "%s: main name type data:\n",
464
       function );
465
      libcnotify_print_data(
466
       &( data[ value_data_offset ] ),
467
       value_data_size,
468
       0 );
469
    }
470
#endif
471
55
    internal_mui_resource->main_name = (uint8_t *) memory_allocate(
472
55
                                                    sizeof( uint8_t ) * value_data_size );
473
474
55
    if( internal_mui_resource->main_name == NULL )
475
0
    {
476
0
      libcerror_error_set(
477
0
       error,
478
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
479
0
       LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
480
0
       "%s: unable to create main name.",
481
0
       function );
482
483
0
      goto on_error;
484
0
    }
485
55
    if( memory_copy(
486
55
         internal_mui_resource->main_name,
487
55
         &( data[ value_data_offset ] ),
488
55
         value_data_size ) == NULL )
489
0
    {
490
0
      libcerror_error_set(
491
0
       error,
492
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
493
0
       LIBCERROR_MEMORY_ERROR_COPY_FAILED,
494
0
       "%s: unable to copy main name.",
495
0
       function );
496
497
0
      goto on_error;
498
0
    }
499
55
    internal_mui_resource->main_name_size = value_data_size;
500
501
#if defined( HAVE_DEBUG_OUTPUT )
502
    if( libcnotify_verbose != 0 )
503
    {
504
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
505
      result = libuna_utf16_string_size_from_utf16_stream(
506
          internal_mui_resource->main_name,
507
          internal_mui_resource->main_name_size,
508
          LIBUNA_ENDIAN_LITTLE,
509
          &value_string_size,
510
          error );
511
#else
512
      result = libuna_utf8_string_size_from_utf16_stream(
513
          internal_mui_resource->main_name,
514
          internal_mui_resource->main_name_size,
515
          LIBUNA_ENDIAN_LITTLE,
516
          &value_string_size,
517
          error );
518
#endif
519
      if( result != 1 )
520
      {
521
        libcerror_error_set(
522
         error,
523
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
524
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
525
         "%s: unable to determine size of main name string.",
526
         function );
527
528
        goto on_error;
529
      }
530
      if( value_string_size > ( (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE / sizeof( system_character_t ) ) )
531
      {
532
        libcerror_error_set(
533
         error,
534
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
535
         LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
536
         "%s: invalid main name string size value exceeds maximum.",
537
         function );
538
539
        goto on_error;
540
      }
541
      value_string = system_string_allocate(
542
          value_string_size );
543
544
      if( value_string == NULL )
545
      {
546
        libcerror_error_set(
547
         error,
548
         LIBCERROR_ERROR_DOMAIN_MEMORY,
549
         LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
550
         "%s: unable to create main name string.",
551
         function );
552
553
        goto on_error;
554
      }
555
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
556
      result = libuna_utf16_string_copy_from_utf16_stream(
557
          (libuna_utf16_character_t *) value_string,
558
          value_string_size,
559
          internal_mui_resource->main_name,
560
          internal_mui_resource->main_name_size,
561
          LIBUNA_ENDIAN_LITTLE,
562
          error );
563
#else
564
      result = libuna_utf8_string_copy_from_utf16_stream(
565
          (libuna_utf8_character_t *) value_string,
566
          value_string_size,
567
          internal_mui_resource->main_name,
568
          internal_mui_resource->main_name_size,
569
          LIBUNA_ENDIAN_LITTLE,
570
          error );
571
#endif
572
      if( result != 1 )
573
      {
574
        libcerror_error_set(
575
         error,
576
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
577
         LIBCERROR_RUNTIME_ERROR_SET_FAILED,
578
         "%s: unable to set main name string.",
579
         function );
580
581
        goto on_error;
582
      }
583
      libcnotify_printf(
584
       "%s: main name\t\t\t\t\t: %" PRIs_SYSTEM "\n",
585
       function,
586
       value_string );
587
588
      memory_free(
589
       value_string );
590
591
      value_string = NULL;
592
    }
593
#endif
594
55
  }
595
690
  if( data_offset > ( data_size - 8 ) )
596
6
  {
597
6
    libcerror_error_set(
598
6
     error,
599
6
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
600
6
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
601
6
     "%s: invalid data size value too small.",
602
6
     function );
603
604
6
    goto on_error;
605
6
  }
606
684
  byte_stream_copy_to_uint32_little_endian(
607
684
   &( data[ data_offset ] ),
608
684
   value_data_offset );
609
610
684
  byte_stream_copy_to_uint32_little_endian(
611
684
   &( data[ data_offset + 4 ] ),
612
684
   value_data_size );
613
614
#if defined( HAVE_DEBUG_OUTPUT )
615
  if( libcnotify_verbose != 0 )
616
  {
617
    libcnotify_printf(
618
     "%s: main identifier type data offset\t\t: 0x%08" PRIx32 "\n",
619
     function,
620
     value_data_offset );
621
622
    libcnotify_printf(
623
     "%s: main identifier type data size\t\t: %" PRIu32 "\n",
624
     function,
625
     value_data_size );
626
  }
627
#endif
628
684
  data_offset += 8;
629
630
684
  if( value_data_size > 0 )
631
136
  {
632
136
    if( ( (size_t) value_data_offset < 0x84 )
633
136
     || ( (size_t) value_data_offset >= data_size ) )
634
83
    {
635
83
      libcerror_error_set(
636
83
       error,
637
83
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
638
83
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
639
83
       "%s: value data offset value out of bounds.",
640
83
       function );
641
642
83
      goto on_error;
643
83
    }
644
53
    if( (size_t) ( value_data_offset + value_data_size ) > data_size )
645
44
    {
646
44
      libcerror_error_set(
647
44
       error,
648
44
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
649
44
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
650
44
       "%s: value data size value out of bounds.",
651
44
       function );
652
653
44
      goto on_error;
654
44
    }
655
#if defined( HAVE_DEBUG_OUTPUT )
656
    if( libcnotify_verbose != 0 )
657
    {
658
      libcnotify_printf(
659
       "%s: main identifier type data:\n",
660
       function );
661
      libcnotify_print_data(
662
       &( data[ value_data_offset ] ),
663
       value_data_size,
664
       0 );
665
    }
666
#endif
667
53
  }
668
557
  if( data_offset > ( data_size - 8 ) )
669
6
  {
670
6
    libcerror_error_set(
671
6
     error,
672
6
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
673
6
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
674
6
     "%s: invalid data size value too small.",
675
6
     function );
676
677
6
    goto on_error;
678
6
  }
679
551
  byte_stream_copy_to_uint32_little_endian(
680
551
   &( data[ data_offset ] ),
681
551
   value_data_offset );
682
683
551
  byte_stream_copy_to_uint32_little_endian(
684
551
   &( data[ data_offset + 4 ] ),
685
551
   value_data_size );
686
687
#if defined( HAVE_DEBUG_OUTPUT )
688
  if( libcnotify_verbose != 0 )
689
  {
690
    libcnotify_printf(
691
     "%s: MUI name type data offset\t\t\t: 0x%08" PRIx32 "\n",
692
     function,
693
     value_data_offset );
694
695
    libcnotify_printf(
696
     "%s: MUI name type data size\t\t\t: %" PRIu32 "\n",
697
     function,
698
     value_data_size );
699
  }
700
#endif
701
551
  data_offset += 8;
702
703
551
  if( value_data_size > 0 )
704
181
  {
705
181
    if( ( (size_t) value_data_offset < 0x84 )
706
181
     || ( (size_t) value_data_offset >= data_size ) )
707
70
    {
708
70
      libcerror_error_set(
709
70
       error,
710
70
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
711
70
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
712
70
       "%s: value data offset value out of bounds.",
713
70
       function );
714
715
70
      goto on_error;
716
70
    }
717
111
    if( ( value_data_size == 0 )
718
111
     || ( value_data_size > (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE )
719
111
     || ( value_data_size > ( data_size - value_data_offset ) ) )
720
45
    {
721
45
      libcerror_error_set(
722
45
       error,
723
45
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
724
45
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
725
45
       "%s: invalid value data size value out of bounds.",
726
45
       function );
727
728
45
      goto on_error;
729
45
    }
730
#if defined( HAVE_DEBUG_OUTPUT )
731
    if( libcnotify_verbose != 0 )
732
    {
733
      libcnotify_printf(
734
       "%s: MUI name type data:\n",
735
       function );
736
      libcnotify_print_data(
737
       &( data[ value_data_offset ] ),
738
       value_data_size,
739
       0 );
740
    }
741
#endif
742
66
    internal_mui_resource->mui_name = (uint8_t *) memory_allocate(
743
66
                                                   sizeof( uint8_t ) * value_data_size );
744
745
66
    if( internal_mui_resource->mui_name == NULL )
746
0
    {
747
0
      libcerror_error_set(
748
0
       error,
749
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
750
0
       LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
751
0
       "%s: unable to create MUI name.",
752
0
       function );
753
754
0
      goto on_error;
755
0
    }
756
66
    if( memory_copy(
757
66
         internal_mui_resource->mui_name,
758
66
         &( data[ value_data_offset ] ),
759
66
         value_data_size ) == NULL )
760
0
    {
761
0
      libcerror_error_set(
762
0
       error,
763
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
764
0
       LIBCERROR_MEMORY_ERROR_COPY_FAILED,
765
0
       "%s: unable to copy MUI name.",
766
0
       function );
767
768
0
      goto on_error;
769
0
    }
770
66
    internal_mui_resource->mui_name_size = value_data_size;
771
772
#if defined( HAVE_DEBUG_OUTPUT )
773
    if( libcnotify_verbose != 0 )
774
    {
775
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
776
      result = libuna_utf16_string_size_from_utf16_stream(
777
          internal_mui_resource->mui_name,
778
          internal_mui_resource->mui_name_size,
779
          LIBUNA_ENDIAN_LITTLE,
780
          &value_string_size,
781
          error );
782
#else
783
      result = libuna_utf8_string_size_from_utf16_stream(
784
          internal_mui_resource->mui_name,
785
          internal_mui_resource->mui_name_size,
786
          LIBUNA_ENDIAN_LITTLE,
787
          &value_string_size,
788
          error );
789
#endif
790
      if( result != 1 )
791
      {
792
        libcerror_error_set(
793
         error,
794
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
795
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
796
         "%s: unable to determine size of MUI name string.",
797
         function );
798
799
        goto on_error;
800
      }
801
      if( value_string_size > ( (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE / sizeof( system_character_t ) ) )
802
      {
803
        libcerror_error_set(
804
         error,
805
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
806
         LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
807
         "%s: invalid MUI name string size value exceeds maximum.",
808
         function );
809
810
        goto on_error;
811
      }
812
      value_string = system_string_allocate(
813
          value_string_size );
814
815
      if( value_string == NULL )
816
      {
817
        libcerror_error_set(
818
         error,
819
         LIBCERROR_ERROR_DOMAIN_MEMORY,
820
         LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
821
         "%s: unable to create MUI name string.",
822
         function );
823
824
        goto on_error;
825
      }
826
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
827
      result = libuna_utf16_string_copy_from_utf16_stream(
828
          (libuna_utf16_character_t *) value_string,
829
          value_string_size,
830
          internal_mui_resource->mui_name,
831
          internal_mui_resource->mui_name_size,
832
          LIBUNA_ENDIAN_LITTLE,
833
          error );
834
#else
835
      result = libuna_utf8_string_copy_from_utf16_stream(
836
          (libuna_utf8_character_t *) value_string,
837
          value_string_size,
838
          internal_mui_resource->mui_name,
839
          internal_mui_resource->mui_name_size,
840
          LIBUNA_ENDIAN_LITTLE,
841
          error );
842
#endif
843
      if( result != 1 )
844
      {
845
        libcerror_error_set(
846
         error,
847
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
848
         LIBCERROR_RUNTIME_ERROR_SET_FAILED,
849
         "%s: unable to set MUI name string.",
850
         function );
851
852
        goto on_error;
853
      }
854
      libcnotify_printf(
855
       "%s: MUI name\t\t\t\t\t: %" PRIs_SYSTEM "\n",
856
       function,
857
       value_string );
858
859
      memory_free(
860
       value_string );
861
862
      value_string = NULL;
863
    }
864
#endif
865
66
  }
866
436
  if( data_offset > ( data_size - 8 ) )
867
5
  {
868
5
    libcerror_error_set(
869
5
     error,
870
5
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
871
5
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
872
5
     "%s: invalid data size value too small.",
873
5
     function );
874
875
5
    goto on_error;
876
5
  }
877
431
  byte_stream_copy_to_uint32_little_endian(
878
431
   &( data[ data_offset ] ),
879
431
   value_data_offset );
880
881
431
  byte_stream_copy_to_uint32_little_endian(
882
431
   &( data[ data_offset + 4 ] ),
883
431
   value_data_size );
884
885
#if defined( HAVE_DEBUG_OUTPUT )
886
  if( libcnotify_verbose != 0 )
887
  {
888
    libcnotify_printf(
889
     "%s: MUI identifier type data offset\t\t: 0x%08" PRIx32 "\n",
890
     function,
891
     value_data_offset );
892
893
    libcnotify_printf(
894
     "%s: MUI identifier type data size\t\t\t: %" PRIu32 "\n",
895
     function,
896
     value_data_size );
897
  }
898
#endif
899
431
  data_offset += 8;
900
901
431
  if( value_data_size > 0 )
902
158
  {
903
158
    if( ( (size_t) value_data_offset < 0x84 )
904
158
     || ( (size_t) value_data_offset >= data_size ) )
905
88
    {
906
88
      libcerror_error_set(
907
88
       error,
908
88
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
909
88
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
910
88
       "%s: value data offset value out of bounds.",
911
88
       function );
912
913
88
      goto on_error;
914
88
    }
915
70
    if( (size_t) ( value_data_offset + value_data_size ) > data_size )
916
46
    {
917
46
      libcerror_error_set(
918
46
       error,
919
46
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
920
46
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
921
46
       "%s: value data size value out of bounds.",
922
46
       function );
923
924
46
      goto on_error;
925
46
    }
926
#if defined( HAVE_DEBUG_OUTPUT )
927
    if( libcnotify_verbose != 0 )
928
    {
929
      libcnotify_printf(
930
       "%s: MUI identifier type data:\n",
931
       function );
932
      libcnotify_print_data(
933
       &( data[ value_data_offset ] ),
934
       value_data_size,
935
       0 );
936
    }
937
#endif
938
70
  }
939
297
  if( data_offset > ( data_size - 8 ) )
940
6
  {
941
6
    libcerror_error_set(
942
6
     error,
943
6
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
944
6
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
945
6
     "%s: invalid data size value too small.",
946
6
     function );
947
948
6
    goto on_error;
949
6
  }
950
291
  byte_stream_copy_to_uint32_little_endian(
951
291
   &( data[ data_offset ] ),
952
291
   value_data_offset );
953
954
291
  byte_stream_copy_to_uint32_little_endian(
955
291
   &( data[ data_offset + 4 ] ),
956
291
   value_data_size );
957
958
#if defined( HAVE_DEBUG_OUTPUT )
959
  if( libcnotify_verbose != 0 )
960
  {
961
    libcnotify_printf(
962
     "%s: language data offset\t\t\t\t: 0x%08" PRIx32 "\n",
963
     function,
964
     value_data_offset );
965
966
    libcnotify_printf(
967
     "%s: language data size\t\t\t\t: %" PRIu32 "\n",
968
     function,
969
     value_data_size );
970
  }
971
#endif
972
291
  data_offset += 8;
973
974
291
  if( data_offset > ( data_size - 8 ) )
975
5
  {
976
5
    libcerror_error_set(
977
5
     error,
978
5
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
979
5
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
980
5
     "%s: invalid data size value too small.",
981
5
     function );
982
983
5
    goto on_error;
984
5
  }
985
286
  byte_stream_copy_to_uint32_little_endian(
986
286
   &( data[ data_offset ] ),
987
286
   value_data_offset );
988
989
286
  byte_stream_copy_to_uint32_little_endian(
990
286
   &( data[ data_offset + 4 ] ),
991
286
   value_data_size );
992
993
286
  if( value_data_size > 0 )
994
278
  {
995
278
    if( ( (size_t) value_data_offset < 0x84 )
996
278
     || ( (size_t) value_data_offset >= data_size ) )
997
101
    {
998
101
      libcerror_error_set(
999
101
       error,
1000
101
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1001
101
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1002
101
       "%s: value data offset value out of bounds.",
1003
101
       function );
1004
1005
101
      goto on_error;
1006
101
    }
1007
177
    if( ( value_data_size == 0 )
1008
177
     || ( value_data_size > (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE )
1009
177
     || ( value_data_size > ( data_size - value_data_offset ) ) )
1010
51
    {
1011
51
      libcerror_error_set(
1012
51
       error,
1013
51
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1014
51
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1015
51
       "%s: invalid value data size value out of bounds.",
1016
51
       function );
1017
1018
51
      goto on_error;
1019
51
    }
1020
#if defined( HAVE_DEBUG_OUTPUT )
1021
    if( libcnotify_verbose != 0 )
1022
    {
1023
      libcnotify_printf(
1024
       "%s: ultimate language data:\n",
1025
       function );
1026
      libcnotify_print_data(
1027
       &( data[ value_data_offset ] ),
1028
       value_data_size,
1029
       0 );
1030
    }
1031
#endif
1032
126
    internal_mui_resource->language = (uint8_t *) memory_allocate(
1033
126
                                                   sizeof( uint8_t ) * value_data_size );
1034
1035
126
    if( internal_mui_resource->language == NULL )
1036
0
    {
1037
0
      libcerror_error_set(
1038
0
       error,
1039
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
1040
0
       LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
1041
0
       "%s: unable to create language.",
1042
0
       function );
1043
1044
0
      goto on_error;
1045
0
    }
1046
126
    if( memory_copy(
1047
126
         internal_mui_resource->language,
1048
126
         &( data[ value_data_offset ] ),
1049
126
         value_data_size ) == NULL )
1050
0
    {
1051
0
      libcerror_error_set(
1052
0
       error,
1053
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
1054
0
       LIBCERROR_MEMORY_ERROR_COPY_FAILED,
1055
0
       "%s: unable to copy language identifier.",
1056
0
       function );
1057
1058
0
      goto on_error;
1059
0
    }
1060
126
    internal_mui_resource->language_size = value_data_size;
1061
1062
#if defined( HAVE_DEBUG_OUTPUT )
1063
    if( libcnotify_verbose != 0 )
1064
    {
1065
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
1066
      result = libuna_utf16_string_size_from_utf16_stream(
1067
          internal_mui_resource->language,
1068
          internal_mui_resource->language_size,
1069
          LIBUNA_ENDIAN_LITTLE,
1070
          &value_string_size,
1071
          error );
1072
#else
1073
      result = libuna_utf8_string_size_from_utf16_stream(
1074
          internal_mui_resource->language,
1075
          internal_mui_resource->language_size,
1076
          LIBUNA_ENDIAN_LITTLE,
1077
          &value_string_size,
1078
          error );
1079
#endif
1080
      if( result != 1 )
1081
      {
1082
        libcerror_error_set(
1083
         error,
1084
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1085
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1086
         "%s: unable to determine size of language string.",
1087
         function );
1088
1089
        goto on_error;
1090
      }
1091
      if( value_string_size > ( (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE / sizeof( system_character_t ) ) )
1092
      {
1093
        libcerror_error_set(
1094
         error,
1095
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1096
         LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
1097
         "%s: invalid language string size value exceeds maximum.",
1098
         function );
1099
1100
        goto on_error;
1101
      }
1102
      value_string = system_string_allocate(
1103
          value_string_size );
1104
1105
      if( value_string == NULL )
1106
      {
1107
        libcerror_error_set(
1108
         error,
1109
         LIBCERROR_ERROR_DOMAIN_MEMORY,
1110
         LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
1111
         "%s: unable to create language string.",
1112
         function );
1113
1114
        goto on_error;
1115
      }
1116
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
1117
      result = libuna_utf16_string_copy_from_utf16_stream(
1118
          (libuna_utf16_character_t *) value_string,
1119
          value_string_size,
1120
          internal_mui_resource->language,
1121
          internal_mui_resource->language_size,
1122
          LIBUNA_ENDIAN_LITTLE,
1123
          error );
1124
#else
1125
      result = libuna_utf8_string_copy_from_utf16_stream(
1126
          (libuna_utf8_character_t *) value_string,
1127
          value_string_size,
1128
          internal_mui_resource->language,
1129
          internal_mui_resource->language_size,
1130
          LIBUNA_ENDIAN_LITTLE,
1131
          error );
1132
#endif
1133
      if( result != 1 )
1134
      {
1135
        libcerror_error_set(
1136
         error,
1137
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1138
         LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1139
         "%s: unable to set language string.",
1140
         function );
1141
1142
        goto on_error;
1143
      }
1144
      libcnotify_printf(
1145
       "%s: language\t\t\t\t\t: %" PRIs_SYSTEM "\n",
1146
       function,
1147
       value_string );
1148
1149
      memory_free(
1150
       value_string );
1151
1152
      value_string = NULL;
1153
    }
1154
#endif
1155
126
  }
1156
#if defined( HAVE_DEBUG_OUTPUT )
1157
  if( libcnotify_verbose != 0 )
1158
  {
1159
    libcnotify_printf(
1160
     "%s: ultimate fallback language data offset\t: 0x%08" PRIx32 "\n",
1161
     function,
1162
     value_data_offset );
1163
1164
    libcnotify_printf(
1165
     "%s: ultimate fallback language data size\t\t: %" PRIu32 "\n",
1166
     function,
1167
     value_data_size );
1168
  }
1169
#endif
1170
134
  if( value_data_size > 0 )
1171
126
  {
1172
126
    if( ( (size_t) value_data_offset < 0x84 )
1173
126
     || ( (size_t) value_data_offset >= data_size ) )
1174
0
    {
1175
0
      libcerror_error_set(
1176
0
       error,
1177
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1178
0
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1179
0
       "%s: value data offset value out of bounds.",
1180
0
       function );
1181
1182
0
      goto on_error;
1183
0
    }
1184
126
    if( ( value_data_size == 0 )
1185
126
     || ( value_data_size > (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE )
1186
126
     || ( value_data_size > ( data_size - value_data_offset ) ) )
1187
0
    {
1188
0
      libcerror_error_set(
1189
0
       error,
1190
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1191
0
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1192
0
       "%s: invalid value data size value out of bounds.",
1193
0
       function );
1194
1195
0
      goto on_error;
1196
0
    }
1197
#if defined( HAVE_DEBUG_OUTPUT )
1198
    if( libcnotify_verbose != 0 )
1199
    {
1200
      libcnotify_printf(
1201
       "%s: ultimate fallback language data:\n",
1202
       function );
1203
      libcnotify_print_data(
1204
       &( data[ value_data_offset ] ),
1205
       value_data_size,
1206
       0 );
1207
    }
1208
#endif
1209
126
    internal_mui_resource->fallback_language = (uint8_t *) memory_allocate(
1210
126
                                                            sizeof( uint8_t ) * value_data_size );
1211
1212
126
    if( internal_mui_resource->fallback_language == NULL )
1213
0
    {
1214
0
      libcerror_error_set(
1215
0
       error,
1216
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
1217
0
       LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
1218
0
       "%s: unable to create fallback language.",
1219
0
       function );
1220
1221
0
      goto on_error;
1222
0
    }
1223
126
    if( memory_copy(
1224
126
         internal_mui_resource->fallback_language,
1225
126
         &( data[ value_data_offset ] ),
1226
126
         value_data_size ) == NULL )
1227
0
    {
1228
0
      libcerror_error_set(
1229
0
       error,
1230
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
1231
0
       LIBCERROR_MEMORY_ERROR_COPY_FAILED,
1232
0
       "%s: unable to copy fallback language.",
1233
0
       function );
1234
1235
0
      goto on_error;
1236
0
    }
1237
126
    internal_mui_resource->fallback_language_size = value_data_size;
1238
1239
#if defined( HAVE_DEBUG_OUTPUT )
1240
    if( libcnotify_verbose != 0 )
1241
    {
1242
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
1243
      result = libuna_utf16_string_size_from_utf16_stream(
1244
          internal_mui_resource->fallback_language,
1245
          internal_mui_resource->fallback_language_size,
1246
          LIBUNA_ENDIAN_LITTLE,
1247
          &value_string_size,
1248
          error );
1249
#else
1250
      result = libuna_utf8_string_size_from_utf16_stream(
1251
          internal_mui_resource->fallback_language,
1252
          internal_mui_resource->fallback_language_size,
1253
          LIBUNA_ENDIAN_LITTLE,
1254
          &value_string_size,
1255
          error );
1256
#endif
1257
      if( result != 1 )
1258
      {
1259
        libcerror_error_set(
1260
         error,
1261
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1262
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1263
         "%s: unable to determine size of fallback language string.",
1264
         function );
1265
1266
        goto on_error;
1267
      }
1268
      if( value_string_size > ( (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE / sizeof( system_character_t ) ) )
1269
      {
1270
        libcerror_error_set(
1271
         error,
1272
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1273
         LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
1274
         "%s: invalid fallback language string size value exceeds maximum.",
1275
         function );
1276
1277
        goto on_error;
1278
      }
1279
      value_string = system_string_allocate(
1280
          value_string_size );
1281
1282
      if( value_string == NULL )
1283
      {
1284
        libcerror_error_set(
1285
         error,
1286
         LIBCERROR_ERROR_DOMAIN_MEMORY,
1287
         LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
1288
         "%s: unable to create fallback language string.",
1289
         function );
1290
1291
        goto on_error;
1292
      }
1293
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
1294
      result = libuna_utf16_string_copy_from_utf16_stream(
1295
          (libuna_utf16_character_t *) value_string,
1296
          value_string_size,
1297
          internal_mui_resource->fallback_language,
1298
          internal_mui_resource->fallback_language_size,
1299
          LIBUNA_ENDIAN_LITTLE,
1300
          error );
1301
#else
1302
      result = libuna_utf8_string_copy_from_utf16_stream(
1303
          (libuna_utf8_character_t *) value_string,
1304
          value_string_size,
1305
          internal_mui_resource->fallback_language,
1306
          internal_mui_resource->fallback_language_size,
1307
          LIBUNA_ENDIAN_LITTLE,
1308
          error );
1309
#endif
1310
      if( result != 1 )
1311
      {
1312
        libcerror_error_set(
1313
         error,
1314
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1315
         LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1316
         "%s: unable to set fallback language string.",
1317
         function );
1318
1319
        goto on_error;
1320
      }
1321
      libcnotify_printf(
1322
       "%s: fallback language\t\t\t\t: %" PRIs_SYSTEM "\n",
1323
       function,
1324
       value_string );
1325
1326
      memory_free(
1327
       value_string );
1328
1329
      value_string = NULL;
1330
    }
1331
#endif
1332
126
  }
1333
#if defined( HAVE_DEBUG_OUTPUT )
1334
  if( libcnotify_verbose != 0 )
1335
  {
1336
    libcnotify_printf(
1337
     "\n" );
1338
  }
1339
#endif
1340
/* TODO print trailing data */
1341
1342
134
  return( 1 );
1343
1344
772
on_error:
1345
#if defined( HAVE_DEBUG_OUTPUT )
1346
  if( value_string != NULL )
1347
  {
1348
    memory_free(
1349
     value_string );
1350
  }
1351
#endif
1352
772
  if( internal_mui_resource->fallback_language != NULL )
1353
0
  {
1354
0
    memory_free(
1355
0
     internal_mui_resource->fallback_language );
1356
1357
0
    internal_mui_resource->fallback_language = NULL;
1358
0
  }
1359
772
  internal_mui_resource->fallback_language_size = 0;
1360
1361
772
  if( internal_mui_resource->language != NULL )
1362
0
  {
1363
0
    memory_free(
1364
0
     internal_mui_resource->language );
1365
1366
0
    internal_mui_resource->language = NULL;
1367
0
  }
1368
772
  internal_mui_resource->language_size = 0;
1369
1370
772
  if( internal_mui_resource->mui_name != NULL )
1371
15
  {
1372
15
    memory_free(
1373
15
     internal_mui_resource->mui_name );
1374
1375
15
    internal_mui_resource->mui_name = NULL;
1376
15
  }
1377
772
  internal_mui_resource->mui_name_size = 0;
1378
1379
772
  if( internal_mui_resource->main_name != NULL )
1380
36
  {
1381
36
    memory_free(
1382
36
     internal_mui_resource->main_name );
1383
1384
36
    internal_mui_resource->main_name = NULL;
1385
36
  }
1386
772
  internal_mui_resource->main_name_size = 0;
1387
1388
772
  return( -1 );
1389
134
}
1390
1391
/* Retrieves the file type
1392
 * Returns 1 if successful or -1 on error
1393
 */
1394
int libwrc_mui_resource_get_file_type(
1395
     libwrc_mui_resource_t *mui_resource,
1396
     uint32_t *file_type,
1397
     libcerror_error_t **error )
1398
0
{
1399
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1400
0
  static char *function                                 = "libwrc_mui_resource_get_file_type";
1401
1402
0
  if( mui_resource == NULL )
1403
0
  {
1404
0
    libcerror_error_set(
1405
0
     error,
1406
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1407
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1408
0
     "%s: invalid MUI resource.",
1409
0
     function );
1410
1411
0
    return( -1 );
1412
0
  }
1413
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1414
1415
0
  if( file_type == NULL )
1416
0
  {
1417
0
    libcerror_error_set(
1418
0
     error,
1419
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1420
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1421
0
     "%s: invalid file type.",
1422
0
     function );
1423
1424
0
    return( -1 );
1425
0
  }
1426
0
  *file_type = internal_mui_resource->file_type;
1427
1428
0
  return( 1 );
1429
0
}
1430
1431
/* Retrieves the size of a specific UTF-8 formatted main name
1432
 * Returns 1 if successful, 0 if not available or -1 on error
1433
 */
1434
int libwrc_mui_resource_get_utf8_main_name_size(
1435
     libwrc_mui_resource_t *mui_resource,
1436
     size_t *utf8_string_size,
1437
     libcerror_error_t **error )
1438
0
{
1439
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1440
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_main_name_size";
1441
1442
0
  if( mui_resource == NULL )
1443
0
  {
1444
0
    libcerror_error_set(
1445
0
     error,
1446
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1447
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1448
0
     "%s: invalid MUI resource.",
1449
0
     function );
1450
1451
0
    return( -1 );
1452
0
  }
1453
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1454
1455
0
  if( utf8_string_size == NULL )
1456
0
  {
1457
0
    libcerror_error_set(
1458
0
     error,
1459
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1460
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1461
0
     "%s: invalid UTF-8 string size.",
1462
0
     function );
1463
1464
0
    return( -1 );
1465
0
  }
1466
0
  if( ( internal_mui_resource->main_name == NULL )
1467
0
   || ( internal_mui_resource->main_name_size == 0 ) )
1468
0
  {
1469
0
    return( 0 );
1470
0
  }
1471
0
  if( libuna_utf8_string_size_from_utf16_stream(
1472
0
       internal_mui_resource->main_name,
1473
0
       internal_mui_resource->main_name_size,
1474
0
       LIBUNA_ENDIAN_LITTLE,
1475
0
       utf8_string_size,
1476
0
       error ) != 1 )
1477
0
  {
1478
0
    libcerror_error_set(
1479
0
     error,
1480
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1481
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1482
0
     "%s: unable to retrieve UTF-8 string size.",
1483
0
     function );
1484
1485
0
    return( -1 );
1486
0
  }
1487
0
  return( 1 );
1488
0
}
1489
1490
/* Retrieves a specific UTF-8 formatted main name
1491
 * Returns 1 if successful, 0 if not available or -1 on error
1492
 */
1493
int libwrc_mui_resource_get_utf8_main_name(
1494
     libwrc_mui_resource_t *mui_resource,
1495
     uint8_t *utf8_string,
1496
     size_t utf8_string_size,
1497
     libcerror_error_t **error )
1498
0
{
1499
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1500
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_main_name";
1501
1502
0
  if( mui_resource == NULL )
1503
0
  {
1504
0
    libcerror_error_set(
1505
0
     error,
1506
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1507
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1508
0
     "%s: invalid MUI resource.",
1509
0
     function );
1510
1511
0
    return( -1 );
1512
0
  }
1513
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1514
1515
0
  if( utf8_string == NULL )
1516
0
  {
1517
0
    libcerror_error_set(
1518
0
     error,
1519
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1520
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1521
0
     "%s: invalid UTF-8 string.",
1522
0
     function );
1523
1524
0
    return( -1 );
1525
0
  }
1526
0
  if( utf8_string_size > (size_t) SSIZE_MAX )
1527
0
  {
1528
0
    libcerror_error_set(
1529
0
     error,
1530
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1531
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
1532
0
     "%s: invalid UTF-8 string size value exceeds maximum.",
1533
0
     function );
1534
1535
0
    return( -1 );
1536
0
  }
1537
0
  if( ( internal_mui_resource->main_name == NULL )
1538
0
   || ( internal_mui_resource->main_name_size == 0 ) )
1539
0
  {
1540
0
    return( 0 );
1541
0
  }
1542
0
  if( libuna_utf8_string_copy_from_utf16_stream(
1543
0
       utf8_string,
1544
0
       utf8_string_size,
1545
0
       internal_mui_resource->main_name,
1546
0
       internal_mui_resource->main_name_size,
1547
0
       LIBUNA_ENDIAN_LITTLE,
1548
0
       error ) != 1 )
1549
0
  {
1550
0
    libcerror_error_set(
1551
0
     error,
1552
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1553
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1554
0
     "%s: unable to retrieve UTF-8 string.",
1555
0
     function );
1556
1557
0
    return( -1 );
1558
0
  }
1559
0
  return( 1 );
1560
0
}
1561
1562
/* Retrieves the size of a specific UTF-16 formatted main name
1563
 * Returns 1 if successful, 0 if not available or -1 on error
1564
 */
1565
int libwrc_mui_resource_get_utf16_main_name_size(
1566
     libwrc_mui_resource_t *mui_resource,
1567
     size_t *utf16_string_size,
1568
     libcerror_error_t **error )
1569
0
{
1570
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1571
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_main_name_size";
1572
1573
0
  if( mui_resource == NULL )
1574
0
  {
1575
0
    libcerror_error_set(
1576
0
     error,
1577
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1578
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1579
0
     "%s: invalid MUI resource.",
1580
0
     function );
1581
1582
0
    return( -1 );
1583
0
  }
1584
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1585
1586
0
  if( utf16_string_size == NULL )
1587
0
  {
1588
0
    libcerror_error_set(
1589
0
     error,
1590
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1591
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1592
0
     "%s: invalid UTF-16 string size.",
1593
0
     function );
1594
1595
0
    return( -1 );
1596
0
  }
1597
0
  if( ( internal_mui_resource->main_name == NULL )
1598
0
   || ( internal_mui_resource->main_name_size == 0 ) )
1599
0
  {
1600
0
    return( 0 );
1601
0
  }
1602
0
  if( libuna_utf16_string_size_from_utf16_stream(
1603
0
       internal_mui_resource->main_name,
1604
0
       internal_mui_resource->main_name_size,
1605
0
       LIBUNA_ENDIAN_LITTLE,
1606
0
       utf16_string_size,
1607
0
       error ) != 1 )
1608
0
  {
1609
0
    libcerror_error_set(
1610
0
     error,
1611
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1612
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1613
0
     "%s: unable to retrieve UTF-16 string size.",
1614
0
     function );
1615
1616
0
    return( -1 );
1617
0
  }
1618
0
  return( 1 );
1619
0
}
1620
1621
/* Retrieves a specific UTF-16 formatted main name
1622
 * Returns 1 if successful, 0 if not available or -1 on error
1623
 */
1624
int libwrc_mui_resource_get_utf16_main_name(
1625
     libwrc_mui_resource_t *mui_resource,
1626
     uint16_t *utf16_string,
1627
     size_t utf16_string_size,
1628
     libcerror_error_t **error )
1629
0
{
1630
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1631
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_main_name";
1632
1633
0
  if( mui_resource == NULL )
1634
0
  {
1635
0
    libcerror_error_set(
1636
0
     error,
1637
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1638
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1639
0
     "%s: invalid MUI resource.",
1640
0
     function );
1641
1642
0
    return( -1 );
1643
0
  }
1644
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1645
1646
0
  if( utf16_string == NULL )
1647
0
  {
1648
0
    libcerror_error_set(
1649
0
     error,
1650
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1651
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1652
0
     "%s: invalid UTF-16 string.",
1653
0
     function );
1654
1655
0
    return( -1 );
1656
0
  }
1657
0
  if( utf16_string_size > (size_t) SSIZE_MAX )
1658
0
  {
1659
0
    libcerror_error_set(
1660
0
     error,
1661
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1662
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
1663
0
     "%s: invalid UTF-16 string size value exceeds maximum.",
1664
0
     function );
1665
1666
0
    return( -1 );
1667
0
  }
1668
0
  if( ( internal_mui_resource->main_name == NULL )
1669
0
   || ( internal_mui_resource->main_name_size == 0 ) )
1670
0
  {
1671
0
    return( 0 );
1672
0
  }
1673
0
  if( libuna_utf16_string_copy_from_utf16_stream(
1674
0
       utf16_string,
1675
0
       utf16_string_size,
1676
0
       internal_mui_resource->main_name,
1677
0
       internal_mui_resource->main_name_size,
1678
0
       LIBUNA_ENDIAN_LITTLE,
1679
0
       error ) != 1 )
1680
0
  {
1681
0
    libcerror_error_set(
1682
0
     error,
1683
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1684
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1685
0
     "%s: unable to retrieve UTF-16 string.",
1686
0
     function );
1687
1688
0
    return( -1 );
1689
0
  }
1690
0
  return( 1 );
1691
0
}
1692
1693
/* Retrieves the size of a specific UTF-8 formatted MUI name
1694
 * Returns 1 if successful, 0 if not available or -1 on error
1695
 */
1696
int libwrc_mui_resource_get_utf8_mui_name_size(
1697
     libwrc_mui_resource_t *mui_resource,
1698
     size_t *utf8_string_size,
1699
     libcerror_error_t **error )
1700
0
{
1701
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1702
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_mui_name_size";
1703
1704
0
  if( mui_resource == NULL )
1705
0
  {
1706
0
    libcerror_error_set(
1707
0
     error,
1708
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1709
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1710
0
     "%s: invalid MUI resource.",
1711
0
     function );
1712
1713
0
    return( -1 );
1714
0
  }
1715
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1716
1717
0
  if( utf8_string_size == NULL )
1718
0
  {
1719
0
    libcerror_error_set(
1720
0
     error,
1721
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1722
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1723
0
     "%s: invalid UTF-8 string size.",
1724
0
     function );
1725
1726
0
    return( -1 );
1727
0
  }
1728
0
  if( ( internal_mui_resource->mui_name == NULL )
1729
0
   || ( internal_mui_resource->mui_name_size == 0 ) )
1730
0
  {
1731
0
    return( 0 );
1732
0
  }
1733
0
  if( libuna_utf8_string_size_from_utf16_stream(
1734
0
       internal_mui_resource->mui_name,
1735
0
       internal_mui_resource->mui_name_size,
1736
0
       LIBUNA_ENDIAN_LITTLE,
1737
0
       utf8_string_size,
1738
0
       error ) != 1 )
1739
0
  {
1740
0
    libcerror_error_set(
1741
0
     error,
1742
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1743
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1744
0
     "%s: unable to retrieve UTF-8 string size.",
1745
0
     function );
1746
1747
0
    return( -1 );
1748
0
  }
1749
0
  return( 1 );
1750
0
}
1751
1752
/* Retrieves a specific UTF-8 formatted MUI name
1753
 * Returns 1 if successful, 0 if not available or -1 on error
1754
 */
1755
int libwrc_mui_resource_get_utf8_mui_name(
1756
     libwrc_mui_resource_t *mui_resource,
1757
     uint8_t *utf8_string,
1758
     size_t utf8_string_size,
1759
     libcerror_error_t **error )
1760
0
{
1761
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1762
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_mui_name";
1763
1764
0
  if( mui_resource == NULL )
1765
0
  {
1766
0
    libcerror_error_set(
1767
0
     error,
1768
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1769
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1770
0
     "%s: invalid MUI resource.",
1771
0
     function );
1772
1773
0
    return( -1 );
1774
0
  }
1775
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1776
1777
0
  if( utf8_string == NULL )
1778
0
  {
1779
0
    libcerror_error_set(
1780
0
     error,
1781
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1782
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1783
0
     "%s: invalid UTF-8 string.",
1784
0
     function );
1785
1786
0
    return( -1 );
1787
0
  }
1788
0
  if( utf8_string_size > (size_t) SSIZE_MAX )
1789
0
  {
1790
0
    libcerror_error_set(
1791
0
     error,
1792
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1793
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
1794
0
     "%s: invalid UTF-8 string size value exceeds maximum.",
1795
0
     function );
1796
1797
0
    return( -1 );
1798
0
  }
1799
0
  if( ( internal_mui_resource->mui_name == NULL )
1800
0
   || ( internal_mui_resource->mui_name_size == 0 ) )
1801
0
  {
1802
0
    return( 0 );
1803
0
  }
1804
0
  if( libuna_utf8_string_copy_from_utf16_stream(
1805
0
       utf8_string,
1806
0
       utf8_string_size,
1807
0
       internal_mui_resource->mui_name,
1808
0
       internal_mui_resource->mui_name_size,
1809
0
       LIBUNA_ENDIAN_LITTLE,
1810
0
       error ) != 1 )
1811
0
  {
1812
0
    libcerror_error_set(
1813
0
     error,
1814
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1815
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1816
0
     "%s: unable to retrieve UTF-8 string.",
1817
0
     function );
1818
1819
0
    return( -1 );
1820
0
  }
1821
0
  return( 1 );
1822
0
}
1823
1824
/* Retrieves the size of a specific UTF-16 formatted MUI name
1825
 * Returns 1 if successful, 0 if not available or -1 on error
1826
 */
1827
int libwrc_mui_resource_get_utf16_mui_name_size(
1828
     libwrc_mui_resource_t *mui_resource,
1829
     size_t *utf16_string_size,
1830
     libcerror_error_t **error )
1831
0
{
1832
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1833
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_mui_name_size";
1834
1835
0
  if( mui_resource == NULL )
1836
0
  {
1837
0
    libcerror_error_set(
1838
0
     error,
1839
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1840
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1841
0
     "%s: invalid MUI resource.",
1842
0
     function );
1843
1844
0
    return( -1 );
1845
0
  }
1846
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1847
1848
0
  if( utf16_string_size == NULL )
1849
0
  {
1850
0
    libcerror_error_set(
1851
0
     error,
1852
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1853
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1854
0
     "%s: invalid UTF-16 string size.",
1855
0
     function );
1856
1857
0
    return( -1 );
1858
0
  }
1859
0
  if( ( internal_mui_resource->mui_name == NULL )
1860
0
   || ( internal_mui_resource->mui_name_size == 0 ) )
1861
0
  {
1862
0
    return( 0 );
1863
0
  }
1864
0
  if( libuna_utf16_string_size_from_utf16_stream(
1865
0
       internal_mui_resource->mui_name,
1866
0
       internal_mui_resource->mui_name_size,
1867
0
       LIBUNA_ENDIAN_LITTLE,
1868
0
       utf16_string_size,
1869
0
       error ) != 1 )
1870
0
  {
1871
0
    libcerror_error_set(
1872
0
     error,
1873
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1874
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1875
0
     "%s: unable to retrieve UTF-16 string size.",
1876
0
     function );
1877
1878
0
    return( -1 );
1879
0
  }
1880
0
  return( 1 );
1881
0
}
1882
1883
/* Retrieves a specific UTF-16 formatted MUI name
1884
 * Returns 1 if successful, 0 if not available or -1 on error
1885
 */
1886
int libwrc_mui_resource_get_utf16_mui_name(
1887
     libwrc_mui_resource_t *mui_resource,
1888
     uint16_t *utf16_string,
1889
     size_t utf16_string_size,
1890
     libcerror_error_t **error )
1891
0
{
1892
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1893
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_mui_name";
1894
1895
0
  if( mui_resource == NULL )
1896
0
  {
1897
0
    libcerror_error_set(
1898
0
     error,
1899
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1900
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1901
0
     "%s: invalid MUI resource.",
1902
0
     function );
1903
1904
0
    return( -1 );
1905
0
  }
1906
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1907
1908
0
  if( utf16_string == NULL )
1909
0
  {
1910
0
    libcerror_error_set(
1911
0
     error,
1912
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1913
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1914
0
     "%s: invalid UTF-16 string.",
1915
0
     function );
1916
1917
0
    return( -1 );
1918
0
  }
1919
0
  if( utf16_string_size > (size_t) SSIZE_MAX )
1920
0
  {
1921
0
    libcerror_error_set(
1922
0
     error,
1923
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1924
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
1925
0
     "%s: invalid UTF-16 string size value exceeds maximum.",
1926
0
     function );
1927
1928
0
    return( -1 );
1929
0
  }
1930
0
  if( ( internal_mui_resource->mui_name == NULL )
1931
0
   || ( internal_mui_resource->mui_name_size == 0 ) )
1932
0
  {
1933
0
    return( 0 );
1934
0
  }
1935
0
  if( libuna_utf16_string_copy_from_utf16_stream(
1936
0
       utf16_string,
1937
0
       utf16_string_size,
1938
0
       internal_mui_resource->mui_name,
1939
0
       internal_mui_resource->mui_name_size,
1940
0
       LIBUNA_ENDIAN_LITTLE,
1941
0
       error ) != 1 )
1942
0
  {
1943
0
    libcerror_error_set(
1944
0
     error,
1945
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1946
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1947
0
     "%s: unable to retrieve UTF-16 string.",
1948
0
     function );
1949
1950
0
    return( -1 );
1951
0
  }
1952
0
  return( 1 );
1953
0
}
1954
1955
/* Retrieves the size of a specific UTF-8 formatted language
1956
 * Returns 1 if successful, 0 if not available or -1 on error
1957
 */
1958
int libwrc_mui_resource_get_utf8_language_size(
1959
     libwrc_mui_resource_t *mui_resource,
1960
     size_t *utf8_string_size,
1961
     libcerror_error_t **error )
1962
0
{
1963
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
1964
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_language_size";
1965
1966
0
  if( mui_resource == NULL )
1967
0
  {
1968
0
    libcerror_error_set(
1969
0
     error,
1970
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1971
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1972
0
     "%s: invalid MUI resource.",
1973
0
     function );
1974
1975
0
    return( -1 );
1976
0
  }
1977
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
1978
1979
0
  if( utf8_string_size == NULL )
1980
0
  {
1981
0
    libcerror_error_set(
1982
0
     error,
1983
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1984
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1985
0
     "%s: invalid UTF-8 string size.",
1986
0
     function );
1987
1988
0
    return( -1 );
1989
0
  }
1990
0
  if( ( internal_mui_resource->language == NULL )
1991
0
   || ( internal_mui_resource->language_size == 0 ) )
1992
0
  {
1993
0
    return( 0 );
1994
0
  }
1995
0
  if( libuna_utf8_string_size_from_utf16_stream(
1996
0
       internal_mui_resource->language,
1997
0
       internal_mui_resource->language_size,
1998
0
       LIBUNA_ENDIAN_LITTLE,
1999
0
       utf8_string_size,
2000
0
       error ) != 1 )
2001
0
  {
2002
0
    libcerror_error_set(
2003
0
     error,
2004
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2005
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2006
0
     "%s: unable to retrieve UTF-8 string size.",
2007
0
     function );
2008
2009
0
    return( -1 );
2010
0
  }
2011
0
  return( 1 );
2012
0
}
2013
2014
/* Retrieves a specific UTF-8 formatted language
2015
 * Returns 1 if successful, 0 if not available or -1 on error
2016
 */
2017
int libwrc_mui_resource_get_utf8_language(
2018
     libwrc_mui_resource_t *mui_resource,
2019
     uint8_t *utf8_string,
2020
     size_t utf8_string_size,
2021
     libcerror_error_t **error )
2022
0
{
2023
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2024
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_language";
2025
2026
0
  if( mui_resource == NULL )
2027
0
  {
2028
0
    libcerror_error_set(
2029
0
     error,
2030
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2031
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2032
0
     "%s: invalid MUI resource.",
2033
0
     function );
2034
2035
0
    return( -1 );
2036
0
  }
2037
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2038
2039
0
  if( utf8_string == NULL )
2040
0
  {
2041
0
    libcerror_error_set(
2042
0
     error,
2043
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2044
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2045
0
     "%s: invalid UTF-8 string.",
2046
0
     function );
2047
2048
0
    return( -1 );
2049
0
  }
2050
0
  if( utf8_string_size > (size_t) SSIZE_MAX )
2051
0
  {
2052
0
    libcerror_error_set(
2053
0
     error,
2054
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2055
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
2056
0
     "%s: invalid UTF-8 string size value exceeds maximum.",
2057
0
     function );
2058
2059
0
    return( -1 );
2060
0
  }
2061
0
  if( ( internal_mui_resource->language == NULL )
2062
0
   || ( internal_mui_resource->language_size == 0 ) )
2063
0
  {
2064
0
    return( 0 );
2065
0
  }
2066
0
  if( libuna_utf8_string_copy_from_utf16_stream(
2067
0
       utf8_string,
2068
0
       utf8_string_size,
2069
0
       internal_mui_resource->language,
2070
0
       internal_mui_resource->language_size,
2071
0
       LIBUNA_ENDIAN_LITTLE,
2072
0
       error ) != 1 )
2073
0
  {
2074
0
    libcerror_error_set(
2075
0
     error,
2076
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2077
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2078
0
     "%s: unable to retrieve UTF-8 string.",
2079
0
     function );
2080
2081
0
    return( -1 );
2082
0
  }
2083
0
  return( 1 );
2084
0
}
2085
2086
/* Retrieves the size of a specific UTF-16 formatted language
2087
 * Returns 1 if successful, 0 if not available or -1 on error
2088
 */
2089
int libwrc_mui_resource_get_utf16_language_size(
2090
     libwrc_mui_resource_t *mui_resource,
2091
     size_t *utf16_string_size,
2092
     libcerror_error_t **error )
2093
0
{
2094
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2095
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_language_size";
2096
2097
0
  if( mui_resource == NULL )
2098
0
  {
2099
0
    libcerror_error_set(
2100
0
     error,
2101
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2102
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2103
0
     "%s: invalid MUI resource.",
2104
0
     function );
2105
2106
0
    return( -1 );
2107
0
  }
2108
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2109
2110
0
  if( utf16_string_size == NULL )
2111
0
  {
2112
0
    libcerror_error_set(
2113
0
     error,
2114
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2115
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2116
0
     "%s: invalid UTF-16 string size.",
2117
0
     function );
2118
2119
0
    return( -1 );
2120
0
  }
2121
0
  if( ( internal_mui_resource->language == NULL )
2122
0
   || ( internal_mui_resource->language_size == 0 ) )
2123
0
  {
2124
0
    return( 0 );
2125
0
  }
2126
0
  if( libuna_utf16_string_size_from_utf16_stream(
2127
0
       internal_mui_resource->language,
2128
0
       internal_mui_resource->language_size,
2129
0
       LIBUNA_ENDIAN_LITTLE,
2130
0
       utf16_string_size,
2131
0
       error ) != 1 )
2132
0
  {
2133
0
    libcerror_error_set(
2134
0
     error,
2135
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2136
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2137
0
     "%s: unable to retrieve UTF-16 string size.",
2138
0
     function );
2139
2140
0
    return( -1 );
2141
0
  }
2142
0
  return( 1 );
2143
0
}
2144
2145
/* Retrieves a specific UTF-16 formatted language
2146
 * Returns 1 if successful, 0 if not available or -1 on error
2147
 */
2148
int libwrc_mui_resource_get_utf16_language(
2149
     libwrc_mui_resource_t *mui_resource,
2150
     uint16_t *utf16_string,
2151
     size_t utf16_string_size,
2152
     libcerror_error_t **error )
2153
0
{
2154
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2155
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_language";
2156
2157
0
  if( mui_resource == NULL )
2158
0
  {
2159
0
    libcerror_error_set(
2160
0
     error,
2161
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2162
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2163
0
     "%s: invalid MUI resource.",
2164
0
     function );
2165
2166
0
    return( -1 );
2167
0
  }
2168
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2169
2170
0
  if( utf16_string == NULL )
2171
0
  {
2172
0
    libcerror_error_set(
2173
0
     error,
2174
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2175
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2176
0
     "%s: invalid UTF-16 string.",
2177
0
     function );
2178
2179
0
    return( -1 );
2180
0
  }
2181
0
  if( utf16_string_size > (size_t) SSIZE_MAX )
2182
0
  {
2183
0
    libcerror_error_set(
2184
0
     error,
2185
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2186
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
2187
0
     "%s: invalid UTF-16 string size value exceeds maximum.",
2188
0
     function );
2189
2190
0
    return( -1 );
2191
0
  }
2192
0
  if( ( internal_mui_resource->language == NULL )
2193
0
   || ( internal_mui_resource->language_size == 0 ) )
2194
0
  {
2195
0
    return( 0 );
2196
0
  }
2197
0
  if( libuna_utf16_string_copy_from_utf16_stream(
2198
0
       utf16_string,
2199
0
       utf16_string_size,
2200
0
       internal_mui_resource->language,
2201
0
       internal_mui_resource->language_size,
2202
0
       LIBUNA_ENDIAN_LITTLE,
2203
0
       error ) != 1 )
2204
0
  {
2205
0
    libcerror_error_set(
2206
0
     error,
2207
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2208
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2209
0
     "%s: unable to retrieve UTF-16 string.",
2210
0
     function );
2211
2212
0
    return( -1 );
2213
0
  }
2214
0
  return( 1 );
2215
0
}
2216
2217
/* Retrieves the size of a specific UTF-8 formatted fallback language
2218
 * Returns 1 if successful, 0 if not available or -1 on error
2219
 */
2220
int libwrc_mui_resource_get_utf8_fallback_language_size(
2221
     libwrc_mui_resource_t *mui_resource,
2222
     size_t *utf8_string_size,
2223
     libcerror_error_t **error )
2224
0
{
2225
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2226
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_fallback_language_size";
2227
2228
0
  if( mui_resource == NULL )
2229
0
  {
2230
0
    libcerror_error_set(
2231
0
     error,
2232
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2233
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2234
0
     "%s: invalid MUI resource.",
2235
0
     function );
2236
2237
0
    return( -1 );
2238
0
  }
2239
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2240
2241
0
  if( utf8_string_size == NULL )
2242
0
  {
2243
0
    libcerror_error_set(
2244
0
     error,
2245
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2246
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2247
0
     "%s: invalid UTF-8 string size.",
2248
0
     function );
2249
2250
0
    return( -1 );
2251
0
  }
2252
0
  if( ( internal_mui_resource->fallback_language == NULL )
2253
0
   || ( internal_mui_resource->fallback_language_size == 0 ) )
2254
0
  {
2255
0
    return( 0 );
2256
0
  }
2257
0
  if( libuna_utf8_string_size_from_utf16_stream(
2258
0
       internal_mui_resource->fallback_language,
2259
0
       internal_mui_resource->fallback_language_size,
2260
0
       LIBUNA_ENDIAN_LITTLE,
2261
0
       utf8_string_size,
2262
0
       error ) != 1 )
2263
0
  {
2264
0
    libcerror_error_set(
2265
0
     error,
2266
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2267
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2268
0
     "%s: unable to retrieve UTF-8 string size.",
2269
0
     function );
2270
2271
0
    return( -1 );
2272
0
  }
2273
0
  return( 1 );
2274
0
}
2275
2276
/* Retrieves a specific UTF-8 formatted fallback language
2277
 * Returns 1 if successful, 0 if not available or -1 on error
2278
 */
2279
int libwrc_mui_resource_get_utf8_fallback_language(
2280
     libwrc_mui_resource_t *mui_resource,
2281
     uint8_t *utf8_string,
2282
     size_t utf8_string_size,
2283
     libcerror_error_t **error )
2284
0
{
2285
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2286
0
  static char *function                                 = "libwrc_mui_resource_get_utf8_fallback_language";
2287
2288
0
  if( mui_resource == NULL )
2289
0
  {
2290
0
    libcerror_error_set(
2291
0
     error,
2292
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2293
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2294
0
     "%s: invalid MUI resource.",
2295
0
     function );
2296
2297
0
    return( -1 );
2298
0
  }
2299
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2300
2301
0
  if( utf8_string == NULL )
2302
0
  {
2303
0
    libcerror_error_set(
2304
0
     error,
2305
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2306
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2307
0
     "%s: invalid UTF-8 string.",
2308
0
     function );
2309
2310
0
    return( -1 );
2311
0
  }
2312
0
  if( utf8_string_size > (size_t) SSIZE_MAX )
2313
0
  {
2314
0
    libcerror_error_set(
2315
0
     error,
2316
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2317
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
2318
0
     "%s: invalid UTF-8 string size value exceeds maximum.",
2319
0
     function );
2320
2321
0
    return( -1 );
2322
0
  }
2323
0
  if( ( internal_mui_resource->fallback_language == NULL )
2324
0
   || ( internal_mui_resource->fallback_language_size == 0 ) )
2325
0
  {
2326
0
    return( 0 );
2327
0
  }
2328
0
  if( libuna_utf8_string_copy_from_utf16_stream(
2329
0
       utf8_string,
2330
0
       utf8_string_size,
2331
0
       internal_mui_resource->fallback_language,
2332
0
       internal_mui_resource->fallback_language_size,
2333
0
       LIBUNA_ENDIAN_LITTLE,
2334
0
       error ) != 1 )
2335
0
  {
2336
0
    libcerror_error_set(
2337
0
     error,
2338
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2339
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2340
0
     "%s: unable to retrieve UTF-8 string.",
2341
0
     function );
2342
2343
0
    return( -1 );
2344
0
  }
2345
0
  return( 1 );
2346
0
}
2347
2348
/* Retrieves the size of a specific UTF-16 formatted fallback language
2349
 * Returns 1 if successful, 0 if not available or -1 on error
2350
 */
2351
int libwrc_mui_resource_get_utf16_fallback_language_size(
2352
     libwrc_mui_resource_t *mui_resource,
2353
     size_t *utf16_string_size,
2354
     libcerror_error_t **error )
2355
0
{
2356
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2357
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_fallback_language_size";
2358
2359
0
  if( mui_resource == NULL )
2360
0
  {
2361
0
    libcerror_error_set(
2362
0
     error,
2363
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2364
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2365
0
     "%s: invalid MUI resource.",
2366
0
     function );
2367
2368
0
    return( -1 );
2369
0
  }
2370
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2371
2372
0
  if( utf16_string_size == NULL )
2373
0
  {
2374
0
    libcerror_error_set(
2375
0
     error,
2376
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2377
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2378
0
     "%s: invalid UTF-16 string size.",
2379
0
     function );
2380
2381
0
    return( -1 );
2382
0
  }
2383
0
  if( ( internal_mui_resource->fallback_language == NULL )
2384
0
   || ( internal_mui_resource->fallback_language_size == 0 ) )
2385
0
  {
2386
0
    return( 0 );
2387
0
  }
2388
0
  if( libuna_utf16_string_size_from_utf16_stream(
2389
0
       internal_mui_resource->fallback_language,
2390
0
       internal_mui_resource->fallback_language_size,
2391
0
       LIBUNA_ENDIAN_LITTLE,
2392
0
       utf16_string_size,
2393
0
       error ) != 1 )
2394
0
  {
2395
0
    libcerror_error_set(
2396
0
     error,
2397
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2398
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2399
0
     "%s: unable to retrieve UTF-16 string size.",
2400
0
     function );
2401
2402
0
    return( -1 );
2403
0
  }
2404
0
  return( 1 );
2405
0
}
2406
2407
/* Retrieves a specific UTF-16 formatted fallback language
2408
 * Returns 1 if successful, 0 if not available or -1 on error
2409
 */
2410
int libwrc_mui_resource_get_utf16_fallback_language(
2411
     libwrc_mui_resource_t *mui_resource,
2412
     uint16_t *utf16_string,
2413
     size_t utf16_string_size,
2414
     libcerror_error_t **error )
2415
0
{
2416
0
  libwrc_internal_mui_resource_t *internal_mui_resource = NULL;
2417
0
  static char *function                                 = "libwrc_mui_resource_get_utf16_fallback_language";
2418
2419
0
  if( mui_resource == NULL )
2420
0
  {
2421
0
    libcerror_error_set(
2422
0
     error,
2423
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2424
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2425
0
     "%s: invalid MUI resource.",
2426
0
     function );
2427
2428
0
    return( -1 );
2429
0
  }
2430
0
  internal_mui_resource = (libwrc_internal_mui_resource_t *) mui_resource;
2431
2432
0
  if( utf16_string == NULL )
2433
0
  {
2434
0
    libcerror_error_set(
2435
0
     error,
2436
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
2437
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
2438
0
     "%s: invalid UTF-16 string.",
2439
0
     function );
2440
2441
0
    return( -1 );
2442
0
  }
2443
0
  if( utf16_string_size > (size_t) SSIZE_MAX )
2444
0
  {
2445
0
    libcerror_error_set(
2446
0
     error,
2447
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2448
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
2449
0
     "%s: invalid UTF-16 string size value exceeds maximum.",
2450
0
     function );
2451
2452
0
    return( -1 );
2453
0
  }
2454
0
  if( ( internal_mui_resource->fallback_language == NULL )
2455
0
   || ( internal_mui_resource->fallback_language_size == 0 ) )
2456
0
  {
2457
0
    return( 0 );
2458
0
  }
2459
0
  if( libuna_utf16_string_copy_from_utf16_stream(
2460
0
       utf16_string,
2461
0
       utf16_string_size,
2462
0
       internal_mui_resource->fallback_language,
2463
0
       internal_mui_resource->fallback_language_size,
2464
0
       LIBUNA_ENDIAN_LITTLE,
2465
0
       error ) != 1 )
2466
0
  {
2467
0
    libcerror_error_set(
2468
0
     error,
2469
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
2470
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
2471
0
     "%s: unable to retrieve UTF-16 string.",
2472
0
     function );
2473
2474
0
    return( -1 );
2475
0
  }
2476
0
  return( 1 );
2477
0
}
2478