v 0.1.2
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
// File: Models/ConcurrentDTO.cs
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
public class ConcurrentDTO
|
||||
{
|
||||
internal readonly object _lock = new object();
|
||||
|
||||
public void LockedSet<T>(ref T dst, T value)
|
||||
{
|
||||
lock (_lock) dst = value;
|
||||
}
|
||||
|
||||
public T LockedGet<T>(ref T src)
|
||||
{
|
||||
lock (_lock) return src;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
// File: Models/MemoryRegion.cs
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
using WebmrAPI.Utils;
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
public class MemoryRegion : ConcurrentDTO
|
||||
public class MemoryRegion : ConcurrentObject
|
||||
{
|
||||
private long _addr = 0;
|
||||
private ulong _size = 0;
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// File: Models/MemoryRegionInfo.cs
|
||||
|
||||
using WebmrAPI.Services;
|
||||
using WebmrAPI.Utils;
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
public class MemoryRegionInfo : MemoryRegion
|
||||
{
|
||||
private WinApi.MemoryState _state = 0;
|
||||
private WinApi.MemoryPageProtectionState _protect = 0;
|
||||
private WinApi.MemoryType _type = 0;
|
||||
private WindowsProcess.MemoryState _state = 0;
|
||||
private WindowsProcess.MemoryPageProtectionState _protect = 0;
|
||||
private WindowsProcess.MemoryType _type = 0;
|
||||
|
||||
public WinApi.MemoryState MemoryState
|
||||
public WindowsProcess.MemoryState MemoryState
|
||||
{
|
||||
get => LockedGet(ref _state);
|
||||
set => LockedSet(ref _state, value);
|
||||
}
|
||||
public WinApi.MemoryPageProtectionState MemoryPageProtection
|
||||
public WindowsProcess.MemoryPageProtectionState MemoryPageProtection
|
||||
{
|
||||
get => LockedGet(ref _protect);
|
||||
set => LockedSet(ref _protect, value);
|
||||
}
|
||||
public WinApi.MemoryType MemoryType
|
||||
public WindowsProcess.MemoryType MemoryType
|
||||
{
|
||||
get => LockedGet(ref _type);
|
||||
set => LockedSet(ref _type, value);
|
||||
|
||||
@@ -4,15 +4,15 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
public enum ProcessStatus
|
||||
{
|
||||
Undefined,
|
||||
Running,
|
||||
NotResponding
|
||||
}
|
||||
|
||||
public class ProcessBaseInfo : MemoryRegion
|
||||
{
|
||||
public enum ProcessStatus
|
||||
{
|
||||
Undefined,
|
||||
Running,
|
||||
NotResponding
|
||||
}
|
||||
|
||||
private TimeSpan _lastPTime = TimeSpan.Zero;
|
||||
private TimeSpan _curPTime = TimeSpan.Zero;
|
||||
|
||||
|
||||
+20
-9
@@ -2,25 +2,36 @@
|
||||
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text.Json.Serialization;
|
||||
using WebmrAPI.Utils;
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ProcessInfo : ProcessBaseInfo
|
||||
{
|
||||
private DateTime _lastUpdate = DateTime.MinValue;
|
||||
private List<MemoryRegionInfo> _regions = new();
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime LastUpdate
|
||||
public LazyConcurrentContainer<MemoryRegionInfo> MemoryRegionsContainer { get; set; } = new();
|
||||
[JsonIgnore]
|
||||
public LazyConcurrentContainer<ProcessModuleInfo> ModulesContainer { get; set; } = new();
|
||||
[JsonIgnore]
|
||||
public LazyConcurrentContainer<ProcessThreadInfo> ThreadsContainer { get; set; } = new();
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public IEnumerable<MemoryRegionInfo>? MemoryRegions
|
||||
{
|
||||
get => LockedGet(ref _lastUpdate);
|
||||
set => LockedSet(ref _lastUpdate, value);
|
||||
get => MemoryRegionsContainer.Values;
|
||||
}
|
||||
public List<MemoryRegionInfo> MemoryRegions
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public IEnumerable<ProcessModuleInfo>? Modules
|
||||
{
|
||||
get => LockedGet(ref _regions);
|
||||
set => LockedSet(ref _regions, value);
|
||||
get => ModulesContainer.Values;
|
||||
}
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public IEnumerable<ProcessThreadInfo>? Threads
|
||||
{
|
||||
get => ThreadsContainer.Values;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// File: Models/ProcessModuleInfo.cs
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
public class ProcessModuleInfo : MemoryRegion
|
||||
{
|
||||
private string? _moduleName = null;
|
||||
private string? _fileName = null;
|
||||
private long _entrypointAddress = 0;
|
||||
|
||||
public string? ModuleName
|
||||
{
|
||||
get => LockedGet(ref _moduleName);
|
||||
set => LockedSet(ref _moduleName, value);
|
||||
}
|
||||
|
||||
public string? FileName
|
||||
{
|
||||
get => LockedGet(ref _fileName);
|
||||
set => LockedSet(ref _fileName, value);
|
||||
}
|
||||
|
||||
public string? EntrypointAddress
|
||||
{
|
||||
get => (EntrypointRawAddress > 0) ? $"0x{EntrypointRawAddress:X16}" : null;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public long EntrypointRawAddress
|
||||
{
|
||||
get => LockedGet(ref _entrypointAddress);
|
||||
set => LockedSet(ref _entrypointAddress, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// File: Models/ProcessThreadInfo.cs
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
using WebmrAPI.Utils;
|
||||
|
||||
namespace WebmrAPI.Models
|
||||
{
|
||||
public class ProcessThreadInfo : ConcurrentObject
|
||||
{
|
||||
private TimeSpan _lastPTime = TimeSpan.Zero;
|
||||
private TimeSpan _curPTime = TimeSpan.Zero;
|
||||
|
||||
private int _id = 0;
|
||||
private int _currentPriority = 0;
|
||||
private int _basePriority = 0;
|
||||
private double _cpuUsage = 0;
|
||||
|
||||
[JsonIgnore]
|
||||
public TimeSpan TotalProcessorTime
|
||||
{
|
||||
set { lock (_lock) { _lastPTime = _curPTime; _curPTime = value; } }
|
||||
}
|
||||
[JsonIgnore]
|
||||
public double ProcessorTime
|
||||
{
|
||||
get { lock (_lock) return (_curPTime - _lastPTime).TotalMilliseconds; }
|
||||
}
|
||||
|
||||
public int ID
|
||||
{
|
||||
get => LockedGet(ref _id);
|
||||
set => LockedSet(ref _id, value);
|
||||
}
|
||||
|
||||
public int CurrentPriority
|
||||
{
|
||||
get => LockedGet(ref _currentPriority);
|
||||
set => LockedSet(ref _currentPriority, value);
|
||||
}
|
||||
|
||||
public int BasePriority
|
||||
{
|
||||
get => LockedGet(ref _basePriority);
|
||||
set => LockedSet(ref _basePriority, value);
|
||||
}
|
||||
public double CpuUsage
|
||||
{
|
||||
get => LockedGet(ref _cpuUsage);
|
||||
set => LockedSet(ref _cpuUsage, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user