├── CheckPrerequisites.bat ├── LICENSE ├── ParsecVDA - Always Connected.cc ├── ParsecVDAAC.xml ├── README.md ├── Setup.bat ├── Setup.iss └── parsec-vdd.h /CheckPrerequisites.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | 4 | rem Check if ParsecVDAAC service is installed 5 | sc query ParsecVDAAC >nul 2>&1 6 | set SERVICE_EXIST=%ERRORLEVEL% 7 | if "%SERVICE_EXIST%"=="0" ( 8 | rem ParsecVDAAC service is already installed, stopping and uninstalling it... 9 | ParsecVDAAC.exe stopwait 10 | ParsecVDAAC.exe uninstall 11 | ) else ( 12 | rem ParsecVDAAC service is not installed, nothing to be done here... 13 | ) 14 | 15 | endlocal -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /ParsecVDA - Always Connected.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "parsec-vdd.h" 12 | 13 | using namespace parsec_vdd; 14 | 15 | // Global variables 16 | bool running = true; 17 | bool cleanupstarted = false; 18 | bool finalshutdown = false; 19 | bool suspend = false; 20 | bool stopmainloop = false; 21 | bool receivedeventsleep = false; 22 | bool receivedeventwake = false; 23 | bool systemalreadyawake = false; 24 | bool receivedeventdrivercrash = false; 25 | bool ParsecVDAfound = true; 26 | int MainLoopResult = 0; 27 | HANDLE vdd = nullptr; 28 | std::vector displays; 29 | std::thread updater; 30 | std::thread CheckForParsecVDAThread; 31 | std::string deviceInstanceId = "ROOT\\Display\\0000"; // Device instance ID of the Parsec Virtual Display Adapter 32 | FILE *logfile = nullptr; 33 | DWORD PrintEventSystemData(EVT_HANDLE hEvent); 34 | DWORD WINAPI SubscriptionCallback(EVT_SUBSCRIBE_NOTIFY_ACTION action, PVOID pContext, EVT_HANDLE hEvent); 35 | 36 | // Function to open the log file 37 | bool OpenLogFile() { 38 | // Get the directory of the executable 39 | char buffer[MAX_PATH]; 40 | GetModuleFileNameA(NULL, buffer, MAX_PATH); 41 | std::string::size_type pos = std::string(buffer).find_last_of("\\/"); 42 | std::string executableDirectory = std::string(buffer).substr(0, pos); 43 | 44 | // Create log file path 45 | std::string logFilePath = executableDirectory + "\\Logfile ParsecVDA - Always Connected.txt"; 46 | 47 | // Open log file in append mode if it already exists 48 | logfile = fopen(logFilePath.c_str(), "a"); 49 | if (!logfile) { 50 | // If file doesn't exist, create it 51 | logfile = fopen(logFilePath.c_str(), "w"); 52 | if (!logfile) { 53 | printf("Error opening log file.\n"); 54 | return false; 55 | } 56 | } 57 | return true; 58 | } 59 | 60 | // Function to log messages with timestamp 61 | void Log(const char* message) { 62 | if (logfile) { 63 | // Get current timestamp 64 | std::time_t now = std::time(nullptr); 65 | char timestamp[20]; 66 | strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", std::localtime(&now)); 67 | 68 | // Write timestamp and message to logfile 69 | fprintf(logfile, "[%s] %s\n", timestamp, message); 70 | fflush(logfile); // Flush the stream to ensure data is written to the file immediately 71 | } 72 | } 73 | 74 | // Console control handler function for Ctrl+C event 75 | BOOL WINAPI ConsoleHandler(DWORD dwCtrlType) { 76 | switch (dwCtrlType) { 77 | case CTRL_C_EVENT: 78 | // Cleanup code for Ctrl+C event 79 | running = false; 80 | finalshutdown = true; 81 | cleanupstarted = true; 82 | Log("Cleanup code reached (Ctrl+C)!"); 83 | for (int index : displays) { 84 | VddRemoveDisplay(vdd, index); 85 | } 86 | if (updater.joinable()) { 87 | updater.join(); 88 | } 89 | if (CheckForParsecVDAThread.joinable()) { 90 | CheckForParsecVDAThread.join(); 91 | } 92 | // Close the device handle. 93 | CloseDeviceHandle(vdd); 94 | stopmainloop = true; 95 | Log("Cleanup done!"); 96 | return TRUE; // Indicate that we've handled the event 97 | default: 98 | return FALSE; 99 | } 100 | } 101 | 102 | // Function to check for system events signaling sleep, waking from sleep and a driver crash 103 | void CheckSystemEventLog(void) { 104 | 105 | DWORD status = ERROR_SUCCESS; 106 | EVT_HANDLE hResults = NULL; 107 | 108 | // Events for going to sleep, waking from sleep and driver crash 109 | #define QUERY \ 110 | L"" \ 111 | L" " \ 112 | L" " \ 113 | L" " \ 114 | L"" 115 | 116 | hResults = EvtSubscribe(NULL, NULL, NULL, QUERY, NULL, NULL, (EVT_SUBSCRIBE_CALLBACK)SubscriptionCallback, EvtSubscribeToFutureEvents); 117 | if (NULL == hResults) 118 | { 119 | status = GetLastError(); 120 | 121 | if (ERROR_EVT_CHANNEL_NOT_FOUND == status) 122 | wprintf(L"The channel was not found.\n"); 123 | else if (ERROR_EVT_INVALID_QUERY == status) 124 | wprintf(L"The query is not valid.\n"); 125 | else 126 | wprintf(L"EvtQuery failed with %lu.\n", status); 127 | 128 | goto cleanup; 129 | } 130 | while(!finalshutdown) { 131 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 132 | } 133 | 134 | cleanup: 135 | 136 | if (hResults) 137 | EvtClose(hResults); 138 | 139 | } 140 | 141 | // The callback that receives the events that match the query criteria. 142 | DWORD WINAPI SubscriptionCallback(EVT_SUBSCRIBE_NOTIFY_ACTION action, PVOID pContext, EVT_HANDLE hEvent) { 143 | 144 | UNREFERENCED_PARAMETER(pContext); 145 | 146 | DWORD status = ERROR_SUCCESS; 147 | 148 | switch (action) 149 | { 150 | case EvtSubscribeActionDeliver: 151 | if (ERROR_SUCCESS != (status = PrintEventSystemData(hEvent))) 152 | { 153 | Log("Error while printing the system event data!"); 154 | return status; // The service ignores the returned status. 155 | } 156 | break; 157 | 158 | default: 159 | Log("SubscriptionCallback: Unknown action. Could not correctly receive the system event!"); 160 | } 161 | 162 | return status; // The service ignores the returned status. 163 | } 164 | 165 | // Render the system EventID 166 | DWORD PrintEventSystemData(EVT_HANDLE hEvent) { 167 | 168 | DWORD status = ERROR_SUCCESS; 169 | EVT_HANDLE hContext = NULL; 170 | DWORD dwBufferSize = 0; 171 | DWORD dwBufferUsed = 0; 172 | DWORD dwPropertyCount = 0; 173 | PEVT_VARIANT pRenderedValues = NULL; 174 | 175 | hContext = EvtCreateRenderContext(0, NULL, EvtRenderContextSystem); 176 | if (NULL == hContext) 177 | { 178 | wprintf(L"EvtCreateRenderContext failed with %lu\n", status = GetLastError()); 179 | if (hContext) 180 | EvtClose(hContext); 181 | 182 | if (pRenderedValues) 183 | free(pRenderedValues); 184 | 185 | return status; 186 | } 187 | 188 | if (!EvtRender(hContext, hEvent, EvtRenderEventValues, dwBufferSize, pRenderedValues, &dwBufferUsed, &dwPropertyCount)) 189 | { 190 | if (ERROR_INSUFFICIENT_BUFFER == (status = GetLastError())) 191 | { 192 | dwBufferSize = dwBufferUsed; 193 | pRenderedValues = (PEVT_VARIANT)malloc(dwBufferSize); 194 | if (pRenderedValues) 195 | { 196 | EvtRender(hContext, hEvent, EvtRenderEventValues, dwBufferSize, pRenderedValues, &dwBufferUsed, &dwPropertyCount); 197 | } 198 | else 199 | { 200 | wprintf(L"malloc failed\n"); 201 | status = ERROR_OUTOFMEMORY; 202 | if (hContext) 203 | EvtClose(hContext); 204 | 205 | if (pRenderedValues) 206 | free(pRenderedValues); 207 | 208 | return status; 209 | } 210 | } 211 | 212 | if (ERROR_SUCCESS != (status = GetLastError())) 213 | { 214 | wprintf(L"EvtRender failed with %d\n", GetLastError()); 215 | if (hContext) 216 | EvtClose(hContext); 217 | 218 | if (pRenderedValues) 219 | free(pRenderedValues); 220 | 221 | return status; 222 | } 223 | } 224 | 225 | // Print the values from the System section of the element. 226 | DWORD EventID = pRenderedValues[EvtSystemEventID].UInt16Val; 227 | if (EvtVarTypeNull != pRenderedValues[EvtSystemQualifiers].Type) 228 | { 229 | EventID = MAKELONG(pRenderedValues[EvtSystemEventID].UInt16Val, pRenderedValues[EvtSystemQualifiers].UInt16Val); 230 | } 231 | 232 | if (EventID == 506 || EventID == 42 || EventID == 187) { 233 | if (!systemalreadyawake) { 234 | receivedeventsleep = true; 235 | } 236 | } else if (EventID == 507 || EventID == 107) { 237 | if (!systemalreadyawake) { 238 | receivedeventwake = true; 239 | } 240 | if (EventID == 107) { 241 | // EventID 506 can be received right after an EventID 107 (happens on Laptops with Modern Standby enabled after Hibernation). 242 | // This variable is needed to not trigger the cleanup procedure again. 243 | systemalreadyawake = true; 244 | } 245 | } else if (EventID == 10111) { 246 | receivedeventdrivercrash = true; 247 | } 248 | 249 | if (hContext) 250 | EvtClose(hContext); 251 | 252 | if (pRenderedValues) 253 | free(pRenderedValues); 254 | 255 | return status; 256 | } 257 | 258 | // Helper function to log messages with error codes 259 | void LogError(const char* message, CONFIGRET cr) { 260 | char logMessage[256]; 261 | snprintf(logMessage, sizeof(logMessage), "%s (Error Code: %lu).", message, cr); 262 | Log(logMessage); 263 | } 264 | 265 | // Helper function to locate and check device node 266 | bool LocateAndCheckDeviceNode(const std::string& deviceInstanceId, DEVINST& devInst, ULONG& status, ULONG& problemNumber) { 267 | CONFIGRET cr = CM_Locate_DevNodeA(&devInst, const_cast(deviceInstanceId.c_str()), CM_LOCATE_DEVNODE_NORMAL); 268 | if (cr != CR_SUCCESS) { 269 | LogError("Failed to locate device node", cr); 270 | return false; 271 | } 272 | 273 | cr = CM_Get_DevNode_Status(&status, &problemNumber, devInst, 0); 274 | if (cr != CR_SUCCESS) { 275 | LogError("Failed to get device node status", cr); 276 | return false; 277 | } 278 | 279 | return true; 280 | } 281 | 282 | // Function to disable the device 283 | bool DisableDevice(const std::string& deviceInstanceId) { 284 | DEVINST devInst; 285 | ULONG status, problemNumber; 286 | 287 | if (!LocateAndCheckDeviceNode(deviceInstanceId, devInst, status, problemNumber)) { 288 | return false; 289 | } 290 | 291 | CONFIGRET cr = CM_Disable_DevNode(devInst, 0); 292 | if (cr != CR_SUCCESS) { 293 | LogError("Failed to disable device node", cr); 294 | return false; 295 | } 296 | 297 | Log("Device disabled successfully."); 298 | return true; 299 | } 300 | 301 | // Function to enable the device 302 | bool EnableDevice(const std::string& deviceInstanceId) { 303 | DEVINST devInst; 304 | ULONG status, problemNumber; 305 | 306 | if (!LocateAndCheckDeviceNode(deviceInstanceId, devInst, status, problemNumber)) { 307 | return false; 308 | } 309 | 310 | CONFIGRET cr = CM_Enable_DevNode(devInst, 0); 311 | if (cr != CR_SUCCESS) { 312 | LogError("Failed to enable device node", cr); 313 | return false; 314 | } 315 | 316 | Log("Device enabled successfully."); 317 | return true; 318 | } 319 | 320 | // Function to recover the driver after a driver crash 321 | bool DriverRecover(const std::string& deviceInstanceId) { 322 | if (!DisableDevice(deviceInstanceId)) { 323 | return false; 324 | } 325 | std::this_thread::sleep_for(std::chrono::seconds(1)); 326 | if (!EnableDevice(deviceInstanceId)) { 327 | return false; 328 | } 329 | std::this_thread::sleep_for(std::chrono::seconds(1)); 330 | return true; 331 | } 332 | 333 | // Helper function to convert std::string to std::wstring 334 | std::wstring StringToWString(const std::string& str) { 335 | int len; 336 | int str_len = (int)str.length() + 1; 337 | len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str_len, 0, 0); 338 | std::wstring wstr(len, L'\0'); 339 | MultiByteToWideChar(CP_ACP, 0, str.c_str(), str_len, &wstr[0], len); 340 | return wstr; 341 | } 342 | 343 | // Helper function to convert std::string to BSTR 344 | BSTR ConvertStringToBSTR(const std::string& str) { 345 | std::wstring wstr = StringToWString(str); 346 | return SysAllocString(wstr.c_str()); 347 | } 348 | 349 | // Class for collecting info about connected monitors 350 | class MonitorInfo { 351 | public: 352 | std::vector friendlyDisplayNames; 353 | bool success; 354 | 355 | MonitorInfo() : success(false) {} 356 | }; 357 | 358 | // Function to retrieve friendly display names of all connected monitors 359 | MonitorInfo GetMonitorFriendlyNamesUsingWMI() { 360 | MonitorInfo monitorInfo; 361 | 362 | HRESULT hr; 363 | IWbemLocator *pLoc = nullptr; 364 | IWbemServices *pSvc = nullptr; 365 | IEnumWbemClassObject* pEnumerator = nullptr; 366 | 367 | // Initialize COM 368 | hr = CoInitializeEx(0, COINIT_MULTITHREADED); 369 | if (FAILED(hr)) { 370 | return monitorInfo; 371 | } 372 | 373 | // Initialize security 374 | hr = CoInitializeSecurity( 375 | NULL, 376 | -1, 377 | NULL, 378 | NULL, 379 | RPC_C_AUTHN_LEVEL_DEFAULT, 380 | RPC_C_IMP_LEVEL_IMPERSONATE, 381 | NULL, 382 | EOAC_NONE, 383 | NULL); 384 | 385 | if (FAILED(hr)) { 386 | CoUninitialize(); 387 | return monitorInfo; 388 | } 389 | 390 | // Obtain the initial locator to WMI 391 | hr = CoCreateInstance( 392 | CLSID_WbemLocator, 393 | 0, 394 | CLSCTX_INPROC_SERVER, 395 | IID_IWbemLocator, 396 | (LPVOID *)&pLoc); 397 | 398 | if (FAILED(hr)) { 399 | CoUninitialize(); 400 | return monitorInfo; 401 | } 402 | 403 | // Connect to the WMI namespace 404 | hr = pLoc->ConnectServer( 405 | ConvertStringToBSTR("ROOT\\WMI"), // WMI namespace 406 | NULL, // User name 407 | NULL, // User password 408 | NULL, // Locale 409 | 0, // Security flags 410 | 0, // Authority 411 | 0, // Context object 412 | &pSvc); // IWbemServices proxy 413 | 414 | if (FAILED(hr)) { 415 | pLoc->Release(); 416 | CoUninitialize(); 417 | return monitorInfo; 418 | } 419 | 420 | // Set security levels on the proxy 421 | hr = CoSetProxyBlanket( 422 | pSvc, 423 | RPC_C_AUTHN_WINNT, 424 | RPC_C_AUTHZ_NONE, 425 | NULL, 426 | RPC_C_AUTHN_LEVEL_CALL, 427 | RPC_C_IMP_LEVEL_IMPERSONATE, 428 | NULL, 429 | EOAC_NONE); 430 | 431 | if (FAILED(hr)) { 432 | pSvc->Release(); 433 | pLoc->Release(); 434 | CoUninitialize(); 435 | return monitorInfo; 436 | } 437 | 438 | // Use WMI to retrieve the friendly names of monitors 439 | hr = pSvc->ExecQuery( 440 | ConvertStringToBSTR("WQL"), 441 | ConvertStringToBSTR("SELECT * FROM WmiMonitorID"), 442 | WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 443 | NULL, 444 | &pEnumerator); 445 | 446 | if (FAILED(hr)) { 447 | pSvc->Release(); 448 | pLoc->Release(); 449 | CoUninitialize(); 450 | return monitorInfo; 451 | } 452 | 453 | // Get the data from the query 454 | IWbemClassObject *pclsObj = nullptr; 455 | ULONG uReturn = 0; 456 | 457 | while (pEnumerator) { 458 | hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); 459 | 460 | if (0 == uReturn) { 461 | break; 462 | } 463 | 464 | VARIANT vtProp; 465 | hr = pclsObj->Get(L"UserFriendlyName", 0, &vtProp, 0, 0); 466 | if (SUCCEEDED(hr)) { 467 | if (vtProp.vt == (VT_ARRAY | VT_I4)) { 468 | SAFEARRAY* sa = vtProp.parray; 469 | LONG* pVals; 470 | SafeArrayAccessData(sa, (void**)&pVals); 471 | 472 | std::wstring ws; 473 | for (LONG i = 0; i < (LONG)sa->rgsabound[0].cElements; ++i) { 474 | ws += static_cast(pVals[i]); 475 | } 476 | std::string monitorName(ws.begin(), ws.end()); 477 | monitorInfo.friendlyDisplayNames.push_back(monitorName); 478 | 479 | SafeArrayUnaccessData(sa); 480 | monitorInfo.success = true; 481 | } 482 | } 483 | VariantClear(&vtProp); 484 | 485 | pclsObj->Release(); 486 | } 487 | 488 | // Cleanup 489 | pSvc->Release(); 490 | pLoc->Release(); 491 | pEnumerator->Release(); 492 | CoUninitialize(); 493 | 494 | return monitorInfo; 495 | } 496 | 497 | // Function to check if ParsecVDA is among the friendly display names 498 | void CheckForParsecVDA() { 499 | while (running) { 500 | std::this_thread::sleep_for(std::chrono::seconds(1)); // Cannot be too long, otherwise joining the thread takes just as long aswell 501 | 502 | MonitorInfo monitorInfo = GetMonitorFriendlyNamesUsingWMI(); 503 | 504 | if (!monitorInfo.success) { 505 | ParsecVDAfound = true; // Added in the event the query fails, otherwise it would cause the program to always disconnect and reconnect the display 506 | return; 507 | } 508 | 509 | bool ParsecVDAresult = std::any_of(monitorInfo.friendlyDisplayNames.begin(), monitorInfo.friendlyDisplayNames.end(), [](const std::string& name) { 510 | return name.find("ParsecVDA") != std::string::npos; 511 | }); 512 | 513 | if (!ParsecVDAresult) { 514 | std::this_thread::sleep_for(std::chrono::seconds(3)); // This is triggered before the driver crash event. Ensures that this is only logged if its not a driver crash 515 | ParsecVDAfound = false; 516 | } 517 | } 518 | } 519 | 520 | // Function for disconnecting the display or doing the cleanup procedure in case of a driver crash or a lost display 521 | void SleepCrashAction() { 522 | while (!finalshutdown) { 523 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 524 | 525 | if (receivedeventsleep || receivedeventdrivercrash || !ParsecVDAfound) { 526 | if (!cleanupstarted) { 527 | if (receivedeventdrivercrash) { 528 | Log("Driver crashed!"); 529 | } 530 | else if (receivedeventsleep) { 531 | Log("Cleanup code reached!"); 532 | } 533 | else if (!ParsecVDAfound) { 534 | Log("ParsecVDA not found!"); 535 | } 536 | cleanupstarted = true; // Solves reaching the cleanup procedure twice, because it it quite common to receive EventID 187 and 42 right after each other 537 | running = false; 538 | suspend = true; 539 | if (receivedeventsleep) { 540 | for (int index : displays) { 541 | VddRemoveDisplay(vdd, index); 542 | } 543 | } 544 | if (updater.joinable()) { 545 | updater.join(); 546 | } 547 | if (CheckForParsecVDAThread.joinable()) { 548 | CheckForParsecVDAThread.join(); 549 | } 550 | // Close the device handle. 551 | CloseDeviceHandle(vdd); 552 | Log("Cleanup done!"); 553 | stopmainloop = true; // In the end, so that the main loop not finishes until cleanup routine is done 554 | } 555 | } 556 | } 557 | } 558 | 559 | // Function for connecting the monitor 560 | int MainLoop() { 561 | Log("New Session started!"); 562 | 563 | // Check driver status. 564 | bool firstattemptfail = false; 565 | DeviceStatus status = QueryDeviceStatus(&VDD_CLASS_GUID, VDD_HARDWARE_ID); 566 | if (status != DEVICE_OK) { 567 | Log("Parsec VDD device is not OK. Trying to recover the driver!"); 568 | if (DriverRecover(deviceInstanceId)) { 569 | DeviceStatus status = QueryDeviceStatus(&VDD_CLASS_GUID, VDD_HARDWARE_ID); 570 | if (status != DEVICE_OK) { 571 | firstattemptfail = true; 572 | Log("Parsec VDD device is not OK. Trying a second time!"); 573 | } 574 | else if (status == DEVICE_OK) { 575 | Log("Parsec VDD device recovered!"); 576 | } 577 | } 578 | else { 579 | firstattemptfail = true; 580 | Log("Parsec VDD device is not OK. Trying a second time!"); 581 | } 582 | if (firstattemptfail == true) { 583 | std::this_thread::sleep_for(std::chrono::seconds(2)); 584 | if (DriverRecover(deviceInstanceId)) { 585 | DeviceStatus status = QueryDeviceStatus(&VDD_CLASS_GUID, VDD_HARDWARE_ID); 586 | if (status != DEVICE_OK) { 587 | Log("Parsec VDD device is not OK. Exiting program!"); 588 | return 1; 589 | } 590 | Log("Parsec VDD device recovered!"); 591 | } 592 | else { 593 | Log("Parsec VDD device is not OK. Exiting program!"); 594 | return 1; 595 | } 596 | } 597 | } 598 | 599 | // Obtain device handle. 600 | vdd = OpenDeviceHandle(&VDD_ADAPTER_GUID); 601 | if (vdd == NULL || vdd == INVALID_HANDLE_VALUE) { 602 | Log("Failed to obtain the device handle. Trying a second time!"); 603 | std::this_thread::sleep_for(std::chrono::seconds(2)); 604 | if (vdd == NULL || vdd == INVALID_HANDLE_VALUE) { 605 | Log("Failed to obtain the device handle. Exiting program!"); 606 | return 1; 607 | } 608 | } 609 | 610 | // Side thread for updating vdd. 611 | updater = std::thread([] { 612 | while (running) { 613 | VddUpdate(vdd); 614 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 615 | } 616 | }); 617 | 618 | //Ad the Display 619 | if (displays.size() < VDD_MAX_DISPLAYS) { 620 | int index = VddAddDisplay(vdd); 621 | displays.push_back(index); 622 | displays.resize(index+1); // Important! Without it, the size increases in every run of the MainLoop! 623 | char logMessageDisplay[100]; 624 | snprintf(logMessageDisplay, sizeof(logMessageDisplay), "Added a new virtual display, index: %d.", index); 625 | Log(logMessageDisplay); 626 | } 627 | else { 628 | Log("Limit exceeded, could not add more virtual displays."); 629 | } 630 | 631 | // Start the thread to periodically check if display is still connected 632 | CheckForParsecVDAThread = std::thread(CheckForParsecVDA); 633 | 634 | // Let the program run indefinitely 635 | while (running || !stopmainloop) { 636 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Sleep briefly to avoid high CPU usage 637 | } 638 | 639 | return 0; 640 | } 641 | 642 | int main() { 643 | 644 | // Open log file 645 | if (!OpenLogFile()) { 646 | printf("Error opening log file.\n"); 647 | return 1; 648 | } 649 | 650 | // Set console control handler to listen for CTRL_C_EVENT 651 | if (!SetConsoleCtrlHandler(ConsoleHandler, TRUE)) { 652 | Log("Error setting console control handler."); 653 | return 1; 654 | } 655 | 656 | // Start the threads to periodically check for system events and execute sleep action 657 | std::thread SystemEventThread(CheckSystemEventLog); 658 | std::thread SleepCrashActionThread(SleepCrashAction); 659 | 660 | // Start the main loop and manage the occurring states 661 | while (!finalshutdown) { 662 | if (!suspend) { 663 | MainLoopResult = MainLoop(); 664 | if (MainLoopResult != 0) { 665 | finalshutdown = true; 666 | } 667 | } 668 | else if (suspend) { 669 | if (receivedeventsleep) { 670 | Log("Suspend stage reached."); 671 | while (!receivedeventwake) { 672 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 673 | } 674 | // Prevent race hazard between !receivedeventwake and systemalreadyawake 675 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 676 | } 677 | // Second waiting time is necessary for three reasons: 678 | // EventID 107 is received so early, that adding a virtual display right after receiving the message is in some cases not possible. 679 | // Furthermore, while systemalreadyawake is true, other EventIDs (506 and 507 after waking from hibernation with modern standby enabled) 680 | // can not be triggered, as intended, because we already received a wakeup event. 681 | // In the event of driver crash a waiting time is necessary before the Parsec Virtual Display Adapter can be disabled and re-enabled. 682 | if (systemalreadyawake || receivedeventdrivercrash || !ParsecVDAfound) { 683 | std::this_thread::sleep_for(std::chrono::seconds(3)); 684 | } 685 | receivedeventsleep = false; 686 | receivedeventwake = false; 687 | receivedeventdrivercrash = false; 688 | systemalreadyawake = false; 689 | ParsecVDAfound = true; 690 | suspend = false; 691 | running = true; 692 | cleanupstarted = false; 693 | stopmainloop = false; 694 | } 695 | } 696 | 697 | // Join the threads 698 | if (SystemEventThread.joinable()) { 699 | SystemEventThread.join(); 700 | } 701 | if (SleepCrashActionThread.joinable()) { 702 | SleepCrashActionThread.join(); 703 | } 704 | 705 | Log("Program is closing!"); 706 | fclose(logfile); // Close log file 707 | 708 | return MainLoopResult; 709 | } -------------------------------------------------------------------------------- /ParsecVDAAC.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ParsecVDAAC 5 | ParsecVDA - Always Connected 6 | This service adds a Virtual Display to your system. 7 | 8 | 9 | %BASE%\ParsecVDA - Always Connected.exe 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

ParsecVDA - Always Connected

4 |

5 | Connects a Virtual Display to your PC 6 |
7 | and allows for a headless operation - 8 |
9 | no need for Dummy Plugs anymore! 10 |

11 |

12 | 13 |
14 | 15 | ## ℹ About 16 | 17 | This project is based on the "parsec-vdd" project from nomi-san. It adds a Virtual Display to your system by using the [Parsec VDD Driver](https://support.parsec.app/hc/en-us/articles/4422939339789-Overview-Prerequisites-and-Installation), without relying on the [Parsec app](https://parsec.app/). 18 | 19 | With the newest release this application runs as a service in the background by using the Windows Service Wrapper [winsw](https://github.com/winsw/winsw). The Virtual Display will stay connected until the next shutdown or restart even when disconnecting through remote apps like Parsec, which is an important feature of this project. 20 | 21 | The latest update also allows the program to correctly handle sleep and hibernation events. Modern Standby is also supported. 22 | 23 | With this application it is possible to run a PC completely headless without relying on Dummy Plugs. 24 | 25 | Furthermore this program can be used in the Hyper-V environment in combination with GPU-Paravirtualization (see GPU-PV) where it is not possible to disconnect the Hyper-V-Monitor which leads to Parsec not automatically falling back to its Virtual Display. This program adds a Virtual Display nonetheless. 26 | 27 | 28 | 29 | > The Virtual Display Driver (VDD) is required to enable virtual displays on a Windows host. Virtual displays is a feature available for **Teams** and **Warp** customers that lets you add up to 3 additional virtual displays to the host while connecting to a machine you own through Parsec. 30 | 31 | > **Parsec VDD** is a perfect software driver developed by Parsec. It utilizes the [IddCx API](https://learn.microsoft.com/en-us/windows-hardware/drivers/display/indirect-display-driver-model-overview) (Indirect Display Driver) to create virtual displays on Windows 10+. This virtual display is particularly useful in situations where a physical monitor may not be available or when additional screens are desired. 32 | 33 | > One of the notable features of Parsec VDD is its support for a wide range of [resolutions and refresh rates](#preset-display-modes), including up to 4K and 240 Hz. This makes it well-suited for gaming, as it can provide a high-quality visual experience. It enables users to simulate the presence of additional screens or work without a physical monitor, enhancing flexibility and customization in display management. 34 | 35 | 36 | ## Steps to get it running: 37 | 38 | 1. Download the latest release and follow the instructions of the Setup Wizard. 39 | 40 | That's all you have to do! A Virtual Display should be added to your system! 41 | 42 | 43 | ## Notes: 44 | 45 | - If you receive a Windows Defender Smartscreen prompt when executing the setup, click on "More info" and then on "Run anyway". 46 | - You will hear a connect/disconnect sound at startup/shutdown and at sleep/hibernation events because the Virtual Display is added/removed at every start/shutdown or sleep/hibernation event. 47 | - If you're using this program together with Parsec, you have to make sure that "Fallback to Virtual Display" in the Parsec App settings under Host is set to off. 48 | - The program also creates a basic logfile in its working directory. 49 | - If you used the application before version 1.2.0, please uninstall it before installing the new version. 50 | 51 | ## Stopping the service: 52 | 53 | If you want to stop the service, are encountering problems or if you want to remove the screen, type "Services" in the Windows search bar and open the application with the same name. Look for the service "ParsecVDA - Always Connected". After clicking on it options for stopping or restarting the service are in the left upper corner. 54 | 55 | ## 😥 Known Limitations 56 | 57 | > This list shows the known limitations of Parsec VDD. 58 | 59 | ### 1. HDR support 60 | 61 | Parsec VDD does not support HDR on its displays (see the EDID below). Theoretically, you can unlock support by editing the EDID, then adding HDR metadata and setting 10-bit+ color depth. Unfortunately, you cannot flash its firmware like a physical device, or modify the registry value. 62 | 63 | All IDDs have their own fixed EDID block inside the driver binary to initialize the monitor specs. So the solution is to modify this block in the driver DLL (mm.dll), then reinstall it with nefconw CLI (see Readme instructions in the project "parsec-vdd" from nomi-san). 64 | 65 | 66 | ### 2. Custom resolutions 67 | 68 | Before connecting, the virtual display looks in the `HKEY_LOCAL_MACHINE\SOFTWARE\Parsec\vdd` registry for additional preset resolutions. Currently this supports a maximum of 5 values. 69 | 70 | ``` 71 | SOFTWARE\Parsec\vdd 72 | key: 0 -> 5 | (width, height, hz) 73 | ``` 74 | 75 | To unlock this limit, you need to patch the driver DLL the same way as above, but **5 is enough** for personal use. 76 | 77 | ## 😑 Known Bugs 78 | 79 | > This is a list of known issues when working with standalone Parsec VDD. 80 | 81 | ### 1. Incompatible with Parsec Privacy Mode 82 | 83 | ![Alt text](https://i.imgur.com/C74IRgC.png) 84 | 85 | If you have enabled "Privacy Mode" in Parsec Host settings, please disable it and clear the connected display configruations in the following Registry path. 86 | 87 | ``` 88 | HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Connectivity 89 | ``` 90 | 91 | This option causes your main display to turn off when virtual displays are added, making it difficult to turn the display on and disrupting the remote desktop session. 92 | 93 | ## 🤔 Comparison with other IDDs 94 | 95 | The table below shows a comparison with other popular Indirect Display Driver projects. 96 | 97 | | Project | Iddcx version | Signed | Gaming | HDR | H-Cursor | Tweakable | Controller 98 | | :-- | :--: | :--: | :--: | :--: | :--: | :-: | :-: 99 | | [usbmmidd_v2] | | ✅ | ❌ | ❌ | ❌ | | 100 | | [IddSampleDriver] | 1.2 | ❌ | ❌ | ❌ | ❌ | | 101 | | [RustDeskIddDriver] | 1.2 | ❌ | ❌ | ❌ | ❌ | | 102 | | [Virtual-Display-Driver (HDR)] | 1.10 | ❌ | | ✅ | ❌ | | 103 | | [virtual-display-rs] | 1.5 | ❌ | | ❌ | ❌ | ✅ | ✅ 104 | | parsec-vdd | 1.4 | ✅ | ✅ | ❌ | ✅ | 🆗 | ✅ 105 | 106 | ✅ - full support, 🆗 - limited support 107 | 108 | [usbmmidd_v2]: https://www.amyuni.com/forum/viewtopic.php?t=3030 109 | [IddSampleDriver]: https://github.com/roshkins/IddSampleDriver 110 | [RustDeskIddDriver]: https://github.com/fufesou/RustDeskIddDriver 111 | [virtual-display-rs]: https://github.com/MolotovCherry/virtual-display-rs 112 | [Virtual-Display-Driver (HDR)]: https://github.com/itsmikethetech/Virtual-Display-Driver 113 | 114 | **Signed** means that the driver files have a valid digital signature. 115 | **H-Cursor** means hardware cursor support, without it you will get double cursor on some remote desktop apps. 116 | **Tweakable** is the ability to customize display modes. Visit [MSDN IddCx versions](https://learn.microsoft.com/en-us/windows-hardware/drivers/display/iddcx-versions) to check the minimum supported Windows version. 117 | 118 | ## 📘 Parsec VDD Specs 119 | 120 | ### Preset display modes 121 | 122 | All of the following display modes are set by driver default. 123 | 124 | | Resolution | Common name | Aspect ratio | Refresh rates (Hz) 125 | | - | :-: | :-: | :-: 126 | | 4096 x 2160 | DCI 4K | 1.90:1 (256:135) | 24/30/60/144/240 127 | | 3840 x 2160 | 4K UHD | 16:9 | 24/30/60/144/240 128 | | 3840 x 1600 | UltraWide | 24:10 | 24/30/60/144/240 129 | | 3840 x 1080 | UltraWide | 32:9 (2x 16:9 FHD) | 24/30/60/144/240 130 | | 3440 x 1440 | | 21.5:9 (43:18) | 24/30/60/144/240 131 | | 3240 x 2160 | | 3:2 | 60 132 | | 3200 x 1800 | 3K | 16:9 | 24/30/60/144/240 133 | | 3000 x 2000 | | 3:2 | 60 134 | | 2880 x 1800 | 2.8K | 16:10 | 60 135 | | 2880 x 1620 | 2.8K | 16:9 | 24/30/60/144/240 136 | | 2736 x 1824 | | | 60 137 | | 2560 x 1600 | 2K | 16:10 | 24/30/60/144/240 138 | | 2560 x 1440 | 2K | 16:9 | 24/30/60/144/240 139 | | 2560 x 1080 | UltraWide | 21:9 | 24/30/60/144/240 140 | | 2496 x 1664 | | | 60 141 | | 2256 x 1504 | | | 60 142 | | 2048 x 1152 | | | 60/144/240 143 | | 1920 x 1200 | FHD | 16:10 | 60/144/240 144 | |**1920 x 1080**| **FHD** | **16:9** | 24/30/**60**/144/240 145 | | 1800 x 1200 | FHD | 3:2 | 60 146 | | 1680 x 1050 | HD+ | 16:10 | 60/144/240 147 | | 1600 x 1200 | HD+ | 4:3 | 24/30/60/144/240 148 | | 1600 x 900 | HD+ | 16:9 | 60/144/240 149 | | 1440 x 900 | HD | 16:10 | 60/144/240 150 | | 1366 x 768 | | | 60/144/240 151 | | 1280 x 800 | HD | 16:10 | 60/144/240 152 | | 1280 x 720 | HD | 16:9 | 60/144/240 153 | 154 | Notes: 155 | - Low GPUs, e.g GTX 1650 will not support the highest DCI 4K. 156 | - All resolutions are compatible with 60 Hz refresh rates. 157 | 158 | 159 | ### Adapter info 160 | 161 | - Name: `Parsec Virtual Display Adapter` 162 | - Hardware ID: `Root\Parsec\VDA` 163 | - Adapter GUID: `{00b41627-04c4-429e-a26e-0265cf50c8fa}` 164 | - Class GUID: `{4d36e968-e325-11ce-bfc1-08002be10318}` 165 | 166 | ### Monitor info 167 | 168 | - ID: `PSCCDD0` 169 | - Name: `ParsecVDA` 170 | - EDID: 171 | 172 | ``` 173 | 00 FF FF FF FF FF FF 00 42 63 D0 CD ED 5F 84 00 174 | 11 1E 01 04 A5 35 1E 78 3B 57 E0 A5 54 4F 9D 26 175 | 12 50 54 27 CF 00 71 4F 81 80 81 40 81 C0 81 00 176 | 95 00 B3 00 01 01 86 6F 80 A0 70 38 40 40 30 20 177 | 35 00 E0 0E 11 00 00 1A 00 00 00 FD 00 30 A5 C1 178 | C1 29 01 0A 20 20 20 20 20 20 00 00 00 FC 00 50 179 | 61 72 73 65 63 56 44 41 0A 20 20 20 00 00 00 10 180 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 C6 181 | 02 03 10 00 4B 90 05 04 03 02 01 11 12 13 14 1F 182 | 8A 4D 80 A0 70 38 2C 40 30 20 35 00 E0 0E 11 00 183 | 00 1A FE 5B 80 A0 70 38 35 40 30 20 35 00 E0 0E 184 | 11 00 00 1A FC 7E 80 88 70 38 12 40 18 20 35 00 185 | E0 0E 11 00 00 1E A4 9C 80 A0 70 38 59 40 30 20 186 | 35 00 E0 0E 11 00 00 1A 02 3A 80 18 71 38 2D 40 187 | 58 2C 45 00 E0 0E 11 00 00 1E 00 00 00 00 00 00 188 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A6 189 | ``` 190 | 191 | Visit http://www.edidreader.com/ to view it online or use an advanced tool [AW EDID Editor](https://www.analogway.com/apac/products/software-tools/aw-edid-editor/) 192 | -------------------------------------------------------------------------------- /Setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | 4 | IF "%1"=="install" ( 5 | rem Run install and start commands 6 | ParsecVDAAC.exe install 7 | ParsecVDAAC.exe start 8 | ) 9 | 10 | IF "%1"=="uninstall" ( 11 | rem Run stop and uninstall commands, delete created files 12 | ParsecVDAAC.exe stopwait 13 | ParsecVDAAC.exe uninstall 14 | del "%~dp0Logfile ParsecVDA - Always Connected.txt" 15 | del "%~dp0ParsecVDAAC.err.log" 16 | del "%~dp0ParsecVDAAC.out.log" 17 | del "%~dp0ParsecVDAAC.wrapper.log" 18 | ) 19 | 20 | IF "%1"=="" ( 21 | echo Missing argument! Valid arguments are "install" or "uninstall". 22 | ) 23 | 24 | endlocal -------------------------------------------------------------------------------- /Setup.iss: -------------------------------------------------------------------------------- 1 | #define MyAppName "ParsecVDA - Always Connected" 2 | #define MyAppVersion "1.4.1" 3 | #define MyAppURL "https://github.com/timminator/ParsecVDA-Always-Connected" 4 | #define MyAppExeName "ParsecVDA - Always Connected.exe" 5 | 6 | #define _Major 7 | #define _Minor 8 | #define _Rev 9 | #define _Build 10 | #define VddVersion GetVersionComponents(".\parsec-vdd-setup.exe", _Major, _Minor, _Rev, _Build), Str(_Major) + "." + Str(_Minor) 11 | 12 | [Setup] 13 | SignTool=signtool $f 14 | AppId={{4EC2E655-53B0-4B4A-A3C9-42C445FA22CE} 15 | AppName={#MyAppName} 16 | AppVersion={#MyAppVersion} 17 | AppPublisherURL={#MyAppURL} 18 | AppSupportURL={#MyAppURL} 19 | AppUpdatesURL={#MyAppURL} 20 | DefaultDirName={commonpf64}\{#MyAppName} 21 | UsePreviousAppDir=yes 22 | LicenseFile=..\..\LICENSE 23 | DisableProgramGroupPage=yes 24 | PrivilegesRequired=admin 25 | OutputBaseFilename={#MyAppName}-v{#MyAppVersion}-setup-x64 26 | SetupIconFile=..\..\parsec.ico 27 | Compression=lzma 28 | SolidCompression=yes 29 | WizardStyle=classic 30 | UninstallDisplayName={#MyAppName} 31 | UninstallDisplayIcon={app}\{#MyAppExeName} 32 | 33 | [Languages] 34 | Name: "english"; MessagesFile: "compiler:Default.isl" 35 | 36 | [Messages] 37 | SelectTasksLabel2=Select the additional tasks you would like Setup to perform.%nParsecVDA - Always Connected requires the Parsec Virtual Display Driver. If the driver is already installed, you can uncheck this task. To continue, click Next. 38 | FinishedLabel=Setup has finished installing [name] on your computer.%n%nAdditional notice: If you are using this software in combination with the Parsec App, make sure that under Settings > Host > "Fallback to Virtual Display" is set to off. 39 | 40 | [Dirs] 41 | Name: "{app}"; Permissions: everyone-full 42 | 43 | [Files] 44 | Source: ".\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion 45 | Source: ".\parsec-vdd-setup.exe"; DestDir: "{app}\driver" 46 | Source: ".\Setup.bat"; DestDir: "{app}"; Flags: ignoreversion 47 | Source: ".\CheckPrerequisites.bat"; DestDir: "{app}"; Flags: ignoreversion 48 | Source: ".\ParsecVDAAC.xml"; DestDir: "{app}"; Flags: onlyifdoesntexist 49 | Source: ".\ParsecVDAAC.exe"; DestDir: "{app}"; Flags: onlyifdoesntexist 50 | Source: ".\LICENSE_parsec-vdd.txt"; Flags: dontcopy 51 | Source: ".\LICENSE_winsw.txt"; Flags: dontcopy 52 | 53 | [Code] 54 | procedure RunBatchFile(FileName: String; WorkingDir: String); 55 | var 56 | ResultCode: Integer; 57 | begin 58 | Exec(ExpandConstant(FileName), '', WorkingDir, SW_HIDE, ewWaitUntilTerminated, ResultCode); 59 | end; 60 | 61 | function PrepareToInstall(var NeedsRestart: Boolean): String; 62 | begin 63 | ExtractTemporaryFile('CheckPrerequisites.bat'); 64 | RunBatchFile('{tmp}\CheckPrerequisites.bat', ExpandConstant('{app}')); 65 | Result := ''; 66 | end; 67 | 68 | var 69 | LicenseAcceptedRadioButtons: array of TRadioButton; 70 | 71 | procedure CheckLicenseAccepted(Sender: TObject); 72 | begin 73 | // Update Next button when user (un)accepts the license 74 | WizardForm.NextButton.Enabled := 75 | LicenseAcceptedRadioButtons[TComponent(Sender).Tag].Checked; 76 | end; 77 | 78 | procedure LicensePageActivate(Sender: TWizardPage); 79 | begin 80 | // Update Next button when user gets to second license page 81 | CheckLicenseAccepted(LicenseAcceptedRadioButtons[Sender.Tag]); 82 | end; 83 | 84 | function CloneLicenseRadioButton( 85 | Page: TWizardPage; Source: TRadioButton): TRadioButton; 86 | begin 87 | Result := TRadioButton.Create(WizardForm); 88 | Result.Parent := Page.Surface; 89 | Result.Caption := Source.Caption; 90 | Result.Left := Source.Left; 91 | Result.Top := Source.Top; 92 | Result.Width := Source.Width; 93 | Result.Height := Source.Height; 94 | // Needed for WizardStyle=modern / WizardResizable=yes 95 | Result.Anchors := Source.Anchors; 96 | Result.OnClick := @CheckLicenseAccepted; 97 | Result.Tag := Page.Tag; 98 | end; 99 | 100 | var 101 | LicenseAfterPage: Integer; 102 | 103 | procedure AddLicensePage(LicenseFileName: string); 104 | var 105 | Idx: Integer; 106 | Page: TOutputMsgMemoWizardPage; 107 | LicenseFilePath: string; 108 | RadioButton: TRadioButton; 109 | begin 110 | Idx := GetArrayLength(LicenseAcceptedRadioButtons); 111 | SetArrayLength(LicenseAcceptedRadioButtons, Idx + 1); 112 | 113 | Page := 114 | CreateOutputMsgMemoPage( 115 | LicenseAfterPage, SetupMessage(msgWizardLicense), 116 | SetupMessage(msgLicenseLabel), SetupMessage(msgLicenseLabel3), ''); 117 | Page.Tag := Idx; 118 | 119 | // Shrink license box to make space for radio buttons 120 | Page.RichEditViewer.Height := WizardForm.LicenseMemo.Height; 121 | Page.OnActivate := @LicensePageActivate; 122 | 123 | // Load license 124 | // Loading ex-post, as Lines.LoadFromFile supports UTF-8, 125 | // contrary to LoadStringFromFile. 126 | ExtractTemporaryFile(LicenseFileName); 127 | LicenseFilePath := ExpandConstant('{tmp}\' + LicenseFileName); 128 | Page.RichEditViewer.Lines.LoadFromFile(LicenseFilePath); 129 | DeleteFile(LicenseFilePath); 130 | 131 | // Clone accept/do not accept radio buttons 132 | RadioButton := 133 | CloneLicenseRadioButton(Page, WizardForm.LicenseAcceptedRadio); 134 | LicenseAcceptedRadioButtons[Idx] := RadioButton; 135 | 136 | RadioButton := 137 | CloneLicenseRadioButton(Page, WizardForm.LicenseNotAcceptedRadio); 138 | // Initially not accepted 139 | RadioButton.Checked := True; 140 | 141 | LicenseAfterPage := Page.ID; 142 | end; 143 | 144 | procedure InitializeWizard(); 145 | begin 146 | LicenseAfterPage := wpLicense; 147 | AddLicensePage('LICENSE_parsec-vdd.txt'); 148 | AddLicensePage('LICENSE_winsw.txt'); 149 | end; 150 | 151 | var 152 | isSilent: Boolean; 153 | 154 | function InitializeSetup(): Boolean; 155 | var 156 | j: Integer; 157 | begin 158 | Result := True; 159 | IsSilent := False; 160 | for j := 1 to ParamCount do 161 | begin 162 | if (CompareText(ParamStr(j), '/verysilent') = 0) or 163 | (CompareText(ParamStr(j), '/silent') = 0) then 164 | begin 165 | IsSilent := True; 166 | Break; 167 | end; 168 | end; 169 | end; 170 | 171 | procedure CurPageChanged(CurPageID: Integer); 172 | var 173 | I: Integer; 174 | begin 175 | // Automatically accept licenses if running in silent mode 176 | if IsSilent then 177 | begin 178 | for I := 0 to GetArrayLength(LicenseAcceptedRadioButtons) - 1 do 179 | begin 180 | LicenseAcceptedRadioButtons[I].Checked := True; 181 | end; 182 | end; 183 | end; 184 | 185 | [Tasks] 186 | Name: install_vdd; Description: "Install Parsec VDD v{#VddVersion}" 187 | 188 | [Icons] 189 | Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 190 | 191 | [Run] 192 | Filename: "{app}\driver\parsec-vdd-setup.exe"; Parameters: "/S"; Flags: runascurrentuser; Tasks: install_vdd 193 | Filename: "{app}\Setup.bat"; Parameters: "install"; Flags: runhidden 194 | 195 | [UninstallRun] 196 | Filename: "{app}\Setup.bat"; Parameters: "uninstall"; Flags: runhidden -------------------------------------------------------------------------------- /parsec-vdd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Nguyen Duy All rights reserved. 3 | * GitHub repo: https://github.com/nomi-san/parsec-vdd/ 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | */ 27 | 28 | #ifndef __PARSEC_VDD_H 29 | #define __PARSEC_VDD_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef _MSC_VER 36 | #pragma comment(lib, "cfgmgr32.lib") 37 | #pragma comment(lib, "setupapi.lib") 38 | #endif 39 | 40 | #ifdef __cplusplus 41 | namespace parsec_vdd 42 | { 43 | #endif 44 | 45 | // Device helper. 46 | ////////////////////////////////////////////////// 47 | 48 | typedef enum { 49 | DEVICE_OK = 0, // Ready to use 50 | DEVICE_INACCESSIBLE, // Inaccessible 51 | DEVICE_UNKNOW, // Unknow status 52 | DEVICE_UNKNOW_PROBLEM, // Unknow problem 53 | DEVICE_DISABLED, // Device is disabled 54 | DEVICE_DRIVER_ERROR, // Device encountered error 55 | DEVICE_RESTART_REQUIRED, // Must restart PC to use (could ignore but would have issue) 56 | DEVICE_DISABLED_SERVICE, // Service is disabled 57 | DEVICE_NOT_INSTALLED // Driver is not installed 58 | } DeviceStatus; 59 | 60 | /** 61 | * Query the driver status. 62 | * 63 | * @param classGuid The GUID of the class. 64 | * @param deviceId The device/hardware ID of the driver. 65 | * @return DeviceStatus 66 | */ 67 | static DeviceStatus QueryDeviceStatus(const GUID *classGuid, const char *deviceId) 68 | { 69 | DeviceStatus status = DEVICE_INACCESSIBLE; 70 | 71 | SP_DEVINFO_DATA devInfoData; 72 | ZeroMemory(&devInfoData, sizeof(SP_DEVINFO_DATA)); 73 | devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); 74 | 75 | HDEVINFO devInfo = SetupDiGetClassDevsA(classGuid, NULL, NULL, DIGCF_PRESENT); 76 | 77 | if (devInfo != INVALID_HANDLE_VALUE) 78 | { 79 | BOOL foundProp = FALSE; 80 | UINT deviceIndex = 0; 81 | 82 | do 83 | { 84 | if (!SetupDiEnumDeviceInfo(devInfo, deviceIndex, &devInfoData)) 85 | break; 86 | 87 | DWORD requiredSize = 0; 88 | SetupDiGetDeviceRegistryPropertyA(devInfo, &devInfoData, 89 | SPDRP_HARDWAREID, NULL, NULL, 0, &requiredSize); 90 | 91 | if (requiredSize > 0) 92 | { 93 | DWORD regDataType = 0; 94 | LPBYTE propBuffer = (LPBYTE)calloc(1, requiredSize); 95 | 96 | if (SetupDiGetDeviceRegistryPropertyA( 97 | devInfo, 98 | &devInfoData, 99 | SPDRP_HARDWAREID, 100 | ®DataType, 101 | propBuffer, 102 | requiredSize, 103 | &requiredSize)) 104 | { 105 | if (regDataType == REG_SZ || regDataType == REG_MULTI_SZ) 106 | { 107 | for (LPCSTR cp = (LPCSTR)propBuffer; ; cp += lstrlenA(cp) + 1) 108 | { 109 | if (!cp || *cp == 0 || cp >= (LPCSTR)(propBuffer + requiredSize)) 110 | { 111 | status = DEVICE_NOT_INSTALLED; 112 | goto except; 113 | } 114 | 115 | if (lstrcmpA(deviceId, cp) == 0) 116 | break; 117 | } 118 | 119 | foundProp = TRUE; 120 | ULONG devStatus, devProblemNum; 121 | 122 | if (CM_Get_DevNode_Status(&devStatus, &devProblemNum, devInfoData.DevInst, 0) != CR_SUCCESS) 123 | { 124 | status = DEVICE_NOT_INSTALLED; 125 | goto except; 126 | } 127 | 128 | if ((devStatus & (DN_DRIVER_LOADED | DN_STARTED)) != 0) 129 | { 130 | status = DEVICE_OK; 131 | } 132 | else if ((devStatus & DN_HAS_PROBLEM) != 0) 133 | { 134 | switch (devProblemNum) 135 | { 136 | case CM_PROB_NEED_RESTART: 137 | status = DEVICE_RESTART_REQUIRED; 138 | break; 139 | case CM_PROB_DISABLED: 140 | case CM_PROB_HARDWARE_DISABLED: 141 | status = DEVICE_DISABLED; 142 | break; 143 | case CM_PROB_DISABLED_SERVICE: 144 | status = DEVICE_DISABLED_SERVICE; 145 | break; 146 | default: 147 | if (devProblemNum == CM_PROB_FAILED_POST_START) 148 | status = DEVICE_DRIVER_ERROR; 149 | else 150 | status = DEVICE_UNKNOW_PROBLEM; 151 | break; 152 | } 153 | } 154 | else 155 | { 156 | status = DEVICE_UNKNOW; 157 | } 158 | } 159 | } 160 | 161 | except: 162 | free(propBuffer); 163 | } 164 | 165 | ++deviceIndex; 166 | } while (!foundProp); 167 | 168 | if (!foundProp && GetLastError() != 0) 169 | status = DEVICE_NOT_INSTALLED; 170 | 171 | SetupDiDestroyDeviceInfoList(devInfo); 172 | } 173 | 174 | return status; 175 | } 176 | 177 | /** 178 | * Obtain the device handle. 179 | * Returns NULL or INVALID_HANDLE_VALUE if fails, otherwise a valid handle. 180 | * Should call CloseDeviceHandle to close this handle after use. 181 | * 182 | * @param interfaceGuid The adapter/interface GUID of the target device. 183 | * @return HANDLE 184 | */ 185 | static HANDLE OpenDeviceHandle(const GUID *interfaceGuid) 186 | { 187 | HANDLE handle = INVALID_HANDLE_VALUE; 188 | HDEVINFO devInfo = SetupDiGetClassDevsA(interfaceGuid, 189 | NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); 190 | 191 | if (devInfo != INVALID_HANDLE_VALUE) 192 | { 193 | SP_DEVICE_INTERFACE_DATA devInterface; 194 | ZeroMemory(&devInterface, sizeof(SP_DEVICE_INTERFACE_DATA)); 195 | devInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); 196 | 197 | for (DWORD i = 0; SetupDiEnumDeviceInterfaces(devInfo, NULL, interfaceGuid, i, &devInterface); ++i) 198 | { 199 | DWORD detailSize = 0; 200 | SetupDiGetDeviceInterfaceDetailA(devInfo, &devInterface, NULL, 0, &detailSize, NULL); 201 | 202 | SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_A *)calloc(1, detailSize); 203 | detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); 204 | 205 | if (SetupDiGetDeviceInterfaceDetailA(devInfo, &devInterface, detail, detailSize, &detailSize, NULL)) 206 | { 207 | handle = CreateFileA(detail->DevicePath, 208 | GENERIC_READ | GENERIC_WRITE, 209 | FILE_SHARE_READ | FILE_SHARE_WRITE, 210 | NULL, 211 | OPEN_EXISTING, 212 | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED | FILE_FLAG_WRITE_THROUGH, 213 | NULL); 214 | 215 | if (handle != NULL && handle != INVALID_HANDLE_VALUE) 216 | break; 217 | } 218 | 219 | free(detail); 220 | } 221 | 222 | SetupDiDestroyDeviceInfoList(devInfo); 223 | } 224 | 225 | return handle; 226 | } 227 | 228 | /* Release the device handle */ 229 | static void CloseDeviceHandle(HANDLE handle) 230 | { 231 | if (handle != NULL && handle != INVALID_HANDLE_VALUE) 232 | CloseHandle(handle); 233 | } 234 | 235 | // Parsec VDD core. 236 | ////////////////////////////////////////////////// 237 | 238 | // Display name info. 239 | static const char *VDD_DISPLAY_ID = "PSCCDD0"; // You will see it in registry (HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY) 240 | static const char *VDD_DISPLAY_NAME = "ParsecVDA"; // You will see it in the [Advanced display settings] tab. 241 | 242 | // Apdater GUID to obtain the device handle. 243 | // {00b41627-04c4-429e-a26e-0265cf50c8fa} 244 | static const GUID VDD_ADAPTER_GUID = { 0x00b41627, 0x04c4, 0x429e, { 0xa2, 0x6e, 0x02, 0x65, 0xcf, 0x50, 0xc8, 0xfa } }; 245 | static const char *VDD_ADAPTER_NAME = "Parsec Virtual Display Adapter"; 246 | 247 | // Class and hwid to query device status. 248 | // {4d36e968-e325-11ce-bfc1-08002be10318} 249 | static const GUID VDD_CLASS_GUID = { 0x4d36e968, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 } }; 250 | static const char *VDD_HARDWARE_ID = "Root\\Parsec\\VDA"; 251 | 252 | // Actually up to 16 devices could be created per adapter 253 | // so just use a half to avoid plugging lag. 254 | static const int VDD_MAX_DISPLAYS = 8; 255 | 256 | // Core IoControl codes, see usage below. 257 | typedef enum { 258 | VDD_IOCTL_ADD = 0x0022e004, 259 | VDD_IOCTL_REMOVE = 0x0022a008, 260 | VDD_IOCTL_UPDATE = 0x0022a00c, 261 | VDD_IOCTL_VERSION = 0x0022e010, 262 | } VddCtlCode; 263 | 264 | // Generic DeviceIoControl for all IoControl codes. 265 | static DWORD VddIoControl(HANDLE vdd, VddCtlCode code, const void *data, size_t size) 266 | { 267 | if (vdd == NULL || vdd == INVALID_HANDLE_VALUE) 268 | return 0; 269 | 270 | BYTE InBuffer[32]; 271 | ZeroMemory(InBuffer, sizeof(InBuffer)); 272 | 273 | OVERLAPPED Overlapped; 274 | ZeroMemory(&Overlapped, sizeof(OVERLAPPED)); 275 | 276 | DWORD OutBuffer = 0; 277 | DWORD NumberOfBytesTransferred; 278 | 279 | if (data != NULL && size > 0) 280 | memcpy(InBuffer, data, (size < sizeof(InBuffer)) ? size : sizeof(InBuffer)); 281 | 282 | Overlapped.hEvent = CreateEventA(NULL, FALSE, FALSE, NULL); 283 | DeviceIoControl(vdd, (DWORD)code, InBuffer, sizeof(InBuffer), &OutBuffer, sizeof(DWORD), NULL, &Overlapped); 284 | 285 | if (!GetOverlappedResultEx(vdd, &Overlapped, &NumberOfBytesTransferred, 5000, FALSE)) 286 | { 287 | CloseHandle(Overlapped.hEvent); 288 | return 0; 289 | } 290 | 291 | if (Overlapped.hEvent != NULL) 292 | CloseHandle(Overlapped.hEvent); 293 | 294 | return OutBuffer; 295 | } 296 | 297 | /** 298 | * Query VDD minor version. 299 | * 300 | * @param vdd The device handle of VDD. 301 | * @return The number of minor version. 302 | */ 303 | static int VddVersion(HANDLE vdd) 304 | { 305 | int minor = VddIoControl(vdd, VDD_IOCTL_VERSION, NULL, 0); 306 | return minor; 307 | } 308 | 309 | /** 310 | * Update/ping to VDD. 311 | * Should call this function in a side thread for each 312 | * less than 100ms to keep all added virtual displays alive. 313 | * 314 | * @param vdd The device handle of VDD. 315 | */ 316 | static void VddUpdate(HANDLE vdd) 317 | { 318 | VddIoControl(vdd, VDD_IOCTL_UPDATE, NULL, 0); 319 | } 320 | 321 | /** 322 | * Add/plug a virtual display. 323 | * 324 | * @param vdd The device handle of VDD. 325 | * @return The index of the added display. 326 | */ 327 | static int VddAddDisplay(HANDLE vdd) 328 | { 329 | int idx = VddIoControl(vdd, VDD_IOCTL_ADD, NULL, 0); 330 | VddUpdate(vdd); 331 | 332 | return idx; 333 | } 334 | 335 | /** 336 | * Remove/unplug a virtual display. 337 | * 338 | * @param vdd The device handle of VDD. 339 | * @param index The index of the display will be removed. 340 | */ 341 | static void VddRemoveDisplay(HANDLE vdd, int index) 342 | { 343 | // 16-bit BE index 344 | UINT16 indexData = ((index & 0xFF) << 8) | ((index >> 8) & 0xFF); 345 | 346 | VddIoControl(vdd, VDD_IOCTL_REMOVE, &indexData, sizeof(indexData)); 347 | VddUpdate(vdd); 348 | } 349 | 350 | #ifdef __cplusplus 351 | } 352 | #endif 353 | 354 | #endif --------------------------------------------------------------------------------