Coverage Report

Created: 2023-06-07 06:53

/src/libagdb/libagdb/libagdb_source_information.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Source information functions
3
 *
4
 * Copyright (C) 2014-2023, Joachim Metz <joachim.metz@gmail.com>
5
 *
6
 * Refer to AUTHORS for acknowledgements.
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
#include <common.h>
23
#include <byte_stream.h>
24
#include <memory.h>
25
#include <types.h>
26
27
#include "libagdb_debug.h"
28
#include "libagdb_definitions.h"
29
#include "libagdb_io_handle.h"
30
#include "libagdb_hash.h"
31
#include "libagdb_libbfio.h"
32
#include "libagdb_libcerror.h"
33
#include "libagdb_libcnotify.h"
34
#include "libagdb_libfcache.h"
35
#include "libagdb_libfdata.h"
36
#include "libagdb_libuna.h"
37
#include "libagdb_source_information.h"
38
39
#include "agdb_source_information.h"
40
41
/* Creates source information
42
 * Make sure the value source_information is referencing, is set to NULL
43
 * Returns 1 if successful or -1 on error
44
 */
45
int libagdb_source_information_initialize(
46
     libagdb_source_information_t **source_information,
47
     libcerror_error_t **error )
48
4.11k
{
49
4.11k
  libagdb_internal_source_information_t *internal_source_information = NULL;
50
4.11k
  static char *function                                              = "libagdb_source_information_initialize";
51
52
4.11k
  if( source_information == 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 source information.",
59
0
     function );
60
61
0
    return( -1 );
62
0
  }
63
4.11k
  if( *source_information != 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 source information value already set.",
70
0
     function );
71
72
0
    return( -1 );
73
0
  }
74
4.11k
  internal_source_information = memory_allocate_structure(
75
4.11k
                                 libagdb_internal_source_information_t );
76
77
4.11k
  if( internal_source_information == 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 source information.",
84
0
     function );
85
86
0
    goto on_error;
87
0
  }
88
4.11k
  if( memory_set(
89
4.11k
       internal_source_information,
90
4.11k
       0,
91
4.11k
       sizeof( libagdb_internal_source_information_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 source information.",
98
0
     function );
99
100
0
    goto on_error;
101
0
  }
102
4.11k
  *source_information = (libagdb_source_information_t *) internal_source_information;
103
104
4.11k
  return( 1 );
105
106
0
on_error:
107
0
  if( internal_source_information != NULL )
108
0
  {
109
0
    memory_free(
110
0
     internal_source_information );
111
0
  }
112
0
  return( -1 );
113
4.11k
}
114
115
/* Frees source information
116
 * Returns 1 if successful or -1 on error
117
 */
118
int libagdb_source_information_free(
119
     libagdb_source_information_t **source_information,
120
     libcerror_error_t **error )
121
0
{
122
0
  static char *function = "libagdb_source_information_free";
123
124
0
  if( source_information == NULL )
125
0
  {
126
0
    libcerror_error_set(
127
0
     error,
128
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
129
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
130
0
     "%s: invalid source information.",
131
0
     function );
132
133
0
    return( -1 );
134
0
  }
135
0
  if( *source_information != NULL )
136
0
  {
137
0
    *source_information = NULL;
138
0
  }
139
0
  return( 1 );
140
0
}
141
142
/* Frees source information
143
 * Returns 1 if successful or -1 on error
144
 */
145
int libagdb_internal_source_information_free(
146
     libagdb_internal_source_information_t **internal_source_information,
147
     libcerror_error_t **error )
148
4.11k
{
149
4.11k
  static char *function = "libagdb_internal_source_information_free";
150
151
4.11k
  if( internal_source_information == NULL )
152
0
  {
153
0
    libcerror_error_set(
154
0
     error,
155
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
156
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
157
0
     "%s: invalid source information.",
158
0
     function );
159
160
0
    return( -1 );
161
0
  }
162
4.11k
  if( *internal_source_information != NULL )
163
4.11k
  {
164
4.11k
    memory_free(
165
4.11k
     *internal_source_information );
166
167
4.11k
    *internal_source_information = NULL;
168
4.11k
  }
169
4.11k
  return( 1 );
170
4.11k
}
171
172
/* Reads the source information
173
 * Returns the number of bytes read if successful or -1 on error
174
 */
175
ssize_t libagdb_source_information_read(
176
         libagdb_internal_source_information_t *internal_source_information,
177
         libagdb_io_handle_t *io_handle,
178
         libfdata_stream_t *uncompressed_data_stream,
179
         libbfio_handle_t *file_io_handle,
180
         uint32_t source_information_index,
181
         off64_t file_offset,
182
         libcerror_error_t **error )
183
4.11k
{
184
4.11k
  uint8_t sub_entry_data[ 32 ];
185
186
4.11k
  uint8_t *source_information_data = NULL;
187
4.11k
  static char *function            = "libagdb_source_information_read";
188
4.11k
  ssize_t read_count               = 0;
189
4.11k
  ssize_t total_read_count         = 0;
190
4.11k
  uint32_t entry_index             = 0;
191
4.11k
  uint32_t number_of_entries       = 0;
192
4.11k
  uint32_t sub_entry_data_size     = 0;
193
194
4.11k
  if( internal_source_information == NULL )
195
0
  {
196
0
    libcerror_error_set(
197
0
     error,
198
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
199
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
200
0
     "%s: invalid source information.",
201
0
     function );
202
203
0
    return( -1 );
204
0
  }
205
4.11k
  if( io_handle == NULL )
206
0
  {
207
0
    libcerror_error_set(
208
0
     error,
209
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
210
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
211
0
     "%s: invalid IO handle.",
212
0
     function );
213
214
0
    return( -1 );
215
0
  }
216
4.11k
  if( ( io_handle->source_information_entry_size == 0 )
217
4.11k
   || ( io_handle->source_information_entry_size > (uint32_t) MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
218
29
  {
219
29
    libcerror_error_set(
220
29
     error,
221
29
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
222
29
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
223
29
     "%s: invalid IO handle - source information entry size value out of bounds.",
224
29
     function );
225
226
29
    return( -1 );
227
29
  }
228
4.08k
  source_information_data = (uint8_t *) memory_allocate(
229
4.08k
                                         sizeof( uint8_t ) * (size_t) io_handle->source_information_entry_size );
230
231
4.08k
  if( source_information_data == NULL )
232
0
  {
233
0
    libcerror_error_set(
234
0
     error,
235
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
236
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
237
0
     "%s: unable to create source information data.",
238
0
     function );
239
240
0
    goto on_error;
241
0
  }
242
#if defined( HAVE_DEBUG_OUTPUT )
243
  if( libcnotify_verbose != 0 )
244
  {
245
    libcnotify_printf(
246
     "%s: reading source: %" PRIu32 " information at offset: %" PRIi64 " (0x%08" PRIx64 ")\n",
247
     function,
248
     source_information_index,
249
     file_offset,
250
     file_offset );
251
  }
252
#endif
253
4.08k
  read_count = libfdata_stream_read_buffer_at_offset(
254
4.08k
                uncompressed_data_stream,
255
4.08k
                (intptr_t *) file_io_handle,
256
4.08k
                source_information_data,
257
4.08k
                (size_t) io_handle->source_information_entry_size,
258
4.08k
                file_offset,
259
4.08k
                0,
260
4.08k
                error );
261
262
4.08k
  if( read_count != (ssize_t) io_handle->source_information_entry_size )
263
120
  {
264
120
    libcerror_error_set(
265
120
     error,
266
120
     LIBCERROR_ERROR_DOMAIN_IO,
267
120
     LIBCERROR_IO_ERROR_READ_FAILED,
268
120
     "%s: unable to read source: %" PRIu32 " information data at offset: %" PRIi64 " (0x%08" PRIx64 ").",
269
120
     function,
270
120
     source_information_index,
271
120
     file_offset,
272
120
     file_offset );
273
274
120
    goto on_error;
275
120
  }
276
3.96k
  total_read_count += read_count;
277
278
3.96k
  if( libagdb_source_information_read_data(
279
3.96k
       internal_source_information,
280
3.96k
       io_handle,
281
3.96k
       source_information_data,
282
3.96k
       (size_t) io_handle->source_information_entry_size,
283
3.96k
       &number_of_entries,
284
3.96k
       error ) != 1 )
285
52
  {
286
52
    libcerror_error_set(
287
52
     error,
288
52
     LIBCERROR_ERROR_DOMAIN_IO,
289
52
     LIBCERROR_IO_ERROR_READ_FAILED,
290
52
     "%s: unable to read source: %" PRIu32 " information.",
291
52
     function,
292
52
     source_information_index );
293
294
52
    goto on_error;
295
52
  }
296
3.91k
  memory_free(
297
3.91k
   source_information_data );
298
299
3.91k
  source_information_data = NULL;
300
301
3.91k
  if( number_of_entries > 0 )
302
311
  {
303
/* TODO is this the correct sub entry type ? */
304
311
    if( ( io_handle->file_information_sub_entry_type2_size != 16 )
305
311
     && ( io_handle->file_information_sub_entry_type2_size != 24 ) )
306
98
    {
307
98
      libcerror_error_set(
308
98
       error,
309
98
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
310
98
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
311
98
       "%s: unsupported file information sub entry type 2 size: %" PRIu32 ".",
312
98
       function,
313
98
       io_handle->file_information_sub_entry_type2_size );
314
315
98
      return( -1 );
316
98
    }
317
213
    sub_entry_data_size = io_handle->file_information_sub_entry_type2_size;
318
319
213
    for( entry_index = 0;
320
2.98k
         entry_index < number_of_entries;
321
2.77k
         entry_index++ )
322
2.83k
    {
323
2.83k
      read_count = libfdata_stream_read_buffer(
324
2.83k
              uncompressed_data_stream,
325
2.83k
              (intptr_t *) file_io_handle,
326
2.83k
              sub_entry_data,
327
2.83k
              (size_t) sub_entry_data_size,
328
2.83k
              0,
329
2.83k
              error );
330
331
2.83k
      if( read_count != (ssize_t) sub_entry_data_size )
332
68
      {
333
68
        libcerror_error_set(
334
68
         error,
335
68
         LIBCERROR_ERROR_DOMAIN_IO,
336
68
         LIBCERROR_IO_ERROR_READ_FAILED,
337
68
         "%s: unable to read sub entry: %" PRIu32 " data.",
338
68
         function,
339
68
         entry_index );
340
341
68
        goto on_error;
342
68
      }
343
2.77k
      total_read_count += read_count;
344
2.77k
      file_offset      += read_count;
345
346
#if defined( HAVE_DEBUG_OUTPUT )
347
      if( libcnotify_verbose != 0 )
348
      {
349
        libcnotify_printf(
350
         "%s: sub entry: %" PRIu32 " data:\n",
351
         function,
352
         entry_index );
353
        libcnotify_print_data(
354
         sub_entry_data,
355
         (size_t) sub_entry_data_size,
356
         0 );
357
      }
358
#endif
359
2.77k
    }
360
213
  }
361
3.74k
  return( total_read_count );
362
363
240
on_error:
364
240
  internal_source_information->executable_filename_size = 0;
365
366
240
  if( source_information_data != NULL )
367
172
  {
368
172
    memory_free(
369
172
     source_information_data );
370
172
  }
371
240
  return( -1 );
372
3.91k
}
373
374
/* Reads the source information
375
 * Returns the number of bytes read if successful or -1 on error
376
 */
377
int libagdb_source_information_read_data(
378
     libagdb_internal_source_information_t *internal_source_information,
379
     libagdb_io_handle_t *io_handle,
380
     const uint8_t *data,
381
     size_t data_size,
382
     uint32_t *number_of_entries,
383
     libcerror_error_t **error )
384
3.96k
{
385
3.96k
  static char *function = "libagdb_source_information_read_data";
386
3.96k
  uint8_t mode          = 0;
387
3.96k
  int string_index      = 0;
388
389
#if defined( HAVE_DEBUG_OUTPUT )
390
  uint64_t value_64bit  = 0;
391
  uint32_t value_32bit  = 0;
392
#endif
393
394
3.96k
  if( internal_source_information == NULL )
395
0
  {
396
0
    libcerror_error_set(
397
0
     error,
398
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
399
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
400
0
     "%s: invalid source information.",
401
0
     function );
402
403
0
    return( -1 );
404
0
  }
405
3.96k
  if( io_handle == NULL )
406
0
  {
407
0
    libcerror_error_set(
408
0
     error,
409
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
410
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
411
0
     "%s: invalid IO handle.",
412
0
     function );
413
414
0
    return( -1 );
415
0
  }
416
3.96k
  if( data == NULL )
417
0
  {
418
0
    libcerror_error_set(
419
0
     error,
420
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
421
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
422
0
     "%s: invalid data.",
423
0
     function );
424
425
0
    return( -1 );
426
0
  }
427
3.96k
  if( data_size < io_handle->source_information_entry_size )
428
0
  {
429
0
    libcerror_error_set(
430
0
     error,
431
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
432
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
433
0
     "%s: invalid data size value too small.",
434
0
     function );
435
436
0
    return( -1 );
437
0
  }
438
3.96k
  if( data_size > (size_t) SSIZE_MAX )
439
0
  {
440
0
    libcerror_error_set(
441
0
     error,
442
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
443
0
     LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM,
444
0
     "%s: invalid data size value exceeds maximum.",
445
0
     function );
446
447
0
    return( -1 );
448
0
  }
449
3.96k
  if( number_of_entries == NULL )
450
0
  {
451
0
    libcerror_error_set(
452
0
     error,
453
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
454
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
455
0
     "%s: invalid number of entries.",
456
0
     function );
457
458
0
    return( -1 );
459
0
  }
460
#if defined( HAVE_DEBUG_OUTPUT )
461
  if( libcnotify_verbose != 0 )
462
  {
463
    libcnotify_printf(
464
     "%s: source information data:\n",
465
     function );
466
    libcnotify_print_data(
467
     data,
468
     (size_t) io_handle->source_information_entry_size,
469
     0 );
470
  }
471
#endif
472
3.96k
  if( ( io_handle->source_information_entry_size == 60 )
473
3.96k
   || ( io_handle->source_information_entry_size == 100 ) )
474
1.97k
  {
475
1.97k
    mode = 32;
476
1.97k
  }
477
1.99k
  else if( ( io_handle->source_information_entry_size == 88 )
478
1.99k
        || ( io_handle->source_information_entry_size == 144 ) )
479
1.93k
  {
480
1.93k
    mode = 64;
481
1.93k
  }
482
52
  else
483
52
  {
484
52
    libcerror_error_set(
485
52
     error,
486
52
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
487
52
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
488
52
     "%s: unsupported source information entry size: %" PRIu32 ".",
489
52
     function,
490
52
     io_handle->source_information_entry_size );
491
492
52
    return( -1 );
493
52
  }
494
3.91k
  if( ( io_handle->source_information_entry_size == 60 )
495
3.91k
   || ( io_handle->source_information_entry_size == 88 ) )
496
633
  {
497
633
    if( mode == 32 )
498
232
    {
499
232
      byte_stream_copy_to_uint32_little_endian(
500
232
       ( (agdb_source_information_60_t *) data )->unknown3,
501
232
       *number_of_entries );
502
232
    }
503
401
    else if( mode == 64 )
504
401
    {
505
401
      byte_stream_copy_to_uint32_little_endian(
506
401
       ( (agdb_source_information_88_t *) data )->unknown3,
507
401
       *number_of_entries );
508
401
    }
509
633
  }
510
#if defined( HAVE_DEBUG_OUTPUT )
511
  if( libcnotify_verbose != 0 )
512
  {
513
    if( mode == 32 )
514
    {
515
      byte_stream_copy_to_uint32_little_endian(
516
       ( (agdb_source_information_60_t *) data )->unknown1,
517
       value_64bit );
518
    }
519
    else if( mode == 64 )
520
    {
521
      byte_stream_copy_to_uint64_little_endian(
522
       ( (agdb_source_information_88_t *) data )->unknown1,
523
       value_64bit );
524
    }
525
    libcnotify_printf(
526
     "%s: unknown1\t\t\t\t: 0x%08" PRIx64 "\n",
527
     function,
528
     value_64bit );
529
530
    if( mode == 32 )
531
    {
532
      byte_stream_copy_to_uint32_little_endian(
533
       ( (agdb_source_information_60_t *) data )->name_hash,
534
       value_64bit );
535
    }
536
    else if( mode == 64 )
537
    {
538
      byte_stream_copy_to_uint64_little_endian(
539
       ( (agdb_source_information_88_t *) data )->name_hash,
540
       value_64bit );
541
    }
542
    libcnotify_printf(
543
     "%s: name hash\t\t\t\t: 0x%08" PRIx64 "\n",
544
     function,
545
     value_64bit );
546
547
    libcnotify_printf(
548
     "%s: number of entries\t\t\t: %" PRIu32 "\n",
549
     function,
550
     *number_of_entries );
551
552
    if( mode == 32 )
553
    {
554
      byte_stream_copy_to_uint32_little_endian(
555
       ( (agdb_source_information_60_t *) data )->unknown4,
556
       value_32bit );
557
    }
558
    else if( mode == 64 )
559
    {
560
      byte_stream_copy_to_uint32_little_endian(
561
       ( (agdb_source_information_88_t *) data )->unknown4,
562
       value_32bit );
563
    }
564
    libcnotify_printf(
565
     "%s: unknown4\t\t\t\t: 0x%08" PRIx32 "\n",
566
     function,
567
     value_32bit );
568
  }
569
#endif
570
571
3.91k
  if( ( io_handle->source_information_entry_size == 60 )
572
3.91k
   || ( io_handle->source_information_entry_size == 88 ) )
573
633
  {
574
#if defined( HAVE_DEBUG_OUTPUT )
575
    if( libcnotify_verbose != 0 )
576
    {
577
      if( mode == 32 )
578
      {
579
        byte_stream_copy_to_uint32_little_endian(
580
         ( (agdb_source_information_60_t *) data )->unknown5,
581
         value_64bit );
582
      }
583
      else if( mode == 64 )
584
      {
585
        byte_stream_copy_to_uint64_little_endian(
586
         ( (agdb_source_information_88_t *) data )->unknown5,
587
         value_64bit );
588
      }
589
      libcnotify_printf(
590
       "%s: unknown5\t\t\t\t: 0x%08" PRIx64 "\n",
591
       function,
592
       value_64bit );
593
594
      libcnotify_printf(
595
       "%s: unknown6:\n",
596
       function );
597
      if( mode == 32 )
598
      {
599
        libcnotify_print_data(
600
         ( (agdb_source_information_60_t *) data )->unknown6,
601
         8,
602
         0 );
603
      }
604
      else if( mode == 64 )
605
      {
606
        libcnotify_print_data(
607
         ( (agdb_source_information_88_t *) data )->unknown6,
608
         16,
609
         0 );
610
      }
611
612
      if( mode == 32 )
613
      {
614
        byte_stream_copy_to_uint32_little_endian(
615
         ( (agdb_source_information_60_t *) data )->unknown7,
616
         value_32bit );
617
      }
618
      else if( mode == 64 )
619
      {
620
        byte_stream_copy_to_uint32_little_endian(
621
         ( (agdb_source_information_88_t *) data )->unknown7,
622
         value_32bit );
623
      }
624
      libcnotify_printf(
625
       "%s: unknown7\t\t\t\t: 0x%08" PRIx32 "\n",
626
       function,
627
       value_32bit );
628
629
      if( mode == 32 )
630
      {
631
        byte_stream_copy_to_uint32_little_endian(
632
         ( (agdb_source_information_60_t *) data )->unknown8,
633
         value_32bit );
634
      }
635
      else if( mode == 64 )
636
      {
637
        byte_stream_copy_to_uint32_little_endian(
638
         ( (agdb_source_information_88_t *) data )->unknown8,
639
         value_32bit );
640
      }
641
      libcnotify_printf(
642
       "%s: unknown8\t\t\t\t: 0x%08" PRIx32 "\n",
643
       function,
644
       value_32bit );
645
646
      if( mode == 32 )
647
      {
648
        byte_stream_copy_to_uint32_little_endian(
649
         ( (agdb_source_information_60_t *) data )->unknown9,
650
         value_64bit );
651
      }
652
      else if( mode == 64 )
653
      {
654
        byte_stream_copy_to_uint64_little_endian(
655
         ( (agdb_source_information_88_t *) data )->unknown9,
656
         value_64bit );
657
      }
658
      libcnotify_printf(
659
       "%s: unknown9\t\t\t\t: 0x%08" PRIx64 "\n",
660
       function,
661
       value_64bit );
662
663
      if( mode == 32 )
664
      {
665
        byte_stream_copy_to_uint32_little_endian(
666
         ( (agdb_source_information_60_t *) data )->unknown10,
667
         value_64bit );
668
      }
669
      else if( mode == 64 )
670
      {
671
        byte_stream_copy_to_uint64_little_endian(
672
         ( (agdb_source_information_88_t *) data )->unknown10,
673
         value_64bit );
674
      }
675
      libcnotify_printf(
676
       "%s: unknown10\t\t\t\t: 0x%08" PRIx64 "\n",
677
       function,
678
       value_64bit );
679
680
      libcnotify_printf(
681
       "%s: unknown11:\n",
682
       function );
683
      if( mode == 32 )
684
      {
685
        libcnotify_print_data(
686
         ( (agdb_source_information_60_t *) data )->unknown11,
687
         8,
688
         0 );
689
      }
690
      else if( mode == 64 )
691
      {
692
        libcnotify_print_data(
693
         ( (agdb_source_information_88_t *) data )->unknown11,
694
         16,
695
         0 );
696
      }
697
    }
698
#endif
699
633
  }
700
3.27k
  else if( ( io_handle->source_information_entry_size == 100 )
701
3.27k
        || ( io_handle->source_information_entry_size == 144 ) )
702
3.27k
  {
703
3.27k
    if( mode == 32 )
704
1.74k
    {
705
1.74k
      if( memory_copy(
706
1.74k
           internal_source_information->executable_filename,
707
1.74k
           ( (agdb_source_information_100_t *) data )->executable_filename,
708
1.74k
           (size_t) 16 ) == NULL )
709
0
      {
710
0
        libcerror_error_set(
711
0
         error,
712
0
         LIBCERROR_ERROR_DOMAIN_MEMORY,
713
0
         LIBCERROR_MEMORY_ERROR_COPY_FAILED,
714
0
         "%s: unable to copy executable filename.",
715
0
         function );
716
717
0
        return( -1 );
718
0
      }
719
1.74k
    }
720
1.53k
    else if( mode == 64 )
721
1.53k
    {
722
1.53k
      if( memory_copy(
723
1.53k
           internal_source_information->executable_filename,
724
1.53k
           ( (agdb_source_information_144_t *) data )->executable_filename,
725
1.53k
           (size_t) 16 ) == NULL )
726
0
      {
727
0
        libcerror_error_set(
728
0
         error,
729
0
         LIBCERROR_ERROR_DOMAIN_MEMORY,
730
0
         LIBCERROR_MEMORY_ERROR_COPY_FAILED,
731
0
         "%s: unable to copy executable filename.",
732
0
         function );
733
734
0
        return( -1 );
735
0
      }
736
1.53k
    }
737
3.27k
    for( string_index = 0;
738
19.2k
         string_index < 16;
739
16.0k
         string_index++ )
740
18.4k
    {
741
18.4k
      if( internal_source_information->executable_filename[ string_index ] == 0 )
742
2.47k
      {
743
2.47k
        break;
744
2.47k
      }
745
18.4k
    }
746
3.27k
    internal_source_information->executable_filename_size = string_index + 1;
747
748
#if defined( HAVE_DEBUG_OUTPUT )
749
    if( libcnotify_verbose != 0 )
750
    {
751
      libcnotify_printf(
752
       "%s: unknown5:\n",
753
       function );
754
      if( mode == 32 )
755
      {
756
        libcnotify_print_data(
757
         ( (agdb_source_information_100_t *) data )->unknown5,
758
         12,
759
         0 );
760
      }
761
      else if( mode == 64 )
762
      {
763
        libcnotify_print_data(
764
         ( (agdb_source_information_144_t *) data )->unknown5,
765
         24,
766
         0 );
767
      }
768
769
      if( mode == 32 )
770
      {
771
        byte_stream_copy_to_uint32_little_endian(
772
         ( (agdb_source_information_100_t *) data )->unknown6,
773
         value_32bit );
774
      }
775
      else if( mode == 64 )
776
      {
777
        byte_stream_copy_to_uint32_little_endian(
778
         ( (agdb_source_information_144_t *) data )->unknown6,
779
         value_32bit );
780
      }
781
      libcnotify_printf(
782
       "%s: unknown6\t\t\t\t: 0x%08" PRIx32 "\n",
783
       function,
784
       value_32bit );
785
786
      if( mode == 32 )
787
      {
788
        byte_stream_copy_to_uint32_little_endian(
789
         ( (agdb_source_information_100_t *) data )->unknown7,
790
         value_32bit );
791
      }
792
      else if( mode == 64 )
793
      {
794
        byte_stream_copy_to_uint32_little_endian(
795
         ( (agdb_source_information_144_t *) data )->unknown7,
796
         value_32bit );
797
      }
798
      libcnotify_printf(
799
       "%s: unknown7\t\t\t\t: 0x%08" PRIx32 "\n",
800
       function,
801
       value_32bit );
802
803
      if( mode == 32 )
804
      {
805
        byte_stream_copy_to_uint32_little_endian(
806
         ( (agdb_source_information_100_t *) data )->prefetch_hash,
807
         value_64bit );
808
      }
809
      else if( mode == 64 )
810
      {
811
        byte_stream_copy_to_uint64_little_endian(
812
         ( (agdb_source_information_144_t *) data )->prefetch_hash,
813
         value_64bit );
814
      }
815
      libcnotify_printf(
816
       "%s: prefetch hash\t\t\t\t: 0x%08" PRIx64 "\n",
817
       function,
818
       value_64bit );
819
820
      if( mode == 32 )
821
      {
822
        byte_stream_copy_to_uint32_little_endian(
823
         ( (agdb_source_information_100_t *) data )->unknown9,
824
         value_64bit );
825
      }
826
      else if( mode == 64 )
827
      {
828
        byte_stream_copy_to_uint64_little_endian(
829
         ( (agdb_source_information_144_t *) data )->unknown9,
830
         value_64bit );
831
      }
832
      libcnotify_printf(
833
       "%s: unknown9\t\t\t\t: 0x%08" PRIx64 "\n",
834
       function,
835
       value_64bit );
836
837
/* TODO allow to set codepage */
838
      if( libagdb_debug_print_string_value(
839
           function,
840
           "executable filename\t\t\t",
841
           internal_source_information->executable_filename,
842
           internal_source_information->executable_filename_size,
843
           LIBUNA_CODEPAGE_ASCII,
844
           error ) != 1 )
845
      {
846
        libcerror_error_set(
847
         error,
848
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
849
         LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
850
         "%s: unable to print string value.",
851
         function );
852
853
        return( -1 );
854
      }
855
      libcnotify_printf(
856
       "\n" );
857
858
      if( mode == 32 )
859
      {
860
        byte_stream_copy_to_uint32_little_endian(
861
         ( (agdb_source_information_100_t *) data )->unknown11,
862
         value_64bit );
863
      }
864
      else if( mode == 64 )
865
      {
866
        byte_stream_copy_to_uint64_little_endian(
867
         ( (agdb_source_information_144_t *) data )->unknown11,
868
         value_64bit );
869
      }
870
      libcnotify_printf(
871
       "%s: unknown11\t\t\t\t: 0x%08" PRIx64 "\n",
872
       function,
873
       value_64bit );
874
875
      if( mode == 32 )
876
      {
877
        byte_stream_copy_to_uint32_little_endian(
878
         ( (agdb_source_information_100_t *) data )->unknown12,
879
         value_64bit );
880
      }
881
      else if( mode == 64 )
882
      {
883
        byte_stream_copy_to_uint64_little_endian(
884
         ( (agdb_source_information_144_t *) data )->unknown12,
885
         value_64bit );
886
      }
887
      libcnotify_printf(
888
       "%s: unknown12\t\t\t\t: 0x%08" PRIx64 "\n",
889
       function,
890
       value_64bit );
891
892
      if( mode == 32 )
893
      {
894
        byte_stream_copy_to_uint32_little_endian(
895
         ( (agdb_source_information_100_t *) data )->unknown13,
896
         value_32bit );
897
      }
898
      else if( mode == 64 )
899
      {
900
        byte_stream_copy_to_uint32_little_endian(
901
         ( (agdb_source_information_144_t *) data )->unknown13,
902
         value_32bit );
903
      }
904
      libcnotify_printf(
905
       "%s: unknown13\t\t\t\t: 0x%08" PRIx32 "\n",
906
       function,
907
       value_32bit );
908
909
      if( mode == 32 )
910
      {
911
        byte_stream_copy_to_uint32_little_endian(
912
         ( (agdb_source_information_100_t *) data )->unknown14,
913
         value_32bit );
914
      }
915
      else if( mode == 64 )
916
      {
917
        byte_stream_copy_to_uint32_little_endian(
918
         ( (agdb_source_information_144_t *) data )->unknown14,
919
         value_32bit );
920
      }
921
      libcnotify_printf(
922
       "%s: unknown14\t\t\t\t: 0x%08" PRIx32 "\n",
923
       function,
924
       value_32bit );
925
926
      if( mode == 32 )
927
      {
928
        byte_stream_copy_to_uint32_little_endian(
929
         ( (agdb_source_information_100_t *) data )->unknown15,
930
         value_32bit );
931
      }
932
      else if( mode == 64 )
933
      {
934
        byte_stream_copy_to_uint32_little_endian(
935
         ( (agdb_source_information_144_t *) data )->unknown15,
936
         value_32bit );
937
      }
938
      libcnotify_printf(
939
       "%s: unknown15\t\t\t\t: 0x%08" PRIx32 "\n",
940
       function,
941
       value_32bit );
942
943
      if( mode == 32 )
944
      {
945
        byte_stream_copy_to_uint32_little_endian(
946
         ( (agdb_source_information_100_t *) data )->unknown16,
947
         value_32bit );
948
      }
949
      else if( mode == 64 )
950
      {
951
        byte_stream_copy_to_uint32_little_endian(
952
         ( (agdb_source_information_144_t *) data )->unknown16,
953
         value_32bit );
954
      }
955
      libcnotify_printf(
956
       "%s: unknown16\t\t\t\t: 0x%08" PRIx32 "\n",
957
       function,
958
       value_32bit );
959
960
      if( mode == 32 )
961
      {
962
        byte_stream_copy_to_uint32_little_endian(
963
         ( (agdb_source_information_100_t *) data )->unknown17,
964
         value_32bit );
965
      }
966
      else if( mode == 64 )
967
      {
968
        byte_stream_copy_to_uint32_little_endian(
969
         ( (agdb_source_information_144_t *) data )->unknown17,
970
         value_32bit );
971
      }
972
      libcnotify_printf(
973
       "%s: unknown17\t\t\t\t: 0x%08" PRIx32 "\n",
974
       function,
975
       value_32bit );
976
977
      if( mode == 32 )
978
      {
979
        byte_stream_copy_to_uint32_little_endian(
980
         ( (agdb_source_information_100_t *) data )->unknown18,
981
         value_32bit );
982
      }
983
      else if( mode == 64 )
984
      {
985
        byte_stream_copy_to_uint32_little_endian(
986
         ( (agdb_source_information_144_t *) data )->unknown18,
987
         value_32bit );
988
      }
989
      libcnotify_printf(
990
       "%s: unknown18\t\t\t\t: 0x%08" PRIx32 "\n",
991
       function,
992
       value_32bit );
993
994
      if( mode == 32 )
995
      {
996
        byte_stream_copy_to_uint32_little_endian(
997
         ( (agdb_source_information_100_t *) data )->unknown19,
998
         value_64bit );
999
      }
1000
      else if( mode == 64 )
1001
      {
1002
        byte_stream_copy_to_uint64_little_endian(
1003
         ( (agdb_source_information_144_t *) data )->unknown19,
1004
         value_64bit );
1005
      }
1006
      libcnotify_printf(
1007
       "%s: unknown19\t\t\t\t: 0x%08" PRIx64 "\n",
1008
       function,
1009
       value_64bit );
1010
1011
      if( mode == 32 )
1012
      {
1013
        byte_stream_copy_to_uint32_little_endian(
1014
         ( (agdb_source_information_100_t *) data )->unknown20,
1015
         value_64bit );
1016
      }
1017
      else if( mode == 64 )
1018
      {
1019
        byte_stream_copy_to_uint64_little_endian(
1020
         ( (agdb_source_information_144_t *) data )->unknown20,
1021
         value_64bit );
1022
      }
1023
      libcnotify_printf(
1024
       "%s: unknown20\t\t\t\t: 0x%08" PRIx64 "\n",
1025
       function,
1026
       value_64bit );
1027
1028
      libcnotify_printf(
1029
       "\n" );
1030
    }
1031
#endif
1032
3.27k
  }
1033
3.91k
  return( 1 );
1034
3.91k
}
1035
1036
/* Retrieves the size of the UTF-8 encoded executable filename
1037
 * The returned size includes the end of string character
1038
 * Returns 1 if successful or -1 on error
1039
 */
1040
int libagdb_source_information_get_utf8_executable_filename_size(
1041
     libagdb_source_information_t *source_information,
1042
     size_t *utf8_string_size,
1043
     libcerror_error_t **error )
1044
0
{
1045
0
  libagdb_internal_source_information_t *internal_source_information = NULL;
1046
0
  static char *function                                              = "libagdb_source_information_get_utf8_executable_filename_size";
1047
1048
0
  if( source_information == NULL )
1049
0
  {
1050
0
    libcerror_error_set(
1051
0
     error,
1052
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1053
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1054
0
     "%s: invalid source information.",
1055
0
     function );
1056
1057
0
    return( -1 );
1058
0
  }
1059
0
  internal_source_information = (libagdb_internal_source_information_t *) source_information;
1060
1061
/* TODO allow to set codepage */
1062
0
  if( libuna_utf8_string_size_from_byte_stream(
1063
0
       internal_source_information->executable_filename,
1064
0
       internal_source_information->executable_filename_size,
1065
0
       LIBUNA_CODEPAGE_ASCII,
1066
0
       utf8_string_size,
1067
0
       error ) != 1 )
1068
0
  {
1069
0
    libcerror_error_set(
1070
0
     error,
1071
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1072
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1073
0
     "%s: unable to retrieve executable filename UTF-8 string size.",
1074
0
     function );
1075
1076
0
    return( -1 );
1077
0
  }
1078
0
  return( 1 );
1079
0
}
1080
1081
/* Retrieves the UTF-8 encoded executable filename
1082
 * The size should include the end of string character
1083
 * Returns 1 if successful or -1 on error
1084
 */
1085
int libagdb_source_information_get_utf8_executable_filename(
1086
     libagdb_source_information_t *source_information,
1087
     uint8_t *utf8_string,
1088
     size_t utf8_string_size,
1089
     libcerror_error_t **error )
1090
0
{
1091
0
  libagdb_internal_source_information_t *internal_source_information = NULL;
1092
0
  static char *function                                              = "libagdb_source_information_get_utf8_executable_filename";
1093
1094
0
  if( source_information == NULL )
1095
0
  {
1096
0
    libcerror_error_set(
1097
0
     error,
1098
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1099
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1100
0
     "%s: invalid source information.",
1101
0
     function );
1102
1103
0
    return( -1 );
1104
0
  }
1105
0
  internal_source_information = (libagdb_internal_source_information_t *) source_information;
1106
1107
/* TODO allow to set codepage */
1108
0
  if( libuna_utf8_string_copy_from_byte_stream(
1109
0
       utf8_string,
1110
0
       utf8_string_size,
1111
0
       internal_source_information->executable_filename,
1112
0
       internal_source_information->executable_filename_size,
1113
0
       LIBUNA_CODEPAGE_ASCII,
1114
0
       error ) != 1 )
1115
0
  {
1116
0
    libcerror_error_set(
1117
0
     error,
1118
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1119
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1120
0
     "%s: unable to copy executable filename to UTF-8 string.",
1121
0
     function );
1122
1123
0
    return( -1 );
1124
0
  }
1125
0
  return( 1 );
1126
0
}
1127
1128
/* Retrieves the size of the UTF-16 encoded executable filename
1129
 * The returned size includes the end of string character
1130
 * Returns 1 if successful or -1 on error
1131
 */
1132
int libagdb_source_information_get_utf16_executable_filename_size(
1133
     libagdb_source_information_t *source_information,
1134
     size_t *utf16_string_size,
1135
     libcerror_error_t **error )
1136
0
{
1137
0
  libagdb_internal_source_information_t *internal_source_information = NULL;
1138
0
  static char *function                                              = "libagdb_source_information_get_utf16_executable_filename_size";
1139
1140
0
  if( source_information == NULL )
1141
0
  {
1142
0
    libcerror_error_set(
1143
0
     error,
1144
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1145
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1146
0
     "%s: invalid source information.",
1147
0
     function );
1148
1149
0
    return( -1 );
1150
0
  }
1151
0
  internal_source_information = (libagdb_internal_source_information_t *) source_information;
1152
1153
/* TODO allow to set codepage */
1154
0
  if( libuna_utf16_string_size_from_byte_stream(
1155
0
       internal_source_information->executable_filename,
1156
0
       internal_source_information->executable_filename_size,
1157
0
       LIBUNA_CODEPAGE_ASCII,
1158
0
       utf16_string_size,
1159
0
       error ) != 1 )
1160
0
  {
1161
0
    libcerror_error_set(
1162
0
     error,
1163
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1164
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1165
0
     "%s: unable to retrieve executable filename UTF-16 string size.",
1166
0
     function );
1167
1168
0
    return( -1 );
1169
0
  }
1170
0
  return( 1 );
1171
0
}
1172
1173
/* Retrieves the UTF-16 encoded executable filename
1174
 * The size should include the end of string character
1175
 * Returns 1 if successful or -1 on error
1176
 */
1177
int libagdb_source_information_get_utf16_executable_filename(
1178
     libagdb_source_information_t *source_information,
1179
     uint16_t *utf16_string,
1180
     size_t utf16_string_size,
1181
     libcerror_error_t **error )
1182
0
{
1183
0
  libagdb_internal_source_information_t *internal_source_information = NULL;
1184
0
  static char *function                                              = "libagdb_source_information_get_utf16_executable_filename";
1185
1186
0
  if( source_information == NULL )
1187
0
  {
1188
0
    libcerror_error_set(
1189
0
     error,
1190
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1191
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1192
0
     "%s: invalid source information.",
1193
0
     function );
1194
1195
0
    return( -1 );
1196
0
  }
1197
0
  internal_source_information = (libagdb_internal_source_information_t *) source_information;
1198
1199
/* TODO allow to set codepage */
1200
0
  if( libuna_utf16_string_copy_from_byte_stream(
1201
0
       utf16_string,
1202
0
       utf16_string_size,
1203
0
       internal_source_information->executable_filename,
1204
0
       internal_source_information->executable_filename_size,
1205
0
       LIBUNA_CODEPAGE_ASCII,
1206
0
       error ) != 1 )
1207
0
  {
1208
0
    libcerror_error_set(
1209
0
     error,
1210
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1211
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1212
0
     "%s: unable to copy executable filename to UTF-16 string.",
1213
0
     function );
1214
1215
0
    return( -1 );
1216
0
  }
1217
0
  return( 1 );
1218
0
}
1219