Commit Graph

340 Commits

Author SHA1 Message Date
Frediano Ziglio
7aa46954fd vdlog: Fix compatibility with MSVC
_wstat64 documentation states that we should include sys/types.h
and sys/stat.h.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-06 09:42:52 +00:00
Uri Lublin
1da442ad73 file-xfer: handle_start: use snprintf instead of sprintf_s
When building with older mingw, sprintf_s does not
always work as expected, but snprintf does.

Also it's more consistent in the file.

Note that when building with VS, snprintf becomes sprintf_s

Related: rhbz#1410181

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-06 09:42:39 +00:00
Frediano Ziglio
dc185029ff vdcommon: Do not use GetVersionEx to get Windows version
GetVersionEx was deprecated by Microsoft in favour of utilities
in versionhelpers.h.
The new function returns the same results as:
- GetVersionEx returns maximum 6.2 version and also 6.0 version
  is Vista, not Windows 7 so SYS_VER_WIN_7_CLASS was returned
  for all system from Windows Vista;
- We don't support version earlier than Windows XP and no Windows
  versions had version >= 5.2 and < 6.0 so SYS_VER_WIN_XP_CLASS
  was returned from Windows XP;
- we don't support any system before Windows XP.

Tested under Windows XP, 7 and 10.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-03 17:43:17 +00:00
Frediano Ziglio
615cd463e0 vdlog: Use _wstat64 instead of GetFileSize
This has different advantages:
- code is shorter and more readable;
- does not need to open the file and close;
- works on files bigger than 4gb.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-11-21 14:48:32 +00:00
Frediano Ziglio
1dd3f3586a Add a test for filter_url function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-18 10:30:14 +00:00
Frediano Ziglio
9207d821d2 file_xfer: Open Download directory after a file transfer is finished
Have the same behaviour of Linux machines.
The directory is not opened again and again, only is not already
opened.
This is done checking the directory opened in explorer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-18 10:30:14 +00:00
Frediano Ziglio
8064ae397a file_xfer: Save files in Downloads directory
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-07 16:13:52 +00:00
Frediano Ziglio
5fbeb1af4e file_xfer: Separate code to get download directory location
Allows to reuse code to get download directory.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-07 16:12:35 +00:00
Frediano Ziglio
7a7c3b22e2 display_configuration: Define WINVER to avoid some declaration
Some declarations are available in MingW only defining a more recent
version of WINVER. Set WINVER to 0x0601 (Windows 7) to enable these
definitions.
This allows to clean some files.
The definition were already available in Fedora 22.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-06 09:24:30 +00:00
Yuri Benditovich
66d44f914c win32/vd_agent: Optionally disable installation of x86 MSI on x64 system
Currently the MSI built for x86 system can be easily installed
on x64 system. When the script is processed by WIX this can be
prevented by passing '-dNoWOW=yes' to the WIX-candle.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-10-18 14:56:02 +01:00
Yuri Benditovich
d8894046f8 win32/vd_agent: Customize MSI product name and install location
Customize these properties of WIX script during build under
WIXL or Windows.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-10-18 14:56:00 +01:00
Yuri Benditovich
886b9450a5 win32/vd_agent: Fix WIX error on .wxs script
Allows the same WIXL script to be used for WIX on Windows.
WIX raises error if Win64 property is not set for x64 MSI.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-10-18 14:55:57 +01:00
Frediano Ziglio
4d4977611f Remove some unused definitions
_ftime_s, vdagent_strcat_s and vdagent_strcpy_s are not used.
Code is using different string functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-04-30 09:22:11 +01:00
Victor Toso
58bc1b9580 Prepare for 0.10.0 release
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-23 10:50:04 +01:00
Victor Toso
b67a887044 Rename NEWS to CHANGELOG and append md suffix
In order to have Gitlab format this properly

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-23 10:50:02 +01:00
Victor Toso
fb8060bd66 gitlab-ci: Add ci for x86 and i686
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-23 10:49:58 +01:00
Frediano Ziglio
f8202210d1 Remove support for very old Fedora versions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-12 10:46:11 +00:00
Yuri Benditovich
93f3aee7b4 make display disconnection persistent
https://bugzilla.redhat.com/show_bug.cgi?id=1477191
Currently on Win10 when one of multiple displays is
disconnected by the client, the qxl-wddm-dod driver
does not receive any update, the system just stops using
this adapter for rendering. As a result, the 'disconnected'
state of the adapter is not saved anywhere. On further
connect the client side recognize the adapter as active
and opens window for it. Current commit fixes the problem
by sending QXL_ESCAPE_MONITOR_CONFIG with zero area
to disabled adapter.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-08 11:43:16 +00:00
Yuri Benditovich
12a8f08f32 introduce turn_monitor_off method of WDDM interface
Adding method 'turn_monitor_off' to WDDM interface.
It sends QXL_ESCAPE_MONITOR_CONFIG escape with zeroed
display size to qxl-wddm-dod driver.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-08 11:43:16 +00:00
Yuri Benditovich
6e159118b2 construct WDDMMonitorConfigEscape also with NULL DisplayMode
Adding possibility to construct WDDMMonitorConfigEscape object
with NULL parameter of DisplayMode. In this case all the fields
depending on DisplayMode are set to zero.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-08 11:40:57 +00:00
Frediano Ziglio
0858cfd211 build: Check we can link libpng statically
Catch the problem during configure instead of having to wait the
build to fail.
On Fedora try for instance to remove mingw64-zlib-static package,
the missing dependency won't be detected during configure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-06 18:29:40 +00:00
Jonathon Jongsma
8bbb89e92b Don't exit when receiving unknown messages
In 8251fa25, a check on the minimum size of a message was introduced.
For unsupported messages, the vdagent simply exited. This makes it
inconsistent with previous behavior and inconsistent with the behavior
of the linux vdagent.  Instead, just print a warning indicating that an
unsupported message was received and ignore it.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-05 13:50:08 +00:00
Frediano Ziglio
5f0f3b590a Fix indentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-02-27 17:06:53 +00:00
谢 昆明
f264f5dec8 Fix typo, change DeviceName to device_name
Signed-off-by: kunming.xie <kunming.xie@hotmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-11-17 12:06:26 +00:00
Frediano Ziglio
348f7ed0cd Use GetModuleHandle to get some functions from user32 library
The library is surely already loaded as providing clipboard and
other utilities we need.
user32 is one of the main win32 libraries.
Avoid using LoadLibrary that increment the reference so we don't
need to call FreeLibrary to cleanly decrement the reference.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 12:20:49 +01:00
Frediano Ziglio
9264c7f367 vdagent: Add a comment around WinSta0_DesktopSwitch event usage
Multiple times while I was reading this code was not clear why the
synchronization of this event was not done in the main event loop.
Also document why we want to use it not relying just on
WTSRegisterSessionNotification and WM_WTSSESSION_CHANGE.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 12:07:27 +01:00
Frediano Ziglio
7038aa83b3 vdagent: Stop correctly helper thread
The thread launched to detect desktop switches events is not stopped
correctly causing potentially dandling pointers.
Queue a APC to make the loop exit and wait for thread termination
from the main thread.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:47:20 +01:00
Frediano Ziglio
2ae3bd5b9c Use destructor instead of cleanup function
More C++ style.
Also avoids missing cleanup calls.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:07:01 +01:00
Frediano Ziglio
0ac9d687e9 Introduce an helper to close VirtIo device
Do not assume we allocated the handle doing the cleanup.
This utility will be reused in next patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:05:50 +01:00
Frediano Ziglio
6d1d4241ac Use proper invalid value for _vio_serial
For some reason kernel handles in Windows have 2 invalid values
depending on the type. Files/devices use INVALID_HANDLE_VALUE (-1),
while others use NULL (0). As _vio_serial is a file, created
with CreateFile, use INVALID_HANDLE_VALUE for consistency.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:05:05 +01:00
Frediano Ziglio
9ddddf205f vdlog: Use GetLocalTime instead of multiple C functions
The GetLocalTime function already returns all information we
need for the log, no needs to call multiple C functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-08 20:19:21 +01:00
Frediano Ziglio
df20de186c vdlog: Factor our a "logf" function to avoid long "LOG" macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-08 20:19:21 +01:00
Frediano Ziglio
c4b8c5349e vdlog: Remove the lookup table for log types
As log type is passed as constant in some macros and the lockup
is basically using this name without the prefix pass to the macro
the name without the prefix.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-08 20:19:21 +01:00
Frediano Ziglio
55290d1766 Avoids to call supported_system_version()
The only reason we call this function is to check if the
system should support some APIs.
Instead just check directly if these APIs are supported
calling GetProcAddress directly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 18:35:31 +01:00
Frediano Ziglio
e9421d09b8 Avoid declaring _system_version member
The check can be done a single time, no reason to cache
supported_system_version() value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 16:38:04 +01:00
Frediano Ziglio
c0a6e42e80 Avoid declaring event_thread_id
As the value is never used we can pass NULL in CreateThread.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:50:36 +01:00
Frediano Ziglio
6a0683707f Allocate _control_event and _stop_event just once
Handle _control_event and _stop_event destruction in destructor.
Allows to call VDAgent::run multiple time if needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:25:42 +01:00
Frediano Ziglio
7b368a134f Allow one more character reading strings from registry
The strings in the registry are usually NUL-terminated but this
is not a requirement.
Handle the case when the string, considering the terminator, fit
into the reading buffer. In this case accept the string. In the
case the string fit into the buffer but is not terminated
returns ERROR_MORE_DATA (the error that would be returned if the
string didn't fit in the buffer as there is no place to add the
terminator).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:12:33 +01:00
Frediano Ziglio
1a2e2d1411 Factor out an utility function to read strings from registry
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:12:33 +01:00
Frediano Ziglio
97ef38dc6d Use always TCHAR to read string from registry
This is a preparation patch in order to factor out code to read
a string from registry.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:12:33 +01:00
Frediano Ziglio
0984079e08 Use std::unique_ptr for _desktop_layout
Make automatic the release of this pointer.
Also avoids having a leak if VDAgent::run is called twice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 13:26:05 +01:00
Frediano Ziglio
18cbe9f306 Replace an assert with proper handling code
Make sure the condition is handled properly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-04 05:33:22 +01:00
Frediano Ziglio
3e8cab6da1 Minor overflow checks improvements
Although source of these data should be safe, improve data checks
to avoid some overflows and make the code more robust.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-04 05:33:22 +01:00
Frediano Ziglio
873464cecc Reduce indentation returning earlier
Also add some comments.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-04 05:33:22 +01:00
Frediano Ziglio
bc3384f359 Use proper type for _clipboard_owner
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-07-03 14:30:12 +01:00
Frediano Ziglio
8251fa25ac Minimal message size check
Avoid some possible integer overflows.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-29 19:51:55 +01:00
Frediano Ziglio
ae94c50ee9 Use enumeration types
No reasons to allow any possible number.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-29 19:34:57 +01:00
Frediano Ziglio
13fb63e328 Fix some minor buffer overflows reading registry informations
Strings in the registry can be not NUL-terminated.
Current code to make sure they are NUL-terminated can add an extra
NUL character at the end of the buffer.
Also RegQueryValueEx returns the number of bytes read, not the number
of characters so the value must be fixed to avoid overflows.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-29 19:22:42 +01:00
Frediano Ziglio
14769f88c9 vdservice: Do not append line terminator to log
vd_printf already add a line terminator

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-29 18:51:06 +01:00
Frediano Ziglio
531dd85f60 Reuse spice-protocol macros instead of defining new ones for alignment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-28 02:17:32 +01:00