34 Commits

Author SHA1 Message Date
suvenka 676d948235 Add process_start_key() to read ProcessStartKey from extended data
Add support for reading EVENT_HEADER_EXT_TYPE_PROCESS_START_KEY from
ETW extended data items, enabled via EVENT_ENABLE_PROPERTY_PROCESS_START_KEY.
The ProcessStartKey uniquely identifies a process instance across a boot
session (unlike PID which can be recycled).

Changes:
- Native C++: schema::process_start_key() in schema.hpp
- Managed .NET: TryGetProcessStartKey() on IEventRecordMetadata/EventRecordMetadata
- Test support: extended_data_builder::add_process_start_key()
- New example: UserTrace008_ProcessStartKey.cs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-06 16:18:29 -08:00
Kyle Reed 924a28ed8d Update for .NET Core 8 (#267)
* Update for .NET Core 8
Clean up the netcore vcxproj files

* Update test assembly path

* Don't define a runtime lib in release builds (this is how it was before)

* Remove assemblyDebug from release builds

* Remember to actually save file after changing it
2025-11-19 16:47:22 -08:00
wwh1004 4ba137cc0a Unify. NET wrappers of callbacks and use error code checking instead of exception handling 2025-02-01 17:47:55 +08:00
Mihai PANDURU 6b3152dbe3 Correctly handle kernel addresses in an x86 stack trace (#241) 2024-08-13 14:46:28 -07:00
HydrophobicMinghao 338d486440 Add Windows ARM64 port for managed wrappers. (#234)
* Add assets for ARM64 port.

* Remove unused element.

* Add new ignore files.

* Compatible with non-SDK projects.

* Fix installation command log.

* Fix CI workflow.

* Fix platform targets.

* Fix x64 managed tests path.

* Migrate csproj to SDK style.

* Fix csproj.

* Align and fix csproj projects.
2024-06-04 08:46:15 -07:00
Septor da66c3a28a Add trace parsing from a file instead of realtime (#206)
* Add trace parsing from a file instead of realtime

Add a new interface set_trace_filename() that will enable reading from
an ETL file rather than real-time capture.

Also added a new NativeExample that demonstrates this capability.

* Minor cleanup to address code review items.

* Bump nuget version
2023-04-03 15:41:03 -07:00
John U 394eb6c52a add call stack enrichment to the C# example (#204) 2022-11-19 20:37:07 -08:00
Henri-Bastien Lamontagne c31d39497a build and package krabs etw with .net 6.0 support 2022-08-01 14:41:08 -07:00
John U 79e8af192e add stack trace helpers (#26) (#191)
* add stack trace helpers (#26)

* use windows-2019 for builds

* [PR feedback] rename StackTrace method to GetStackTrace
2022-04-24 18:13:42 -07:00
Matt Swann b41b57cd42 Send schema errors to OnError callback in all cases (#175)
* Gracefully handle schema errors when applying filters

* Gracefully handle schema errors when applying filters

* Fix error message
Dispose managed error callbacks

* Improve error callback on event_filter

* Rename event callback for improved readability

* Add additional ETW trace flags described in public documentation or Microsoft open-source projects

* Remove TODO which has already been resolved through IEventRecordMetadata

* Add an interface for EventRecordError to enable unit-testing

* Address code review feedback

* Delete extraneous file

* Fix delegate name

* Resolve nits identified during self-review
2021-09-06 12:28:18 -07:00
Nicole 405abd59fb Upgraded toolset and target platform; enabled Spectre mitigation on Release builds 2021-07-16 10:45:43 -07:00
John U 31679cf84b Rundown event support and examples (#155)
* added user-mode rundown support

* [bugfix] EVENT_TRACE_FLAG_DISK_FILE_IO enables events for the FileIo provider

* added examples for kernel rundown events (#138)

* added user-mode rundown support to C++/CLI API
2021-01-19 15:13:44 -08:00
John U fa2f89a583 added ability to set a default event callback (#147) (#151) 2020-12-23 12:52:22 -08:00
John U c526c45e5b add support for MOF providers, and update WPP example (#143) (#145)
* add support for MOF providers, and update WPP example (#143)

* updated predicate vector example doco

Co-authored-by: Matt Swann <mswann@Microsoft.com>
2020-11-19 16:30:12 -08:00
John U 84b77ed850 added a WPP trace example (#66) (#135) 2020-08-05 17:56:42 -07:00
turingcompl33t 261f0bdfb1 Remove Boost Dependency (#126)
* refactor predicate comparers to use std algorithms in place of boost algorithms

* update implementation of contains() to match semantics of boost::contains()

* update implementation based on feedback from PR review

* refactor unecessary use of std::distance and refactor parameter names for consistency with STL

* update solution configuration to remove boost dependency and bump package version
2020-04-20 12:10:09 -07:00
path/to/file 8034e9fa08 Feature/vector predicates (#124)
* added new and/or/none predicate functions that compare a vectorlist of arbitrary predicates

* added examples and tests

* reverted visual studio version in krabs.sln

* improved comments in predicate_base

* fixed formatting in user_trace_006_predicate_vectors.cpp

* reverted change to sln

* renamed vector predicates

* updated versions and releaseNotes in nuspec files
2020-04-16 08:49:07 -07:00
John U 75a5be3406 Fixed Windows 7 support (#110) (#113)
* Fixed Windows 7 support (#109)

* set minimum supported version to Windows 7 for NativeExamples and krabstests
2020-03-18 10:44:44 -07:00
Johannes Rave 3e974bd0c7 Create github action ci flow (#112) 2020-03-13 10:25:27 -07:00
John U 5ad82eff2a added PERFINFO_GROUPMASK typedefs and macros (#108)
* added PERFINFO_GROUPMASK macros

* added PERFINFO_GROUPMASK examples
2020-03-10 10:45:55 -07:00
John U 9863c2cb8a [bugfix] thread-safe schema_locator (#61) (#96)
* [poc] inject schema_locator

* Apply suggestions from code review

Co-Authored-By: Kyle Reed <kareed@kallanreed.com>

* inject schema_locator [C++/CLI]

* inject schema_locator into predicate

* Update krabs/krabs/schema.hpp

Co-Authored-By: Kyle Reed <kareed@kallanreed.com>

* updated docs

* updated nuspec

Co-authored-by: Kyle Reed <kareed@kallanreed.com>
2020-02-09 20:20:09 +04:00
John U 66ff440b91 .stop() should always call ControlTrace(STOP) - even if .open()/.start() has not been called (#90)
* .stop() should always call ControlTrace(STOP), and ignore any trace not found errors

* query_stats() should always call ControlTrace(QUERY),
and gracefully handle 'trace not found'

* tabs -> spaces

Co-authored-by: Matt Swann <3lemenopy@gmail.com>
2020-01-15 13:57:01 -08:00
John U aad6efc81f tracing Microsoft-Windows-Security-Auditing (#5) (#93)
Merge commit by: Matt Swann <3lemenopy@gmail.com>
2020-01-14 10:08:55 -08:00
Andrea Spadaccini 5b110cadf0 Cosmetic fixes (wording, formatting) (#86)
* Improve wording for ETW interface

Rename nightmare.hpp to etw.hpp to reflect its function,
and remove opinions on the ETW API in the comments.

* Add vim files to .gitignore

* Port Readme.txt to markdown and improve its formatting

* Improve .gitignore wording

* Fix typo in krabs/README.md

* Rename O365.Security.Native.ETW to Microsoft.O365.Security.Native.ETW

- change all occurrences in solution and project files;
- rename the directory containing the project;
- rename the project files.
2019-10-14 08:32:35 -07:00
Matt Swann ab944eeef1 Add support in C++/CLI for native ETW filtering (#84)
* Add support in C++/CLI for native ETW filtering

* Update nuspec

* Fix constructor comments

* Define a marshal_as template for List<T> to vector<T>

* Revert back to a helper method

* Add a generic list -> vector converter
Extract to a separate file

* CR feedback
2019-09-30 11:31:47 -07:00
Zac Brown 2cc089a0b7 Formatting updates and a little cleanup. (#65)
* Update ut.hpp

* More formatting fixes.

Signed-off-by: Zac Brown <zacbrown@users.noreply.github.com>
2018-12-29 21:44:55 -08:00
Issahar G f4aa34ff7e boosting krabs performance by filtering by event id on api level (without predicates) (#60)
* add native support for event filters via API

* not finished:
created one unittest to show usage of native filtering...

* adjust memory usage out of scope....

* file delete event in tests....

* resolving issue 1 in comments of pull request

* issue 2 in pull request comments

* comment 3 in pull request: indentation

* issue 4: identation of if

* excessive comment

* fixed typedef

* removing hungarian convention

* camelCase to snake_case

* snake_case

* fixing more comments in pull request

* uncommenting the first test

* applying comments of pull request

* supporting native event filtering alternated with predicates on other settings

* fix identation

* fixing style

* fixing tabs to spaces

* fix identation

* basing on last change requests except the different method for filterDesc composition which is reasked by me if we could ignore or not.

* fix to reference

* undo excessive change in styling. The file whole written in other style

* fixing indentation of for loop
2018-12-28 11:22:51 -08:00
Matt Swann 10661ab379 Comply with requirements for MSFT-owned nuget packages (#56)
* Disable strict compliance on tests project to work around a VS2017 compiler bug: https://developercommunity.visualstudio.com/content/problem/288560/cppunittestassert-doesnt-compile-with-permissive-i.html

* Disabling /permissive- for all build flavors

* Add ESRP delay signing key

* Add Microsoft prefix per MSFT requirements

* Sign.cmd is no longer needed

* Update assembly namespace to match nuget id

* Fix nuget file references

* Update expected public key

* Bump nuget version to 2.0.0
2018-10-02 12:14:48 -07:00
Zac Brown 00eb0cbcb3 Address issues related to setting the C++ standard to C++17. Also upgrades boost to 1.68. (#51)
Signed-off-by: Zac Brown <zacbrown@users.noreply.github.com>
2018-09-19 11:49:26 -07:00
Johannes Rave ed1feacc52 Fix errors when building with /permissive- (#42) (#43)
* Fix errors when building with /permissive- (#42)

* Update solution and projects to VS 2017 (#42)
2018-04-11 21:43:50 -07:00
Zac Brown 12f32bfda4 Fix kernel examples. 2017-04-24 11:09:23 -07:00
Zac Brown (ODSP SECURITY) d2a053e762 Create DebugSigning and ReleaseSigning build targets for when we release to NuGet. This fixes issues with delay signing and the regular Debug/Release builds.
Signed-off-by: Zac Brown (ODSP SECURITY) <zbrown@microsoft.com>
2017-03-24 15:06:56 -07:00
Zac Brown c81c3c41f6 - Make projects for Managed and Native example code. (#3)
* - Make projects for Managed and Native example code.
- Create a 'tests' directory.
- Remove SampleCSharpKrabsExe as it is redundant with respect to the example code.

Signed-off-by: Zac Brown (ODSP SECURITY) <zbrown@microsoft.com>

* - Add note about TYPEASSERT and NDEBUG compilation flags to README.md.
- Add /W4 /WX compiler flags to NativeExample project.
- vcxproj.filters updates based on VS magic.

Signed-off-by: Zac Brown (ODSP SECURITY) <zbrown@microsoft.com>
2016-11-28 14:06:40 -08:00
Zac Brown (ODSP SECURITY) d741c16cc8 Initial public release. 2016-10-26 15:08:31 -07:00