1
0
forked from 0ad/0ad

fix: wasn't checking function pointers => crash on older windows versions

This was SVN commit r7724.
This commit is contained in:
janwas 2010-07-08 21:07:46 +00:00
parent 778af99416
commit fad4383a23

View File

@ -9,14 +9,17 @@ static const DWORD provider = FOURCC_BE('A','C','P','I');
std::vector<u32> wacpi_TableIDs()
{
std::vector<u32> tableIDs;
WUTIL_FUNC(pEnumSystemFirmwareTables, UINT, (DWORD, PVOID, DWORD));
WUTIL_IMPORT_KERNEL32(EnumSystemFirmwareTables, pEnumSystemFirmwareTables);
if(!pEnumSystemFirmwareTables)
return tableIDs; // empty list
const UINT bufSize = pEnumSystemFirmwareTables(provider, 0, 0);
debug_assert(bufSize != 0);
debug_assert(bufSize % sizeof(DWORD) == 0);
std::vector<u32> tableIDs(DivideRoundUp((size_t)bufSize, sizeof(DWORD)));
tableIDs.resize(DivideRoundUp((size_t)bufSize, sizeof(DWORD)));
const UINT ret = pEnumSystemFirmwareTables(provider, &tableIDs[0], bufSize);
debug_assert(ret == bufSize);
@ -27,13 +30,16 @@ std::vector<u32> wacpi_TableIDs()
std::vector<u8> wacpi_GetTable(u32 id)
{
std::vector<u8> table;
WUTIL_FUNC(pGetSystemFirmwareTable, UINT, (DWORD, DWORD, PVOID, DWORD));
WUTIL_IMPORT_KERNEL32(GetSystemFirmwareTable, pGetSystemFirmwareTable);
if(!pGetSystemFirmwareTable)
return table; // empty table
const UINT bufSize = pGetSystemFirmwareTable(provider, id, 0, 0);
debug_assert(bufSize != 0);
std::vector<u8> table(bufSize);
table.resize(bufSize);
const UINT ret = pGetSystemFirmwareTable(provider, id, &table[0], bufSize);
debug_assert(ret == bufSize);