Commit Graph

282 Commits

Author SHA1 Message Date
Simon Rozman
ad2d67e680 Add AllocateAndInitializeSid()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-17 16:03:07 +02:00
Simon Rozman
322ada3dd5 Add CoGetObject()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-17 09:16:59 +02:00
Simon Rozman
bd5c1fdd9d Add DuplicateTokenEx()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 14:24:27 +02:00
Simon Rozman
3cf2e96b07 Cleanup
sizeof(BYTE), really?

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 14:04:33 +02:00
Simon Rozman
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
Simon Rozman
a052c028b5 Add CreateWellKnownSid()
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 13:58:42 +02:00
Simon Rozman
f7c31329cd Fix documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 13:24:59 +02:00
Simon Rozman
28b70eedb8 Add winstd::system_impersonator
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-14 13:21:36 +02:00
Simon Rozman
539828dd2c Update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-13 12:36:09 +02:00
Simon Rozman
1f0b8cdb6d Cleanup 2022-10-03 19:43:47 +02:00
Simon Rozman
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
Simon Rozman
83c749e394 Add SC_HANDLE helper class
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-21 14:16:37 +01:00
Simon Rozman
7defbb8cab Add SECURITY_ATTRIBUTES wrapper
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-10 14:51:29 +01:00
Simon Rozman
6a8310a9e7 Update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-10 14:50:44 +01:00
Simon Rozman
8244dea1a4 Split CredEnumerate to A and W variants
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-10 14:50:10 +01:00
Simon Rozman
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
Simon Rozman
7ef082ca26 UnitTests: Enable PREfast and code analysis
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-08 19:44:07 +01:00
Simon Rozman
9dc3af9797 UnitTests: Make independent Visual Studio solution
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-08 14:57:41 +01:00
Simon Rozman
64a0c07dd4 Create SECURITY.md
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 15:51:36 +01:00
Simon Rozman
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
Simon Rozman
013e6b1625 UnitTests: Include all headers
See if CodeQL provides better coverage then.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 15:02:22 +01:00
Simon Rozman
49ffd4c186 CodeQL: Let's see if this works on GitHub Windows worker
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 14:43:29 +01:00
Simon Rozman
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
Simon Rozman
3b110f7dc5 Update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 13:00:17 +01:00
Simon Rozman
2468f67e26 Create codeql-analysis.yml 2022-03-07 12:58:34 +01:00
Simon Rozman
b21f2efa91 Doxygen: Unify group definitions and add \files
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 10:10:16 +01:00
Simon Rozman
3fd6e5b604 Doxygen: Add static functions and templates
Marking all global functions and templates as static made Doxygen hide
them from the documentation. However, they were marked as static because
of the portable nature of WinStd. Not to isolate them.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-07 10:09:16 +01:00
Simon Rozman
ad76305ce9 Remove deprecated methods
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-03 15:51:13 +01:00
Simon Rozman
266996bd67 Add winstd::thread and winstd::process_snapshot
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-03-03 09:17:22 +01:00
Simon Rozman
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
Simon Rozman
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
Simon Rozman
e2aad54a13 Add file_mapping and UnmapViewOfFile_delete
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-10 12:13:10 +01:00
Simon Rozman
29a9d1d69f Update documentation
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>
2022-02-10 12:12:25 +01:00
Simon Rozman
2493f3790e Add event_log
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-09 12:04:48 +01:00
Simon Rozman
0029a491a9 Readme: Link to gh-pages documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 14:37:04 +01:00
Simon Rozman
21c1bf5084 Doxygen: Address warnings
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 14:37:04 +01:00
Simon Rozman
e3d9fffd4f Doxygen: Suggest #include <WinStd/header.h>
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 13:57:39 +01:00
Simon Rozman
2bfb369692 Move vector_queue from WinStd to stdex
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 13:49:05 +01:00
Simon Rozman
89a79c330b Doxygen: Instruct GitHub Actions to build documentation on push
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 13:23:29 +01:00
Simon Rozman
f4a39589a1 Doxygen: Update configuration
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 13:19:18 +01:00
Simon Rozman
921aa9f4e9 Discontinue forward declarations
They are pain to maintain. We'll use them only if really needed (cyclic
dependencies).

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 13:06:34 +01:00
Simon Rozman
e513782854 Use explicit char/wchar_t type for ...A/W Win32 API
Using template type for string type could potentially allow mixup of
MBCS and UCS-2/UTF-16 strings. Fortunately, MSVC errors where char*/
wchar_t* are not aligned with LPSTR/LPWSTR.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 09:54:01 +01:00
Simon Rozman
04c2f9b9c3 Reuse free_internal() when destructing the handle<> implementations
Depending on the settings, compiler inlines the free_internal() call
inside the destructor. No need to copy&paste code.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-04 09:18:45 +01:00
Simon Rozman
4520593e49 Readme: Update examples
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 16:07:51 +01:00
Simon Rozman
7fab825e5f Readme: Remove AppVeyor badge
Going portable, there is no project left to build in this repo. Maybe
I add some unit tests one day?

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 15:58:15 +01:00
Simon Rozman
081df56d18 Fix MsiFormatRecordW forward declaration to match implementation
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 15:46:25 +01:00
Simon Rozman
918cdb9cd6 Switch to MIT license
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 15:39:44 +01:00
Simon Rozman
cd025b449a Move Hex from WinStd to stdex
Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 15:12:27 +01:00
Simon Rozman
465c52f0a0 Discontinue manual inline hinting
Compiler knows better than we do.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 15:05:30 +01:00
Simon Rozman
880fd34e16 Move our Base64 implementation to stdex
Base64 is general algorithm not provided with Win32 API.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-02-03 13:42:46 +01:00