VB.NET随机System.StackOverflowException错误 [英] VB.NET Random System.StackOverflowException Error

查看:101
本文介绍了VB.NET随机System.StackOverflowException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是VB.NET开发人员的新手.

我从应用程序中获取了一个代码,因此我将单独对其进行测试:这是一个xor解密器.

有时它运行良好,并且常常使我对Public Sub New()中的System.StackOverflowException哭泣.

有很多这样的行(0到999)

Hello everybody,

I''m a newbie in VB.NET dev.

I get a code from a app and i would to test it alone: this is a xor decrypter.

Sometimes it works well and often it makes me cry with System.StackOverflowException from Public Sub New()

there is lot of line (0 to 999) like this

Me
.keyarr(0) = Chr(35) & Chr(54) & Chr(158) & Chr(43) & Chr(90) & Chr(143) & Chr(107) & Chr(172) & Chr(64) & Chr(150) & Chr(139) & Chr(199) & Chr(1) & Chr(26) & Chr(71) & Chr(51) & Chr(139) & Chr(187) & Chr(245) & Chr(212) & Chr(44) & Chr(232) & Chr(67) & Chr(93) & Chr(153) & Chr(206) & Chr(100) & Chr(212) & Chr(81) & Chr(159) & Chr(182) & Chr(47) & Chr(82) & Chr(11) & Chr(190) & Chr(147) & Chr(29) & Chr(57) & Chr(249) & Chr(106) & Chr(252) & Chr(32) & Chr(132) & Chr(180) & Chr(126) & Chr(152) & Chr(252) & Chr(231) & Chr(50) & Chr(243) & Chr(195) & Chr(185) & Chr(125) & Chr(129) & Chr(193) & Chr(50) & Chr(169) & Chr(202) & Chr(16) & Chr(81) & Chr(250) & Chr(231) & Chr(168) & Chr(158) & Chr(233) & Chr(195) & Chr(63) & Chr(24) & Chr(85) & Chr(161) & Chr(180) & Chr(169) & Chr(212) & Chr(190) & Chr(19) & Chr(180) & Chr(225) & Chr(122) & Chr(151) & Chr(209) & Chr(26) & Chr(164) & Chr(189) & Chr(83) & Chr(76) & Chr(166) & Chr(178) & Chr(180) & Chr(134) & Chr(253) & Chr(79) & Chr(123) & Chr(217) & Chr(156) & Chr(225) & Chr(164) & Chr(42) & Chr(1) & Chr(245) & Chr(78) & Chr(132) & Chr(58) & Chr(68) & Chr(138) & Chr(118) & Chr(236) & Chr(43) & Chr(35) & Chr(248) & Chr(103) & Chr(188) & Chr(57) & Chr(35) & Chr(218) & Chr(179) & Chr(129) & Chr(122) & Chr(249) & Chr(122) & Chr(17) & Chr(249) & Chr(201) & Chr(139) & Chr(120) & Chr(154) & Chr(19) & Chr(77) & Chr(20)



我认为我的计算机中有足够的内存,但是我不明白为什么会出现此错误,在应用程序中没有问题.
我可能在调用函数或类似的函数中犯了一个错误吗?


这是其余的代码:



I think there is enough memory in my computer but i don''t understand why i get this error, in the app there is no problem.
May i made a mistake in call function or something like that ?


Here the rest of the code:

Imports System

Module Module1




 Sub Main()

  Dim password As New Password

  password.EncryptedPassword = "2945D7F0F653C2EDFF"
  password.keyindex = 154



  password.getPassword()





 End Sub
 Public Class Password



  '' Keyarray, where the Xor-Keys are stored (To compile, use 0 to 999, for debugging use 0 to 25!)

  Const debugging As Boolean = True

  Private keyarr(0 To 999) As String

  '' Keyindex is used to find the Xor-Key in the Keyarray
  Public keyindex As Integer = 0

  '' Stores the encrypted password
  Public EncryptedPassword As String = ""

  '' Initiates the Keyarray





[Public Sub() ... End Sub] 0 to 999 lines ...





''This Function decrypts a password. The Function takes the Password and the KeyIndex. Encryption will be done with an Xor operation, and the result will be HEX-encoded, so the result is a string
  Private Function dec(ByVal Hex As String, ByVal keyindex As Integer) As String

   ''lenght of the password
   Dim Lenght As Integer

   ''The whole key, which will be used to encrypt the key. This key will be shorten to the needed lenght, and then be stored in the xorwith-variable.
   Dim Key As String

   ''The result, as cleartext
   Dim Result As String = ""

   ''Counter Variable
   Dim pwPosition As Integer

   ''This is set to the numeric value of the character which is going to be xored against the key
   Dim intXorValueHex As Short

   ''This is set to the numeric value of the character which is going to be xored against the Hex
   Dim intXorValueKey As Short

   ''String for Temporary Use
   Dim TempStr As String

   ''Integer for Temporary Use
   Dim TempInt As Integer

   Key = keyarr(keyindex)

   If Me.EncryptedPassword.Length > 0 Then



    Try
     ''get the lenght of the password, it''s half of the hex-lenght
     Lenght = Hex.Length / 2

     ''As long as we are inside the Password
     For pwPosition = 1 To Lenght Step 1

      ''Get the Char from the Key and the Hex as integer, at which position we are.
      intXorValueHex = CInt("&H" & Mid(Hex, pwPosition * 2 - 1, 2))
      intXorValueKey = Asc(Mid(Key, pwPosition, 1))

      ''XOR this characters against eachother
      TempInt = (intXorValueHex Xor intXorValueKey)

      ''Write the Char as Hex into the TempStr
      TempStr = Chr(TempInt)

      ''Append the two chars of the Hex to the result-string
      Result &= TempStr
     Next
    Catch ex As System.Exception
     ''MsgBox(ex.Message & vbNewLine & "Most possible, the Password was unencrypted")
    End Try

   End If



   Console.WriteLine(Result)

   Return Result

  End Function


  Public Function getPassword() As String
   '' Function which returns the Password as string
   Return Me.dec(EncryptedPassword, keyindex)
  End Function


 End Class


End Module



感谢您的帮助



最好的问候



Samuel



Thanks for your help



Best Regards



Samuel

推荐答案

您知道,调试器是最好的朋友.
:)
You know, the debugger is the best friend.
:)


大声笑,调试员什么也没说

我只给''System.StackOverflowException''

有时,当我将keyindex设置为0并重新生成并重新启动时,该程序可以工作了,我应该重新编译... 这是一个线索吗?

谢谢
lol, the debbuger say nothing

i give just ''System.StackOverflowException''

sometimes the program works when i set keyindex to 0 and i rebuild and restart then i should recompile...
it is a clue ?

thanks


这篇关于VB.NET随机System.StackOverflowException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆