Skip to content

Commit

Permalink
YogaWMI: fix BMF parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
zhen-zen committed Feb 13, 2021
1 parent bc0c9ab commit bc3d9ec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
YogaSMC Changelog
============================

#### v1.4.3
- YogaWMI: fix BMF parsing

#### v1.4.2
- YogaWMI: complete event handling
- NC: use timer for distinguish input method switch, thx @vnln
Expand Down
4 changes: 2 additions & 2 deletions YogaSMC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.4.2;
CURRENT_PROJECT_VERSION = 1.4.3;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -1101,7 +1101,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.4.2;
CURRENT_PROJECT_VERSION = 1.4.3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
19 changes: 10 additions & 9 deletions YogaSMC/WMI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool WMI::initialize()
name = mDevice->getName();
mData = OSDictionary::withCapacity(1);
mEvent = OSDictionary::withCapacity(1);
mBMFCandidate = OSDictionary::withCapacity(1);
mBMFCandidate = OSArray::withCapacity(1);

if (!extractData()) {
AlwaysLog("WMI method %s not found", kWMIMethod);
Expand Down Expand Up @@ -176,7 +176,7 @@ void WMI::parseWDGEntry(struct WMI_DATA* block)

DebugLog("Validating buffer %s", bmfName);
if (mDevice->validateObject(bmfName) == kIOReturnSuccess)
mBMFCandidate->setObject(guid_string, dict);
mBMFCandidate->setObject(dict);
}
}

Expand Down Expand Up @@ -312,19 +312,20 @@ bool WMI::getEventData(UInt32 event, OSObject **result)

void WMI::extractBMF()
{
OSCollectionIterator *it = OSCollectionIterator::withCollection(mBMFCandidate);
if (it) {
while (OSDictionary* dict = OSDynamicCast(OSDictionary, it->getNextObject())) {
if (foundBMF) break;
parseBMF(dict);
}
it->release();
DebugLog("Extract %d possible BMF object", mBMFCandidate->getCount());
for (unsigned int i = 0; i < mBMFCandidate->getCount(); i++) {
DebugLog("%d / %d possible BMF object", i, mBMFCandidate->getCount());
if (foundBMF) break;
parseBMF(OSDynamicCast(OSDictionary, mBMFCandidate->getObject(i)));
}
mDevice->setProperty("WDG", mData);
}

bool WMI::parseBMF(OSDictionary* dict)
{
if (!dict)
return false;

OSObject *bmf;
OSData *data;

Expand Down
2 changes: 1 addition & 1 deletion YogaSMC/WMI.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WMI
IOACPIPlatformDevice* mDevice {nullptr};
OSDictionary* mData = {nullptr};
OSDictionary* mEvent = {nullptr};
OSDictionary* mBMFCandidate = {nullptr};
OSArray* mBMFCandidate = {nullptr};
const char* name;

public:
Expand Down

0 comments on commit bc3d9ec

Please sign in to comment.