kernelbase: Use nameless unions/structs for loader data.

This commit is contained in:
Alexandre Julliard 2023-06-06 17:54:17 +02:00
parent 59b175d96c
commit 9276d53ee8
2 changed files with 22 additions and 26 deletions

View file

@ -22,8 +22,6 @@
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@ -683,7 +681,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceLanguagesExA( HMODULE module, LPCSTR t
{
for (i = 0; i < resdir->NumberOfNamedEntries + resdir->NumberOfIdEntries; i++)
{
ret = func( module, type, name, et[i].u.Id, param );
ret = func( module, type, name, et[i].Id, param );
if (!ret) break;
}
}
@ -743,7 +741,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceLanguagesExW( HMODULE module, LPCWSTR
{
for (i = 0; i < resdir->NumberOfNamedEntries + resdir->NumberOfIdEntries; i++)
{
ret = func( module, type, name, et[i].u.Id, param );
ret = func( module, type, name, et[i].Id, param );
if (!ret) break;
}
}
@ -801,9 +799,9 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExA( HMODULE module, LPCSTR type,
{
for (i = 0; i < resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries; i++)
{
if (et[i].u.s.NameIsString)
if (et[i].NameIsString)
{
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)basedir + et[i].u.s.NameOffset);
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)basedir + et[i].NameOffset);
newlen = WideCharToMultiByte(CP_ACP, 0, str->NameString, str->Length, NULL, 0, NULL, NULL);
if (newlen + 1 > len)
{
@ -821,7 +819,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExA( HMODULE module, LPCSTR type,
}
else
{
ret = func( module, type, UIntToPtr(et[i].u.Id), param );
ret = func( module, type, UIntToPtr(et[i].Id), param );
}
if (!ret) break;
}
@ -880,9 +878,9 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExW( HMODULE module, LPCWSTR type
{
for (i = 0; i < resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries; i++)
{
if (et[i].u.s.NameIsString)
if (et[i].NameIsString)
{
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)basedir + et[i].u.s.NameOffset);
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)basedir + et[i].NameOffset);
if (str->Length + 1 > len)
{
len = str->Length + 1;
@ -899,7 +897,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExW( HMODULE module, LPCWSTR type
}
else
{
ret = func( module, type, UIntToPtr(et[i].u.Id), param );
ret = func( module, type, UIntToPtr(et[i].Id), param );
}
if (!ret) break;
}
@ -957,9 +955,9 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExA( HMODULE module, ENUMRESTYPEP
et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
for (i = 0; i < resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries; i++)
{
if (et[i].u.s.NameIsString)
if (et[i].NameIsString)
{
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)resdir + et[i].u.s.NameOffset);
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)resdir + et[i].NameOffset);
newlen = WideCharToMultiByte( CP_ACP, 0, str->NameString, str->Length, NULL, 0, NULL, NULL);
if (newlen + 1 > len)
{
@ -973,7 +971,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExA( HMODULE module, ENUMRESTYPEP
}
else
{
ret = func( module, UIntToPtr(et[i].u.Id), param );
ret = func( module, UIntToPtr(et[i].Id), param );
}
if (!ret) break;
}
@ -1007,9 +1005,9 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExW( HMODULE module, ENUMRESTYPEP
et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
for (i = 0; i < resdir->NumberOfNamedEntries + resdir->NumberOfIdEntries; i++)
{
if (et[i].u.s.NameIsString)
if (et[i].NameIsString)
{
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)resdir + et[i].u.s.NameOffset);
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)resdir + et[i].NameOffset);
if (str->Length + 1 > len)
{
len = str->Length + 1;
@ -1022,7 +1020,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExW( HMODULE module, ENUMRESTYPEP
}
else
{
ret = func( module, UIntToPtr(et[i].u.Id), param );
ret = func( module, UIntToPtr(et[i].Id), param );
}
if (!ret) break;
}

View file

@ -30,8 +30,6 @@
#include "ntstatus.h"
#define WIN32_NO_STATUS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winver.h"
@ -286,13 +284,13 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DI
while (min <= max)
{
pos = (min + max) / 2;
if (entry[pos].u.Id == id)
if (entry[pos].Id == id)
{
DWORD offset = entry[pos].u2.s2.OffsetToDirectory;
DWORD offset = entry[pos].OffsetToDirectory;
if (offset > root_size - sizeof(*dir)) return NULL;
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + offset);
}
if (entry[pos].u.Id > id) max = pos - 1;
if (entry[pos].Id > id) max = pos - 1;
else min = pos + 1;
}
return NULL;
@ -311,7 +309,7 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry->u2.s2.OffsetToDirectory);
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry->OffsetToDirectory);
}
@ -1698,19 +1696,19 @@ LONG WINAPI PackageIdFromFullName(const WCHAR *full_name, UINT32 flags, UINT32 *
}
buffer += sizeof(*id);
id->version.u.s.Major = wcstol(version_str, NULL, 10);
id->version.Major = wcstol(version_str, NULL, 10);
if (!(s = wcschr(version_str, L'.')))
return ERROR_INVALID_PARAMETER;
++s;
id->version.u.s.Minor = wcstol(s, NULL, 10);
id->version.Minor = wcstol(s, NULL, 10);
if (!(s = wcschr(s, L'.')))
return ERROR_INVALID_PARAMETER;
++s;
id->version.u.s.Build = wcstol(s, NULL, 10);
id->version.Build = wcstol(s, NULL, 10);
if (!(s = wcschr(s, L'.')))
return ERROR_INVALID_PARAMETER;
++s;
id->version.u.s.Revision = wcstol(s, NULL, 10);
id->version.Revision = wcstol(s, NULL, 10);
id->name = (WCHAR *)buffer;
len = version_str - name - 1;