Searching/patching binary file


I have to patch binary file. Also have to find a pattern/string in the file, to determine proper position/offset for patching.

What is the best way to do it with JUCE ? I was thinking to load file into MemoryBlock - is this the right approach ?

Are there any JUCE functions to search memory block for a pattern ?

Sorry for rookie questions :)


Anyone ?

Thank you !!!


Here's how to find the position using plain C++, provided that you have the data inside any kind of container offering a pointer to the data and/or iterators:

auto offset = std::distance (​
    std::search (data.begin(), data.end(), pattern.begin(), pattern.end()));

(Replace begin/end with ptr/ptr+size if you have plain pointers instead of iterators)


Thank you - simple & elegant solution ... have to check this standard library more often :)