Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): distinguish the error states of VddAddDisplay. #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions core/parsec-vdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,22 @@ static const int VDD_MAX_DISPLAYS = 8;

// Core IoControl codes, see usage below.
typedef enum {
VDD_IOCTL_ADD = 0x0022e004,
VDD_IOCTL_REMOVE = 0x0022a008,
VDD_IOCTL_UPDATE = 0x0022a00c,
VDD_IOCTL_VERSION = 0x0022e010,
VDD_IOCTL_ADD = 0x0022e004, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
VDD_IOCTL_REMOVE = 0x0022a008, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
VDD_IOCTL_UPDATE = 0x0022a00c, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 3, METHOD_BUFFERED, FILE_WRITE_ACCESS)
VDD_IOCTL_VERSION = 0x0022e010, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)

// new code in driver v0.45
// relates to IOCTL_UPDATE and per display state
// but unused in Parsec app
VDD_IOCTL_UNKONWN = 0x0022a00c, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 5, METHOD_BUFFERED, FILE_WRITE_ACCESS)
} VddCtlCode;

// Generic DeviceIoControl for all IoControl codes.
static DWORD VddIoControl(HANDLE vdd, VddCtlCode code, const void *data, size_t size)
{
if (vdd == NULL || vdd == INVALID_HANDLE_VALUE)
return 0;
return -1;

BYTE InBuffer[32];
ZeroMemory(InBuffer, sizeof(InBuffer));
Expand All @@ -285,7 +290,7 @@ static DWORD VddIoControl(HANDLE vdd, VddCtlCode code, const void *data, size_t
if (!GetOverlappedResultEx(vdd, &Overlapped, &NumberOfBytesTransferred, 5000, FALSE))
{
CloseHandle(Overlapped.hEvent);
return 0;
return -1;
}

if (Overlapped.hEvent != NULL)
Expand Down
11 changes: 7 additions & 4 deletions core/vdd-demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ int main()
}
});

updater.detach();

// Print out guide.
printf("Press A to add a virtual display.\n");
printf("Press R to remove the last added.\n");
Expand All @@ -53,8 +51,13 @@ int main()
case 'a':
if (displays.size() < VDD_MAX_DISPLAYS) {
int index = VddAddDisplay(vdd);
displays.push_back(index);
printf("Added a new virtual display, index: %d.\n", index);
if (index != -1) {
displays.push_back(index);
printf("Added a new virtual display, index: %d.\n", index);
}
else {
printf("Add virtual display failed.");
}
}
else {
printf("Limit exceeded (%d), could not add more virtual displays.\n", VDD_MAX_DISPLAYS);
Expand Down