Sign in to follow this  
Followers 0
KaFu

Determine executable file types

2 posts in this topic

Browsing MSDN I've found the function SaferiIsExecutableFileType.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms722429%28v=vs.85%29.aspx

"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)
        EndSwitch
        $b_FirstExtensionFound = True
    Else
        If $b_FirstExtensionFound Then ExitLoop
    EndIf
WEnd
ConsoleWrite(@CRLF & $iFound & @CRLF)
1 person likes this

Share this post


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
Sign in to follow this  
Followers 0