Skip to content

Commit e818d41

Browse files
committed
SEBWIN-1147: Implemented changes.
1 parent 397f8e1 commit e818d41

4 files changed

Lines changed: 21 additions & 37 deletions

File tree

SafeExamBrowser.Client/Responsibilities/IntegrityResponsibility.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,9 @@ private void HandleRuntimeIntegrityStatus(bool isValid)
167167
{
168168
Logger.Info("Runtime integrity successfully verified.");
169169
}
170-
else if (coordinator.RequestSessionLock())
171-
{
172-
Logger.Warn("Runtime integrity is compromised!");
173-
174-
Task.Run(() =>
175-
{
176-
ShowLockScreen(text.Get(TextKey.LockScreen_RuntimeIntegrityMessage), text.Get(TextKey.LockScreen_Title), Enumerable.Empty<LockScreenOption>());
177-
coordinator.ReleaseSessionLock();
178-
});
179-
}
180170
else
181171
{
182-
Logger.Warn("Runtime integrity is compromised but lock screen is already active!");
172+
Logger.Warn("Runtime integrity is compromised!");
183173
}
184174
}
185175

SafeExamBrowser.Configuration/Integrity/IntegrityModule.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,20 @@ public bool TryVerifyRuntimeIntegrity(out bool isValid)
194194

195195
try
196196
{
197-
isValid = Native.VerifyRuntimeIntegrity();
197+
isValid = Native.VerifyRuntimeIntegrity(out var data, out var count);
198+
199+
for (var index = 0; index < count; index++)
200+
{
201+
var pointer = Marshal.ReadIntPtr(data, index * IntPtr.Size);
202+
var raw = Marshal.PtrToStringBSTR(pointer);
203+
var item = string.Join(" ", raw.ToCharArray().Select(c => Convert.ToInt32(c)));
204+
205+
logger.Warn($"Runtime Integrity Violation #{index}: {item}");
206+
207+
Marshal.FreeBSTR(pointer);
208+
}
209+
210+
Marshal.FreeCoTaskMem(data);
198211
success = true;
199212
}
200213
catch (DllNotFoundException)
@@ -326,7 +339,7 @@ private static class Native
326339
internal static extern bool VerifyCodeSignature();
327340

328341
[DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
329-
internal static extern bool VerifyRuntimeIntegrity();
342+
internal static extern bool VerifyRuntimeIntegrity(out IntPtr data, out int count);
330343
}
331344
}
332345
}

SafeExamBrowser.Runtime/Operations/Bootstrap/ApplicationIntegrityOperation.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,13 @@ public ApplicationIntegrityOperation(IIntegrityModule module, ILogger logger)
2929

3030
public OperationResult Perform()
3131
{
32-
var result = OperationResult.Success;
33-
34-
logger.Info($"Attempting to verify application integrity...");
32+
logger.Info("Attempting to verify application and runtime integrity...");
3533
StatusChanged?.Invoke(TextKey.OperationStatus_VerifyApplicationIntegrity);
3634

3735
VerifyCodeSignature();
36+
VerifyRuntimeIntegrity();
3837

39-
if (!VerifyRuntimeIntegrity())
40-
{
41-
result = OperationResult.Failed;
42-
}
43-
44-
return result;
38+
return OperationResult.Success;
4539
}
4640

4741
public OperationResult Revert()
@@ -78,7 +72,7 @@ private bool VerifyRuntimeIntegrity()
7872
}
7973
else
8074
{
81-
logger.Error("Runtime integrity is compromised!");
75+
logger.Warn("Runtime integrity is compromised!");
8276
}
8377
}
8478
else

SafeExamBrowser.Runtime/Responsibilities/IntegrityResponsibility.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
using System;
10-
using System.Threading.Tasks;
1110
using System.Timers;
1211
using SafeExamBrowser.Configuration.Contracts.Integrity;
1312
using SafeExamBrowser.Logging.Contracts;
@@ -88,19 +87,7 @@ private void HandleRuntimeIntegrityStatus(bool isValid)
8887
}
8988
else
9089
{
91-
Logger.Error("Runtime integrity is compromised!");
92-
93-
StopIntegrityMonitoring();
94-
95-
Task.Run(() =>
96-
{
97-
if (SessionIsRunning)
98-
{
99-
Context.Responsibilities.Delegate(RuntimeTask.StopSession);
100-
}
101-
102-
shutdown.Invoke();
103-
});
90+
Logger.Warn("Runtime integrity is compromised!");
10491
}
10592
}
10693
}

0 commit comments

Comments
 (0)