Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #CRC32 with system plugin
  2.  
  3. !include LogicLib.nsh
  4. !include Util.nsh
  5.  
  6. Function ZIPCRC32_Begin
  7. push $0
  8. push $1
  9. push $2
  10. push $3
  11. push $4
  12. System::Call '*(&i1024,&i4 0xFFFFFFFF)i.r0'
  13. ${For} $1 0 255
  14.     StrCpy $3 $1
  15.     ${For} $2 0 7
  16.         IntOp $4 $3 & 1
  17.         IntOp $3 $3 >> 1
  18.         IntOp $3 $3 & 0x7FFFFFFF
  19.         ${If} $4 != 0
  20.             IntOp $3 $3 ^ 0xEDB88320   
  21.         ${EndIf}
  22.     ${Next}
  23.     System::Call *$0(&i4r3)
  24.     IntOp $0 $0 + 4
  25. ${Next}
  26. IntOp $0 $0 - 1024
  27. pop $4
  28. pop $3
  29. pop $2
  30. pop $1
  31. exch $0
  32. FunctionEnd
  33. !macro ZIPCRC32_Begin outvarSTATE
  34. call ZIPCRC32_Begin
  35. pop ${outvarSTATE}
  36. !macroend
  37. Function ZIPCRC32_End
  38. Exch $0
  39. System::Call *$0(&i1024,&i4.s)
  40. System::Free $0
  41. pop $0
  42. IntOp $0 $0 ^ 0xFFFFFFFF
  43. Exch $0
  44. FunctionEnd
  45. !macro ZIPCRC32_End varSTATE outvarCRC
  46. push ${varSTATE}
  47. call ZIPCRC32_End
  48. pop ${outvarCRC}
  49. !macroend
  50. Function ZIPCRC32_Update
  51. System::Store "s"
  52. pop $2 ;cbBuf
  53. pop $1 ;buf
  54. pop $0 ;varSTATE
  55. IntOp $2 $1 + $2
  56. System::Call *$0(&i1024,&i4.r9)
  57. loop:
  58.     System::Call *$1(&i1.r7)
  59.     IntOp $1 $1 + 1
  60.     IntOp $8 $9 & 0xFF
  61.     IntOp $8 $8 ^ $7
  62.     IntOp $8 $8 * 4
  63.     IntOp $7 $0 + $8
  64.     System::Call *$7(&i4.r8)
  65.     IntOp $9 $9 >> 8
  66.     IntOp $9 $9 & 0xFFFFFF
  67.     IntOp $9 $9 ^ $8
  68.     IntCmpU $1 $2 0 loop
  69. System::Call *$0(&i1024,&i4r9)
  70. System::Store "l"
  71. FunctionEnd
  72. !macro ZIPCRC32_Update varSTATE buf cbBuf
  73. push ${varSTATE}
  74. push ${buf}
  75. push ${cbBuf}
  76. call ZIPCRC32_Update
  77. !macroend
  78. !macro _ZIPCRC32_UpdateFromFileHandle
  79. System::Store "s"
  80. pop $1 ;filehandle
  81. pop $0 ;varSTATE
  82. System::Call *(&i4096)i.r2
  83. loop:
  84.     System::Call 'kernel32::ReadFile(ir1,ir2,i4096,*i.r3,i0)i.r4'
  85.     ${If} $4 <> 0
  86.     ${AndIf} $3 U> 0
  87.         !insertmacro ZIPCRC32_Update $0 $2 $3
  88.         goto loop
  89.     ${EndIf}
  90. System::Free $2
  91. System::Store "l"
  92. !macroend
  93. !macro ZIPCRC32_UpdateFromFileHandle varSTATE filehandle
  94. push ${varSTATE}
  95. push ${filehandle}
  96. ${CallArtificialFunction} _ZIPCRC32_UpdateFromFileHandle
  97. !macroend
  98.  
  99.  
  100. Section
  101. !insertmacro ZIPCRC32_Begin $0
  102. #System::Call '*(&m99 "ABC")i.r1'
  103. #!insertmacro ZIPCRC32_Update $0 $1 3
  104. FileOpen $1 "$windir\regedit.exe" r
  105. !insertmacro ZIPCRC32_UpdateFromFileHandle $0 $1
  106. FileClose $1
  107. !insertmacro ZIPCRC32_End $0 $0
  108. IntFmt $0 "0x%X" $0
  109. DetailPrint CRC=$0
  110.  
  111. CRCCheck::GenCRC "$windir\regedit.exe"
  112. pop $0
  113. IntFmt $0 "0x%X" $0
  114. DetailPrint CRC=$0
  115.  
  116. SectionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement