Skip to content

Commit

Permalink
Merge pull request #250 from microsoft/users/mijeong/remove_raw_provi…
Browse files Browse the repository at this point in the history
…der_allocation

Only allocate one EventRecordMetadata^ and reuse it for RawProvider events
  • Loading branch information
mjeong92 authored Nov 12, 2024
2 parents 4b1456c + 3a7b787 commit af17f4c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Microsoft.O365.Security.Native.ETW/AssemblyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace System::Security::Permissions;
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly:AssemblyVersionAttribute("4.4.2.0")];
[assembly:AssemblyVersionAttribute("4.4.3.0")];

[assembly:ComVisible(false)];

Expand Down
11 changes: 11 additions & 0 deletions Microsoft.O365.Security.Native.ETW/EventRecordMetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ namespace Microsoft { namespace O365 { namespace Security { namespace ETW {
: record_(&record)
, header_(&record.EventHeader) { }

EventRecordMetadata() { }

/// <summary>
/// Updates this instance to point to the specified event record.
/// </summary>
virtual void Update(const EVENT_RECORD& record)
{
record_ = &record;
header_ = &record.EventHeader;
}

public:
// For container ID's, we are expecting format "00000000-0000-0000-0000-0000000000000",
// 32 hex digits with 4 hyphens, no braces.
Expand Down
7 changes: 6 additions & 1 deletion Microsoft.O365.Security.Native.ETW/RawProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ namespace Microsoft { namespace O365 { namespace Security { namespace ETW {
NativePtr<krabs::provider<>> provider_;
GCHandle delegateHookHandle_;
GCHandle delegateHandle_;
EventRecordMetadata^ data_;
void SetUpProvider();
};

Expand All @@ -148,6 +149,8 @@ namespace Microsoft { namespace O365 { namespace Security { namespace ETW {
delegateHookHandle_ = GCHandle::Alloc(bridged);

provider_->add_on_event_callback((krabs::c_provider_callback)bridged.ToPointer());

data_ = gcnew EventRecordMetadata();
}

inline RawProvider::~RawProvider()
Expand All @@ -165,6 +168,8 @@ namespace Microsoft { namespace O365 { namespace Security { namespace ETW {

inline void RawProvider::EventNotification(const EVENT_RECORD &record)
{
OnEvent(gcnew EventRecordMetadata(record));
data_->Update(record);

OnEvent(data_);
}
} } } }
6 changes: 3 additions & 3 deletions O365.Security.Native.ETW.Debug.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Microsoft.O365.Security.Native.ETW.Debug</id>
<version>4.4.2</version>
<version>4.4.3</version>
<title>Microsoft.O365.Security.Native.ETW Debug - managed wrappers for krabsetw</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand All @@ -12,8 +12,8 @@
<description>Microsoft.O365.Security.Native.ETW Debug is a managed wrapper around the krabsetw ETW library. This is the Debug build.</description>
<summary>Microsoft.O365.Security.Native.ETW Debug is a managed wrapper around the krabsetw ETW library. This is the Debug build.</summary>
<releaseNotes>
Version 4.4.2:
- Support reading TraceLogging events.
Version 4.4.3:
- RawProvider only allocates EventRecordMetadata once per instance.
</releaseNotes>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<language />
Expand Down
6 changes: 3 additions & 3 deletions O365.Security.Native.ETW.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Microsoft.O365.Security.Native.ETW</id>
<version>4.4.2</version>
<version>4.4.3</version>
<title>Microsoft.O365.Security.Native.ETW - managed wrappers for krabsetw</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand All @@ -12,8 +12,8 @@
<description>Microsoft.O365.Security.Native.ETW is a managed wrapper around the krabsetw ETW library.</description>
<summary>Microsoft.O365.Security.Native.ETW is a managed wrapper around the krabsetw ETW library.</summary>
<releaseNotes>
Version 4.4.2:
- Support reading TraceLogging events.
Version 4.4.3:
- RawProvider only allocates EventRecordMetadata once per instance.
</releaseNotes>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<language />
Expand Down
6 changes: 3 additions & 3 deletions krabsetw.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Microsoft.O365.Security.Krabsetw</id>
<version>4.4.2</version>
<version>4.4.3</version>
<title>Krabs ETW Wrappers</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand All @@ -12,8 +12,8 @@
<description>Krabs ETW provides a modern C++ wrapper around the low-level ETW trace consumption functions</description>
<summary>Krabs ETW provides a modern C++ wrapper around the low-level ETW trace consumption functions</summary>
<releaseNotes>
Version 4.4.2:
- Support reading TraceLogging events.
Version 4.4.3:
- RawProvider only allocates EventRecordMetadata once per instance.
</releaseNotes>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<language />
Expand Down

0 comments on commit af17f4c

Please sign in to comment.