Upper levels usually just catch std::exception and display what()
message to the user. Rather than requiring typed exception catching and
per-type user message synthesis, it's easier for upper levels if we
stuff the Windows/Winsock2 formatted error message at the end of the
string returned by what() and leave the catch (std::exception&) do the
magic.
Signed-off-by: Simon Rozman <simon@rozman.si>
An exception can be way more elaborate why duplication failed and it
doesn't require consistent checking for result.
Signed-off-by: Simon Rozman <simon@rozman.si>
When using winstd::com_obj<> as a member of another class and we want
to create an instance of the object in another class' constructor, this
comes convenient.
Signed-off-by: Simon Rozman <simon@rozman.si>
Documentation says hInstall may be NULL "in which case only the record
field parameters are processed and properties are not available for
substitution."
Signed-off-by: Simon Rozman <simon@rozman.si>
When used in place of void*, typecasting is redundant. In other
situations use reinterpret_cast<true type>() rather than C-style
typecasting.
Signed-off-by: Simon Rozman <simon@rozman.si>
LoggerNameOffset represents offset (in bytes) from the start of the prop
to the beginning of the null-terminated string that contains the session
name. Hence, the prop must be cast from EVENT_TRACE_PROPERTIES* to char*
or BYTE* first, to calculate address properly.
Reference: https://docs.microsoft.com/en-us/windows/win32/api/evntrace/ns-evntrace-event_trace_propertiesFixes: #1
Signed-off-by: Simon Rozman <simon@rozman.si>
Other than having a convenient framework to test our helpers, this
allows CodeQL code analysis GitHub action.
Signed-off-by: Simon Rozman <simon@rozman.si>
The helper methods, which are so simple they merely assign the pointer/
handle to the class instance, were simply marked depreciated.
The helper methods, which require extra variable to store the output
pointer/handle before assigning it to the class instance, were replaced
with function overloads named by the original function helpers initially
wrapped. This allows easy porting of the legacy code to use WinStd
classes.
This commit also splits the helper functions to A and W (_UNICODE)
variants.
Signed-off-by: Simon Rozman <simon@rozman.si>
Being portable means not interfering with *any* user project settings.
Adapt user projects accordingly when sockets are used.
Signed-off-by: Simon Rozman <simon@rozman.si>
Although, most of the Windows handles may be duplicated with
DuplicateHandle(), this requires knowledge of the processes, desired
access and what not. The dplhandle<> supports only trivial duplication.
Hence win_handle is not a child of dplhandle<>, but handle<> instead.
Signed-off-by: Simon Rozman <simon@rozman.si>