-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInclude.au3
More file actions
105 lines (86 loc) · 3.37 KB
/
Include.au3
File metadata and controls
105 lines (86 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
;-Begin-----------------------------------------------------------------
;-Directives----------------------------------------------------------
AutoItSetOption("MustDeclareVars", 1)
;-Constants-----------------------------------------------------------
Const $RAR_OM_EXTRACT = 1
Const $ERAR_SUCCESS = 0
Const $RAR_EXTRACT = 2
;-Sub UnPackInclude---------------------------------------------------
Func UnPackInclude($FileName)
;-Variables-------------------------------------------------------
Local $hUnRAR, $RAROpenArchiveDataEx, $RARHeaderDataEx
Local $RARFileName, $hArc, $Ret, $Test
$hUnRAR = DLLOpen("unrar.dll")
If $hUnRAR <> -1 Then
$RAROpenArchiveDataEx = DllStructCreate("Struct;" & _
"Ptr ArcName;" & _
"Ptr ArcNameW;" & _
"uInt OpenMode;" & _
"uInt OpenResult;" & _
"Ptr CmtBuf;" & _
"uInt CmtBufSize;" & _
"uInt CmtSize;" & _
"uInt CmtState;" & _
"uInt Flags;" & _
"Ptr Callback;" & _
"lParam UserData;" & _
"uInt Reserved[28];" & _
"EndStruct")
$RARHeaderDataEx = DllStructCreate("Struct;" & _
"Char ArcName[1024];" & _
"wChar ArcNameW[1024];" & _
"Char FileName[1024];" & _
"wChar FileNameW[1024];" & _
"uInt Flags;" & _
"uInt PackSize;" & _
"uInt PackSizeHigh;" & _
"uInt UnpSize;" & _
"uInt UnpSizeHigh;" & _
"uInt HostOS;" & _
"uInt FileCRC;" & _
"uInt FileTime;" & _
"uInt UnpVer;" & _
"uInt Method;" & _
"uInt FileAttr;" & _
"Ptr CmtBuf;" & _
"uInt CmtBufSize;" & _
"uInt CmtSize;" & _
"uInt CmtState;" & _
"uInt DictSize;" & _
"uInt HashType;" & _
"Char Hash[32];" & _
"uInt RedirType;" & _
"Ptr RedirName;" & _
"uInt RedirNameSize;" & _
"uInt DirTarget;" & _
"uInt Reserved[994];" & _
"EndStruct")
$RARFileName = DllStructCreate("Char[65535]")
DllStructSetData($RARFileName, 1, _
@ScriptDir & "\" & $FileName & Chr(0))
DllStructSetData($RAROpenArchiveDataEx, "ArcName", _
DllStructGetPtr($RARFileName))
DllStructSetData($RAROpenArchiveDataEx, "OpenMode", _
$RAR_OM_EXTRACT)
$hArc = DllCall($hUnRAR, "Int", "RAROpenArchiveEx", _
"Ptr", DllStructGetPtr($RAROpenArchiveDataEx))
If $hArc[0] <> 0 And DllStructGetData($RAROpenArchiveDataEx, _
"OpenResult") = $ERAR_SUCCESS Then
Do
DllCall($hUnRAR, "Int", "RARProcessFileW", "Handle", _
$hArc[0], "Int", $RAR_EXTRACT, "Ptr", 0, "Ptr", 0)
$Ret = DllCall($hUnRAR, "Int", "RARReadHeaderEx", "Handle", _
$hArc[0], "Ptr", DllStructGetPtr($RARHeaderDataEx))
Until $Ret[0] <> $ERAR_SUCCESS
DllCall($hUnRAR, "Int", "RARCloseArchive", "Handle", $hArc[0])
EndIf
DLLClose($hUnRAR)
EndIf
EndFunc
;-Sub Main------------------------------------------------------------
Func Main()
UnPackInclude("Include.rar")
EndFunc
;-Main----------------------------------------------------------------
Main()
;-End-------------------------------------------------------------------