Jump to content

Determine executable file types

Recommended Posts

Browsing MSDN I've found the function SaferiIsExecutableFileType.


"The SaferiIsExecutableFileType function determines whether a specified file is an executable file. Applications use this function to determine whether a file is an executable file, and if it is, then the application can take security precautions to prevent invoking untrustworthy code."

$b_FirstExtensionFound = False
$i = 0
$iFound = 0
While 1
    $i += 1
    $var = RegEnumKey("HKCR", $i)
    If @error <> 0 Then ExitLoop
    If StringLeft($var, 1) = "." Then
        $aRes = DllCall("Advapi32.dll", "int", "SaferiIsExecutableFileType", "wstr", "test" & $var, "byte", 0)
        Switch $aRes[0]
            Case 1
                ConsoleWrite("+ Executable" & @TAB & $var & @TAB & $aRes[0] & @CRLF)
                $iFound += 1
            Case 0
                ;ConsoleWrite("- Not Executable" & @TAB & $var & @TAB & $aRes[0] & @CRLF)
        $b_FirstExtensionFound = True
        If $b_FirstExtensionFound Then ExitLoop
ConsoleWrite(@CRLF & $iFound & @CRLF)
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...