| 60 | |
| 61 | |
| 62 | void QuickOpen::Load(uint64 BlockPos) |
| 63 | { |
| 64 | if (!Loaded) |
| 65 | { |
| 66 | // If loading for the first time, perform additional intialization. |
| 67 | SeekPos=Arc->Tell(); |
| 68 | UnsyncSeekPos=false; |
| 69 | |
| 70 | int64 SavePos=SeekPos; |
| 71 | Arc->Seek(BlockPos,SEEK_SET); |
| 72 | |
| 73 | // If BlockPos points to original main header, we'll have the infinite |
| 74 | // recursion, because ReadHeader() for main header will attempt to load |
| 75 | // QOpen and call QuickOpen::Load again. If BlockPos points to long chain |
| 76 | // of other main headers, we'll have multiple recursive calls of this |
| 77 | // function wasting resources. So we prohibit QOpen temporarily to |
| 78 | // prevent this. ReadHeader() calls QOpen.Init and sets MainHead Locator |
| 79 | // and QOpenOffset fields, so we cannot use them to prohibit QOpen. |
| 80 | Arc->SetProhibitQOpen(true); |
| 81 | size_t ReadSize=Arc->ReadHeader(); |
| 82 | Arc->SetProhibitQOpen(false); |
| 83 | |
| 84 | if (ReadSize==0 || Arc->GetHeaderType()!=HEAD_SERVICE || |
| 85 | !Arc->SubHead.CmpName(SUBHEAD_TYPE_QOPEN)) |
| 86 | { |
| 87 | Arc->Seek(SavePos,SEEK_SET); |
| 88 | return; |
| 89 | } |
| 90 | QOHeaderPos=Arc->CurBlockPos; |
| 91 | RawDataStart=Arc->Tell(); |
| 92 | RawDataSize=Arc->SubHead.UnpSize; |
| 93 | Arc->Seek(SavePos,SEEK_SET); |
| 94 | |
| 95 | Loaded=true; // Set only after all file processing calls like Tell, Seek, ReadHeader. |
| 96 | } |
| 97 | |
| 98 | if (Arc->SubHead.Encrypted) |
| 99 | { |
| 100 | RAROptions *Cmd=Arc->GetRAROptions(); |
| 101 | #ifndef RAR_NOCRYPT |
| 102 | if (Cmd->Password.IsSet()) |
| 103 | Crypt.SetCryptKeys(false,CRYPT_RAR50,&Cmd->Password,Arc->SubHead.Salt, |
| 104 | Arc->SubHead.InitV,Arc->SubHead.Lg2Count, |
| 105 | Arc->SubHead.HashKey,Arc->SubHead.PswCheck); |
| 106 | else |
| 107 | #endif |
| 108 | { |
| 109 | Loaded=false; |
| 110 | return; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | RawDataPos=0; |
| 115 | ReadBufSize=0; |
| 116 | ReadBufPos=0; |
| 117 | LastReadHeader.Reset(); |
| 118 | LastReadHeaderPos=0; |
| 119 |
no test coverage detected