-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
DetourHelpers.cs
57 lines (44 loc) · 1.37 KB
/
DetourHelpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Helper class for dealing with RF detours
/// </summary>
public class DetourHelpers
{
private ReliabilityTestSet _testSet;
public void Initialize(ReliabilityTestSet testSet)
{
_testSet = testSet;
InstallDetours();
}
public void Uninitialize()
{
RemoveDetours();
}
public void SetThreadTestId(int index)
{
SetThreadTest(index);
}
public int GetThreadTestId()
{
return ((int)GetThreadTest());
}
public void SetTestIdName(int id, string name)
{
AddTestToNameMapping(id, name);
}
[DllImport("RFDetours")]
private static extern void AddTestToNameMapping(int id, [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)] string name);
[DllImport("RFDetours")]
private static extern void InstallDetours();
[DllImport("RFDetours")]
private static extern void RemoveDetours();
[DllImport("RFDetours")]
private static extern void SetThreadTest(int testId);
[DllImport("RFDetours")]
private static extern IntPtr GetThreadTest();
}