fusion: Handle DWORD-sized string indices when loading the assembly name.

This commit is contained in:
James Hawkins 2008-07-16 10:57:44 -05:00 committed by Alexandre Julliard
parent 0edab123aa
commit 2a51df3b7a
1 changed files with 12 additions and 5 deletions

View File

@ -735,7 +735,7 @@ HRESULT assembly_release(ASSEMBLY *assembly)
return S_OK; return S_OK;
} }
static LPSTR assembly_dup_str(ASSEMBLY *assembly, WORD index) static LPSTR assembly_dup_str(ASSEMBLY *assembly, DWORD index)
{ {
LPSTR str = (LPSTR)&assembly->strings[index]; LPSTR str = (LPSTR)&assembly->strings[index];
LPSTR cpy = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1); LPSTR cpy = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1);
@ -746,18 +746,25 @@ static LPSTR assembly_dup_str(ASSEMBLY *assembly, WORD index)
HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name) HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name)
{ {
ASSEMBLYTABLE *asmtbl; BYTE *ptr;
ULONG offset; ULONG offset;
DWORD stridx;
offset = assembly->tables[TableFromToken(mdtAssembly)].offset; offset = assembly->tables[TableFromToken(mdtAssembly)].offset;
if (offset == -1) if (offset == -1)
return E_FAIL; return E_FAIL;
asmtbl = (ASSEMBLYTABLE *)assembly_data_offset(assembly, offset); ptr = assembly_data_offset(assembly, offset);
if (!asmtbl) if (!ptr)
return E_FAIL; return E_FAIL;
*name = assembly_dup_str(assembly, asmtbl->Name); ptr += FIELD_OFFSET(ASSEMBLYTABLE, PublicKey) + assembly->blobsz;
if (assembly->stringsz == sizeof(DWORD))
stridx = *((DWORD *)ptr);
else
stridx = *((WORD *)ptr);
*name = assembly_dup_str(assembly, stridx);
if (!*name) if (!*name)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;