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