29 Commits

Author SHA1 Message Date
Benjamin Höglinger-Stelzer
6942f17e36 Updated links in README.md 2022-06-25 15:20:24 +02:00
Benjamin Höglinger-Stelzer
ee83bbaa45 Updated to latest nuke 2022-06-25 15:18:14 +02:00
Benjamin Höglinger-Stelzer
83b89dc860 Fixed cache settings 2022-06-24 22:41:48 +02:00
Benjamin Höglinger-Stelzer
fa43acce66 Fixed appveyor.yml 2022-06-24 22:40:20 +02:00
Benjamin Höglinger-Stelzer
735ee2984f Added cache instruction 2022-06-24 22:38:29 +02:00
Benjamin Höglinger-Stelzer
10825759c8 Bumped version 2022-06-24 22:36:34 +02:00
Benjamin Höglinger-Stelzer
53673bda45 Updated to more secure memory allocation function 2022-06-24 22:34:02 +02:00
Benjamin Höglinger-Stelzer
da4b8419f5 Downgraded to WDK for Windows 10, version 2004 2022-06-24 12:36:04 +02:00
Benjamin Höglinger-Stelzer
01b9ebd75e Updated WDK in appveyor.yml 2022-06-24 12:06:48 +02:00
Benjamin Höglinger-Stelzer
a9e7d6b38b Create support.yml 2021-12-31 05:26:18 +01:00
Benjamin Höglinger-Stelzer
7411c4fee3 Typo fix 2021-09-20 11:27:53 +02:00
Benjamin Höglinger-Stelzer
816ebc524f Delete you-need-support.md 2021-08-17 09:40:18 +02:00
Benjamin Höglinger-Stelzer
4316457837 Create config.yml 2021-08-17 09:39:46 +02:00
Benjamin Höglinger-Stelzer
3102c94dfc Create use-this-for-problems-with-the-setup.md 2021-07-05 20:46:54 +02:00
Benjamin Höglinger
442ae3b856 Delete FUNDING.yml 2021-04-06 11:57:03 +02:00
Benjamin Höglinger-Stelzer
41cc4f8398 Merge branch 'master' of github.com:ViGEm/ViGEmBus 2021-01-08 22:16:34 +01:00
Benjamin Höglinger-Stelzer
a33e223774 Fixed build output formatting 2021-01-08 22:16:24 +01:00
Benjamin Höglinger
d24ab69f45 Merge pull request #70 from Filoppi/patch-1
Fix Y touchpad resolution comment
2021-01-07 19:54:03 +01:00
Filippo Tarpini
7d3027c7db Fix Y touchpad resolution comment 2021-01-07 19:24:28 +02:00
Benjamin Höglinger
a1b58be426 Added Windows Server versions to supported systems 2021-01-07 13:44:34 +01:00
Benjamin Höglinger-Stelzer
9fdbe34bac Fix for issue #65 2020-12-22 22:51:46 +01:00
Benjamin Höglinger-Stelzer
346548689d Added devcon binaries compiled with /MT 2020-12-21 16:36:18 +01:00
Benjamin Höglinger-Stelzer
111ff8e170 Added missing README.md 2020-12-17 16:21:54 +01:00
Benjamin Höglinger-Stelzer
c5ecfbdd03 Updated outdated links 2020-12-17 16:20:22 +01:00
Benjamin Höglinger-Stelzer
df39fe6ed3 Minor formatting update 2020-12-17 08:30:12 +01:00
Benjamin Höglinger-Stelzer
2b02e029c1 Updated test signing link 2020-12-17 08:28:41 +01:00
Benjamin Höglinger-Stelzer
dce6de1a6f Corrected version compatibility 2020-12-16 20:46:10 +01:00
Benjamin Höglinger-Stelzer
4ddf7639e3 Added Regame - Cloud Gaming Engine 2020-12-16 20:20:59 +01:00
Benjamin Höglinger-Stelzer
b4980ceb82 Updated build instructions 2020-12-16 20:19:41 +01:00
17 changed files with 386 additions and 301 deletions

2
.github/FUNDING.yml vendored
View File

@@ -1,2 +0,0 @@
patreon: nefarius
custom: ["https://paypal.me/NefariusMaximus"]

11
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: 💬 Community support
url: https://vigem.org/Community-Support/
about: Use these resources for support.
- name: 📖 Documentation
url: https://vigem.org/projects/
about: Extended documentation about the projects.
- name: ❓ Other issue?
url: https://forums.vigem.org/
about: Search on the community forums.

View File

@@ -0,0 +1,30 @@
---
name: Setup issues
about: Use this if you have problems with the setup
---
## README first
Before you report issues with the setup, make sure to check the following things **first**:
- Are you on anything older than Windows **10**? Windows XP/Vista/7/8/8.1 **are not supported** so don't report this as an issue, it is intentional.
- [Have you chosen the right setup for your CPU architecture?](https://vigem.org/research/How-to-check-architecture/)
- You **can not mix these**, make sure to download and run the correct setup.
- **ARM/ARM64** is **not supported**. See above link to check for yourself.
## I verified all that and am still stuck
Please provide the following **log files** and attach them to the issue. Failing to do so will result in the issue being closed without any further comment.
### Setup log
Run the setup from the command line (either old-school `cmd` or PowerShell) with the following additional arguments: `/L*V .\install.log`
This will generate the log file `install.log` in the same directory the setup resides in. Attach it once the setup is "done" failing.
Last but not least look for `C:\Windows\INF\setupapi.dev.log` and attach it as well.
Optionally compress both files down if it gives you troubles uploading.
Your compliance is appreciated! 😘

View File

@@ -1,7 +0,0 @@
---
name: You need support
about: This is the wrong place to ask for support
---
**Please don't abuse the issue tracker as a helpdesk!** We have a Discord server (linked in the README) where you can ask the lovely like-minded folks for assistance. Thank you for your compliance :smiley:

25
.github/workflows/support.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: 'Support Requests'
on:
issues:
types: [labeled, unlabeled, reopened]
permissions:
issues: write
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/support-requests@v2
with:
github-token: ${{ github.token }}
support-label: 'support'
issue-comment: >
:wave: @{issue-author}, we use the issue tracker exclusively
for bug reports and feature requests. However, this issue appears
to be a support request. Please use our support channels
to get help with the project.
close-issue: true
lock-issue: true
issue-lock-reason: 'off-topic'

View File

@@ -37,19 +37,30 @@ A few examples of the most common use cases for `ViGEm` are:
## Supported Systems
The driver is built for Windows 7/8.1/10 (x86 and amd64).
### Version 1.16 and below
The driver is built for Windows 7/8.1/10/Server 2016/Server 2019 (x86 and amd64).
### Version 1.17 and above
The driver is built for Windows 10/Server 2016/Server 2019 only (x86 and amd64).
## License
The `ViGEm` Bus Driver is licensed under the **BSD-3-Clause**, see [LICENSE](./LICENSE.md) for more information.
The ViGEm Bus Driver is licensed under the **BSD-3-Clause**, see [LICENSE](./LICENSE.md) for more information.
## How to build
[Install Visual Studio 2019 and WDK for Windows 10, version 1903](https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk#wdk-for-windows-10-version-1903).
### Prerequisites
- [Step 1: Install Visual Studio 2019](https://docs.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads#step-1-install-visual-studio)
- [Step 2: Install WDK for Windows 10, version 2004](https://docs.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads#step-2-install-the-wdk)
- [Step 3: Clone the Driver Module Framework (DMF)](https://github.com/microsoft/DMF) into the same parent directory.
- Build the `DmfK` project with Release and Debug configurations for all architectures (x64 and Win32).
You can build directly within Visual Studio.
Do bear in mind that you'll need to **sign** the driver to use it without [test mode](<https://technet.microsoft.com/en-us/ff553484(v=vs.96)>).
Do bear in mind that you'll need to **sign** the driver to use it without [test mode](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/the-testsigning-boot-configuration-option#enable-or-disable-use-of-test-signed-code).
## Contribute
@@ -72,8 +83,8 @@ Pre-built production-signed binaries are provided by `Nefarius Software Solution
Sponsors listed here have helped the project flourish by either financial support or by gifting licenses:
- [3dRudder](https://www.3drudder.com/)
- [Parsec](https://parsecgaming.com/)
- [Rainway, Inc](https://rainway.io/)
- [Parsec](https://parsec.app/)
- [Rainway, Inc](https://rainway.com/)
- [JetBrains](https://www.jetbrains.com/resharper/)
- [Advanced Installer](https://www.advancedinstaller.com/)
- [ICAROS](https://www.icaros.com/)
@@ -85,18 +96,19 @@ A brief listing of projects/companies/vendors known to build upon the powers of
This list is non-exhaustive, if you'd like to see your project included, contact us!
- [3dRudder](https://www.3drudder.com/)
- [Parsec](https://parsecgaming.com/)
- [Parsec](https://parsec.app/)
- [GloSC](https://github.com/Alia5/GloSC)
- [UCR](https://github.com/Snoothy/UCR)
- [InputMapper](https://inputmapper.com/)
- [Oculus VR, LLC.](https://www.oculus.com/)
- [Rainway, Inc](https://rainway.io/)
- [Rainway, Inc](https://rainway.com/)
- [WiimoteHook](https://forum.cemu.info/showthread.php/140-WiimoteHook-Nintendo-Wii-Remote-with-Motion-Rumble-and-Nunchuk-support)
- [XJoy](https://github.com/sam0x17/XJoy)
- [HP](https://www8.hp.com/us/en/campaigns/gamingpcs/overview.html)
- [HP](https://www8.hp.com/us/en/gaming/omen.html)
- [DS4Windows](https://ryochan7.github.io/ds4windows-site/)
- [XOutput](https://github.com/csutorasa/XOutput)
- [RdpGamepad](https://github.com/microsoft/RdpGamepad)
- [Touchmote](https://github.com/Ryochan7/Touchmote/tree/ryochan7)
- [Mi-ViGEm](https://github.com/grayver/mi-vigem)
- [BetterJoy](https://github.com/Davidobot/BetterJoy)
- [Regame - Cloud Gaming Engine](https://github.com/ksyun-kenc/liuguang)

View File

@@ -1,19 +1,30 @@
version: 1.17.{build}.0
version: 1.18.{build}.0
image: Visual Studio 2019
skip_commits:
files:
- '**/*.md'
cache:
- C:\projects\DMF
platform:
- x86
- x64
configuration:
- Release
install:
- ps: iwr "https://download.microsoft.com/download/c/f/8/cf80b955-d578-4635-825c-2801911f9d79/wdk/wdksetup.exe" -OutFile wdksetup.exe
- cmd: .\wdksetup.exe /features + /q /norestart
- cmd: git submodule -q update --init
- cmd: git clone -q https://github.com/microsoft/DMF.git C:\projects\DMF
- cmd: git clone -q https://github.com/microsoft/DMF.git C:\projects\DMF 2> nul || set ERRORLEVEL=0
- cmd: |
cd "C:\projects\DMF"
git pull > NUL
cd %appveyor_build_folder%
before_build:
- ps: Invoke-WebRequest "https://github.com/nefarius/vpatch/releases/latest/download/vpatch.exe" -OutFile vpatch.exe
- cmd: vpatch.exe --stamp-version "%APPVEYOR_BUILD_VERSION%" --target-file ".\sys\ViGEmBus.vcxproj" --vcxproj.inf-time-stamp
- cmd: vpatch.exe --stamp-version "%APPVEYOR_BUILD_VERSION%" --target-file ".\sys\ViGEmBus.rc" --resource.file-version --resource.product-version
build_script:
- ps: .\build.ps1
- cmd: .\build.cmd
after_build:
- cmd: makecab.exe /f ViGEmBus_%PLATFORM%.ddf
artifacts:

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
@@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.0.0" />
<PackageReference Include="Nuke.Common" Version="6.1.1" />
</ItemGroup>
</Project>

3
drivers/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Drivers directory
Place the attestation signed driver files into the corresponding sub-directories and locally build the setup and sign it afterwards for production release.

Binary file not shown.

Binary file not shown.

View File

@@ -212,7 +212,7 @@ typedef struct _DS4_TOUCH
BYTE bTouchData1[3]; // Two 12 bits values (for X and Y)
// middle byte holds last 4 bits of X and the starting 4 bits of Y
BYTE bIsUpTrackingNum2; // second touch data immediately follows data of first touch
BYTE bTouchData2[3]; // resolution is 1920x943
BYTE bTouchData2[3]; // resolution is 1920x942
} DS4_TOUCH, * PDS4_TOUCH;
//

View File

@@ -61,7 +61,7 @@
<!-- https://stackoverflow.com/a/23061358 -->
<Condition Message="This application can only be installed on Windows 10.">
<![CDATA[WIN10FOUND]]>
<![CDATA[Installed OR WIN10FOUND]]>
</Condition>
<!-- write version value to registry -->

View File

@@ -44,7 +44,7 @@ void* operator new
size_t size
)
{
return ExAllocatePoolWithTag(NonPagedPoolNx, size, cpp_pool_tag);
return ExAllocatePoolZero(NonPagedPoolNx, size, cpp_pool_tag);
}
void* operator new[]
@@ -52,7 +52,7 @@ void* operator new[]
size_t size
)
{
return ExAllocatePoolWithTag(NonPagedPoolNx, size, cpp_pool_tag);
return ExAllocatePoolZero(NonPagedPoolNx, size, cpp_pool_tag);
}
void operator delete
@@ -107,7 +107,7 @@ void* __CRTDECL operator new
size_t size
)
{
return ExAllocatePoolWithTag(NonPagedPoolNx, size, cpp_pool_tag);
return ExAllocatePoolZero(NonPagedPoolNx, size, cpp_pool_tag);
}
void* __CRTDECL operator new[]
@@ -115,7 +115,7 @@ void* __CRTDECL operator new[]
size_t size
)
{
return ExAllocatePoolWithTag(NonPagedPoolNx, size, cpp_pool_tag);
return ExAllocatePoolZero(NonPagedPoolNx, size, cpp_pool_tag);
}
void __CRTDECL operator delete

View File

@@ -66,40 +66,42 @@ EXTERN_C_START
//
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;
WDFDRIVER driver;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_DRIVER_CONFIG config;
NTSTATUS status;
WDFDRIVER driver;
WDF_OBJECT_ATTRIBUTES attributes;
KdPrint((DRIVERNAME "Virtual Gamepad Emulation Bus Driver [built: %s %s]\n", __DATE__, __TIME__));
KdPrint((DRIVERNAME "Virtual Gamepad Emulation Bus Driver [built: %s %s]\n", __DATE__, __TIME__));
//
// Initialize WPP Tracing
//
WPP_INIT_TRACING(DriverObject, RegistryPath);
//
// Initialize WPP Tracing
//
WPP_INIT_TRACING(DriverObject, RegistryPath);
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"Loading Virtual Gamepad Emulation Bus Driver"
);
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"Loading Virtual Gamepad Emulation Bus Driver"
);
//
// Register cleanup callback
//
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.EvtCleanupCallback = Bus_EvtDriverContextCleanup;
ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
WDF_DRIVER_CONFIG_INIT(&config, Bus_EvtDeviceAdd);
//
// Register cleanup callback
//
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.EvtCleanupCallback = Bus_EvtDriverContextCleanup;
status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, &driver);
WDF_DRIVER_CONFIG_INIT(&config, Bus_EvtDeviceAdd);
if (!NT_SUCCESS(status))
{
WPP_CLEANUP(DriverObject);
KdPrint((DRIVERNAME "WdfDriverCreate failed with status 0x%x\n", status));
}
status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, &driver);
return status;
if (!NT_SUCCESS(status))
{
WPP_CLEANUP(DriverObject);
KdPrint((DRIVERNAME "WdfDriverCreate failed with status 0x%x\n", status));
}
return status;
}
//
@@ -107,168 +109,168 @@ NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING Registry
//
NTSTATUS Bus_EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
{
WDF_CHILD_LIST_CONFIG config;
NTSTATUS status;
WDFDEVICE device;
WDF_IO_QUEUE_CONFIG queueConfig;
PNP_BUS_INFORMATION busInfo;
WDFQUEUE queue;
WDF_FILEOBJECT_CONFIG foConfig;
WDF_OBJECT_ATTRIBUTES fdoAttributes;
WDF_OBJECT_ATTRIBUTES fileHandleAttributes;
PFDO_DEVICE_DATA pFDOData;
PWSTR pSymbolicNameList;
WDF_CHILD_LIST_CONFIG config;
NTSTATUS status;
WDFDEVICE device;
WDF_IO_QUEUE_CONFIG queueConfig;
PNP_BUS_INFORMATION busInfo;
WDFQUEUE queue;
WDF_FILEOBJECT_CONFIG foConfig;
WDF_OBJECT_ATTRIBUTES fdoAttributes;
WDF_OBJECT_ATTRIBUTES fileHandleAttributes;
PFDO_DEVICE_DATA pFDOData;
PWSTR pSymbolicNameList;
UNREFERENCED_PARAMETER(Driver);
UNREFERENCED_PARAMETER(Driver);
PAGED_CODE();
PAGED_CODE();
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
#pragma region Check for duplicated FDO
//
// Note: this could be avoided if converted to non-PNP driver
// and use of named device object. Food for thought for future.
//
status = IoGetDeviceInterfaces(
&GUID_DEVINTERFACE_BUSENUM_VIGEM,
NULL,
0, // Important!
&pSymbolicNameList
);
if (NT_SUCCESS(status))
{
const bool deviceAlreadyExists = (0 != *pSymbolicNameList);
ExFreePool(pSymbolicNameList);
//
// Note: this could be avoided if converted to non-PNP driver
// and use of named device object. Food for thought for future.
//
if (deviceAlreadyExists)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"Device with interface GUID {%!GUID!} already exists (%ws)",
&GUID_DEVINTERFACE_BUSENUM_VIGEM,
pSymbolicNameList
);
status = IoGetDeviceInterfaces(
&GUID_DEVINTERFACE_BUSENUM_VIGEM,
NULL,
0, // Important!
&pSymbolicNameList
);
if (NT_SUCCESS(status))
{
const bool deviceAlreadyExists = (0 != *pSymbolicNameList);
ExFreePool(pSymbolicNameList);
return STATUS_RESOURCE_IN_USE;
}
}
else
{
TraceEvents(TRACE_LEVEL_WARNING,
TRACE_DRIVER,
"IoGetDeviceInterfaces failed with status %!STATUS!",
status);
}
if (deviceAlreadyExists)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"Device with interface GUID {%!GUID!} already exists (%ws)",
&GUID_DEVINTERFACE_BUSENUM_VIGEM,
pSymbolicNameList
);
return STATUS_RESOURCE_IN_USE;
}
}
else
{
TraceEvents(TRACE_LEVEL_WARNING,
TRACE_DRIVER,
"IoGetDeviceInterfaces failed with status %!STATUS!",
status);
}
#pragma endregion
WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_BUS_EXTENDER);
// More than one process may talk to the bus at the same time
WdfDeviceInitSetExclusive(DeviceInit, FALSE);
// Bus is power policy owner over all PDOs
WdfDeviceInitSetPowerPolicyOwnership(DeviceInit, TRUE);
WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_BUS_EXTENDER);
// More than one process may talk to the bus at the same time
WdfDeviceInitSetExclusive(DeviceInit, FALSE);
// Bus is power policy owner over all PDOs
WdfDeviceInitSetPowerPolicyOwnership(DeviceInit, TRUE);
#pragma region Prepare child list
WDF_CHILD_LIST_CONFIG_INIT(&config, sizeof(PDO_IDENTIFICATION_DESCRIPTION), Bus_EvtDeviceListCreatePdo);
WDF_CHILD_LIST_CONFIG_INIT(&config, sizeof(PDO_IDENTIFICATION_DESCRIPTION), Bus_EvtDeviceListCreatePdo);
config.EvtChildListIdentificationDescriptionCompare = EmulationTargetPDO::EvtChildListIdentificationDescriptionCompare;
config.EvtChildListIdentificationDescriptionCompare = EmulationTargetPDO::EvtChildListIdentificationDescriptionCompare;
WdfFdoInitSetDefaultChildListConfig(DeviceInit, &config, WDF_NO_OBJECT_ATTRIBUTES);
WdfFdoInitSetDefaultChildListConfig(DeviceInit, &config, WDF_NO_OBJECT_ATTRIBUTES);
#pragma endregion
#pragma region Assign File Object Configuration
WDF_FILEOBJECT_CONFIG_INIT(&foConfig, Bus_DeviceFileCreate, Bus_FileClose, NULL);
WDF_FILEOBJECT_CONFIG_INIT(&foConfig, Bus_DeviceFileCreate, Bus_FileClose, NULL);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fileHandleAttributes, FDO_FILE_DATA);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fileHandleAttributes, FDO_FILE_DATA);
WdfDeviceInitSetFileObjectConfig(DeviceInit, &foConfig, &fileHandleAttributes);
WdfDeviceInitSetFileObjectConfig(DeviceInit, &foConfig, &fileHandleAttributes);
#pragma endregion
#pragma region Create FDO
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fdoAttributes, FDO_DEVICE_DATA);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fdoAttributes, FDO_DEVICE_DATA);
status = WdfDeviceCreate(&DeviceInit, &fdoAttributes, &device);
status = WdfDeviceCreate(&DeviceInit, &fdoAttributes, &device);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfDeviceCreate failed with status %!STATUS!",
status);
return status;
}
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfDeviceCreate failed with status %!STATUS!",
status);
return status;
}
pFDOData = FdoGetData(device);
if (pFDOData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FdoGetData failed");
return STATUS_UNSUCCESSFUL;
}
pFDOData = FdoGetData(device);
if (pFDOData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FdoGetData failed");
return STATUS_UNSUCCESSFUL;
}
pFDOData->InterfaceReferenceCounter = 0;
pFDOData->NextSessionId = FDO_FIRST_SESSION_ID;
pFDOData->InterfaceReferenceCounter = 0;
pFDOData->NextSessionId = FDO_FIRST_SESSION_ID;
#pragma endregion
#pragma region Create default I/O queue for FDO
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel);
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel);
queueConfig.EvtIoDeviceControl = Bus_EvtIoDeviceControl;
queueConfig.EvtIoDeviceControl = Bus_EvtIoDeviceControl;
__analysis_assume(queueConfig.EvtIoStop != 0);
status = WdfIoQueueCreate(device, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, &queue);
__analysis_assume(queueConfig.EvtIoStop == 0);
__analysis_assume(queueConfig.EvtIoStop != 0);
status = WdfIoQueueCreate(device, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, &queue);
__analysis_assume(queueConfig.EvtIoStop == 0);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfIoQueueCreate failed with status %!STATUS!",
status);
return status;
}
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfIoQueueCreate failed with status %!STATUS!",
status);
return status;
}
#pragma endregion
#pragma region Expose FDO interface
status = WdfDeviceCreateDeviceInterface(device, &GUID_DEVINTERFACE_BUSENUM_VIGEM, NULL);
status = WdfDeviceCreateDeviceInterface(device, &GUID_DEVINTERFACE_BUSENUM_VIGEM, NULL);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfDeviceCreateDeviceInterface failed with status %!STATUS!",
status);
return status;
}
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfDeviceCreateDeviceInterface failed with status %!STATUS!",
status);
return status;
}
#pragma endregion
#pragma region Set bus information
busInfo.BusTypeGuid = GUID_BUS_TYPE_USB;
busInfo.LegacyBusType = PNPBus;
busInfo.BusNumber = 0;
busInfo.BusTypeGuid = GUID_BUS_TYPE_USB;
busInfo.LegacyBusType = PNPBus;
busInfo.BusNumber = 0;
WdfDeviceSetBusInformationForChildren(device, &busInfo);
WdfDeviceSetBusInformationForChildren(device, &busInfo);
#pragma endregion
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit with status %!STATUS!", status);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit with status %!STATUS!", status);
return status;
return status;
}
// Gets called when the user-land process (or kernel driver) exits or closes the handle,
@@ -277,60 +279,60 @@ NTSTATUS Bus_EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
_Use_decl_annotations_
VOID
Bus_DeviceFileCreate(
_In_ WDFDEVICE Device,
_In_ WDFREQUEST Request,
_In_ WDFFILEOBJECT FileObject
_In_ WDFDEVICE Device,
_In_ WDFREQUEST Request,
_In_ WDFFILEOBJECT FileObject
)
{
NTSTATUS status = STATUS_INVALID_PARAMETER;
PFDO_FILE_DATA pFileData = NULL;
PFDO_DEVICE_DATA pFDOData = NULL;
LONG refCount = 0;
LONG sessionId = 0;
NTSTATUS status = STATUS_INVALID_PARAMETER;
PFDO_FILE_DATA pFileData = NULL;
PFDO_DEVICE_DATA pFDOData = NULL;
LONG refCount = 0;
LONG sessionId = 0;
UNREFERENCED_PARAMETER(Request);
UNREFERENCED_PARAMETER(Request);
PAGED_CODE();
PAGED_CODE();
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
pFileData = FileObjectGetData(FileObject);
pFileData = FileObjectGetData(FileObject);
if (pFileData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FileObjectGetData failed to return file object from WDFFILEOBJECT 0x%p",
FileObject);
}
else
{
pFDOData = FdoGetData(Device);
if (pFDOData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FdoGetData failed");
status = STATUS_NO_SUCH_DEVICE;
}
else
{
refCount = InterlockedIncrement(&pFDOData->InterfaceReferenceCounter);
sessionId = InterlockedIncrement(&pFDOData->NextSessionId);
if (pFileData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FileObjectGetData failed to return file object from WDFFILEOBJECT 0x%p",
FileObject);
}
else
{
pFDOData = FdoGetData(Device);
if (pFDOData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FdoGetData failed");
status = STATUS_NO_SUCH_DEVICE;
}
else
{
refCount = InterlockedIncrement(&pFDOData->InterfaceReferenceCounter);
sessionId = InterlockedIncrement(&pFDOData->NextSessionId);
pFileData->SessionId = sessionId;
status = STATUS_SUCCESS;
pFileData->SessionId = sessionId;
status = STATUS_SUCCESS;
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"File/session id = %d, device ref. count = %d",
(int)sessionId, (int)refCount);
}
}
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"File/session id = %d, device ref. count = %d",
(int)sessionId, (int)refCount);
}
}
WdfRequestComplete(Request, status);
WdfRequestComplete(Request, status);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit with status %!STATUS!", status);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit with status %!STATUS!", status);
}
//
@@ -339,139 +341,139 @@ Bus_DeviceFileCreate(
_Use_decl_annotations_
VOID
Bus_FileClose(
WDFFILEOBJECT FileObject
WDFFILEOBJECT FileObject
)
{
WDFDEVICE device;
WDFDEVICE hChild;
NTSTATUS status;
WDFCHILDLIST list;
WDF_CHILD_LIST_ITERATOR iterator;
WDF_CHILD_RETRIEVE_INFO childInfo;
PDO_IDENTIFICATION_DESCRIPTION description;
PFDO_FILE_DATA pFileData = NULL;
PFDO_DEVICE_DATA pFDOData = NULL;
LONG refCount = 0;
WDFDEVICE device;
WDFDEVICE hChild;
NTSTATUS status;
WDFCHILDLIST list;
WDF_CHILD_LIST_ITERATOR iterator;
WDF_CHILD_RETRIEVE_INFO childInfo;
PDO_IDENTIFICATION_DESCRIPTION description;
PFDO_FILE_DATA pFileData = NULL;
PFDO_DEVICE_DATA pFDOData = NULL;
LONG refCount = 0;
PAGED_CODE();
PAGED_CODE();
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
// Check common context
pFileData = FileObjectGetData(FileObject);
if (pFileData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FileObjectGetData failed to return file object from WDFFILEOBJECT 0x%p",
FileObject);
return;
}
// Check common context
pFileData = FileObjectGetData(FileObject);
if (pFileData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FileObjectGetData failed to return file object from WDFFILEOBJECT 0x%p",
FileObject);
return;
}
device = WdfFileObjectGetDevice(FileObject);
device = WdfFileObjectGetDevice(FileObject);
pFDOData = FdoGetData(device);
if (pFDOData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FdoGetData failed");
status = STATUS_NO_SUCH_DEVICE;
}
else
{
refCount = InterlockedDecrement(&pFDOData->InterfaceReferenceCounter);
pFDOData = FdoGetData(device);
if (pFDOData == NULL)
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"FdoGetData failed");
status = STATUS_NO_SUCH_DEVICE;
}
else
{
refCount = InterlockedDecrement(&pFDOData->InterfaceReferenceCounter);
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"Device ref. count = %d",
(int)refCount);
}
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"Device ref. count = %d",
(int)refCount);
}
list = WdfFdoGetDefaultChildList(device);
list = WdfFdoGetDefaultChildList(device);
WDF_CHILD_LIST_ITERATOR_INIT(&iterator, WdfRetrievePresentChildren);
WDF_CHILD_LIST_ITERATOR_INIT(&iterator, WdfRetrievePresentChildren);
WdfChildListBeginIteration(list, &iterator);
WdfChildListBeginIteration(list, &iterator);
for (;;)
{
WDF_CHILD_RETRIEVE_INFO_INIT(&childInfo, &description.Header);
WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(&description.Header, sizeof(description));
for (;;)
{
WDF_CHILD_RETRIEVE_INFO_INIT(&childInfo, &description.Header);
WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(&description.Header, sizeof(description));
status = WdfChildListRetrieveNextDevice(list, &iterator, &hChild, &childInfo);
if (!NT_SUCCESS(status) || status == STATUS_NO_MORE_ENTRIES)
{
break;
}
status = WdfChildListRetrieveNextDevice(list, &iterator, &hChild, &childInfo);
if (!NT_SUCCESS(status) || status == STATUS_NO_MORE_ENTRIES)
{
break;
}
//TraceEvents(TRACE_LEVEL_VERBOSE,
// TRACE_DRIVER,
// "PDO properties: status = %!STATUS!, pdoPID = %d, curPID = %d, pdoSID = %d, curSID = %d, internal = %d",
// (int)childInfo.Status,
// (int)description.OwnerProcessId,
// (int)CURRENT_PROCESS_ID(),
// (int)description.SessionId,
// (int)pFileData->SessionId,
// (int)description.OwnerIsDriver
//);
//TraceEvents(TRACE_LEVEL_VERBOSE,
// TRACE_DRIVER,
// "PDO properties: status = %!STATUS!, pdoPID = %d, curPID = %d, pdoSID = %d, curSID = %d, internal = %d",
// (int)childInfo.Status,
// (int)description.OwnerProcessId,
// (int)CURRENT_PROCESS_ID(),
// (int)description.SessionId,
// (int)pFileData->SessionId,
// (int)description.OwnerIsDriver
//);
// Only unplug devices with matching session id
if (childInfo.Status == WdfChildListRetrieveDeviceSuccess
&& description.SessionId == pFileData->SessionId)
{
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"Unplugging device with serial %d",
description.SerialNo);
// Only unplug devices with matching session id
if (childInfo.Status == WdfChildListRetrieveDeviceSuccess
&& description.SessionId == pFileData->SessionId)
{
TraceEvents(TRACE_LEVEL_INFORMATION,
TRACE_DRIVER,
"Unplugging device with serial %d",
description.SerialNo);
// "Unplug" child
status = WdfChildListUpdateChildDescriptionAsMissing(list, &description.Header);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfChildListUpdateChildDescriptionAsMissing failed with status %!STATUS!",
status);
}
}
}
// "Unplug" child
status = WdfChildListUpdateChildDescriptionAsMissing(list, &description.Header);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfChildListUpdateChildDescriptionAsMissing failed with status %!STATUS!",
status);
}
}
}
WdfChildListEndIteration(list, &iterator);
WdfChildListEndIteration(list, &iterator);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit with status %!STATUS!", status);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit with status %!STATUS!", status);
}
VOID
Bus_EvtDriverContextCleanup(
_In_ WDFOBJECT DriverObject
_In_ WDFOBJECT DriverObject
)
/*++
Routine Description:
Free all the resources allocated in DriverEntry.
Free all the resources allocated in DriverEntry.
Arguments:
DriverObject - handle to a WDF Driver object.
DriverObject - handle to a WDF Driver object.
Return Value:
VOID.
VOID.
--*/
{
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(DriverObject);
PAGED_CODE();
PAGED_CODE();
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
//
// Stop WPP Tracing
//
WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject));
//
// Stop WPP Tracing
//
WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject));
}

View File

@@ -1189,8 +1189,8 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::SubmitReportImpl(PVOID NewRepo
VOID ViGEm::Bus::Targets::EmulationTargetDS4::ReverseByteArray(PUCHAR Array, INT Length)
{
const auto s = static_cast<PUCHAR>(ExAllocatePoolWithTag(
NonPagedPool,
const auto s = static_cast<PUCHAR>(ExAllocatePoolZero(
NonPagedPoolNx,
sizeof(UCHAR) * Length,
'U4SD'
));

View File

@@ -684,7 +684,7 @@ VOID ViGEm::Bus::Core::EmulationTargetPDO::DumpAsHex(PCSTR Prefix, PVOID Buffer,
#ifdef DBG
size_t dumpBufferLength = ((BufferLength * sizeof(CHAR)) * 2) + 1;
PSTR dumpBuffer = static_cast<PSTR>(ExAllocatePoolWithTag(
PSTR dumpBuffer = static_cast<PSTR>(ExAllocatePoolZero(
NonPagedPoolNx,
dumpBufferLength,
'1234'