${SegmentFile}

!define GetUserSID "!insertmacro CallGetUserSID"
!macro CallGetUserSID USERNAME SID
      System::Store S
      StrCpy '$0' '${USERNAME}'
      StrCmp '$0' '' 0 +2
      ExpandEnvStrings '$0' "%USERNAME%"
      System::Call "*(&t1024)i.r1"
      System::Call "advapi32::LookupAccountName(tn,tr0,ir1,*i1024,tn,*i1024,*in)i.r0"
      IntCmp $0 1 0 +2 +2
      System::Call "advapi32::ConvertSidToStringSid(ir1,*t.s)"
      IntCmp $0 1 +2 0 0
      Push error
      System::Free $1
      System::Store L
      Pop "${SID}"
!macroend 

${Segment.OnInit}
	; Borrowed the following from PAL 2.2, Remove on release of PAL 2.2
		; Work out if it's 64-bit or 32-bit
	System::Call kernel32::GetCurrentProcess()i.s
	System::Call kernel32::IsWow64Process(is,*i.r0)
        System::Call kernel32::Wow64EnableWow64FsRedirection(i0)
	${If} $0 == 0
		StrCpy $Bits 32
	${Else}
		StrCpy $Bits 64
	${EndIf}
!macroend

${SegmentPrePrimary}
            ${GetUserSID} "" $0
            CreateDirectory "$EXEDIR\Data\ReviverSoft\PC Reviver\$0"
		CopyFiles /SILENT "$EXEDIR\Data\PCReviver.ini" "$EXEDIR\Data\ReviverSoft\PC Reviver\$0\" 
!macroend