Jump to content

inf driver file structure check.


Recommended Posts

Hello!

I made a script to check a structure of a .inf file from hardware drivers, to confirm if all of files needed has captured by DoubleDriver, because some times DoubleDriver fail to capture all of files to all correct functionality.

DoubleDriver its a tool to capture all of driver installed on a computer system.

Heres my Script.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=GNexToolKit7296.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
$arquivo = $cmdline[1]
;$arquivo = "C:\TEMP\Drivers Packages\FEITOS\STI\TECRA R840\Ports\Intel(R) Active Management Technology - SOL\oem126.inf"
Global $szDrive, $szDir, $szFName, $szExt
_PathSplit($arquivo, $szDrive, $szDir, $szFName, $szExt)
global $caminho = $szDrive&$szDir
$sections = IniReadSectionNames($arquivo)
Global $CatalogFile, $folder, $erro, $files, $CatalogFile,$source,$SourceDisksNames
Global $notification = "E estrutura dos arquivos está correta"

;Check driver architecture
For $x = 1 To UBound($sections) - 1
    if $sections[$x] = "SourceDisksFiles" Then
        $SourceDisksFiles = "SourceDisksFiles"
    EndIf
    if $sections[$x] = "SourceDisksFiles.amd64" then
        $SourceDisksFiles = "SourceDisksFiles.amd64"
    EndIf
    if $sections[$x] = "SourceDisksNames" Then
        $SourceDisksNames = "SourceDisksNames"
    EndIf
    if $sections[$x] = "SourceDisksNames.amd64" then
        $SourceDisksNames = "SourceDisksNames.amd64"
    EndIf
Next

;Check catalog file
$CatalogFileSection = IniReadSection($arquivo, "Version")
For $x = 1 To $CatalogFileSection[0][0]
    if $CatalogFileSection[$x][0] = "CatalogFile" Then
        $CatalogFile = $CatalogFileSection[$x][1]
    EndIf
    if $CatalogFileSection[$x][0] = "CatalogFile.NT" Then
        $CatalogFile = $CatalogFileSection[$x][1]
    EndIf
    if $CatalogFileSection[$x][0] = "CatalogFile.NTamd64" Then
        $CatalogFile = $CatalogFileSection[$x][1]
    EndIf
Next

if FileExists ($caminho&$CatalogFile) Then
Else
    MsgBox (16, "ERRO.", "O arquivo de catálogo " &$caminho&$CatalogFile&" NÃO foi localizado.")
    $erro=1
EndIf

;Check folder structure
$source = IniReadSection($arquivo, $SourceDisksNames)
if $source <> 1 then
    For $f = 1 To $source[0][0]
        $SourceDisksNames = StringInStr($source[$f][1], "\")
        If $SourceDisksNames="0" Then
        Else
            $folder = StringTrimLeft($source[$f][1], (StringInStr($source[$f][1], "\")))
            DirCreate($caminho&"\"&$folder)
            $notification = "E estrutura dos arquivos foi corrigida"
            $files = IniReadSection($arquivo, $SourceDisksFiles)
            For $i = 1 To $files[0][0]
                if FileExists ($caminho&$files[$i][0]) Then
                    FileMove ($caminho&$files[$i][0], $caminho & $folder)
                EndIf
            Next
        EndIf
    Next
Else
    MsgBox(64, "Estrutura de seções não localizada.", "Nenhuma informação disponível.")
    exit(0)
EndIf

;check driver version
$DriverVersion = IniReadSection($arquivo, "Version")
For $x = 1 To $DriverVersion[0][0]
    if $DriverVersion[$x][0] = "DriverVer" Then
        $version = $DriverVersion[$x][1]
    EndIf
Next

;check if have files in folder strutucture
Local $files = IniReadSection($arquivo, $SourceDisksFiles)
        For $i = 1 To $files[0][0]
            if FileExists ($caminho&$folder&"\"&$files[$i][0]) Then
                $erro=$erro
            Else
                $erro=1
                MsgBox (16, "ERRO", "O arquivo " &$files[$i][0]&" NÃO foi localizado")
                ClipPut($version)
            EndIf
        Next

if $erro = 0 Then
    MsgBox (0, "Tudo OK",$notification )
EndIf

I make a association of .inf files to my executable script, and every time when i open one .inf file my script will check your structure.

I attach one example of driver captured by DoubleDriver.

One observation. Its only for 64bits drivers, and its work for me.

Anyone have ideas to improve this script?

Intel(R) Management Engine Interface.7z

Edited by MaGRauN
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...