Mark Rogers wrote:
> Specifically, I want to replace bytes "EC 10 00 00 69 81 00 00" with "86
> 11 00 00 00 43 00 00" in a driver module. I though sed could cope with
> binary but it doesn't look like it can now I've looked into it. But it
> may just be that I haven't worked out how to construct the commandline...
>   

I found my own solution:
    mv r8169.ko r8169.ko.orig
    xxd -g8 r8169.ko.orig
        | sed s/ec10000069810000/8611000000430000/
        | xxd -r > r8169.ko

The xxd stuff should all be on one line, I just wrapped it to stop the
Internet doing it for me. r8169.ko is just the name of the driver file.

Note that this may not be a perfect solution; it relies on the 8 bytes I
need to change being on an 8-byte boundary otherwise the output from the
first xxd will split the bytes across multiple lines and sed won't find
it to replace. But I'm pretty sure that the string I want to change
would always be on an 8-byte boundary.

Didn't know xxd existed until now. Dunno how common it is, but it was on
my box without being installed specially.

-- 
Mark Rogers
More Solutions Ltd :: 0845 45 89 555



_______________________________________________
Peterboro mailing list
Peterboro@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/peterboro

Reply via email to