Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
5.6.1.4: Use in-memory archive instead of file IO
- Loading branch information
Showing
22 changed files
with
233 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| ArcMemory::ArcMemory() | ||
| { | ||
| Loaded=false; | ||
| SeekPos=0; | ||
| } | ||
|
|
||
|
|
||
| void ArcMemory::Load(const byte *Data,size_t Size) | ||
| { | ||
| ArcData.Alloc(Size); | ||
| memcpy(&ArcData[0],Data,Size); | ||
| Loaded=true; | ||
| SeekPos=0; | ||
| } | ||
|
|
||
|
|
||
| bool ArcMemory::Unload() | ||
| { | ||
| if (!Loaded) | ||
| return false; | ||
| Loaded=false; | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
| bool ArcMemory::Read(void *Data,size_t Size,size_t &Result) | ||
| { | ||
| if (!Loaded) | ||
| return false; | ||
| Result=(size_t)Min(Size,ArcData.Size()-SeekPos); | ||
| memcpy(Data,&ArcData[(size_t)SeekPos],Result); | ||
| SeekPos+=Result; | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
| bool ArcMemory::Seek(int64 Offset,int Method) | ||
| { | ||
| if (!Loaded) | ||
| return false; | ||
| if (Method==SEEK_SET) | ||
| SeekPos=Min(Offset,ArcData.Size()); | ||
| else | ||
| if (Method==SEEK_CUR || Method==SEEK_END) | ||
| { | ||
| if (Method==SEEK_END) | ||
| SeekPos=ArcData.Size(); | ||
| SeekPos+=(uint64)Offset; | ||
| if (SeekPos>ArcData.Size()) | ||
| SeekPos=Offset<0 ? 0 : ArcData.Size(); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
| bool ArcMemory::Tell(int64 *Pos) | ||
| { | ||
| if (!Loaded) | ||
| return false; | ||
| *Pos=SeekPos; | ||
| return true; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #ifndef _RAR_ARCMEM_ | ||
| #define _RAR_ARCMEM_ | ||
|
|
||
| // Memory interface for software fuzzers. | ||
|
|
||
| class ArcMemory | ||
| { | ||
| private: | ||
| bool Loaded; | ||
| Array<byte> ArcData; | ||
| uint64 SeekPos; | ||
| public: | ||
| ArcMemory(); | ||
| void Load(const byte *Data,size_t Size); | ||
| bool Unload(); | ||
| bool IsLoaded() {return Loaded;} | ||
| bool Read(void *Data,size_t Size,size_t &Result); | ||
| bool Seek(int64 Offset,int Method); | ||
| bool Tell(int64 *Pos); | ||
| }; | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.