
在SIL验算学习1中,推导出的2oo3状态转移矩阵计算结果与主流SIL验算软件不一致,采用DNSPY对软件进行逆向,记录逆向笔记学习
目前已知流程
int_39是记录了构型比如2oo3、1oo1等的整数,0-11
int_35是TI
int_36是SD
int_37是aMTTR
Me.int_48 是24小时
method_24执行马尔科夫链计算
Me.double_71 = 1.0 – Math.Exp(-1.0 / CDbl(Me.int_37)) μ0
Me.double_72 = 1.0 – Math.Exp(-1.0 / CDbl(Me.int_36)) μSD
double_15是beta数值
double_16是测试覆盖率
double20和21是SD/SU(未明确)
double_22是dd
double_23是du
1、对于1oo1调用method_7进行判断,在case0中调用method_35,在method_35中调用了两次method_36
2、method_36对double_83/63/65矩阵清零,对double_83赋值,执行完成后,从method_7跳转到GoTo IL_80C
3、在GoTo IL_80C中调用method_12归一化矩阵
以下摘出主要逻辑做简要注释
'这里执行的是判断分支
Private Function method_7(ByRef gclass44_0 As GClass44, int_52 As Integer, ByRef gclass39_0 As GClass39) As Boolean
Dim flag As Boolean = False
Dim result As Boolean = True
If gclass44_0 IsNot Nothing Then
Me.int_41(1) = 4
Me.int_41(2) = 4
Me.int_41(3) = 4
Me.int_43(1) = 4
Me.int_43(2) = 4
Me.int_43(3) = 4
'这里看起来像是xml中记录SIF是否计算的判断函数
Me.int_39 = CInt(gclass44_0.method_31()) '整数值
Me.bool_4 = gclass44_0.method_29() '布尔值
'这两个好像都是
Me.double_15 = CDbl(gclass44_0.method_12().method_16()) / 100.0 'double_15是beta数值
Me.int_37 = gclass44_0.method_13().method_16() 'aMTTR
Me.int_38 = gclass44_0.method_14().method_16() * 365 / 12 'aPtint 测试间隔
Me.double_16 = gclass44_0.method_15().method_18() / 100.0 'aPtc 测试覆盖率
Me.bool_5(1) = False
Me.string_8(int_52) = gclass44_0.method_11().method_15() 'aGname ?
Dim num As Integer = 1
If Me.bool_4 Then
If Me.int_39 >= 1 Then
num = 2
End If
If Me.int_39 >= 3 Then
num = 3
End If
End If
Me.method_17()
Dim num2 As Integer = 1
Dim num3 As Integer = num
For i As Integer = num2 To num3
Me.double_2(0) = 0.0
Me.double_3(0) = 0.0
Me.double_4(0) = 0.0
Me.double_5(0) = 0.0
Me.double_6(0) = 0.0
Me.double_7(0) = 0.0
Me.double_8(0) = 0.0
Me.double_9(0) = 0.0
Me.double_10(0) = 0.0
Me.double_11(0) = 0.0
Me.string_5(0) = "A"
Me.bool_3 = True
Me.int_45(0) = 4
Dim gclass As GClass46 = gclass44_0.method_33(i)
'遍历 GClass44 的子节点(GClass46)
If gclass IsNot Nothing Then
Dim double_ As Double = 0.0
Dim gclass2 As GClass47 = gclass.method_23()
If Not gclass2.method_46() Then
Me.method_15(gclass2, double_, False)
End If
If gclass.method_11().method_16() Then
If gclass.method_15().method_16() Then
double_ = gclass.method_16().method_18() / 100.0
Else
double_ = 0.0
End If
If gclass.method_12().method_16() Then
gclass2 = gclass.method_27()
If Not gclass2.method_46() Then
Me.method_15(gclass2, double_, False)
End If
Else
gclass2 = gclass.method_25()
If Not gclass2.method_46() Then
Me.method_15(gclass2, double_, False)
End If
gclass2 = gclass.method_26()
If Not gclass2.method_46() Then
Me.method_15(gclass2, double_, False)
End If
End If
gclass2 = gclass.method_28()
If Not gclass2.method_46() Then
Me.method_15(gclass2, double_, False)
End If
gclass2 = gclass.method_29()
If Not gclass2.method_46() Then
Me.method_15(gclass2, double_, False)
End If
End If
gclass2 = gclass.method_24()
If Not gclass2.method_46() Then
Me.method_15(gclass2, 0.0, False)
End If
Me.method_19(i, 0)
Dim genum10_ As GEnum10 = GEnum10.const_0
If gclass39_0 IsNot Nothing Then
genum10_ = CType(gclass39_0.method_30().method_16(), GEnum10)
End If
If Me.method_28(i, Class5.smethod_56(gclass44_0.method_31()), Class5.smethod_57(genum10_)) Then
flag = True
End If
gclass.method_19().method_19(Me.double_13(i))
gclass.method_20().method_19(Me.double_14(i))
If Me.int_39 >= 1 Then
Me.method_21(i)
End If
End If
Next
If Not flag Then
Me.int_41(1) = 27
Me.int_41(2) = 27
Me.int_41(3) = 27
Me.int_43(1) = 27
Me.int_43(2) = 27
Me.int_43(3) = 27
End If
If num > 1 Then
Me.method_22(num)
If num >= 3 Then
Me.method_23()
End If
End If
If Me.bool_4 Then
Select Case Me.int_39
Case 1
If Not Me.method_41() Then
result = False
End If
Me.int_44(int_52) = Me.method_30(New Integer() { Me.int_43(1), Me.int_43(2) })
If Me.bool_2 Then
Me.int_42(int_52) = Me.method_30(New Integer() { Me.int_41(1), Me.int_41(2) }) + 1
GoTo IL_80C
End If
Me.int_42(int_52) = Me.method_32(New Integer() { Me.int_41(1), Me.int_41(2) }) + 1
GoTo IL_80C
Case 2
If Not Me.method_49() Then
result = False
End If
Me.int_44(int_52) = Me.method_30(New Integer() { Me.int_43(1), Me.int_43(2) })
Me.int_42(int_52) = Me.method_30(New Integer() { Me.int_41(1), Me.int_41(2) })
GoTo IL_80C
Case 3
If Not Me.method_53() Then
result = False
End If
Me.int_44(int_52) = Me.method_30(New Integer() { Me.int_43(1), Me.int_43(2), Me.int_43(3) })
If Me.bool_2 Then
Me.int_42(int_52) = Me.method_30(New Integer() { Me.int_41(1), Me.int_41(2), Me.int_41(3) }) + 2
GoTo IL_80C
End If
Me.int_42(int_52) = Me.method_32(New Integer() { Me.int_41(1), Me.int_41(2), Me.int_41(3) }) + 2
GoTo IL_80C
Case 4
If Not Me.method_61() Then
result = False
End If
Me.int_44(int_52) = Me.method_30(New Integer() { Me.int_43(1), Me.int_43(2), Me.int_43(3) })
Me.int_42(int_52) = Me.method_30(New Integer() { Me.int_41(1), Me.int_41(2), Me.int_41(3) })
GoTo IL_80C
End Select
Else
Me.int_44(int_52) = Me.int_43(1)
Select Case Me.int_39
Case 0
If Not Me.method_35() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1)
GoTo IL_80C
Case 1
If Not Me.method_43() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1) + 1
GoTo IL_80C
Case 2
If Not Me.method_51() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1)
GoTo IL_80C
Case 3
If Not Me.method_55() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1) + 2
GoTo IL_80C
Case 4
If Not Me.method_63() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1)
GoTo IL_80C
Case 5
If Not Me.method_65() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1) + 1
GoTo IL_80C
Case 6
If Not Me.method_67() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1)
GoTo IL_80C
Case 7
If Not Me.method_69() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1)
GoTo IL_80C
Case 8
If Not Me.method_71() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1)
GoTo IL_80C
Case 9
If Not Me.method_75() Then
result = False
End If
Me.int_42(int_52) = Me.int_41(1) + 3
GoTo IL_80C
End Select
End If
Dim result2 As Boolean
Return result2
IL_80C:
Dim num4 As Integer = 2
Dim num5 As Integer = Information.UBound(Me.double_65, 1)
For j As Integer = num4 To num5
Me.double_65(j, 1) = Me.double_16 '将二维数组 double_65 从第 2 行到最后一行的 第 1 列,全部赋值为 Me.double_16(测试覆盖率???) 的值。
Next
If Not Me.method_12(Me.double_63) Then
result = False
End If
If Not Me.method_12(Me.double_65) Then
result = False
End If
If Not Me.method_24(int_52) Then
result = False
End If
gclass44_0.method_17().method_19(Me.double_19)
gclass44_0.method_18().method_19(Me.double_18(int_52))
End If
Return result
End Function
Private Function method_35() As Boolean
Dim double_ As Double(,) = Nothing
Me.method_36(Me.double_63)
Me.method_36(double_)
Me.enum9_0 = GClass21.Enum9.const_1
Return Me.method_34(Me.double_63, double_, "Build1oo1")'比较两个矩阵是否相等 返回布尔值
End Function
Private Sub method_36(ByRef double_83 As Double(,))
double_83 = New Double(4, 4) {} ' 新建一个 5x5 的二维 Double 数组(索引从0到4)
Me.double_65 = New Double(4, 4) {} ' 同样新建另一个 5x5 的二维 Double 数组,赋给成员变量 double_65
Me.double_66 = New Double(1, 4) {} ' 新建一个 2x5 的二维 Double 数组,赋给成员变量 double_66
Me.method_10(double_83) ' 调用 method_10 (清零数组)
Me.method_10(Me.double_65) ' 同样处理 double_65
Me.method_38() ' 调用接口方法,传入参数 4(具体作用依赖接口定义)
' 给 double_83 数组的部分元素赋值:
double_83(0, 0) = 2.0
double_83(0, 2) = 1.0
double_83(0, 3) = 2.0
double_83(0, 4) = 2.0
double_83(1, 2) = Me.double_20(1) + Me.double_21(1)
double_83(1, 3) = Me.double_22(1)
double_83(1, 4) = Me.double_23(1)
double_83(2, 1) = Me.double_72
double_83(3, 1) = Me.double_71
End Sub
'归一化矩阵
Private Function method_12(double_83 As Double(,)) As Boolean
Dim result As Boolean = True
If double_83 Is Nothing Then
Return True
End If
Dim num As Integer = 1
Dim num2 As Integer = Information.UBound(double_83, 1)
For i As Integer = num To num2
double_83(i, i) = 1.0
Dim num3 As Integer = 1
Dim num4 As Integer = Information.UBound(double_83, 2)
For j As Integer = num3 To num4
If i <> j Then
double_83(i, i) -= double_83(i, j)
End If
Next
Dim num5 As Double = 0.0
Dim num6 As Integer = 1
Dim num7 As Integer = Information.UBound(double_83, 2)
For j As Integer = num6 To num7
num5 += double_83(i, j)
Next
If Math.Abs(1.0 - num5) > 1E-09 Then
result = False
Me.string_7 = String.Concat(New String() { Me.string_7, "Transition Matrix Row ", Conversions.ToString(i), " Sum = ", num5.ToString(), "; " })
End If
Next
Return result
End Function
'校验状态转移矩阵 double_63 是否合法
'校验另一个转移矩阵 double_65 是否合法
Private Function method_12(double_83 As Double(,)) As Boolean
Dim result As Boolean = True
If double_83 Is Nothing Then
Return True
End If
Dim num As Integer = 1
Dim num2 As Integer = Information.UBound(double_83, 1)
For i As Integer = num To num2
double_83(i, i) = 1.0
Dim num3 As Integer = 1
Dim num4 As Integer = Information.UBound(double_83, 2)
For j As Integer = num3 To num4
If i <> j Then
double_83(i, i) -= double_83(i, j)
End If
Next
Dim num5 As Double = 0.0
Dim num6 As Integer = 1
Dim num7 As Integer = Information.UBound(double_83, 2)
For j As Integer = num6 To num7
num5 += double_83(i, j)
Next
If Math.Abs(1.0 - num5) > 1E-09 Then
result = False
Me.string_7 = String.Concat(New String() { Me.string_7, "Transition Matrix Row ", Conversions.ToString(i), " Sum = ", num5.ToString(), "; " })
End If
Next
Return result
End Function
'method_24(int_52) → 模拟状态演化、计算指标,并更新 double_17、double_18、double_19
Private Function method_24(int_52 As Integer) As Boolean
Dim array As Double() = New Double(4) {}
Dim array2 As Integer() = New Integer(4) {}
Dim num As Integer = Me.int_35 * 8760 / Me.int_48
Me.double_66 = New Double(1, Information.UBound(Me.double_63, 2) + 1 - 1) {}
Dim double_ As Double(,) = New Double(1, Information.UBound(Me.double_66, 2) + 1 - 1) {}
Me.double_70 = New Double(1, Information.UBound(Me.double_66, 2) + 1 - 1) {}
Me.double_64 = New Double(Information.UBound(Me.double_63, 1) + 1 - 1, Information.UBound(Me.double_63, 2) + 1 - 1) {}
Me.method_10(Me.double_66)
Me.double_66(1, 1) = 1.0
Me.gclass19_0.imethod_3(Me.double_63, Me.int_48, Me.double_64)
Me.method_10(double_)
Me.double_17(int_52, 0) = 0.0
Me.double_18(int_52) = 0.0
Me.double_19 = 0.0
Dim num2 As Integer = CInt(Math.Round(Me.double_63(0, 0)))
Dim num3 As Double = CDbl((Me.int_38 * Me.int_48)) / 24.0
array(1) = Me.double_67(1) * 365.0 / 12.0 * CDbl(Me.int_48) / 24.0
array2(1) = 0
Dim num4 As Integer = 0
Dim num5 As Integer = 1
Dim num6 As Integer = num
For i As Integer = num5 To num6
Me.gclass19_0.imethod_0(Me.double_66, Me.double_64, Me.double_66)
If Me.enum5_0 = Class5.Enum5.const_0 Then
Dim num7 As Integer
If Me.bool_5(1) Then
num7 = CInt(Math.Round(CDbl(i) Mod array(1)))
If num7 < array2(1) And array(1) < CDbl(num) And i < num Then
Me.method_25(Me.double_69, Me.double_70)
End If
array2(1) = num7
End If
num7 = CInt(Math.Round(CDbl(i) Mod num3))
If num7 < num4 And num3 < CDbl(num) And i < num Then
Me.gclass19_0.GClass19.GInterface0.imethod_2(Me.double_66, double_, Me.double_66)
Me.gclass19_0.imethod_0(Me.double_66, Me.double_65, Me.double_66)
Me.gclass19_0.GClass19.GInterface0.imethod_1(Me.double_66, double_, Me.double_66)
Me.method_33(Me.double_66, double_)
Me.method_33(double_, Me.double_70)
End If
num4 = num7
End If
Me.double_17(int_52, i) = 0.0
Dim num8 As Integer = 1
Dim num9 As Integer = Information.UBound(Me.double_66, 2)
For j As Integer = num8 To num9
If Me.double_63(0, j) <> 1.0 Then
Me.double_18(int_52) = Me.double_18(int_52) + Me.double_66(1, j) * Me.double_63(j, num2)
End If
If Me.double_63(0, j) = 2.0 Then
Me.double_17(int_52, i) = Me.double_17(int_52, i) + Me.double_66(1, j)
End If
Next
Me.double_19 += Me.double_17(int_52, i)
Next
Dim result As Boolean
If Me.method_100(Me.double_66) Then
Me.double_18(int_52) = Me.double_18(int_52) / CDbl(num)
If Me.enum5_0 = Class5.Enum5.const_0 Then
Me.double_19 /= CDbl(num)
Else
Me.double_19 = Me.double_17(int_52, num) / CDbl((num * Me.int_48))
Me.double_17(int_52, 0) = Me.double_19
End If
result = True
Else
Me.double_18(int_52) = 0.0
Me.double_19 = 0.0
result = False
End If
Return result
End Function
Private Function method_101(ByRef gclass61_0 As GClass61, string_9 As String, string_10 As String, double_83 As Double(,)) As Double
Dim num As Integer = Information.UBound(double_83, 1)
Dim num2 As Integer = Information.UBound(double_83, 2)
Dim array As Double() = New Double(num2 + 1 - 1) {}
Dim array2 As Double() = New Double(num2 + 1 - 1) {}
Dim num11 As Double
If Me.enum5_0 = Class5.Enum5.const_0 Then
Try
Dim zedGraphControl As ZedGraphControl = Nothing
Dim num3 As Integer = 0
While num3 <= 100 And zedGraphControl Is Nothing
zedGraphControl = New ZedGraphControl()
num3 += 1
End While
zedGraphControl.GraphPane.CurveList.Clear()
zedGraphControl.GraphPane.Title = string_10
zedGraphControl.GraphPane.XAxis.Title = "Years"
zedGraphControl.GraphPane.YAxis.Title = "PFD"
Dim control As Control = zedGraphControl
Dim size As Size = New Size(500, 375)
control.Size = size
Dim num4 As Integer = 0
Dim num5 As Integer = num2
For i As Integer = num4 To num5
array(i) = CDbl(i) / 365.0
Next
Dim num6 As Double = 0.0
Dim num7 As Integer = 1
Dim num8 As Integer = num
For j As Integer = num7 To num8
Dim num9 As Integer = 1
Dim num10 As Integer = num2
For i As Integer = num9 To num10
array2(i) = double_83(j, i)
num11 += double_83(j, i)
If double_83(j, i) > num6 Then
num6 = double_83(j, i)
End If
Next
num11 /= CDbl(num2)
Dim lineItem As LineItem = zedGraphControl.GraphPane.AddCurve("PFD", array, array2, Color.Red, SymbolType.None)
lineItem.Line.Width = 2F
Dim lineItem2 As LineItem = zedGraphControl.GraphPane.AddCurve("PFDavg", New Double() { 0.0, CDbl(num2) / 365.0 }, New Double() { num11, num11 }, Color.Black, SymbolType.None)
lineItem2.Line.Style = DashStyle.Dash
lineItem2.Line.Width = 2F
Next
Dim x As Double() = New Double() { 0.0, CDbl(num2) / 365.0 }
Dim hiLowBarItem As HiLowBarItem = zedGraphControl.GraphPane.AddHiLowBar("", x, New Double() { 0.1, 0.1 }, New Double() { 0.01, 0.01 }, Color.Red)
hiLowBarItem.Bar.Size = 1000F
Dim hiLowBarItem2 As HiLowBarItem = zedGraphControl.GraphPane.AddHiLowBar("", x, New Double() { 0.01, 0.01 }, New Double() { 0.001, 0.001 }, Color.OrangeRed)
hiLowBarItem2.Bar.Size = 1000F
Dim hiLowBarItem3 As HiLowBarItem = zedGraphControl.GraphPane.AddHiLowBar("", x, New Double() { 0.001, 0.001 }, New Double() { 0.0001, 0.0001 }, Color.Yellow)
hiLowBarItem3.Bar.Size = 1000F
Dim hiLowBarItem4 As HiLowBarItem = zedGraphControl.GraphPane.AddHiLowBar("", x, New Double() { 0.0001, 0.0001 }, New Double() { 1E-05, 1E-05 }, Color.Green)
hiLowBarItem4.Bar.Size = 1000F
zedGraphControl.GraphPane.XAxis.Max = CDbl(num2) / 365.0
If num6 >= 0.0001 Then
zedGraphControl.GraphPane.YAxis.Min = 1E-05
zedGraphControl.GraphPane.YAxis.Max = 1.0
ElseIf num6 >= 1E-08 Then
zedGraphControl.GraphPane.YAxis.Min = 1E-09
zedGraphControl.GraphPane.YAxis.Max = 0.0001
Else
zedGraphControl.GraphPane.YAxis.Min = 1E-13
zedGraphControl.GraphPane.YAxis.Max = 1E-08
End If
zedGraphControl.GraphPane.YAxis.Type = AxisType.Log
zedGraphControl.GraphPane.AxisFill = New Fill(Color.White, Color.LightGoldenrodYellow)
zedGraphControl.AxisChange()
Dim image As Bitmap = zedGraphControl.GraphPane.Image
Dim font As Font = New Font("Lucida Sans", 9F, FontStyle.Regular, GraphicsUnit.Point)
Dim graphics As Graphics = Graphics.FromImage(image)
Dim text As String = "© " + Conversions.ToString(2009) + " exida.com L.L.C."
Dim sizeF As SizeF = graphics.MeasureString(text, font)
Dim x2 As Single = CSng(image.Width) - sizeF.Width - 10F
Dim y As Single = CSng(image.Height) - sizeF.Height - 10F
graphics.DrawString(text, font, Brushes.Black, x2, y)
Dim flag As Boolean = True
Dim gdelegate As GClass21.GDelegate21 = Me.gdelegate21_0
If gdelegate IsNot Nothing Then
gdelegate(string_9, string_10, zedGraphControl, num6, flag)
End If
If flag Then
zedGraphControl.Dispose()
End If
gclass61_0.method_1(image)
Return num11
Catch ex As Exception
Dim gdelegate2 As GClass21.GDelegate22 = Me.gdelegate22_0
If gdelegate2 IsNot Nothing Then
gdelegate2("UpdatePFDChart", ex)
End If
Me.string_7 = Me.string_7 + "PFD Chart Failed: " + ex.Message + "; "
num11 = 0.0
Dim num12 As Integer = 1
Dim num13 As Integer = num2
For i As Integer = num12 To num13
num11 += double_83(1, i)
Next
Return num11 / CDbl(num2)
End Try
End If
Try
gclass61_0.method_1(Nothing)
Catch ex2 As Exception
End Try
Return num11
End Function
记录局部变量

