Old 29th August 2018, 00:07   #1
mnga
Junior Member
 
Join Date: Aug 2018
Posts: 2
Alternative data streams

How can i delete alternative data stream Zone.Identifier using NSIS?
mnga is offline   Reply With Quote
Old 29th August 2018, 10:59   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
Just the zone info or the entire stream?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th August 2018, 14:42   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
There is a documented API to manipulate the internet zone:

PHP Code:
!include Win\COM.nsh
Section
!ifndef CLSID_PersistentZoneIdentifier
!define CLSID_PersistentZoneIdentifier {0968e258-16c7-4dba-aa86-462dd61e31a3}
!endif
!
ifndef IID_IZoneIdentifier
!define IID_IZoneIdentifier {cd45f185-1b21-48e2-967b-ead743a8914e}
${
NSISCOMIFACEDECL}IZoneIdentifier GetId 3 (*i)i
${NSISCOMIFACEDECL}IZoneIdentifier SetId 4 (i)i
${NSISCOMIFACEDECL}IZoneIdentifier Remove 5 ()i
!endif
!
insertmacro ComHlpr_CreateInProcInstance ${CLSID_PersistentZoneIdentifier} ${IID_IZoneIdentifierr0 ""
${If} $0 P<> 0
    
${IZoneIdentifier::Remove} $'()'
    
${IUnknown::QueryInterface} $'("${IID_IPersistFile}",.r1)'
        
${If} $1 P<> 0
            
${IPersistFile::Save} $'("C:\mypath\myfile.txt",1)'
            
${IUnknown::Release} $""
        
${EndIf}
    ${
IUnknown::Release} $""
${EndIf}
SectionEnd 
As a hack you can use the .ini function directly to just remove the zone:

PHP Code:
System::Call 'KERNEL32::WritePrivateProfileString(t "ZoneTransfer", t "ZoneId", p 0, t "C:\test.txt:Zone.Identifier")' 
or the entire zone section:

PHP Code:
System::Call 'KERNEL32::WritePrivateProfileString(t "ZoneTransfer", p 0, p 0, t "C:\test.txt:Zone.Identifier")' 
(Does NOT delete the stream unlike IZoneIdentifier::Remove)

or to delete any stream:

PHP Code:
System::Call 'KERNEL32::DeleteFile(t"C:\test.txt:secret")' 
You cannot use the NSIS native instructions because they don't allow the stream suffix in paths.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th August 2018, 19:46   #4
mnga
Junior Member
 
Join Date: Aug 2018
Posts: 2
thanks, it works.

Quote:
Originally Posted by Anders View Post
There is a documented API
where do you find this?
mnga is offline   Reply With Quote
Old 29th August 2018, 20:42   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
Quote:
Originally Posted by mnga View Post



where do you find this?
It is documented on MSDN. I just made the NSIS definitions for you.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 30th August 2018, 16:55   #6
safedoom
Banned
 
Join Date: Aug 2018
Posts: 1
Thanks its working
safedoom is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump