diff options
| author | a1xd <[email protected]> | 2021-04-08 02:30:01 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-04-08 02:30:01 -0400 |
| commit | c55d1bfd01147fa014ac07d4b03ef3cad8427ae6 (patch) | |
| tree | 39ffa4a79bc6b019443521f10203f787c4b98698 /driver | |
| parent | unmark fill as const (diff) | |
| download | rawaccel-c55d1bfd01147fa014ac07d4b03ef3cad8427ae6.tar.xz rawaccel-c55d1bfd01147fa014ac07d4b03ef3cad8427ae6.zip | |
optimize a bit/refactor modify
Diffstat (limited to 'driver')
| -rw-r--r-- | driver/driver.cpp | 33 | ||||
| -rw-r--r-- | driver/driver.vcxproj | 12 |
2 files changed, 21 insertions, 24 deletions
diff --git a/driver/driver.cpp b/driver/driver.cpp index fa2415d..feace77 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -23,6 +23,7 @@ struct { extern "C" PULONG InitSafeBootMode; +__declspec(guard(ignore)) VOID RawaccelCallback( IN PDEVICE_OBJECT DeviceObject, @@ -56,26 +57,18 @@ Arguments: auto num_packets = InputDataEnd - InputDataStart; - bool any = num_packets > 0; - bool rel_move = !(InputDataStart->Flags & MOUSE_MOVE_ABSOLUTE); - bool dev_match = global.args.device_id[0] == 0 || - global.args.ignore == - bool(wcsncmp(devExt->dev_id, global.args.device_id, ra::MAX_DEV_ID_LEN)); - - if (any && rel_move && dev_match) { - milliseconds time; - - if (global.args.time_min == global.args.time_max) { - time = global.args.time_min; - } - else { - counter_t now = KeQueryPerformanceCounter(NULL).QuadPart; - counter_t ticks = now - devExt->counter; - devExt->counter = now; - milliseconds t = ticks * global.tick_interval / num_packets; - time = ra::clampsd(t, global.args.time_min, global.args.time_max); - } - + if (num_packets > 0 && + !(InputDataStart->Flags & MOUSE_MOVE_ABSOLUTE) && + (global.args.device_id[0] == 0 || + bool(wcsncmp(devExt->dev_id, global.args.device_id, ra::MAX_DEV_ID_LEN)) == + global.args.ignore)) { + counter_t now = KeQueryPerformanceCounter(NULL).QuadPart; + counter_t ticks = now - devExt->counter; + devExt->counter = now; + milliseconds raw_elapsed = ticks * global.tick_interval; + milliseconds time = ra::clampsd(raw_elapsed / num_packets, + global.args.time_min, + global.args.time_max); auto it = InputDataStart; do { if (it->LastX || it->LastY) { diff --git a/driver/driver.vcxproj b/driver/driver.vcxproj index 9034680..c2e4629 100644 --- a/driver/driver.vcxproj +++ b/driver/driver.vcxproj @@ -30,6 +30,7 @@ <ConfigurationType>Driver</ConfigurationType> <OverrideDefaultRuntimeLibrary>true</OverrideDefaultRuntimeLibrary> <SpectreMitigation>Spectre</SpectreMitigation> + <Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation> </PropertyGroup> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetVersion>Windows7</TargetVersion> @@ -38,6 +39,7 @@ <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> + <Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> @@ -74,18 +76,18 @@ </RuntimeLibrary> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <CallingConvention>StdCall</CallingConvention> - <AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput> + <AssemblerOutput>AssemblyCode</AssemblerOutput> <ExpandAttributedSource>false</ExpandAttributedSource> <UseUnicodeForAssemblerListing>false</UseUnicodeForAssemblerListing> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <Optimization>MaxSpeed</Optimization> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <IntrinsicFunctions>true</IntrinsicFunctions> - <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed> <WholeProgramOptimization>false</WholeProgramOptimization> <BufferSecurityCheck>true</BufferSecurityCheck> <ControlFlowGuard>Guard</ControlFlowGuard> - <FloatingPointModel>Precise</FloatingPointModel> + <FloatingPointModel>Fast</FloatingPointModel> </ClCompile> <Link> <LinkTimeCodeGeneration> @@ -114,9 +116,11 @@ <RuntimeLibrary> </RuntimeLibrary> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> - <FloatingPointModel>Precise</FloatingPointModel> + <FloatingPointModel>Fast</FloatingPointModel> <CallingConvention>StdCall</CallingConvention> <Optimization>MaxSpeed</Optimization> + <ControlFlowGuard>Guard</ControlFlowGuard> + <BufferSecurityCheck>true</BufferSecurityCheck> </ClCompile> <Link> <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |