MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ReadHeader15

Method ReadHeader15

Libraries/unrar/arcread.cpp:137–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135
136
137size_t Archive::ReadHeader15()
138{
139 RawRead Raw(this);
140
141 bool Decrypt=Encrypted && CurBlockPos>(int64)SFXSize+SIZEOF_MARKHEAD3;
142
143 if (Decrypt)
144 {
145#ifdef RAR_NOCRYPT // For rarext.dll and unrar_nocrypt.dll.
146 return 0;
147#else
148 RequestArcPassword();
149
150 byte Salt[SIZE_SALT30];
151 if (Read(Salt,SIZE_SALT30)!=SIZE_SALT30)
152 {
153 UnexpEndArcMsg();
154 return 0;
155 }
156 HeadersCrypt.SetCryptKeys(false,CRYPT_RAR30,&Cmd->Password,Salt,NULL,0,NULL,NULL);
157 Raw.SetCrypt(&HeadersCrypt);
158#endif
159 }
160
161 Raw.Read(SIZEOF_SHORTBLOCKHEAD);
162 if (Raw.Size()==0)
163 {
164 UnexpEndArcMsg();
165 return 0;
166 }
167
168 ShortBlock.HeadCRC=Raw.Get2();
169
170 ShortBlock.Reset();
171
172 uint HeaderType=Raw.Get1();
173 ShortBlock.Flags=Raw.Get2();
174 ShortBlock.SkipIfUnknown=(ShortBlock.Flags & SKIP_IF_UNKNOWN)!=0;
175 ShortBlock.HeadSize=Raw.Get2();
176
177 ShortBlock.HeaderType=(HEADER_TYPE)HeaderType;
178 if (ShortBlock.HeadSize<SIZEOF_SHORTBLOCKHEAD)
179 {
180 BrokenHeaderMsg();
181 return 0;
182 }
183
184 // For simpler further processing we map header types common
185 // for RAR 1.5 and 5.0 formats to RAR 5.0 values. It does not include
186 // header types specific for RAR 1.5 - 4.x only.
187 switch(ShortBlock.HeaderType)
188 {
189 case HEAD3_MAIN: ShortBlock.HeaderType=HEAD_MAIN; break;
190 case HEAD3_FILE: ShortBlock.HeaderType=HEAD_FILE; break;
191 case HEAD3_SERVICE: ShortBlock.HeaderType=HEAD_SERVICE; break;
192 case HEAD3_ENDARC: ShortBlock.HeaderType=HEAD_ENDARC; break;
193 }
194 CurHeaderType=ShortBlock.HeaderType;

Callers

nothing calls this directly

Calls 15

ArcCharToWideFunction · 0.85
CharToWideFunction · 0.85
SafeAddFunction · 0.85
uiMsgFunction · 0.85
SetCryptKeysMethod · 0.80
SetCryptMethod · 0.80
Get2Method · 0.80
Get1Method · 0.80
Get4Method · 0.80
GetBMethod · 0.80
AllocMethod · 0.80
CmpNameMethod · 0.80

Tested by

no test coverage detected