264 Commits

Author SHA1 Message Date
16df7b86a1 sanitizing_allocator: fix zeroing memory when sizeof(T)>1
std::allocator<>::deallocate() second parameter is number of elements,
not array size!

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-11-07 08:50:04 +01:00
b39aecb224 Fix FormatMessage helper functions
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-18 13:43:40 +02:00
f9090e02f4 Throw on 4G overflows
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-16 14:33:11 +02:00
ff8136f708 Add load_msg_from_res and fmt_msg_from_res helpers
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-13 11:56:58 +02:00
f9f9aade69 Add clipboard_opener
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:50:35 +02:00
f8f8e7e76e Cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:50:20 +02:00
e0fc1ae56a Cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-06 15:57:36 +02:00
2680cdb3fd Upgrade win_runtime_error and ws_runtime_error to include error message
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>
2023-10-03 15:18:25 +02:00
d99aedecc1 Add winstd::http
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-01 22:49:05 +02:00
c1bd614597 Add GetThreadPreferredUILanguages
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-01 22:48:33 +02:00
7637d86c7d Add winstd::mutex
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-01 22:48:07 +02:00
ca4e9d069f Cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-01 22:47:28 +02:00
40003c4054 COM: Improve bstr constructors
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-01 22:44:38 +02:00
0addbd825a icon: Add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-03 13:54:46 +02:00
da8bd86d83 Add helpers for GlobalAlloc
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-08 11:14:03 +01:00
bf9ab7c4e2 Cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-08 09:48:03 +01:00
3698ca011a COM: Introduce SAFEARRAY helpers
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-08 09:48:02 +01:00
31ebd9b08f Make duplicate_internal() and other allocation methods throw
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>
2023-03-08 09:28:13 +01:00
1d206602e6 com_obj: Add CoCreateInstance constructor
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>
2023-03-08 09:28:13 +01:00
fc0060d3bd COM: Throw in constructors and operators
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-08 09:28:13 +01:00
12046216e9 Discontinue terminal punctuation in exception messages
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-06 16:04:56 +01:00
db23a5a984 Bump copyright year
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-12-29 11:09:06 +01:00
963c2e44ac Update MsiFormatRecord() SAL
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>
2022-10-18 09:32:03 +02:00
93b3157f31 Add PathRemoveBackslash()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-17 16:03:24 +02:00
0fea2d1ed7 Add SetEntriesInAcl()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-17 16:03:24 +02:00
ad2d67e680 Add AllocateAndInitializeSid()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-17 16:03:07 +02:00
322ada3dd5 Add CoGetObject()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-17 09:16:59 +02:00
bd5c1fdd9d Add DuplicateTokenEx()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 14:24:27 +02:00
3cf2e96b07 Cleanup
sizeof(BYTE), really?

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 14:04:33 +02:00
95fb94d828 Cleanup excessive memory allocation check
Operator new throws rather than returns NULL.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 14:00:16 +02:00
a052c028b5 Add CreateWellKnownSid()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 13:58:42 +02:00
f7c31329cd Fix documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 13:24:59 +02:00
28b70eedb8 Add winstd::system_impersonator
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 13:21:36 +02:00
539828dd2c Update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-13 12:36:09 +02:00
1f0b8cdb6d Cleanup 2022-10-03 19:43:47 +02:00
49b55331e4 Unify std::vector::data() typecasting
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>
2022-05-05 13:37:30 +02:00
83c749e394 Add SC_HANDLE helper class
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-21 14:16:37 +01:00
7defbb8cab Add SECURITY_ATTRIBUTES wrapper
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-10 14:51:29 +01:00
6a8310a9e7 Update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-10 14:50:44 +01:00
8244dea1a4 Split CredEnumerate to A and W variants
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-10 14:50:10 +01:00
212ee66296 Simplify critical section creation
RIP Windows XP.

Reference: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initializecriticalsection
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-08 19:46:19 +01:00
ae7211d6b3 Silence false CodeQL issue and update event_session::name() doc
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_properties
Fixes: #1
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 15:17:32 +01:00
017d5d5c99 UnitTests: Introduce
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>
2022-03-07 14:20:58 +01:00
3b110f7dc5 Update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 13:00:17 +01:00
b21f2efa91 Doxygen: Unify group definitions and add \files
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 10:10:16 +01:00
ad76305ce9 Remove deprecated methods
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-03 15:51:13 +01:00
266996bd67 Add winstd::thread and winstd::process_snapshot
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-03 09:17:22 +01:00
24f11e5253 Deprecate helper methods of "smart-pointer" classes
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>
2022-03-02 15:26:27 +01:00
328646b2d9 Stop defining _WINSOCKAPI_
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>
2022-02-10 12:16:34 +01:00
e2aad54a13 Add file_mapping and UnmapViewOfFile_delete
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-10 12:13:10 +01:00