While I'm doing a patching using IDA, I accidentally patch wrong bites and I can't remember what bytes were there before. Is there a way to undo it..?
There is a window to see all patched bytes, along with their unpatched versions: in the menu, use
Open Subviews /
Patched Bytes, or press
This is for IDA 6.8 (newest version), i don't know if older versions have the same thing.
However, i recommend you to install the ida patcher plugin, which improves working with patches greatly; for example, you can copy/paste a patch from somewhere else; you can fill a region with identical bytes, and there is a window that's similar to the standard patcher window, but lets you assign comments to patches, and revert them with a single click to the context menu.
Go to View / Open Subviews / Patched Bytes, where patches are. Right click on a line and click "Revert" . This works in Ida 6.8
I don't know how you could unpatch them, since I think there is no way to do that(I'm talking about IDA 6.5, which I use). But I would recommend you for future to use Database Snapshots in IDA. It's very convenient - you can save the state of all your bytes, function names, comments and so on. If something went wrong you can just restore a snapshot in snapshot manager. You can find the it in View --> Database Snapshot Manager in IDA Pro 6.5
An alternative solution, for older IDA versions:
File>Produce file>Create DIF file... to dump all the changes.
File format is
Offset: Old New for every patched byte in file.
Find the bytes you want to change back, and do it manually.
Just remember that offsets are from file start, they are not memory addresses.