Sandboxie/SandboxiePlus/QSbieAPI/SbieTrace.h

112 lines
3.0 KiB
C
Raw Normal View History

2021-10-15 16:39:43 +01:00
/*
*
* Copyright (c) 2020, David Xanatos
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QThread>
#include "qsbieapi_global.h"
#include "SbieStatus.h"
2023-01-07 15:57:55 +00:00
//#define USE_MERGE_TRACE
2021-10-15 16:39:43 +01:00
class QSBIEAPI_EXPORT CTraceEntry : public QSharedData
{
public:
2023-05-27 08:03:42 +01:00
CTraceEntry(quint64 Timestamp, quint32 ProcessId, quint32 ThreadId, quint32 Type, const QStringList& LogData, const QVector<quint64>& Stack = QVector<quint64>());
2021-10-15 16:39:43 +01:00
2022-03-26 09:09:24 +00:00
virtual QString GetName() const { return m_Name; }
2021-10-15 16:39:43 +01:00
virtual QString GetMessage() const { return m_Message; }
virtual quint32 GetProcessId() const { return m_ProcessId; }
virtual quint32 GetThreadId() const { return m_ThreadId; }
2023-01-12 22:10:50 +00:00
virtual quint64 GetTimeStamp() const { return m_TimeStamp; }
2021-10-15 16:39:43 +01:00
2022-03-26 09:09:24 +00:00
virtual quint8 GetType() const { return m_Type.Type; }
2021-10-30 16:08:05 +01:00
static QList<quint32>AllTypes();
2021-10-15 16:39:43 +01:00
static QString GetTypeStr(quint32 Type);
virtual QString GetTypeStr() const;
virtual QString GetStautsStr() const;
virtual void SetProcessName(const QString& name) { m_ProcessName = name; }
virtual QString GetProcessName() const { return m_ProcessName; }
2023-05-27 08:03:42 +01:00
const QVector<quint64> GetStack() const { return m_Stack; }
2021-10-15 16:39:43 +01:00
virtual void SetBoxPtr(void* ptr) { m_BoxPtr = ptr; }
virtual void* GetBoxPtr() const { return m_BoxPtr; }
2023-01-07 15:57:55 +00:00
#ifdef USE_MERGE_TRACE
2021-10-15 16:39:43 +01:00
virtual int GetCount() const { return m_Counter; }
virtual bool Equals(const QSharedDataPointer<CTraceEntry>& pOther) const {
return pOther->m_ProcessId == this->m_ProcessId && pOther->m_ThreadId == this->m_ThreadId
2022-03-26 09:09:24 +00:00
&& pOther->m_Name == this->m_Name
2021-10-15 16:39:43 +01:00
&& pOther->m_Message == this->m_Message;
}
virtual void Merge(const QSharedDataPointer<CTraceEntry>& pOther) {
m_Counter++; this->m_Type.Flags |= pOther->m_Type.Flags;
}
2023-01-07 15:57:55 +00:00
#endif
2021-10-15 16:39:43 +01:00
virtual bool IsOpen() const;
virtual bool IsClosed() const;
virtual bool IsTrace() const;
quint64 GetUID() const { return m_uid; }
protected:
2022-03-26 09:09:24 +00:00
QString m_Name;
2021-10-15 16:39:43 +01:00
QString m_Message;
2022-05-15 11:27:33 +01:00
QString m_SubType;
2021-10-15 16:39:43 +01:00
quint32 m_ProcessId;
quint32 m_ThreadId;
2023-01-12 22:10:50 +00:00
quint64 m_TimeStamp;
2021-10-15 16:39:43 +01:00
QString m_ProcessName;
2023-05-27 08:03:42 +01:00
QVector<quint64> m_Stack;
2021-10-15 16:39:43 +01:00
void* m_BoxPtr;
union
{
quint32 Flags;
struct
{
quint32
Type : 8,
SubType : 8,
Disposition : 4,
Allowed : 1,
Denided : 1,
Success : 1,
Failed : 1,
Reserved : 6,
Trace : 1,
User : 1;
};
} m_Type;
quint64 m_uid;
2023-01-07 15:57:55 +00:00
#ifdef USE_MERGE_TRACE
2021-10-15 16:39:43 +01:00
int m_Counter;
2023-01-07 15:57:55 +00:00
#endif
2021-10-15 16:39:43 +01:00
};
typedef QSharedDataPointer<CTraceEntry> CTraceEntryPtr;