Jump to content

[Solved] Error allocating memory for a 6 MB file


 Share

Recommended Posts

The mentionned doc dissects the file format. The part of interest here is the 7z header named SignatureHeader. All we have to do is read the header section (binary of course) and copy that into a C-like structure to access the offset and size of the next header. Reading past that we get the trailer you appended.

Note that zip-style archives can be built in several steps, adding new headers and packed data at the end of the file. If you use such "add to existing archive" feature, you'll have to reiterate the process until last header is found (something not yet done in my sample [simple] code).

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

@jchd Just tested your snippet in my application... Here are the results:

Your code: 0.169343761563984 ms

My code: 0.342108609220169 ms (50.5% slower)

 

Very happy with the results :D

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • 2 months later...

@jchd Sorry for bugging you again but your script is suddenly not working for me :unsure:...

Download Test File: https://we.tl/zYIHvAKj04 (Expiry in 7 days)

#include <FileConstants.au3>

Local Const $7zHeaderSize = 32
Local $filename = @ScriptDir & "\MC Snapshot Testing World.mcmap"
Local $filehdl = FileOpen($filename, $FO_BINARY)
Local $fileheader = FileRead($filehdl, $7zHeaderSize)
If BinaryMid($fileheader, 1, 6) <> Binary('0x377ABCAF271C') Then
    MsgBox(0, '', 'File is not a 7z archive')
    Exit
EndIf
Local $blockheader = DllStructCreate("byte[" & $7zHeaderSize & "]")
DllStructSetData($blockheader, 1, $fileheader)
Local $header = DllStructCreate("align 1;byte tag[6];byte major;byte minor;uint crc1;uint64 offset;uint64 size;uint crc2", DllStructGetPtr($blockheader))
FileSetPos($filehdl, DllStructGetData($header, 'offset') + DllStructGetData($header, 'size'), $FILE_CURRENT)
Local $sTrailer = BinaryToString(FileRead($filehdl))
ConsoleWrite($sTrailer)

Sleep(1000)

I only get "M" as the console output... Thanks in advance, TD :D

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

My contribution only covers part of the file format specifications. Archive files can be built in more than one step, in which case there is a series of headers and archive parts. You'll have to work thru the specifications to adapt my little sample code for support of the full file format.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

@jchd Yes, That indeed is true but that file is generated normally as the first provided file... Why is it not working? Does it have multiple headers?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Can't tell. Dissect the file from specs. Maybe archive uses some max block size of something. I currently don't have the free time to dig further.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Just now, jchd said:

Dissect the file from specs

The specs are too complex for me to understand :(

1 minute ago, jchd said:

I currently don't have the free time to dig further

Oh :o... Ok then... can you please look while once you are free? I don't want to use my chunk by chunk search system :(

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...