Results 1 to 14 of 14

Thread: VB2012 Array of Bytes Scan with textbox as an Input

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    VB2012 Array of Bytes Scan with textbox as an Input

    <<First of all I would like to say thank you to the Admin for giving me permission to post>>

    I'm here to share my project VB2012 regarding scanning Array of Bytes and ofcourse I really need your help to fix this project. I'm willing to share this codes for everyone when this project done.


    1.) Here's the working code without using textbox as my Array of bytes input:

    Private Sub btnScan_Click(sender As Object, e As EventArgs) Handles btnScan.Click

    AOB.BytesToScan = {&H31, &H0, &H32, &H0, &H33, &H0, &H34, &H0, &H35, &H0, &H36 ,&H0, &H37, &H0, &H38, &H0, &H39, &H0, &H31, &H0, &H32, &H0, &H33, &H0, &H34, &H0, &H35, &H0, &H36 ,&H0, &H37, &H0, &H38, &H0, &H39, &H0}
    Dim Address As IntPtr = AOB.AobScan(txtboxProcess.Text)
    txtAdressResult.Text = (Address.ToString())

    End Sub

    I have no problem with the codes above when I inserted the Array of Bytes to be scanned in the codes.



    2.) And here's the code w/c is not working. I tried to use textbox as my Array of bytes input to scan:

    Private Sub btnScan_Click(sender As Object, e As EventArgs) Handles btnScan.Click

    AOB.BytesToScan = {txtboxAOB.Text}
    Dim Address As IntPtr = AOB.AobScan(txtboxProcess.Text)
    txtAdressResult.Text = (Address.ToString())

    End Sub

    Note really working. I tried the codes bellow but still can't find the solution:
    1st try: AOB.BytesToScan = {&HtxtboxAOB.Text} <--- Not working
    2nd try: AOB.BytesToScan = {&H(txtboxAOB.Text)} <--- Not working
    3rd try: AOB.BytesToScan = {Hex(txtboxAOB.Text)} <--- Not working

    Here's the images:
    Name:  formtttttttt.jpg
Views: 1356
Size:  35.0 KB
    Name:  Notepad234324234.jpg
Views: 1057
Size:  32.9 KB

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    If you want to set the BytesToScan property using a literal array then what you put between the braces has to actually be a comma-separated list of Byte values. The Text property of a TextBox is obviously not that, so you will need to convert it to a Byte array in some way. How you do that depends on what the Byte values are supposed to represent, which you haven't explained. Do you want the ASCII values of each character in the text? If not then what do you want? Please explain FULLY and CLEARLY.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Quote Originally Posted by jmcilhinney View Post
    If you want to set the BytesToScan property using a literal array then what you put between the braces has to actually be a comma-separated list of Byte values. The Text property of a TextBox is obviously not that, so you will need to convert it to a Byte array in some way. How you do that depends on what the Byte values are supposed to represent, which you haven't explained. Do you want the ASCII values of each character in the text? If not then what do you want? Please explain FULLY and CLEARLY.
    Quote Originally Posted by jmcilhinney View Post
    If you want to set the BytesToScan property using a literal array then what you put between the braces has to actually be a comma-separated list of Byte values. The Text property of a TextBox is obviously not that, so you will need to convert it to a Byte array in some way. How you do that depends on what the Byte values are supposed to represent, which you haven't explained. Do you want the ASCII values of each character in the text? If not then what do you want? Please explain FULLY and CLEARLY.
    Hello Sir Good day. Thank you for your reply.

    The array of byte in notepad value w/c I'm going to find is in "UNICODE" values. I have already use the Unicode converter but I really don't know how to auto insert the comma separately in the list of array of bytes. There's always "-" minus symbol in the array of bytes. I can remove the minus and replace a comma but in a textbox only I used to manipulate a string there such substring and replace command.

    I hope someone will post a code here such using a textbox as an input of the array of bytes values and find the address.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    You don't insert commas into an array of Bytes and there is no "-" symbol. Bytes are numbers in the range of 0 to 255. That's it, that's all.

    If you want to convert a String to its equivalent Unicode Bytes then you call Encoding.Unicode.GetBytes and pass the String. That will return a Byte array. There's nothing else to do.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Quote Originally Posted by jmcilhinney View Post
    You don't insert commas into an array of Bytes and there is no "-" symbol. Bytes are numbers in the range of 0 to 255. That's it, that's all.

    If you want to convert a String to its equivalent Unicode Bytes then you call Encoding.Unicode.GetBytes and pass the String. That will return a Byte array. There's nothing else to do.
    Dim hexString1 As String = txtboxAOB.Text
    Dim array As Byte() = Encoding.UNICODE.GetBytes(hexString1)
    AOB.BytesToScan = array

    I tried the code above but still not working. I also tried this one or I changed it into AOB.BytesToScan = {array} but the "array" is error.
    Last edited by eddecatoria; Oct 17th, 2017 at 12:41 AM. Reason: change spelling

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    So are you saying, without actually saying, that the TextBox contains a series of hexadecimal digits where each pair represents a byte? If you provide a clear explanation then there will be no confusion.

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Quote Originally Posted by jmcilhinney View Post
    So are you saying, without actually saying, that the TextBox contains a series of hexadecimal digits where each pair represents a byte? If you provide a clear explanation then there will be no confusion.
    Yes sir that's what I mean.Name:  1.jpg
Views: 1003
Size:  41.4 KB
    Last edited by eddecatoria; Oct 17th, 2017 at 02:28 AM. Reason: adding picture

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    So then, what you need to do is break the Text of the TextBox up into substrings of two characters each and then convert each substring to a Byte. There are a number of ways you could do that. This is probably the most basic:
    vb.net Code:
    1. Dim byteList As New List(Of Byte)
    2. Dim text = myTextBox.Text
    3.  
    4. For i = 0 To text.Length - 2 Step 2
    5.     Dim substring = text.Substring(i, 2)
    6.     Dim number = Convert.ToByte(substring, 16)
    7.  
    8.     byteList.Add(number)
    9. Next
    10.  
    11. Dim bytes = byteList.ToArray()
    This is probably the most succinct:
    vb.net Code:
    1. Dim bytes = Enumerable.Range(0, myTextBox.TextLength \ 2)
    2.                       .Select(Function(i) Convert.ToByte(myTextBox.Text.Substring(i * 2, 2), 16))
    3.                       .ToArray()
    Both of those assume that the text is valid, i.e. has a multiple of 2 characters and contains all hexadecimal digits. You'd probably want to include code to validate that. I'd tend to check the length first and then maybe use Byte.TryParse instead of Convert.ToByte. Note that TryParse methods work a bit differently, so you'd have to change your code structure accordingly. I'll leave that part to you.

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Quote Originally Posted by jmcilhinney View Post
    So then, what you need to do is break the Text of the TextBox up into substrings of two characters each and then convert each substring to a Byte. There are a number of ways you could do that. This is probably the most basic:
    vb.net Code:
    1. Dim byteList As New List(Of Byte)
    2. Dim text = myTextBox.Text
    3.  
    4. For i = 0 To text.Length - 2 Step 2
    5.     Dim substring = text.Substring(i, 2)
    6.     Dim number = Convert.ToByte(substring, 16)
    7.  
    8.     byteList.Add(number)
    9. Next
    10.  
    11. Dim bytes = byteList.ToArray()
    This is probably the most succinct:
    vb.net Code:
    1. Dim bytes = Enumerable.Range(0, myTextBox.TextLength \ 2)
    2.                       .Select(Function(i) Convert.ToByte(myTextBox.Text.Substring(i * 2, 2), 16))
    3.                       .ToArray()
    Both of those assume that the text is valid, i.e. has a multiple of 2 characters and contains all hexadecimal digits. You'd probably want to include code to validate that. I'd tend to check the length first and then maybe use Byte.TryParse instead of Convert.ToByte. Note that TryParse methods work a bit differently, so you'd have to change your code structure accordingly. I'll leave that part to you.
    Sir the code Dim "bytes" got error I really don't know why. Please see attached images. Thanks.Name:  2222.jpg
Views: 864
Size:  14.4 KBName:  11.jpg
Views: 1000
Size:  23.6 KB
    Last edited by eddecatoria; Oct 19th, 2017 at 12:52 AM. Reason: for clarification

  10. #10

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    I also tried to remove the "{}" in bytes but still din't work.Name:  333.jpg
Views: 1193
Size:  31.2 KB
    Last edited by eddecatoria; Oct 19th, 2017 at 12:59 AM. Reason: add image for more explaination

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Letting us know where the error happens is good... but you should also tell us what the error message is, because that tells us very important details of the problem.

  12. #12

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Quote Originally Posted by si_the_geek View Post
    Letting us know where the error happens is good... but you should also tell us what the error message is, because that tells us very important details of the problem.
    Sir Please see attached picture to view error of the code "bytes". Thanks
    Name:  Untitled.jpg
Views: 962
Size:  34.2 KB
    Name:  34343.jpg
Views: 908
Size:  19.7 KB

    Private Sub btnScan_Click(sender As Object, e As EventArgs) Handles btnScan.Click
    BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    Dim byteList As New List(Of Byte)
    Dim text = txtboxAOB.Text

    For i As Integer = 0 To text.Length - 2 Step 2
    Dim substring = text.Substring(i, 2)
    Dim number = Convert.ToByte(substring, 16)

    byteList.Add(number)
    Next

    Dim bytes = byteList.ToArray()

    AOB.BytesToScan = {bytes}
    Dim Address As IntPtr = AOB.AobScan(txtboxProcess.Text)
    txtAddressResult.Text = Address.ToString()

    End Sub
    Last edited by eddecatoria; Oct 20th, 2017 at 01:47 AM. Reason: Add zoom picture to clearly see the error of the code and also add the current codes.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    That line of code should be like this:
    Code:
    AOB.BytesToScan = bytes
    The variable bytes is an array already, so doesn't need {} around it (those brackets are to make an array from the list of values, but bytes already contains the equivalent).

    What happens then?

  14. #14

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    12

    Re: VB2012 Array of Bytes Scan with textbox as an Input

    Quote Originally Posted by si_the_geek View Post
    That line of code should be like this:
    Code:
    AOB.BytesToScan = bytes
    The variable bytes is an array already, so doesn't need {} around it (those brackets are to make an array from the list of values, but bytes already contains the equivalent).

    What happens then?
    still the same sir. Please see attached picture. Thanks
    Name:  44444.jpg
Views: 845
Size:  15.0 KB
    Attached Images Attached Images  
    Last edited by eddecatoria; Oct 20th, 2017 at 10:10 AM. Reason: change cleared piture

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width