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>
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>
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>
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>
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>
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>
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>
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>
_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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>