Jump to content

how to successfully translate between encryptedPIDL and normal folder path


 Share

Recommended Posts

Hi, Friends and Support Team of AutoIt,

I am a new fan of AutoIt scripts from PR.China. I came accross problems when trying to use AutoIt script to change the default directory of Windows SlideShow screensaver through changing EncryptedPIDL in registry(HKEY_Current_User\Software\Microsoft\PhotoViewer\SlideShow\ScreenSaver\EncryptedPIDL).

I would like to write a small script that can quickly change the default folder path of Windows built-in SlideShow ScreenSaver, instead of clicking the Windows UI step by step to finish the process.

And I get a clue that The EncryptedPIDL may relate with this setting, but I copy and write some scripts, failing to change between EncryptedPIDL and the normal folder path, as shown by the attached script.

Could anyone help me to write the correct scripts to translate between EncryptedPIDL and the normal folder path, at least from the normal folder path to the EncryptedPIDL.

Or it is ok if anyone could show me a little utitily of commandline to change the default folder path of Windows built-in slideshow screensaver.

Thank you very much!

JF -->

#include <Crypt.au3>
#include <WinAPI.au3>

Opt("MustDeclareVars", 1)      ;0=no, 1=require pre-declare

============= Test to get folder path from EncryptedPIDL, fail =================
; The following EncryptedPIDL is copied from the registry of my computer
$encoded = "FAAfUOBP0CDqOmkQotgIACswMJ0ZAC9IOlwAAAAAAAAAAAAAAAAAAAAAAAAASgAx" & @CRLF & _
     "AAAAAACqQJlOEAB0ZXN0AAA2AAgABADvvjNASwqqQJlOKgAAACSPAAAAAAcAAAAA" & @CRLF & _
     "AAAAAAAAAAAAAAB0AGUAcwB0AAAAFABOADUAAAAAAKpA+U0QACxnH2c6X2NoAAA2" & @CRLF & _
     "AAgABADvvgAAAACqQPlNKgAAACzIAAAAAAQAAAAAAAAAAAAAAAAAAAAsZx9nOl9j" & @CRLF & _
     "aAAAGAAAAA=="
local $decoded = _Base64Decode($encoded)
Msgbox(0, "Types", "$decoded is " & VarGetType($decoded))
local $pidl = $decoded
Local $folderpath = DllStructCreate("char[260]")
; try to decrypt the EncryptedPIDL, but the coming result of $folderPath is no as expected
Local $ret = DllCall("shell32.dll", "int", "SHGetPathFromIDList", _
         "ptr", $decoded, _
         "ptr", DllStructGetPtr($folderPath))
Local $return
if (@error=0) and ($ret[0] <> 0) Then
$return = DllStructGetData($folderpath, 1)
EndIf
MsgBox(0, 'Base64 Decoded - foldername', $folderpath)
============= Test to get EncryptedPIDL from a folder path, fail =================
; create a pidl from a specific path
local $ppidl = DllCall("shell32.dll","ptr","ILCreateFromPathW","wstr","H:\test")
Msgbox(0, "Types", "$ppidl is " & VarGetType($ppidl[0]))
ConsoleWrite($ppidl[0] & @CRLF)
$encoded = _Base64Encode($ppidl[0])
MsgBox(0, 'Base64 encoded - string', $encoded)
; The coming out result is not long, seeming not the form of EncryptedPIDL
Func _Base64Encode($input)      
$input = Binary($input)     
Local $struct = DllStructCreate("byte[" & BinaryLen($input) & "]")      
DllStructSetData($struct, 1, $input)        
Local $strc = DllStructCreate("int")        
Local $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _          
       "ptr", DllStructGetPtr($struct), _           
       "int", DllStructGetSize($struct), _          
       "int", 1, _          
       "ptr", 0, _          
       "ptr", DllStructGetPtr($strc))       
      
If @error Or Not $a_Call[0] Then        
  Return SetError(1, 0, "") ; error calculating the length of the buffer needed 
EndIf       
Local $a = DllStructCreate("char[" & DllStructGetData($strc, 1) & "]")      
$a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _            
     "ptr", DllStructGetPtr($struct), _         
     "int", DllStructGetSize($struct), _            
     "int", 1, _            
     "ptr", DllStructGetPtr($a), _          
     "ptr", DllStructGetPtr($strc))     
If @error Or Not $a_Call[0] Then        
  Return SetError(2, 0, ""); error encoding 
EndIf
   Return DllStructGetData($a, 1)
  EndFunc   ;==>_Base64Encode
 
Func _Base64Decode($input_string)       
Local $struct = DllStructCreate("int")      
local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _          
     "str", $input_string, _          
     "int", 0, _            
     "int", 1, _            
     "ptr", 0, _            
     "ptr", DllStructGetPtr($struct, 1), _          
     "ptr", 0, _            
     "ptr", 0)  
If @error Or Not $a_Call[0] Then        
Return  SetError(1, 0, "") ; error calculating the length of the buffer needed  
EndIf   
Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
$a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _       
     "str", $input_string, _            
     "int", 0, _            
     "int", 1, _            
     "ptr", DllStructGetPtr($a), _          
     "ptr", DllStructGetPtr($struct, 1), _    
     "ptr", 0, _            
     "ptr", 0)      
If @error Or Not $a_Call[0] Then        
  Return SetError(2, 0, ""); error decoding 
EndIf   
Return DllStructGetData($a, 1)  

EndFunc   ;==>_Base64Decode
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...