Advertisement
tolikpunkoff

Locate.nsi

Mar 15th, 2023
1,483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Locate
  2.     !define Locate `!insertmacro LocateCall`
  3.  
  4.     !macro LocateCall _PATH _OPTIONS _FUNC
  5.         Push $0
  6.         Push `${_PATH}`
  7.         Push `${_OPTIONS}`
  8.         GetFunctionAddress $0 `${_FUNC}`
  9.         Push `$0`
  10.         Call Locate
  11.         Pop $0
  12.     !macroend
  13.  
  14.     Exch $2
  15.     Exch
  16.     Exch $1
  17.     Exch
  18.     Exch 2
  19.     Exch $0
  20.     Exch 2
  21.     Push $3
  22.     Push $4
  23.     Push $5
  24.     Push $6
  25.     Push $7
  26.     Push $8
  27.     Push $9
  28.     Push $R6
  29.     Push $R7
  30.     Push $R8
  31.     Push $R9
  32.     ClearErrors
  33.  
  34.     StrCpy $3 ''
  35.     StrCpy $4 ''
  36.     StrCpy $5 ''
  37.     StrCpy $6 ''
  38.     StrCpy $7 ''
  39.     StrCpy $8 0
  40.     StrCpy $R7 ''
  41.  
  42.     StrCpy $R9 $0 1 -1
  43.     StrCmp $R9 '\' 0 +3
  44.     StrCpy $0 $0 -1
  45.     goto -3
  46.     IfFileExists '$0\*.*' 0 error
  47.  
  48.     option:
  49.     StrCpy $R9 $1 1
  50.     StrCpy $1 $1 '' 1
  51.     StrCmp $R9 ' ' -2
  52.     StrCmp $R9 '' sizeset
  53.     StrCmp $R9 '/' 0 -4
  54.     StrCpy $9 -1
  55.     IntOp $9 $9 + 1
  56.     StrCpy $R9 $1 1 $9
  57.     StrCmp $R9 '' +2
  58.     StrCmp $R9 '/' 0 -3
  59.     StrCpy $R8 $1 $9
  60.     StrCpy $R8 $R8 '' 2
  61.     StrCpy $R9 $R8 '' -1
  62.     StrCmp $R9 ' ' 0 +3
  63.     StrCpy $R8 $R8 -1
  64.     goto -3
  65.     StrCpy $R9 $1 2
  66.     StrCpy $1 $1 '' $9
  67.  
  68.     StrCmp $R9 'L=' 0 mask
  69.     StrCpy $3 $R8
  70.     StrCmp $3 '' +6
  71.     StrCmp $3 'FD' +5
  72.     StrCmp $3 'F' +4
  73.     StrCmp $3 'D' +3
  74.     StrCmp $3 'DE' +2
  75.     StrCmp $3 'FDE' 0 error
  76.     goto option
  77.  
  78.     mask:
  79.     StrCmp $R9 'M=' 0 size
  80.     StrCpy $4 $R8
  81.     goto option
  82.  
  83.     size:
  84.     StrCmp $R9 'S=' 0 gotosubdir
  85.     StrCpy $6 $R8
  86.     goto option
  87.  
  88.  
  89.     gotosubdir:
  90.     StrCmp $R9 'G=' 0 banner
  91.     StrCpy $7 $R8
  92.     StrCmp $7 '' +3
  93.     StrCmp $7 '1' +2
  94.     StrCmp $7 '0' 0 error
  95.     goto option
  96.  
  97.     banner:
  98.     StrCmp $R9 'B=' 0 error
  99.     StrCpy $R7 $R8
  100.     StrCmp $R7 '' +3
  101.     StrCmp $R7 '1' +2
  102.     StrCmp $R7 '0' 0 error
  103.     goto option
  104.  
  105.     sizeset:
  106.     StrCmp $6 '' default
  107.     StrCpy $9 0
  108.     StrCpy $R9 $6 1 $9
  109.     StrCmp $R9 '' +4
  110.     StrCmp $R9 ':' +3
  111.     IntOp $9 $9 + 1
  112.     goto -4
  113.     StrCpy $5 $6 $9
  114.     IntOp $9 $9 + 1
  115.     StrCpy $1 $6 1 -1
  116.     StrCpy $6 $6 -1 $9
  117.     StrCmp $5 '' +2
  118.     IntOp $5 $5 + 0
  119.     StrCmp $6 '' +2
  120.     IntOp $6 $6 + 0
  121.  
  122.     StrCmp $1 'B' 0 +3
  123.     StrCpy $1 1
  124.     goto default
  125.     StrCmp $1 'K' 0 +3
  126.     StrCpy $1 1024
  127.     goto default
  128.     StrCmp $1 'M' 0 +3
  129.     StrCpy $1 1048576
  130.     goto default
  131.     StrCmp $1 'G' 0 error
  132.     StrCpy $1 1073741824
  133.  
  134.     default:
  135.     StrCmp $3 '' 0 +2
  136.     StrCpy $3 'FD'
  137.     StrCmp $4 '' 0 +2
  138.     StrCpy $4 '*.*'
  139.     StrCmp $7 '' 0 +2
  140.     StrCpy $7 '1'
  141.     StrCmp $R7 '' 0 +2
  142.     StrCpy $R7 '0'
  143.     StrCpy $7 'G$7B$R7'
  144.  
  145.     StrCpy $8 1
  146.     Push $0
  147.     SetDetailsPrint textonly
  148.  
  149.     nextdir:
  150.     IntOp $8 $8 - 1
  151.     Pop $R8
  152.  
  153.     StrCpy $9 $7 2 2
  154.     StrCmp $9 'B0' +3
  155.     GetLabelAddress $9 findfirst
  156.     goto call
  157.     DetailPrint 'Search in: $R8'
  158.  
  159.     findfirst:
  160.     FindFirst $0 $R7 '$R8\$4'
  161.     IfErrors subdir
  162.     StrCmp $R7 '.' 0 +5
  163.     FindNext $0 $R7
  164.     StrCmp $R7 '..' 0 +3
  165.     FindNext $0 $R7
  166.     IfErrors subdir
  167.  
  168.     dir:
  169.     IfFileExists '$R8\$R7\*.*' 0 file
  170.     StrCpy $R6 ''
  171.     StrCmp $3 'DE' +4
  172.     StrCmp $3 'FDE' +3
  173.     StrCmp $3 'FD' precall
  174.     StrCmp $3 'F' findnext precall
  175.     FindFirst $9 $R9 '$R8\$R7\*.*'
  176.     StrCmp $R9 '.' 0 +4
  177.     FindNext $9 $R9
  178.     StrCmp $R9 '..' 0 +2
  179.     FindNext $9 $R9
  180.     FindClose $9
  181.     IfErrors precall findnext
  182.  
  183.     file:
  184.     StrCmp $3 'FDE' +3
  185.     StrCmp $3 'FD' +2
  186.     StrCmp $3 'F' 0 findnext
  187.     StrCpy $R6 0
  188.     StrCmp $5$6 '' precall
  189.     FileOpen $9 '$R8\$R7' r
  190.     IfErrors +3
  191.     FileSeek $9 0 END $R6
  192.     FileClose $9
  193.     System::Int64Op $R6 / $1
  194.     Pop $R6
  195.     StrCmp $5 '' +2
  196.     IntCmp $R6 $5 0 findnext
  197.     StrCmp $6 '' +2
  198.     IntCmp $R6 $6 0 0 findnext
  199.  
  200.     precall:
  201.     StrCpy $9 0
  202.     StrCpy $R9 '$R8\$R7'
  203.  
  204.     call:
  205.     Push $0
  206.     Push $1
  207.     Push $2
  208.     Push $3
  209.     Push $4
  210.     Push $5
  211.     Push $6
  212.     Push $7
  213.     Push $8
  214.     Push $9
  215.     Push $R7
  216.     Push $R8
  217.     StrCmp $9 0 +4
  218.     StrCpy $R6 ''
  219.     StrCpy $R7 ''
  220.     StrCpy $R9 ''
  221.     Call $2
  222.     Pop $R9
  223.     Pop $R8
  224.     Pop $R7
  225.     Pop $9
  226.     Pop $8
  227.     Pop $7
  228.     Pop $6
  229.     Pop $5
  230.     Pop $4
  231.     Pop $3
  232.     Pop $2
  233.     Pop $1
  234.     Pop $0
  235.     IfErrors error
  236.  
  237.     StrCmp $R9 'StopLocate' clearstack
  238.     goto $9
  239.  
  240.     findnext:
  241.     FindNext $0 $R7
  242.     IfErrors 0 dir
  243.     FindClose $0
  244.  
  245.     subdir:
  246.     StrCpy $9 $7 2
  247.     StrCmp $9 'G0' end
  248.     FindFirst $0 $R7 '$R8\*.*'
  249.     StrCmp $R7 '.' 0 +5
  250.     FindNext $0 $R7
  251.     StrCmp $R7 '..' 0 +3
  252.     FindNext $0 $R7
  253.     IfErrors +7
  254.  
  255.     IfFileExists '$R8\$R7\*.*' 0 +3
  256.     Push '$R8\$R7'
  257.     IntOp $8 $8 + 1
  258.     FindNext $0 $R7
  259.     IfErrors 0 -4
  260.     FindClose $0
  261.     StrCmp $8 0 end nextdir
  262.  
  263.     error:
  264.     SetErrors
  265.  
  266.     clearstack:
  267.     StrCmp $8 0 end
  268.     IntOp $8 $8 - 1
  269.     Pop $R8
  270.     goto clearstack
  271.  
  272.     end:
  273.     SetDetailsPrint both
  274.     Pop $R9
  275.     Pop $R8
  276.     Pop $R7
  277.     Pop $R6
  278.     Pop $9
  279.     Pop $8
  280.     Pop $7
  281.     Pop $6
  282.     Pop $5
  283.     Pop $4
  284.     Pop $3
  285.     Pop $2
  286.     Pop $1
  287.     Pop $0
  288. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement