microsoft / DMF

Driver Module Framework
MIT License
312 stars 78 forks source link

Merge20230714 #241

Closed samtertzakian closed 1 year ago

samtertzakian commented 1 year ago

Merge20230714

  1. Fix regression in pre-1809 Windows due to ExAllocatePool2.
  2. Track buffers actually used in BufferPool so that better initial preallocation choices can be made.
  3. Fix BSOD when Modules are created and memory is not available. (Fault injection/low memory situations.) Also fix associated asserts that failed in this case.
  4. Use more tags to make it easier to understand what memory is allocated. (No logical change to algorithm...just additional counters.)
  5. Add DMF_HidTarget_HidCollectionInformationGet() to HidTarget Module.
nefarius commented 1 year ago

FYI building this branch gives me some warnings:

C:\projects\DMF\Dmf\Framework\DmfHelpers.c(636): warning C28167: The function 'DMF_GenericSpinLockAcquire' changes the IRQL and does not restore the IRQL before it exits. It should be annotated to reflect the change or the IRQL should be restored. IRQL was last set to 2 at line 659. [C:\projects\DMF\Dmf\Solution\DmfUFramework\DmfUFramework.vcxproj]
11:02:44 [DBG]     11>C:\projects\DMF\Dmf\Framework\DmfHelpers.c(636): warning C6101: Returning uninitialized memory '*NativeLockContext'. [C:\projects\DMF\Dmf\Solution\DmfUFramework\DmfUFramework.vcxproj]
11:02:45 [DBG]     11>C:\projects\DMF\Dmf\Framework\DmfHelpers.c(663): warning C28167: The function 'DMF_GenericSpinLockRelease' changes the IRQL and does not restore the IRQL before it exits. It should be annotated to reflect the change or the IRQL should be restored. IRQL was last set at line 686. [C:\projects\DMF\Dmf\Solution\DmfUFramework\DmfUFramework.vcxproj]
C:\projects\DMF\Dmf\Framework\DmfHelpers.c(747): warning C28167: The function 'DMF_GenericSpinLockAcquire' changes the IRQL and does not restore the IRQL before it exits. It should be annotated to reflect the change or the IRQL should be restored. IRQL was last set to 2 at line 768. [C:\projects\DMF\Dmf\Solution\DmfKFramework\DmfKFramework.vcxproj]
11:03:56 [DBG]      8>C:\projects\DMF\Dmf\Framework\DmfHelpers.c(773): warning C28167: The function 'DMF_GenericSpinLockRelease' changes the IRQL and does not restore the IRQL before it exits. It should be annotated to reflect the change or the IRQL should be restored. IRQL was last set at line 795. [C:\projects\DMF\Dmf\Solution\DmfKFramework\DmfKFramework.vcxproj]
11:03:58 [DBG]        Lib:
11:03:58 [DBG]          C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64\Lib.exe /OUT:"C:\projects\DMF\Release\x64\individual_libs\DmfKModules.Library\DmfKModules.Library.lib" /LIBPATH:"C:\tools\vcpkg\installed\x64-windows\lib" /LIBPATH:"C:\tools\vcpkg\installed\x64-windows\lib\manual-link" /NOLOGO /MACHINE:X64 x64\Release\Dmf_BufferPool.obj
C:\projects\DMF\Dmf\Modules.Library\Dmf_HidTarget.c(4307): warning C28172: The function 'DMF_HidTarget_HidCollectionInformationGet' has PAGED_CODE or PAGED_CODE_LOCKED but is not declared to be in a paged segment. [C:\projects\DMF\Dmf\Solution\DmfKModules.Library\DmfKModules.Library.vcxproj]
C:\projects\DMF\Dmf\Modules.Library\Dmf_ActivitySensor.cpp(165): warning C26495: Variable 'ActivitySensorDevice::thisModuleHandle' is uninitialized. Always initialize a member variable (type.6). [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]
11:04:48 [DBG]     10>C:\projects\DMF\Dmf\Modules.Library\Dmf_BufferPool.c(1962): warning C26819: Unannotated fallthrough between switch labels (es.78). [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]
11:04:48 [DBG]     10>C:\projects\DMF\Dmf\Modules.Library\Dmf_BufferPool.c(2012): warning C26819: Unannotated fallthrough between switch labels (es.78). [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]
11:04:48 [DBG]     10>C:\projects\DMF\Dmf\Modules.Library\Dmf_BufferPool.c(2026): warning C26819: Unannotated fallthrough between switch labels (es.78). [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]
11:04:48 [DBG]     10>C:\projects\DMF\Dmf\Modules.Library\Dmf_HingeAngle.cpp(165): warning C26495: Variable 'HingeAngleDevice::thisModuleHandle' is uninitialized. Always initialize a member variable (type.6). [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]
11:04:48 [DBG]     10>C:\projects\DMF\Dmf\Modules.Library\Dmf_SimpleOrientation.cpp(166): warning C26495: Variable 'SimpleOrientationDevice::thisModuleHandle' is uninitialized. Always initialize a member variable (type.6). [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]
11:04:48 [DBG]     10>C:\projects\DMF\Dmf\Modules.Library\DMF_UefiLogs.c(242): warning C6001: Using uninitialized memory 'remainingBytes'. [C:\projects\DMF\Dmf\Solution\DmfUModules.Library\DmfUModules.Library.vcxproj]

Some might have been pre-existing but I noticed today by browsing through my CI logs.