Skip to content
This repository has been archived by the owner on Jun 23, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:nefarius/ScpVBus
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Jun 11, 2017
2 parents 6d92219 + f081018 commit 7a23cf3
Show file tree
Hide file tree
Showing 28 changed files with 2,362 additions and 298 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,26 @@ vXboxInstall/vXboxInstall.h
/ScpVBus/SDV-default.xml
/ScpVBus/sdv
/ScpVBus/runsdvui.cmd
*.tlog
*.iobj
*.ipdb
*.idb
StaticLib/ReadMe.txt
StaticLib/TestStatic/ReadMe.txt
XOutput/Win32/Debug-Static/Lib/XOutput.res
XOutput/Win32/Release-Static/Lib/XOutput.res
StaticLib/ReadMe.txt
StaticLib/TestStatic/ReadMe.txt
*.iobj
*.ipdb
*.tlog
*.idb
XOutput/Win32/Debug-Static/Lib/
XOutput/Win32/Release-Static/Lib/
StaticLib/ReadMe.txt
StaticLib/TestStatic/ReadMe.txt
*.idb
XOutput/Win32/Debug-Static/Lib/XOutput.res
XOutput/Win32/Release-Static/Lib/XOutput.res
XOutput/Win32/Release-Static/XOutput.res
XOutput/Win32/
1 change: 1 addition & 0 deletions Common/IoCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
#define IOCTL_BUSENUM_ISDEVPLUGGED BUSENUM_RW_IOCTL(IOCTL_BUSENUM_BASE + 0x100)
#define IOCTL_BUSENUM_EMPTY_SLOTS BUSENUM_RW_IOCTL(IOCTL_BUSENUM_BASE + 0x101)
#define IOCTL_BUSENUM_PROC_ID BUSENUM_RW_IOCTL(IOCTL_BUSENUM_BASE + 0x102)
#define IOCTL_BUSENUM_VERSION BUSENUM_RW_IOCTL(IOCTL_BUSENUM_BASE + 0x103)
16 changes: 16 additions & 0 deletions Common/ScpVBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ DEFINE_GUID (GUID_DEVINTERFACE_SCPVBUS, 0xf679f562, 0x3164, 0x42ce, 0xa4, 0xdb,
#ifndef __SCPVBUS_H
#define __SCPVBUS_H

// Bus Version
#define VER_L_ 0x02
#define VER_M_ 0x01
#define VER_H_ 0x07
#define VER_X_ 0x01

// Bus Version Number
#define BUS_VERSION (VER_L_ + 0x10*VER_M_ + 0x100*VER_H_ + 0x1000*VER_X_)

// Bus Version String
#define STRINGIFY_1(x) #x
#define STRINGIFY(x) STRINGIFY_1(x)
#define PASTE(x, y) x##y
#define MAKEWIDE(x) PASTE(L,x)
#define BUS_VERSION_STR MAKEWIDE(STRINGIFY(VER_H_)) L"." MAKEWIDE(STRINGIFY(VER_M_)) L"." MAKEWIDE(STRINGIFY(VER_L_))


// HID Report size
#define REPORT_SIZE 20
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Scarlett.Crush Productions Virtual Bus Driver
This is part of the [ScpToolkit](../../../ScpToolkit) project.

This project is published for historical reasons and no longer maintained by me. If you're seeking for a modern reincarnation take a look at [ViGEm](../../../ViGEm).
60 changes: 59 additions & 1 deletion ScpVBus.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScpVBus", "ScpVBus\ScpVBus.vcxproj", "{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}"
EndProject
Expand All @@ -19,10 +19,18 @@ Global
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Debug-Static|ARM = Debug-Static|ARM
Debug-Static|ARM64 = Debug-Static|ARM64
Debug-Static|x64 = Debug-Static|x64
Debug-Static|x86 = Debug-Static|x86
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
Release-Static|ARM = Release-Static|ARM
Release-Static|ARM64 = Release-Static|ARM64
Release-Static|x64 = Release-Static|x64
Release-Static|x86 = Release-Static|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug|ARM.ActiveCfg = Debug|ARM
Expand All @@ -37,6 +45,18 @@ Global
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug|x86.ActiveCfg = Debug|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug|x86.Build.0 = Debug|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug|x86.Deploy.0 = Debug|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|ARM.ActiveCfg = Debug|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|ARM.Build.0 = Debug|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|ARM.Deploy.0 = Debug|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|ARM64.ActiveCfg = Debug|ARM64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|ARM64.Build.0 = Debug|ARM64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|ARM64.Deploy.0 = Debug|ARM64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|x64.ActiveCfg = Debug|x64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|x64.Build.0 = Debug|x64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|x64.Deploy.0 = Debug|x64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|x86.ActiveCfg = Debug|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|x86.Build.0 = Debug|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Debug-Static|x86.Deploy.0 = Debug|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release|ARM.ActiveCfg = Release|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release|ARM.Build.0 = Release|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release|ARM.Deploy.0 = Release|ARM
Expand All @@ -49,30 +69,68 @@ Global
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release|x86.ActiveCfg = Release|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release|x86.Build.0 = Release|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release|x86.Deploy.0 = Release|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|ARM.ActiveCfg = Release|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|ARM.Build.0 = Release|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|ARM.Deploy.0 = Release|ARM
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|ARM64.ActiveCfg = Release|ARM64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|ARM64.Build.0 = Release|ARM64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|ARM64.Deploy.0 = Release|ARM64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|x64.ActiveCfg = Release|x64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|x64.Build.0 = Release|x64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|x64.Deploy.0 = Release|x64
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|x86.ActiveCfg = Release|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|x86.Build.0 = Release|Win32
{B01A6B39-6A31-4A43-9DC9-65685C14E4B6}.Release-Static|x86.Deploy.0 = Release|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug|ARM.ActiveCfg = Debug|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug|ARM64.ActiveCfg = Debug|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug|x64.ActiveCfg = Debug|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug|x64.Build.0 = Debug|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug|x86.ActiveCfg = Debug|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug|x86.Build.0 = Debug|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug-Static|ARM.ActiveCfg = Debug-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug-Static|ARM64.ActiveCfg = Debug-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug-Static|x64.ActiveCfg = Debug-Static|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug-Static|x64.Build.0 = Debug-Static|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug-Static|x86.ActiveCfg = Debug-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Debug-Static|x86.Build.0 = Debug-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release|ARM.ActiveCfg = Release|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release|ARM64.ActiveCfg = Release|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release|x64.ActiveCfg = Release|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release|x64.Build.0 = Release|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release|x86.ActiveCfg = Release|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release|x86.Build.0 = Release|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release-Static|ARM.ActiveCfg = Release-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release-Static|ARM64.ActiveCfg = Release-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release-Static|x64.ActiveCfg = Release-Static|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release-Static|x64.Build.0 = Release-Static|x64
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release-Static|x86.ActiveCfg = Release-Static|Win32
{AE3E422E-4C52-4582-A757-FA110C6E9F3A}.Release-Static|x86.Build.0 = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug|ARM.ActiveCfg = Debug|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug|ARM64.ActiveCfg = Debug|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug|x64.ActiveCfg = Debug|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug|x64.Build.0 = Debug|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug|x86.ActiveCfg = Debug|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug|x86.Build.0 = Debug|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|ARM.ActiveCfg = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|ARM.Build.0 = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|ARM64.ActiveCfg = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|ARM64.Build.0 = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|x64.ActiveCfg = Debug-Static|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|x64.Build.0 = Debug-Static|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|x86.ActiveCfg = Debug-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Debug-Static|x86.Build.0 = Debug-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release|ARM.ActiveCfg = Release|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release|ARM64.ActiveCfg = Release|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release|x64.ActiveCfg = Release|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release|x64.Build.0 = Release|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release|x86.ActiveCfg = Release|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release|x86.Build.0 = Release|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release-Static|ARM.ActiveCfg = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release-Static|ARM64.ActiveCfg = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release-Static|x64.ActiveCfg = Release-Static|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release-Static|x64.Build.0 = Release-Static|x64
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release-Static|x86.ActiveCfg = Release-Static|Win32
{83C7BDBD-5B2E-43E8-972C-D72374A45512}.Release-Static|x86.Build.0 = Release-Static|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
28 changes: 25 additions & 3 deletions ScpVBus/bus/busenum.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ NTSTATUS Bus_IoCtl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
* a byte array including rumble information (8 bytes) and the LED index (1 byte)
* is returned to the caller of DeviceIoControl() for further processing.
*/
if (NT_SUCCESS(status)) Irp->IoStatus.Information = (RUMBLE_SIZE + LEDNUM_SIZE);
if (NT_SUCCESS(status)) Irp->IoStatus.Information = (RUMBLE_SIZE + LEDNUM_SIZE + STATUS_SIZE);
}
break;

Expand Down Expand Up @@ -406,6 +406,18 @@ NTSTATUS Bus_IoCtl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
}
break;

// Get the driver version
case IOCTL_BUSENUM_VERSION:
// check I/O buffer size submitted by DeviceIoControl()
if ((sizeof(DWORD) == outlen))
{
// Call the worker function
*(DWORD *)buffer = BUS_VERSION;
Irp->IoStatus.Information = sizeof(DWORD);
status = STATUS_SUCCESS;
}
break;

default:

break; // default status is STATUS_INVALID_PARAMETER
Expand Down Expand Up @@ -1382,6 +1394,12 @@ NTSTATUS Bus_ReportDevice(PBUSENUM_REPORT_HARDWARE Report, PFDO_DEVICE_DATA fdoD
// pass back current LED number for this PDO
Transfer[8] = pdoData->LedNumber;

// pass back presence of device
if (pdoData->Started)
Transfer[9] = 1;
else
Transfer[9] = 0;

return STATUS_SUCCESS;
}

Expand Down Expand Up @@ -1416,8 +1434,9 @@ NTSTATUS Bus_IsDevicePluggedIn(PVOID Report, PFDO_DEVICE_DATA fdoData, PUCHAR Tr
{
Bus_KdPrint(("No devices to report!\n"));
ExReleaseFastMutex(&fdoData->Mutex);
Transfer[0] = 0;

return STATUS_NO_SUCH_DEVICE;
return STATUS_SUCCESS;
}

// Test that the input id is legitimate
Expand Down Expand Up @@ -1475,7 +1494,8 @@ NTSTATUS Bus_GetDeviceCreateProcID(PVOID Report, PFDO_DEVICE_DATA fdoData, PULON
{
Bus_KdPrint(("No devices to report!\n"));
ExReleaseFastMutex(&fdoData->Mutex);
return STATUS_NO_SUCH_DEVICE;
*Transfer = 0;
return STATUS_SUCCESS;
}

// Test that the input id is legitimate
Expand Down Expand Up @@ -1563,3 +1583,5 @@ NTSTATUS Bus_GetNumberOfEmptySlots(PFDO_DEVICE_DATA fdoData, PUCHAR Transfer)
Transfer[0] = count;
return STATUS_SUCCESS;
}


6 changes: 4 additions & 2 deletions ScpVBus/bus/busenum.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ DEFINE_GUID (GUID_DEVCLASS_X360WIRED_CUSTOM, 0xA8BA2D1F, 0x894F, 0x464A, 0xB0, 0
#define RUMBLE_SIZE 8
#define LEDSET_SIZE 3
#define LEDNUM_SIZE 1
#define STATUS_SIZE 1

#define CURRENT_PROCESS_ID() ((DWORD)((DWORD_PTR)PsGetCurrentProcessId() & 0xFFFFFFFF))

Expand Down Expand Up @@ -122,8 +123,9 @@ typedef struct _PDO_DEVICE_DATA {

LIST_ENTRY Link;

BOOLEAN Present;
BOOLEAN ReportedMissing;
BOOLEAN Present;
BOOLEAN Started;
BOOLEAN ReportedMissing;
UCHAR Reserved[2]; // for 4 byte alignment

ULONG InterfaceRefCount;
Expand Down
3 changes: 3 additions & 0 deletions ScpVBus/bus/buspdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ NTSTATUS Bus_PDO_PnP(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp, __in PIO_S

if (NT_SUCCESS(status))
{
// Device is starting
IoSetDeviceInterfaceState(&DeviceData->InterfaceName, TRUE);
DeviceData->Started = TRUE;
}

status = STATUS_SUCCESS;
Expand All @@ -44,6 +46,7 @@ NTSTATUS Bus_PDO_PnP(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp, __in PIO_S
case IRP_MN_STOP_DEVICE:

SET_NEW_PNP_STATE(DeviceData, Stopped);
DeviceData->Started = FALSE;

status = STATUS_SUCCESS;
break;
Expand Down
1 change: 1 addition & 0 deletions ScpVBus/bus/pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ VOID Bus_InitializePdo(__drv_in(__drv_aliasesMem) PDEVICE_OBJECT Pdo, PFDO_DEVIC
pdoData->ParentFdo = FdoData->Self;

pdoData->Present = TRUE;
pdoData->Started = FALSE;
pdoData->ReportedMissing = FALSE;

INITIALIZE_PNP_STATE(pdoData);
Expand Down
Loading

0 comments on commit 7a23cf3

Please sign in to comment.