1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** GUIX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** Binres Loader Management (Binres Loader) */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
#define GX_SOURCE_CODE |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/* Include necessary system files. */ |
26 |
|
|
|
27 |
|
|
#include "gx_api.h" |
28 |
|
|
#include "gx_binres_loader.h" |
29 |
|
|
|
30 |
|
|
/**************************************************************************/ |
31 |
|
|
/* */ |
32 |
|
|
/* FUNCTION RELEASE */ |
33 |
|
|
/* */ |
34 |
|
|
/* gx_binres_language_info_load PORTABLE C */ |
35 |
|
|
/* 6.1 */ |
36 |
|
|
/* AUTHOR */ |
37 |
|
|
/* */ |
38 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
39 |
|
|
/* */ |
40 |
|
|
/* DESCRIPTION */ |
41 |
|
|
/* */ |
42 |
|
|
/* This function retrives language header information. */ |
43 |
|
|
/* */ |
44 |
|
|
/* INPUT */ |
45 |
|
|
/* */ |
46 |
|
|
/* root_address Root address of binary */ |
47 |
|
|
/* resource data */ |
48 |
|
|
/* header Returned Language header */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* Status Completion status */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* None */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLED BY */ |
59 |
|
|
/* */ |
60 |
|
|
/* Application Code */ |
61 |
|
|
/* GUIX Internal Code */ |
62 |
|
|
/* */ |
63 |
|
|
/**************************************************************************/ |
64 |
|
|
#ifdef GX_BINARY_RESOURCE_SUPPORT |
65 |
|
4 |
UINT _gx_binres_language_info_load(GX_UBYTE *root_address, GX_LANGUAGE_HEADER *put_info) |
66 |
|
|
{ |
67 |
|
4 |
UINT status = GX_SUCCESS; |
68 |
|
|
GX_BINRES_DATA_INFO info; |
69 |
|
|
GX_RESOURCE_HEADER header; |
70 |
|
|
GX_STRING_HEADER string_header; |
71 |
|
|
UINT lang_index; |
72 |
|
|
|
73 |
|
4 |
memset(&info, 0, sizeof(GX_BINRES_DATA_INFO)); |
74 |
|
|
|
75 |
|
4 |
info.gx_binres_root_address = root_address; |
76 |
|
|
|
77 |
|
|
/* Read Resource header. */ |
78 |
|
4 |
info.gx_binres_read_offset = 0; |
79 |
|
4 |
_gx_binres_resource_header_load(&info, &header); |
80 |
|
|
|
81 |
|
|
/* Skip theme info. */ |
82 |
|
4 |
info.gx_binres_read_offset += header.gx_resource_header_theme_data_size; |
83 |
|
|
|
84 |
✓✓ |
4 |
if (header.gx_resource_header_magic_number != GX_MAGIC_NUMBER) |
85 |
|
|
{ |
86 |
|
1 |
return GX_INVALID_FORMAT; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
/* Read string header. */ |
90 |
|
3 |
_gx_binres_string_header_load(&info, &string_header); |
91 |
|
|
|
92 |
✓✓ |
3 |
if (string_header.gx_string_header_magic_number != GX_MAGIC_NUMBER) |
93 |
|
|
{ |
94 |
|
1 |
status = GX_INVALID_FORMAT; |
95 |
|
|
} |
96 |
|
|
else |
97 |
|
|
{ |
98 |
✓✓ |
3 |
for (lang_index = 0; lang_index < string_header.gx_string_header_language_count; lang_index++) |
99 |
|
|
{ |
100 |
|
|
/* Read language header. */ |
101 |
|
2 |
_gx_binres_language_header_load(&info, put_info); |
102 |
|
|
|
103 |
✓✓ |
2 |
if (put_info -> gx_language_header_magic_number != GX_MAGIC_NUMBER) |
104 |
|
|
{ |
105 |
|
1 |
status = GX_INVALID_FORMAT; |
106 |
|
1 |
break; |
107 |
|
|
} |
108 |
|
1 |
info.gx_binres_read_offset += put_info -> gx_language_header_data_size; |
109 |
|
1 |
put_info++; |
110 |
|
|
} |
111 |
|
|
} |
112 |
|
|
|
113 |
|
3 |
return status; |
114 |
|
|
} |
115 |
|
|
#endif |
116 |
|
|
|