pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

autoit private pastebin - collaborative debugging tool What's a private pastebin?


Posted by bjkaiser on Wed 13 May 11:04
report abuse | View followups from bj-kaiser | download | new post

  1. #cs ----------------------------------------------------------------------------
  2.        
  3.         AutoIt Version: 3.2.4.9
  4.         Author:         Björn Kaiser <kaiser.bjoern@gmx.net>
  5.        
  6.         Script Function:
  7.         wimgapi.dll wrapper
  8.        
  9. #ce ----------------------------------------------------------------------------
  10.  
  11. ; function list
  12. ;===============================================================================
  13. ;       _WIM_ApplyImage
  14. ;       _WIM_CaptureImage
  15. ;       _WIM_CloseHandle
  16. ;       _WIM_CreateFile
  17. ;       _WIM_GetImageInformation
  18. ;       _WIM_LoadImage
  19. ;       _WIM_SetImageInformation
  20. ;       _WIM_SetTemporaryPath
  21. ;       _WIM_Shutdown
  22. ;       _WIM_Startup
  23.  
  24. #comments-start
  25.         User Calltips:
  26.         _WIM_CreateFile($sPath,[$dWIM_DesiredAccess],[$dWIM_CreationDisposition],[$dWIM_FlagsAndAttributes],[$dWIM_CompressionType],[$lWIM_CreationResult])
  27.         _WIM_CaptureImage($hWIM,$sPath,[$dWIM_CaptureFlags])
  28.         _WIM_ApplyImage($hImage,$sPath,[$dWIM_ApplyFlags])
  29.         _WIM_LoadImage($hWIM,$dWIM_ImageIndex)
  30.         _WIM_SetTemporaryPath($hWIM,$sPath)
  31.         _WIM_CloseHandle($hObject)
  32.         _WIM_StartUp()
  33.         _WIM_Shutdown()
  34. #comments-end
  35.  
  36. #include-once
  37.  
  38. #region ### START $wim_... constants ###
  39. Global Const $wim_debug = 1
  40. Global Const $wim_dll = @ProgramFilesDir & "\Windows AIK\Tools\x86\wimgapi.dll"
  41. Global Const $wim_generic_read = 0x80000000
  42. Global Const $wim_generic_write = 0x40000000
  43. Global Const $wim_create_new = 0x00000001
  44. Global Const $wim_create_always = 0x00000002
  45. Global Const $wim_open_existing = 0x00000003
  46. Global Const $wim_open_always = 0x00000004
  47. Global Const $wim_compress_none = 0x00000000
  48. Global Const $wim_compress_xpress = 0x00000001
  49. Global Const $wim_compress_lzx = 0x00000002
  50. Global Const $wim_created_new = 0x00000000
  51. Global Const $wim_opened_existing = 0x00000001
  52. Global Const $wim_flag_reserved = 0x00000001
  53. Global Const $wim_flag_verify = 0x00000002
  54. Global Const $wim_flag_index = 0x00000004
  55. Global Const $wim_flag_no_apply = 0x00000008
  56. Global Const $wim_flag_no_diracl = 0x00000010
  57. Global Const $wim_flag_no_fileacl = 0x00000020
  58. Global Const $wim_flag_share_write = 0x00000040
  59. Global Const $wim_flag_fileinfo = 0x00000080
  60. ;~ Ursprünglich Integer Wert
  61. Global Const $wim_flag_no_rp_fix = 0x00000064
  62. ;~ Aufgefüllte Werte
  63. Global Const $wim_reference_append = 0x10000000
  64. Global Const $wim_reference_replace = 0x20000000
  65. ;~ --
  66. Global Const $wim_export_allow_duplicates = 0x00000001
  67. Global Const $wim_export_only_resources = 0x00000002
  68. Global Const $wim_export_only_metadata = 0x00000004
  69. Global Const $invalid_callback_value = 0xFFFFFFFF
  70. Global Const $wim_copy_file_retry = 0x1000000
  71. Global Const $wim_msg_success = 0x00000000
  72. Global Const $wim_msg_done = 0xFFFFFFF0
  73. Global Const $wim_msg_skip_error = 0xFFFFFFFE
  74. Global Const $wim_msg_abort_image = 0xFFFFFFFF
  75. Global Const $wim_attribute_normal = 0x00000000
  76. Global Const $wim_attribute_resource_only = 0x00000001
  77. Global Const $wim_attribute_metadata_only = 0x00000002
  78. Global Const $wim_attribute_verify_data = 0x00000004
  79. Global Const $wim_attribute_rp_fix = 0x00000008
  80. Global Const $wim_attribute_spanned = 0x00000010
  81. Global Const $wim_attribute_readonly = 0x00000020
  82. #endregion ### END $wim_... constants ###
  83.  
  84. Global $g_wimgapi = _WIM_Startup()
  85.  
  86.  
  87. ;===============================================================================
  88. ;
  89. ; Function Name:        _WIM_CreateFile
  90. ; Parameter(s):         $sPath - Path to the file to read/create
  91. ;                                       $iWIM_DesiredAccess - Optional, specify read/write/query access
  92. ;                                       default: $wim_generic_read
  93. ;                                       $iWIM_CreationDisposition - Optional, specifies how existing files are handled
  94. ;                                       default: $wim_open_always
  95. ;                                       $iWIM_FlagsAndAttributes - Optional, specifies actions to be taken for the file
  96. ;                                       default: $wim_flag_share_write
  97. ;                                       $iWIM_CompressionType - Optional, specifies the compression level for a newly created file
  98. ;                                       default: $wim_compress_xpress
  99. ;                                       $iWIM_CreationResult - Optional, pointer to a variable that receives the creation result
  100. ;                                       default: NULL
  101. ; Description:      Makes a new image file or opens an existing image file.
  102. ; Requirement:          None
  103. ; Return Value(s):  If the function succeeds, the return value is an open handle
  104. ;                                       to the specified image file. If the function fails, the
  105. ;                                       return value is NULL.
  106. ;
  107. ; @error Value(s):      1 - Error in DLLCall
  108. ;
  109. ; User CallTip:         _WIM_CreateFile($sPath,[$dWIM_DesiredAccess],[$dWIM_CreationDisposition],[$dWIM_FlagsAndAttributes],[$dWIM_CompressionType],[$lWIM_CreationResult])
  110. ; Author(s):
  111. ;
  112. ;===============================================================================
  113. Func _WIM_CreateFile(Const $sPath, Const $WIM_DesiredAccess = 0x80000000, Const $WIM_CreationDisposition = 0x00000004, _
  114.                 $WIM_FlagsAndAttributes = 0x00000040, $WIM_CompressionType = 0x00000001, $WIM_CreationResult = "NULL")
  115.        
  116.         Local $hWIM, $create
  117.         $create = DllCall($g_wimgapi, "int", "WIMCreateFile", "wstr", $sPath, "int", $WIM_DesiredAccess, _
  118.                         "int", $WIM_CreationDisposition, "int", $WIM_FlagsAndAttributes, "int", $WIM_CompressionType, "int", $WIM_CreationResult)
  119.         If @error Then
  120.                 If $wim_debug Then ConsoleWriteError("_WIM_CreateFile error: " & @error & @CRLF)
  121.                 SetError(1)
  122.         EndIf
  123.         If $wim_debug Then
  124.                 ConsoleWrite("_WIM_CreateFile rc: " & $create[0] & @CRLF & _
  125.                                 "UBound $create: " & UBound($create) & @CRLF)
  126.         EndIf
  127.         $hWIM = $create[0]
  128.         Return $hWIM
  129. EndFunc   ;==>_WIM_CreateFile
  130.  
  131.  
  132. ;===============================================================================
  133. ;
  134. ; Function Name:        _WIM_CaptureImage
  135. ; Parameter(s):         $hWIM - Handle as returned by _WIM_CreateFile
  136. ;                                       $sPath - Path to capture
  137. ; Description:      Captures an image from a directory path and stores it in an
  138. ;                                       image file.
  139. ; Requirement:          None
  140. ; Return Value(s):  If the function succeeds, then the return value is a handle
  141. ;                                       to an object representing the volume image. If the function
  142. ;                                       fails, then the return value is NULL.
  143. ; @error Value(s):      1 - Error in DLLCall
  144. ;
  145. ; User CallTip:         _WIM_CaptureImage($hWIM,$sPath,[$dWIM_CaptureFlags])
  146. ; Author(s):
  147. ;
  148. ;===============================================================================
  149. Func _WIM_CaptureImage(Const $hWIM, Const $sPath, Const $WIM_CaptureFlags = 0x00000002)
  150.         Local $capture
  151.         $capture = DllCall($g_wimgapi, "int", "WIMCaptureImage", "ptr", $hWIM, "wstr", $sPath, "int", $WIM_CaptureFlags)
  152.         If @error Then
  153.                 If $wim_debug Then ConsoleWriteError("_WIM_CaptureImage error: " & @error & @CRLF)
  154.                 SetError(1)
  155.         EndIf
  156.         If $wim_debug Then ConsoleWrite("_WIM_CaptureImage rc: " & $capture[0] & @CRLF)
  157.         Return $capture[0]
  158. EndFunc   ;==>_WIM_CaptureImage
  159.  
  160.  
  161. ;===============================================================================
  162. ;
  163. ; Function Name:        _WIM_ApplyImage
  164. ; Parameter(s):         $hImage - Handle as returned by _WIM_CreateFile or _WIM_CaptureImage
  165. ;                                       $sPath - Path to apply the image to
  166. ; Requirement:          None
  167. ; Return Value(s):  If the function succeeds, then the return value is nonzero.
  168. ;                                       If the function fails, then the return value is zero.
  169. ; Description:          Applies an image to a directory path from a Windows image
  170. ;                                       (.wim) file.
  171. ; @error Value(s):      1 - Error in DLLCall
  172. ;
  173. ; User CallTip:         _WIM_ApplyImage($hImage,$sPath,[$dWIM_ApplyFlags])
  174. ; Author(s):
  175. ;
  176. ;===============================================================================
  177. Func _WIM_ApplyImage(Const $hImage, Const $sPath, Const $WIM_ApplyFlags = 0x00000004)
  178.         Local $apply
  179.         $apply = DllCall($g_wimgapi, "int", "WIMApplyImage", "ptr", $hImage, "wstr", $sPath, "int", $wim_flag_index)
  180.         If @error Then
  181.                 If $wim_debug Then ConsoleWriteError("_WIM_ApplyImage error: " & @error & @CRLF)
  182.                 SetError(1)
  183.         EndIf
  184.         If $wim_debug Then ConsoleWrite("_WIM_ApplyImage rc: " & $apply[0] & @CRLF)
  185.         Return $apply[0]
  186. EndFunc   ;==>_WIM_ApplyImage
  187.  
  188.  
  189. ;===============================================================================
  190. ;
  191. ; Function Name:        _WIM_LoadImage
  192. ; Parameter(s):         $hWIM - Handle as returned by _WIM_CreateFile
  193. ;                                       $dImageIndex - Index of the image to load
  194. ; Requirement:          None
  195. ; Return Value(s):  If the function succeeds, then the return value is a handle to
  196. ;                                       an object representing the volume image. If the function fails,
  197. ;                                       then the return value is NULL.
  198. ; Description:          Loads a volume image from a Windows image (.wim) file
  199. ; @error Value(s):      1 - Error in DLLCall
  200. ;
  201. ; User CallTip:         _WIM_LoadImage($hWIM,$dWIM_ImageIndex)
  202. ; Author(s):
  203. ;
  204. ;===============================================================================
  205. Func _WIM_LoadImage(Const $hWIM, Const $WIM_ImageIndex)
  206.         Local $load
  207.         $load = DllCall($g_wimgapi, "int", "WIMLoadImage", "ptr", $hWIM, "int", $WIM_ImageIndex)
  208.         If @error Then
  209.                 If $wim_debug Then ConsoleWriteError("_WIM_LoadImage error: " & @error & @CRLF)
  210.                 SetError(1)
  211.         EndIf
  212.                 If $wim_debug Then ConsoleWrite("_WIM_LoadImage rc: " & $load[0] & @CRLF)
  213.         Return $load[0]
  214. EndFunc   ;==>_WIM_LoadImage
  215.  
  216.  
  217. ;===============================================================================
  218. ;
  219. ; Function Name:        _WIM_SetTemporaryPath
  220. ; Parameter(s):         $hWIM - Handle as returned by _WIM_CreateFile
  221. ;                                       $sPath - The path where temporary image (.wim) files are to be stored during capture or application.
  222. ; Requirement:          None
  223. ; Return Value(s):  Returns nonzero if successful or NULL otherwise.
  224. ; Description:          Sets the location where temporary imaging files are to be stored.
  225. ; @error Value(s):      1 - Error in DLLCall
  226. ;
  227. ; User CallTip:         _WIM_SetTemporaryPath($hWIM,$sPath)
  228. ; Author(s):
  229. ;
  230. ;===============================================================================
  231. Func _WIM_SetTemporaryPath(Const $hWIM, Const $sPath)
  232.         Local $load
  233.         $load = DllCall($g_wimgapi, "int", "WIMSetTemporaryPath", "ptr", $hWIM, "wstr", $sPath)
  234.         If @error Then
  235.                 If $wim_debug Then ConsoleWriteError("_WIM_SetTemporaryPath error: " & @error & @CRLF)
  236.                 SetError(1)
  237.         EndIf
  238.         If $wim_debug Then ConsoleWrite("_WIM_SetTemporaryPath rc: " & $load[0] & @CRLF)
  239.         Return $load[0]
  240. EndFunc   ;==>_WIM_SetTemporaryPath
  241.  
  242.  
  243. ;===============================================================================
  244. ;
  245. ; Function Name:        _WIM_CloseHandle
  246. ; Parameter(s):         $hObject - Handle of a image-based object
  247. ; Requirement:          None
  248. ; Return Value(s):  If the function succeeds, the return value is nonzero.
  249. ;                                       If the function fails, the return value is zero.
  250. ; Description:          Closes an open Windows Imaging (.wim) file or image handle.
  251. ; @error Value(s):      1 - Error in DLLCall
  252. ;
  253. ; User CallTip:         _WIM_CloseHandle($hObject)
  254. ; Author(s):
  255. ;
  256. ;===============================================================================
  257. Func _WIM_CloseHandle($hObject)
  258.         Local $close
  259.         $close = DllCall($g_wimgapi, "int", "WIMCloseHandle", "ptr", $hObject)
  260.         If @error Then
  261.                 If $wim_debug Then ConsoleWriteError("_WIM_CloseHandle error: " & @error & @CRLF)
  262.                 SetError(1)
  263.         EndIf
  264.         If $wim_debug Then ConsoleWrite("_WIM_CloseHandle rc: " & $close[0] & @CRLF)
  265.         Return $close[0]
  266. EndFunc   ;==>_WIM_CloseHandle
  267.  
  268. ;===============================================================================
  269. ;
  270. ; Function Name:        _WIM_RegisterMessageCallback
  271. ; Parameter(s):         $hWIM -
  272. ;                                       $
  273. ; Requirement:          None
  274. ; Return Value(s):  If the function succeeds, the return value is nonzero.
  275. ;                                       If the function fails, the return value is zero.
  276. ; Description:          Registers a function to be called with imaging-specific data.
  277. ; @error Value(s):      1 - Error in DLLCall
  278. ;
  279. ; User CallTip:         _WIM_RegisterMessageCallback($hWIM,$pWIM_MessageProc)
  280. ; Author(s):
  281. ;
  282. ;===============================================================================
  283. Func _WIM_RegisterMessageCallback($hWIM, $WIM_MessageProc)
  284.         Local $register
  285.         $register = DllCall($g_wimgapi, "int", "WIMRegisterMessageCallback", "ptr", $hWIM, "ptr", $WIM_MessageProc, "int", "NULL")
  286.         If @error Then
  287.                 If $wim_debug Then ConsoleWriteError("_WIM_RegisterMessageCallback error: " & @error & @CRLF)
  288.                 SetError(1)
  289.         EndIf
  290.         If $wim_debug Then ConsoleWrite("_WIM_RegisterMessageCallback rc: " & $register[0] & @CRLF)
  291.         Return $register[0]
  292. EndFunc   ;==>_WIM_RegisterMessageCallback
  293.  
  294.  
  295. ;===============================================================================
  296. ;
  297. ; Function Name:        _WIM_UnregisterMessageCallback
  298. ; Parameter(s):         $hObject - Handle of a image-based object
  299. ; Requirement:          None
  300. ; Return Value(s):  If the function succeeds, the return value is nonzero.
  301. ;                                       If the function fails, the return value is zero.
  302. ; Description:          Registers a function to be called with imaging-specific data.
  303. ; @error Value(s):      1 - Error in DLLCall
  304. ;
  305. ; User CallTip:         _WIM_UnregisterMessageCallback($hWIM,$pWIM_MessageProc)
  306. ; Author(s):
  307. ;
  308. ;===============================================================================
  309. Func _WIM_UnregisterMessageCallback($hWIM, $WIM_MessageProc)
  310.         Local $unregister
  311.         $unregister = DllCall($g_wimgapi, "int", "WIMUnregisterMessageCallback", "ptr", $hWIM, "ptr", $WIM_MessageProc)
  312.         If @error Then
  313.                 If $wim_debug Then ConsoleWriteError("_WIM_UnregisterMessageCallback error: " & @error & @CRLF)
  314.                 SetError(1)
  315.         EndIf
  316.         If $wim_debug Then ConsoleWrite("_WIM_UnregisterMessageCallback rc: " & $unregister[0] & @CRLF)
  317.         Return $unregister[0]
  318. EndFunc   ;==>_WIM_UnregisterMessageCallback
  319.  
  320.  
  321. ;===============================================================================
  322. ;
  323. ; Function Name:        _WIM_GetImageInformation
  324. ; Description:          Returns information about an image within the .wim
  325. ;                                       (Windows image) file.
  326. ; Return Value:
  327. ;                                       !!! NOT WORKING  ATM !!!
  328. ;===============================================================================
  329. Func _WIM_GetImageInformation($wim_handle)
  330.         Local $struct, $size, $rc_getinfo, $a_return[4], $xml
  331.         $struct = DllStructCreate("ptr")
  332.         $size = DllStructCreate("int structsize")
  333. ;~      DllStructSetData($size,1,DllStructGetSize($struct))
  334.         $rc_getinfo = DllCall($g_wimgapi, "int", "WIMGetImageInformation", "ptr", $wim_handle, "ptr", DllStructGetPtr($struct), "ptr", DllStructGetPtr($size))
  335.         If @error Then
  336.                 ConsoleWriteError("_WIM_GetImageInformation error: " & @error & @CRLF & "_WIM_GetImageInformation rc: " & $rc_getinfo & @CRLF)
  337.                 Return 0
  338.         EndIf
  339.         $xml = DllStructCreate("char [" & DllStructGetData($size, 1) & "]", DllStructGetData($struct, 1))
  340.         $a_return[0] = DllStructGetData($struct, 1)
  341.         $a_return[1] = DllStructGetData($size, 1)
  342.         $a_return[2] = $rc_getinfo
  343.         $a_return[3] = DllStructGetData($xml, 1)
  344.         Return $a_return
  345. EndFunc   ;==>_WIM_GetImageInformation
  346.  
  347.  
  348. ;===============================================================================
  349. ;
  350. ; Function Name:        _WIM_SetImageInformation
  351. ; Description:          Stores information about an image in the Windows image
  352. ;                                       (.wim) file.
  353. ; Return Value:
  354. ;                                       !!! NOT WORKING  ATM !!!
  355. ;===============================================================================
  356. Func _WIM_SetImageInformation($wim_handle, $xml_pointer, $xml_size)
  357.         Local $rc_setinfo, $a_return[4], $xml
  358.         $rc_setinfo = DllCall($g_wimgapi, "int", "WIMSetImageInformation", "ptr", $wim_handle, "ptr", $xml_pointer, "ptr", $xml_size)
  359.         If @error Then
  360.                 ConsoleWriteError("_WIM_GetImageInformation error: " & @error & @CRLF & "_WIM_SetImageInformation rc: " & $rc_setinfo & @CRLF)
  361.                 Return 0
  362.         EndIf
  363.         $a_return[0] = $rc_setinfo
  364.         Return $a_return
  365. EndFunc   ;==>_WIM_SetImageInformation
  366.  
  367.  
  368. ;===============================================================================
  369. ;
  370. ; Function Name:        _WIM_Startup
  371. ; Description:          Load wimgapi.dll
  372. ; Return Value:
  373. ;
  374. ;===============================================================================
  375. Func _WIM_Startup()
  376.         Local $wimgapi
  377.         $wimgapi = DllOpen($wim_dll)
  378.         If @error Then
  379.                 If $wim_debug Then ConsoleWriteError("_WIM_Startup error: " & @error & @CRLF)
  380.                 SetError(1)
  381.         EndIf
  382.         If $wim_debug Then ConsoleWrite("_WIM_Startup rc: " & $wimgapi & @CRLF)
  383.         Return $wimgapi
  384. EndFunc   ;==>_WIM_Startup
  385.  
  386.  
  387. ;===============================================================================
  388. ;
  389. ; Function Name:        _WIM_Shutdown
  390. ; Description:          Unload wimgapi.dll
  391. ; Return Value:
  392. ;
  393. ;===============================================================================
  394. Func _WIM_Shutdown()
  395.         Local $rc_close
  396.         $rc_close = DllClose($g_wimgapi)
  397.         If @error Then
  398.                 If $wim_debug Then ConsoleWriteError("_WIM_Shutdown error: " & @error & @CRLF)
  399.                 SetError(1)
  400.         EndIf
  401.         If $wim_debug Then ConsoleWrite("_WIM_Shutdown rc: " & $rc_close & @CRLF)
  402.         Return $rc_close
  403. EndFunc   ;==>_WIM_Shutdown

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post