[Requests] How to get slic version?

Discussion in 'Mixed Languages' started by ElTele, Dec 11, 2010.

  1. ElTele

    ElTele MDL Novice

    Feb 25, 2010
    6
    0
    0
    Hello, i write to ask if someone could help me get the version of SLIC,
    preferably in VB.NET; if not in any way.
    Thank you.

    Pardon my English.
     
  2. flare4000

    flare4000 MDL Senior Member

    Apr 23, 2010
    414
    111
    10
    #2 flare4000, Dec 11, 2010
    Last edited by a moderator: Apr 20, 2017
    Here is what I used for my program
    Code:
    Dim firmwareProviderID As UInteger = Asc("A") << 24 Or Asc("C") << 16 Or Asc("P") << 8 Or Asc("I")
            Dim size As UInteger = EnumSystemFirmwareTables(firmwareProviderID, IntPtr.Zero, 0)
            Dim ptr As IntPtr = Marshal.AllocHGlobal(CInt(size))
            Dim buffer As Byte() = New Byte(size - 1) {}
            EnumSystemFirmwareTables(firmwareProviderID, ptr, size)
            Marshal.Copy(ptr, buffer, 0, buffer.Length)
            Marshal.FreeHGlobal(ptr)
            Dim str As String = Encoding.GetEncoding(1252).GetString(buffer)
            Dim array As New ArrayList()
            For i As Integer = 0 To str.Length - 1 Step 4
                array.Add(str.Substring(i, 4))
            Next
            If array.Contains("SLIC") Then
                Dim tableID As UInteger = BitConverter.ToUInt32(buffer, array.IndexOf("SLIC") * 4)
                size = GetSystemFirmwareTable(firmwareProviderID, tableID, IntPtr.Zero, 0)
                Dim buffer2 As Byte() = New Byte(size - 1) {}
                ptr = Marshal.AllocHGlobal(CInt(size))
                GetSystemFirmwareTable(firmwareProviderID, tableID, ptr, size)
                Marshal.Copy(ptr, buffer2, 0, buffer2.Length)
                Marshal.FreeHGlobal(ptr)
                Label2.Text = ("Slic 2.1")
                Dim slic As New ArrayList()
                Dim enc As Encoding = Encoding.ASCII
                slic.Add(enc.GetString(buffer2, &HA, 6))
                slic.Add(enc.GetString(buffer2, &H10, 8))
                slic.Add(enc.GetString(buffer2, &HCC, 6))
                slic.Add(enc.GetString(buffer2, &HD2, 8))
                If buffer2(&HE4) = 0 Then
                    slic.Add("2.0")
                Else
                    slic.Add((buffer2(&HE4).ToString() & ".") + buffer2(&HE2).ToString())
                End If
                If slic(0).Equals(slic(2)) Then
                    Label2.Text = ("Slic " & slic(4))
                Else
                    Label2.Text = ("No Slic")
                End If
            Else
                Label2.Text = ("No Slic")
            End If
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. ElTele

    ElTele MDL Novice

    Feb 25, 2010
    6
    0
    0
    #3 ElTele, Dec 12, 2010
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thank you very much for your help. I have just one problem, I do not recognize "Marshal" and
    "Encoding", I get an error. (error in the image)
    img810.imageshack.us/img810/9051/capturadu.jpg


    The functions are well used?:

    Code:
     Declare Auto Function EnumSystemFirmwareTables _
       Lib "kernel32" Alias "EnumSystemFirmwareTables" ( _
       ByVal FirmwareTableProviderSignature As UInteger, _
       ByVal pFirmwareTableBuffer As IntPtr, _
       ByVal BufferSize As Byte) _
       As String
    
    
        Declare Auto Function GetSystemFirmwareTable _
       Lib "kernel32" Alias "GetSystemFirmwareTable" ( _
       ByVal FirmwareTableProviderSignature As UInteger, _
       ByVal FirmwareTableID As UInteger, _
       ByVal pFirmwareTableBuffer As IntPtr, _
       ByVal BufferSize As Byte) _
       As String
    Thanks You

    Pardon my Inglés
     
  4. Calistoga

    Calistoga MDL Senior Member

    Jul 25, 2009
    420
    198
    10
    #4 Calistoga, Dec 12, 2010
    Last edited by a moderator: Apr 20, 2017
    Have you added the required imports to the code file?

    Code:
    Imports System.Text
    Imports System.Runtime.InteropServices
     
  5. ElTele

    ElTele MDL Novice

    Feb 25, 2010
    6
    0
    0
    #5 ElTele, Dec 12, 2010
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Yes, this error is resolved. Now the problem is that this line fails
    Code:
    Dim size As UInteger = EnumSystemFirmwareTables(firmwareProviderID, IntPtr.Zero, 0)
    Returns this error "NullReferenceException"

    Thanks You

    Pardon my Inglés
     
  6. ElTele

    ElTele MDL Novice

    Feb 25, 2010
    6
    0
    0
    Here is the error:
    img232.imageshack.us/img232/2931/capturahu.jpg
     
  7. flare4000

    flare4000 MDL Senior Member

    Apr 23, 2010
    414
    111
    10
    #7 flare4000, Dec 12, 2010
    Last edited by a moderator: Apr 20, 2017
    Sorry forgot that you needed to declare this
    Code:
       Declare Auto Function EnumSystemFirmwareTables Lib "kernel32" Alias "EnumSystemFirmwareTables" (ByVal FirmwareTableProviderSignature As UInteger, ByVal pFirmwareTableBuffer As IntPtr, ByVal BufferSize As UInteger) As UInteger
        Declare Auto Function GetSystemFirmwareTable Lib "kernel32" Alias "GetSystemFirmwareTable" (ByVal FirmwareTableProviderSignature As UInteger, ByVal FirmwareTableID As UInteger, ByVal pFirmwareTableBuffer As IntPtr, ByVal BufferSize As UInteger) As UInteger
    Note MD gave me this code
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. ElTele

    ElTele MDL Novice

    Feb 25, 2010
    6
    0
    0
    #8 ElTele, Dec 12, 2010
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thank you very much, I was looking for a long time and you did it.

    Pardon my Inglés
     
  9. flare4000

    flare4000 MDL Senior Member

    Apr 23, 2010
    414
    111
    10
    Np but it isn't my code it's MD's this is only a port of his C# code he/she gave me
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...