-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0 of Bitness, included old MouseSpeed repo.
- Loading branch information
Showing
13 changed files
with
486 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{26DC4DFB-F0B0-421A-AAAD-CA225C762AFF}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Bitness</RootNamespace> | ||
<AssemblyName>Bitness</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace Bitness | ||
{ | ||
class Program | ||
{ | ||
|
||
/// <summary> | ||
/// Source: https://docs.microsoft.com/en-gb/windows/desktop/debug/pe-format | ||
/// </summary> | ||
private static Dictionary<Int32, string> MachineType = new Dictionary<Int32, string>() | ||
{ | ||
{0x0000, "The contents of this field are assumed to be applicable to any machine type"}, | ||
{0x01d3, "Matsushita AM33"}, | ||
{0x8664, "x64"}, | ||
{0x01c0, "ARM little endian"}, | ||
{0xaa64, "ARM64 little endian"}, | ||
{0x01c4, "ARM Thumb-2 little endian"}, | ||
{0x0ebc, "EFI byte code"}, | ||
{0x014c, "Intel 386 or later processors and compatible processors"}, | ||
{0x0200, "Intel Itanium processor family"}, | ||
{0x9041, "Mitsubishi M32R little endian"}, | ||
{0x0266, "MIPS16"}, | ||
{0x0366, "MIPS with FPU"}, | ||
{0x0466, "MIPS16 with FPU"}, | ||
{0x01f0, "Power PC little endian"}, | ||
{0x01f1, "Power PC with floating point support"}, | ||
{0x0166, "MIPS little endian"}, | ||
{0x5032, "RISC-V 32-bit address space"}, | ||
{0x5064, "RISC-V 64-bit address space"}, | ||
{0x5128, "RISC-V 128-bit address space"}, | ||
{0x01a2, "Hitachi SH3"}, | ||
{0x01a3, "Hitachi SH3 DSP"}, | ||
{0x01a6, "Hitachi SH4"}, | ||
{0x01a8, "Hitachi SH5"}, | ||
{0x01c2, "Thumb"}, | ||
{0x0169, "MIPS little-endian WCE v2"} | ||
}; | ||
|
||
static void Main(string[] args) | ||
{ | ||
// Initial checks. | ||
if (args.Length != 1) { Environment.Exit(0); } // Wrong args (probably none). Just get out of here. | ||
if (!File.Exists(args[0])) { Environment.Exit(2); } // File not found | ||
|
||
// File exists. Get PE offset from position 0x3c. FileShare.ReadWrite means we can read the file even if it's in use. | ||
var Stream = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | ||
byte[] PeOffset = new byte[2]; | ||
Stream.Seek(0x3c, SeekOrigin.Begin); | ||
Stream.Read(PeOffset, 0, 2); | ||
|
||
// Jump to offset specified in MS-DOS stub and read the PE signature. | ||
Stream.Seek(PeOffset[0] | PeOffset[1] << 8, SeekOrigin.Begin); | ||
byte[] Values = new byte[4]; | ||
Stream.Read(Values, 0, 4); | ||
|
||
// For sanity's sake, make sure we've got an actual PE signature - "P E NULL NULL"? | ||
if (Values.SequenceEqual(new byte[] { 0x50, 0x45, 0x00, 0x00 })) | ||
{ | ||
// Machine type is the next 2 bytes after the signature. | ||
Stream.Read(Values, 0, 2); | ||
Int32 TypeId = Values[0] | Values[1] << 8; | ||
string TypeName; | ||
if (MachineType.TryGetValue(TypeId, out TypeName)) | ||
{ | ||
Console.WriteLine("This assembly is compiled for {0}.", TypeName); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Machine type could not be determined for this assembly."); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Machine type could not be determined for this assembly."); | ||
} | ||
Console.WriteLine("Press any key to exit."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Bitness")] | ||
[assembly: AssemblyDescription("Determine machine type for a Windows assembly.")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Bitness")] | ||
[assembly: AssemblyCopyright("Copyright © 2019 Daniel Price and contributors")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("26dc4dfb-f0b0-421a-aaad-ca225c762aff")] | ||
|
||
[assembly: AssemblyVersion("1.0.*")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
|
||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace MouseSpeed | ||
{ | ||
public class MouseOptions | ||
{ | ||
|
||
/// <summary> | ||
/// Use System Parameters Info from User32 to get the current mouse speed. | ||
/// </summary> | ||
/// <returns>Current mouse speed.</returns> | ||
public static int GetMouseSpeed() | ||
{ | ||
IntPtr Ptr; | ||
Ptr = Marshal.AllocCoTaskMem(4); | ||
SPI.SystemParametersInfo(SPI.SPI_GETMOUSESPEED, 0, Ptr, 0); | ||
int Speed = Marshal.ReadInt32(Ptr); | ||
Marshal.FreeCoTaskMem(Ptr); | ||
|
||
return Speed; | ||
} | ||
|
||
/// <summary> | ||
/// Use System Parameters Info to set the mouse speed to a new value. | ||
/// </summary> | ||
/// <param name="speed">Value to set the mouse speed to. Accepts integers from 1 to 20.</param> | ||
/// <returns>True if speed was changed successfully.</returns> | ||
public static bool SetMouseSpeed(int speed) | ||
{ | ||
// Range of values allowed by Windows is 1 to 20. | ||
if (speed < 1 || speed > 20) | ||
{ | ||
throw new ArgumentOutOfRangeException("Valid speeds are integer values from 1 to 20."); | ||
} | ||
|
||
IntPtr ptr = new IntPtr(speed); | ||
return SPI.SystemParametersInfo(SPI.SPI_SETMOUSESPEED, 0, ptr, SPI.SPIF_SENDWININICHANGE); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{AC97B715-0D18-4C7E-A991-1F53C2CDF921}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>MouseSpeed</RootNamespace> | ||
<AssemblyName>MouseSpeed</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>false</Deterministic> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="MouseOptions.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SPI.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
|
||
namespace MouseSpeed | ||
{ | ||
partial class Program | ||
{ | ||
static unsafe void Main(string[] args) | ||
{ | ||
int NewSpeed; | ||
|
||
// A single cmd line argument? Set speed and exit if it's an integer. | ||
if (args.Length == 1 && int.TryParse(args[0], out NewSpeed)) | ||
{ | ||
if (MouseOptions.SetMouseSpeed(NewSpeed)) | ||
{ | ||
Console.WriteLine("Mouse speed changed to {0}", NewSpeed); | ||
Environment.Exit(0); | ||
} | ||
} | ||
|
||
// Otherwise, tell the user the existing speed and prompt for a new one. | ||
Console.WriteLine("Mouse speed is currently set to {0}.", MouseOptions.GetMouseSpeed()); | ||
Console.WriteLine("Enter a new speed [1..20] to set the speed, or any other value to exit."); | ||
string Entry = Console.ReadLine(); | ||
if (int.TryParse(Entry, out NewSpeed)) | ||
{ | ||
if (NewSpeed > 0 && NewSpeed < 21) | ||
{ | ||
bool Success = MouseOptions.SetMouseSpeed(NewSpeed); | ||
if (Success) | ||
{ | ||
Console.WriteLine("Speed changed to {0}", NewSpeed); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Unable to set speed."); | ||
} | ||
Console.WriteLine("Press any key to exit."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.