Lines 44-51
struct resource
Link Here
|
44 |
{ |
44 |
{ |
45 |
struct string_id type; |
45 |
struct string_id type; |
46 |
struct string_id name; |
46 |
struct string_id name; |
47 |
const char *input_name; |
|
|
48 |
unsigned int input_offset; |
49 |
const void *data; |
47 |
const void *data; |
50 |
unsigned int data_size; |
48 |
unsigned int data_size; |
51 |
unsigned int data_offset; |
49 |
unsigned int data_offset; |
Lines 158-163
static void put_string( const struct string_id *str )
Link Here
|
158 |
} |
156 |
} |
159 |
} |
157 |
} |
160 |
|
158 |
|
|
|
159 |
static void dump_res_data( const struct resource *res ) |
160 |
{ |
161 |
unsigned int i = 0; |
162 |
unsigned int size = (res->data_size + 3) & ~3; |
163 |
|
164 |
if (!size) return; |
165 |
|
166 |
input_buffer = res->data; |
167 |
input_buffer_pos = 0; |
168 |
input_buffer_size = size; |
169 |
|
170 |
output( "\t.long " ); |
171 |
while (size > 4) |
172 |
{ |
173 |
if ((i++ % 16) == 15) output( "0x%08x\n\t.long ", get_dword() ); |
174 |
else output( "0x%08x,", get_dword() ); |
175 |
size -= 4; |
176 |
} |
177 |
output( "0x%08x\n", get_dword() ); |
178 |
assert( input_buffer_pos == input_buffer_size ); |
179 |
} |
180 |
|
161 |
/* check the file header */ |
181 |
/* check the file header */ |
162 |
/* all values must be zero except header size */ |
182 |
/* all values must be zero except header size */ |
163 |
static int check_header(void) |
183 |
static int check_header(void) |
Lines 179-185
static int check_header(void)
Link Here
|
179 |
} |
199 |
} |
180 |
|
200 |
|
181 |
/* load the next resource from the current file */ |
201 |
/* load the next resource from the current file */ |
182 |
static void load_next_resource( DLLSPEC *spec, const char *name ) |
202 |
static void load_next_resource( DLLSPEC *spec ) |
183 |
{ |
203 |
{ |
184 |
unsigned int hdr_size; |
204 |
unsigned int hdr_size; |
185 |
struct resource *res = add_resource( spec ); |
205 |
struct resource *res = add_resource( spec ); |
Lines 189-197
static void load_next_resource( DLLSPEC *spec, const char *name )
Link Here
|
189 |
if (hdr_size & 3) fatal_error( "%s header size not aligned\n", input_buffer_filename ); |
209 |
if (hdr_size & 3) fatal_error( "%s header size not aligned\n", input_buffer_filename ); |
190 |
if (hdr_size < 32) fatal_error( "%s invalid header size %u\n", input_buffer_filename, hdr_size ); |
210 |
if (hdr_size < 32) fatal_error( "%s invalid header size %u\n", input_buffer_filename, hdr_size ); |
191 |
|
211 |
|
192 |
res->input_name = xstrdup( name ); |
|
|
193 |
res->input_offset = input_buffer_pos - 2*sizeof(unsigned int) + hdr_size; |
194 |
|
195 |
res->data = input_buffer + input_buffer_pos - 2*sizeof(unsigned int) + hdr_size; |
212 |
res->data = input_buffer + input_buffer_pos - 2*sizeof(unsigned int) + hdr_size; |
196 |
if ((const unsigned char *)res->data < input_buffer || |
213 |
if ((const unsigned char *)res->data < input_buffer || |
197 |
(const unsigned char *)res->data >= input_buffer + input_buffer_size) |
214 |
(const unsigned char *)res->data >= input_buffer + input_buffer_size) |
Lines 220-226
int load_res32_file( const char *name, DLLSPEC *spec )
Link Here
|
220 |
|
237 |
|
221 |
if ((ret = check_header())) |
238 |
if ((ret = check_header())) |
222 |
{ |
239 |
{ |
223 |
while (input_buffer_pos < input_buffer_size) load_next_resource( spec, name ); |
240 |
while (input_buffer_pos < input_buffer_size) load_next_resource( spec ); |
224 |
} |
241 |
} |
225 |
return ret; |
242 |
return ret; |
226 |
} |
243 |
} |
Lines 473-479
void output_resources( DLLSPEC *spec )
Link Here
|
473 |
{ |
490 |
{ |
474 |
output( "\n\t.align %d\n", get_alignment(4) ); |
491 |
output( "\n\t.align %d\n", get_alignment(4) ); |
475 |
output( ".L__wine_spec_res_%d:\n", i ); |
492 |
output( ".L__wine_spec_res_%d:\n", i ); |
476 |
output( "\t.incbin \"%s\",%d,%d\n", res->input_name, res->input_offset, res->data_size ); |
493 |
dump_res_data( res ); |
477 |
} |
494 |
} |
478 |
|
495 |
|
479 |
if (!is_pe()) |
496 |
if (!is_pe()) |