Re: Search through a (large) binary file.

Tech-Archive recommends: Fix windows errors by optimizing your registry



Peter,

[. . .]
You can use the Position property to adjust from where you're reading in
the file; save the current position, set the current position to 4 bytes
earlier than the offset of the found string, read the 4 bytes of
interest, then restore the current position to the previously saved
value.
Int64 Offset1 = (ibBaseOffset + ibOffset); offset = 41152
Int64 Offset2 = stream.Position; offset = 49152

Why is Offset1 not equal to Offset2 ?
Offset1 is the right offset. Changing the block size has affect ( byte[]
rgbBlockCur = new byte[4096]; )

I tried several options with stream.Seek(Offset, SeekOrigin) to set the
current position and restore the previously saved position.
But when I read the previous 4 bytes and restore the position to the
previous saved,
the returned offset is not right anymore. The search continues, but it's not
the right offset anymore.

The first 'hit' has a right offset and the previous read bytes are right.
After restoring the position to the previous saved, then it goes wrong.

Michelle



.



Relevant Pages

  • Re: Time GMT down
    ... So to restore must stop and restart. ... In logo, when the time is correct appear: ... offset would be really correct for you? ...
    (comp.lang.php)
  • Re: Search through a (large) binary file.
    ... But when I read the previous 4 bytes and restore the position to the previous saved, ... the returned offset is not right anymore. ... If for some reason that's not possible, and you don't want to literally save and restore the necessary values and buffers, an alternative would be to modify the "FindByteString" method so that it takes an argument specifying where to start searching. ... you'd simply set the stream Position to this offset immediately after opening the stream. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: works on console but not when writing to a string or file
    ... I would think that what's strange is that your code doesn't work, not that some other code does. ... System.Console.Write(Encoding.ASCII.GetString(data, offset, ... in the outputdata string the last packets gets chopped off. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I find strings with wildcards?
    ... offset in a string. ... set match = match + 1 ...
    (comp.lang.pascal.delphi.misc)
  • Re: after ids
    ... I have no string opinion yet, I'd just like to know your analysis. ... Normally this Tcl_Obj probably won't shimmer, ... objPtr->internalRep would have an integer value that we use as an offset ... Then when we want to acccess a TimerHandler struct for after id or after ...
    (comp.lang.tcl)