Commit 328383d4 authored by Alexandre Julliard's avatar Alexandre Julliard

fusion: Simplify the parsing of clr tables.

parent 5e512993
...@@ -482,8 +482,9 @@ static inline ULONG get_table_size(const ASSEMBLY *assembly, DWORD index) ...@@ -482,8 +482,9 @@ static inline ULONG get_table_size(const ASSEMBLY *assembly, DWORD index)
static HRESULT parse_clr_tables(ASSEMBLY *assembly, ULONG offset) static HRESULT parse_clr_tables(ASSEMBLY *assembly, ULONG offset)
{ {
DWORD i, previ, offidx; DWORD i, count;
ULONG currofs; ULONG currofs;
ULONGLONG mask;
currofs = offset; currofs = offset;
assembly->tableshdr = assembly_data_offset(assembly, currofs); assembly->tableshdr = assembly_data_offset(assembly, currofs);
...@@ -502,44 +503,22 @@ static HRESULT parse_clr_tables(ASSEMBLY *assembly, ULONG offset) ...@@ -502,44 +503,22 @@ static HRESULT parse_clr_tables(ASSEMBLY *assembly, ULONG offset)
if (!assembly->numrows) if (!assembly->numrows)
return E_FAIL; return E_FAIL;
assembly->numtables = 0;
for (i = 0; i < MAX_CLR_TABLES; i++)
{
if ((i < 32 && (assembly->tableshdr->MaskValid.u.LowPart >> i) & 1) ||
(i >= 32 && (assembly->tableshdr->MaskValid.u.HighPart >> i) & 1))
{
assembly->numtables++;
}
}
currofs += assembly->numtables * sizeof(DWORD);
memset(assembly->tables, -1, MAX_CLR_TABLES * sizeof(CLRTABLE)); memset(assembly->tables, -1, MAX_CLR_TABLES * sizeof(CLRTABLE));
if (assembly->tableshdr->MaskValid.u.LowPart & 1) for (i = count = 0, mask = 1; i < MAX_CLR_TABLES; i++, mask <<= 1)
assembly->tables[0].offset = currofs;
offidx = 0;
for (i = 0; i < MAX_CLR_TABLES; i++)
{ {
if ((i < 32 && (assembly->tableshdr->MaskValid.u.LowPart >> i) & 1) || if (assembly->tableshdr->MaskValid.QuadPart & mask)
(i >= 32 && (assembly->tableshdr->MaskValid.u.HighPart >> i) & 1)) assembly->tables[i].rows = assembly->numrows[count++];
{
assembly->tables[i].rows = assembly->numrows[offidx];
offidx++;
}
} }
assembly->numtables = count;
currofs += assembly->numtables * sizeof(DWORD);
previ = 0; for (i = 0, mask = 1; i < MAX_CLR_TABLES; i++, mask <<= 1)
offidx = 1;
for (i = 1; i < MAX_CLR_TABLES; i++)
{ {
if ((i < 32 && (assembly->tableshdr->MaskValid.u.LowPart >> i) & 1) || if (assembly->tableshdr->MaskValid.QuadPart & mask)
(i >= 32 && (assembly->tableshdr->MaskValid.u.HighPart >> i) & 1))
{ {
currofs += get_table_size(assembly, previ) * assembly->numrows[offidx - 1];
assembly->tables[i].offset = currofs; assembly->tables[i].offset = currofs;
offidx++; currofs += get_table_size(assembly, i) * assembly->tables[i].rows;
previ = i;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment