mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Add support for copying bytes formatted as Python byte-string, Python list, and C/Java array
This commit is contained in:
parent
7940f96c8c
commit
00ef824dbd
3 changed files with 101 additions and 1 deletions
|
@ -43,6 +43,9 @@ public class ByteViewerClipboardProvider extends ByteCopier
|
|||
List<ClipboardType> copyTypesList = new LinkedList<>();
|
||||
copyTypesList.add(BYTE_STRING_TYPE);
|
||||
copyTypesList.add(BYTE_STRING_NO_SPACE_TYPE);
|
||||
copyTypesList.add(PYTHON_BYTE_STRING_TYPE);
|
||||
copyTypesList.add(PYTHON_LIST_TYPE);
|
||||
copyTypesList.add(CPP_BYTE_ARRAY_TYPE);
|
||||
return copyTypesList;
|
||||
}
|
||||
|
||||
|
@ -117,6 +120,18 @@ public class ByteViewerClipboardProvider extends ByteCopier
|
|||
else if (copyType == BYTE_STRING_NO_SPACE_TYPE) {
|
||||
byteString = copyBytesAsString(currentSelection, false, monitor);
|
||||
}
|
||||
else if (copyType == PYTHON_BYTE_STRING_TYPE) {
|
||||
byteString = "b'"
|
||||
+ copyBytesAsString(currentSelection, true, monitor).replaceAll(" ", "\\x") + "'";
|
||||
}
|
||||
else if (copyType == PYTHON_LIST_TYPE) {
|
||||
byteString = "[ "
|
||||
+ copyBytesAsString(currentSelection, true, monitor).replaceAll(" ", ", 0x") + " ]";
|
||||
}
|
||||
else if (copyType == CPP_BYTE_ARRAY_TYPE) {
|
||||
byteString = "{ "
|
||||
+ copyBytesAsString(currentSelection, true, monitor).replaceAll(" ", ", 0x") + " }";
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue