From 5b29d93a8fdfc8399dd3d417e6dda5421e1f6366 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 21 Dec 2023 06:19:17 -0800 Subject: [PATCH] Add option to copy raw address without relativization --- Bit Slicer/Base.lproj/Debugger Window.xib | 34 +++++++++++-------- Bit Slicer/Base.lproj/MainMenu.xib | 6 ++++ .../Base.lproj/Search Document Window.xib | 8 ++++- Bit Slicer/ZGDebuggerController.m | 8 ++++- Bit Slicer/ZGDocumentWindowController.m | 7 +++- Bit Slicer/ZGMemoryViewerController.m | 18 ++++++++-- Bit Slicer/ZGVariableController.h | 2 ++ Bit Slicer/ZGVariableController.m | 19 +++++++++++ Bit Slicer/en.lproj/Debugger Window.strings | 3 ++ Bit Slicer/en.lproj/MainMenu.strings | 3 ++ .../en.lproj/Search Document Window.strings | 3 ++ Bit Slicer/es.lproj/Debugger Window.strings | 3 ++ Bit Slicer/es.lproj/MainMenu.strings | 3 ++ .../es.lproj/Search Document Window.strings | 3 ++ Bit Slicer/ru.lproj/Debugger Window.strings | 3 ++ Bit Slicer/ru.lproj/MainMenu.strings | 3 ++ .../ru.lproj/Search Document Window.strings | 3 ++ 17 files changed, 110 insertions(+), 19 deletions(-) diff --git a/Bit Slicer/Base.lproj/Debugger Window.xib b/Bit Slicer/Base.lproj/Debugger Window.xib index cf1ed09c4..7f7a7623a 100644 --- a/Bit Slicer/Base.lproj/Debugger Window.xib +++ b/Bit Slicer/Base.lproj/Debugger Window.xib @@ -1,8 +1,8 @@ - + - + @@ -38,6 +38,12 @@ + + + + + + @@ -85,7 +91,7 @@ - + @@ -100,7 +106,7 @@ - + @@ -132,7 +138,7 @@ - + @@ -144,7 +150,7 @@ - + @@ -216,7 +222,7 @@ - + @@ -254,10 +260,6 @@ - - - - @@ -269,6 +271,10 @@ + + + + @@ -314,7 +320,7 @@ - + @@ -353,8 +359,8 @@ - - + + diff --git a/Bit Slicer/Base.lproj/MainMenu.xib b/Bit Slicer/Base.lproj/MainMenu.xib index f2947e1fb..9f496498e 100644 --- a/Bit Slicer/Base.lproj/MainMenu.xib +++ b/Bit Slicer/Base.lproj/MainMenu.xib @@ -168,6 +168,12 @@ + + + + + + diff --git a/Bit Slicer/Base.lproj/Search Document Window.xib b/Bit Slicer/Base.lproj/Search Document Window.xib index 33cb30227..474ffa092 100644 --- a/Bit Slicer/Base.lproj/Search Document Window.xib +++ b/Bit Slicer/Base.lproj/Search Document Window.xib @@ -48,6 +48,12 @@ + + + + + + @@ -229,7 +235,7 @@ - + diff --git a/Bit Slicer/ZGDebuggerController.m b/Bit Slicer/ZGDebuggerController.m index 04c856f2c..e102c5f3b 100644 --- a/Bit Slicer/ZGDebuggerController.m +++ b/Bit Slicer/ZGDebuggerController.m @@ -1454,7 +1454,7 @@ - (BOOL)validateUserInterfaceItem:(id )userInterfa return NO; } } - else if (userInterfaceItem.action == @selector(copyAddress:)) + else if (userInterfaceItem.action == @selector(copyAddress:) || userInterfaceItem.action == @selector(copyRawAddress:)) { if ([self selectedInstructions].count != 1) { @@ -1685,6 +1685,12 @@ - (IBAction)copyAddress:(id)__unused sender }]; } +- (IBAction)copyRawAddress:(id)__unused sender +{ + ZGInstruction *selectedInstruction = [[self selectedInstructions] objectAtIndex:0]; + [ZGVariableController copyVariableRawAddress:selectedInstruction.variable]; +} + - (void)scrollAndSelectRow:(NSUInteger)selectionRow { // Scroll such that the selected row is centered diff --git a/Bit Slicer/ZGDocumentWindowController.m b/Bit Slicer/ZGDocumentWindowController.m index c5e52de80..dcd09ce4b 100644 --- a/Bit Slicer/ZGDocumentWindowController.m +++ b/Bit Slicer/ZGDocumentWindowController.m @@ -1323,7 +1323,7 @@ - (BOOL)validateUserInterfaceItem:(id )userInterfa } } - else if (menuItem.action == @selector(copyAddress:)) + else if (menuItem.action == @selector(copyAddress:) || menuItem.action == @selector(copyRawAddress:)) { if ([self selectedVariables].count != 1) { @@ -1791,6 +1791,11 @@ - (IBAction)copyAddress:(id)__unused sender [_variableController copyAddress]; } +- (IBAction)copyRawAddress:(id)sender +{ + [_variableController copyRawAddress]; +} + - (IBAction)paste:(id)__unused sender { [_variableController pasteVariables]; diff --git a/Bit Slicer/ZGMemoryViewerController.m b/Bit Slicer/ZGMemoryViewerController.m index 00b3acdc8..945af2842 100644 --- a/Bit Slicer/ZGMemoryViewerController.m +++ b/Bit Slicer/ZGMemoryViewerController.m @@ -250,7 +250,7 @@ - (BOOL)validateUserInterfaceItem:(id )userInterfa { [menuItem setState:_showsDataInspector]; } - else if (userInterfaceItem.action == @selector(copyAddress:) || userInterfaceItem.action == @selector(showDebugger:)) + else if (userInterfaceItem.action == @selector(copyAddress:) || userInterfaceItem.action == @selector(copyRawAddress:) || userInterfaceItem.action == @selector(showDebugger:)) { if (!self.currentProcess.valid) { @@ -703,17 +703,31 @@ - (void)jumpToMemoryAddress:(ZGMemoryAddress)memoryAddress withSelectionLength:( #pragma mark Copying -- (IBAction)copyAddress:(id)__unused sender +- (ZGVariable *)_variableFromSelectedAddressRange { HFRange selectedAddressRange = [self selectedAddressRange]; ZGVariable *variable = [[ZGVariable alloc] initWithValue:NULL size:selectedAddressRange.length address:selectedAddressRange.location type:ZGByteArray qualifier:ZGUnsigned pointerSize:self.currentProcess.pointerSize]; + return variable; +} + +- (IBAction)copyAddress:(id)__unused sender +{ + ZGVariable *variable = [self _variableFromSelectedAddressRange]; + [ZGVariableController annotateVariables:@[variable] process:self.currentProcess symbols:NO async:NO completionHandler:^{ [[NSPasteboard generalPasteboard] declareTypes:@[NSPasteboardTypeString] owner:self]; [[NSPasteboard generalPasteboard] setString:variable.addressFormula forType:NSPasteboardTypeString]; }]; } +- (IBAction)copyRawAddress:(id)__unused sender +{ + ZGVariable *variable = [self _variableFromSelectedAddressRange]; + + [ZGVariableController copyVariableRawAddress:variable]; +} + #pragma mark Showing Debugger - (IBAction)showDebugger:(id)__unused sender diff --git a/Bit Slicer/ZGVariableController.h b/Bit Slicer/ZGVariableController.h index 596edde04..09488263b 100644 --- a/Bit Slicer/ZGVariableController.h +++ b/Bit Slicer/ZGVariableController.h @@ -58,9 +58,11 @@ typedef struct + (void)copyVariablesToPasteboard:(NSArray *)variables; + (void)copyVariableAddress:(ZGVariable *)variable; ++ (void)copyVariableRawAddress:(ZGVariable *)variable; - (void)copyVariables; - (void)copyAddress; +- (void)copyRawAddress; - (void)pasteVariables; - (void)clear; diff --git a/Bit Slicer/ZGVariableController.m b/Bit Slicer/ZGVariableController.m index fbcab3f44..b97851c14 100644 --- a/Bit Slicer/ZGVariableController.m +++ b/Bit Slicer/ZGVariableController.m @@ -174,6 +174,25 @@ - (void)copyAddress [[self class] copyVariableAddress:windowController.selectedVariables[0]]; } ++ (void)copyVariableRawAddress:(ZGVariable *)variable +{ + [NSPasteboard.generalPasteboard + declareTypes:@[NSPasteboardTypeString] + owner:self]; + + [NSPasteboard.generalPasteboard + setString:variable.addressStringValue + forType:NSPasteboardTypeString]; +} + +- (void)copyRawAddress +{ + ZGDocumentWindowController *windowController = _windowController; + ZGVariable *variable = windowController.selectedVariables[0]; + + [[self class] copyVariableRawAddress:variable]; +} + + (void)copyVariablesToPasteboard:(NSArray *)variables { [NSPasteboard.generalPasteboard diff --git a/Bit Slicer/en.lproj/Debugger Window.strings b/Bit Slicer/en.lproj/Debugger Window.strings index fc6caf7fe..dc6eda7aa 100644 --- a/Bit Slicer/en.lproj/Debugger Window.strings +++ b/Bit Slicer/en.lproj/Debugger Window.strings @@ -17,6 +17,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "286"; */ "286.title" = "Copy Address"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "Iwu-Sv-lDF"; */ +"Iwu-Sv-lDF.title" = "Copy Raw Address"; + /* Class = "NSMenuItem"; title = "Go to Call Address"; ObjectID = "292"; */ "292.title" = "Go to Call Address"; diff --git a/Bit Slicer/en.lproj/MainMenu.strings b/Bit Slicer/en.lproj/MainMenu.strings index 64f549d2f..ff6d64a50 100644 --- a/Bit Slicer/en.lproj/MainMenu.strings +++ b/Bit Slicer/en.lproj/MainMenu.strings @@ -311,6 +311,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "1087"; */ "1087.title" = "Copy Address"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "Y5k-Nh-cGe"; */ +"Y5k-Nh-cGe.title" = "Copy Raw Address"; + /* Class = "NSMenuItem"; title = "Check for Updates…"; ObjectID = "1093"; */ "1093.title" = "Check for Updates…"; diff --git a/Bit Slicer/en.lproj/Search Document Window.strings b/Bit Slicer/en.lproj/Search Document Window.strings index 5ec3aad4b..224d4844f 100644 --- a/Bit Slicer/en.lproj/Search Document Window.strings +++ b/Bit Slicer/en.lproj/Search Document Window.strings @@ -62,6 +62,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "100889"; */ "100889.title" = "Copy Address"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "peg-wi-Uav"; */ +"peg-wi-Uav.title" = "Copy Raw Address"; + /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "0RQ-cA-Uk7"; */ "0RQ-cA-Uk7.title" = "Text Cell"; diff --git a/Bit Slicer/es.lproj/Debugger Window.strings b/Bit Slicer/es.lproj/Debugger Window.strings index 76deddc03..ad70700df 100644 --- a/Bit Slicer/es.lproj/Debugger Window.strings +++ b/Bit Slicer/es.lproj/Debugger Window.strings @@ -17,6 +17,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "286"; */ "286.title" = "Copiar dirección"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "Iwu-Sv-lDF"; */ +"Iwu-Sv-lDF.title" = "Copy Raw Address"; + /* Class = "NSMenuItem"; title = "Go to Call Address"; ObjectID = "292"; */ "292.title" = "Ir a la dirección de llamada"; diff --git a/Bit Slicer/es.lproj/MainMenu.strings b/Bit Slicer/es.lproj/MainMenu.strings index 2820d24d1..a06e83946 100644 --- a/Bit Slicer/es.lproj/MainMenu.strings +++ b/Bit Slicer/es.lproj/MainMenu.strings @@ -311,6 +311,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "1087"; */ "1087.title" = "Copiar dirección"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "Y5k-Nh-cGe"; */ +"Y5k-Nh-cGe.title" = "Copy Raw Address"; + /* Class = "NSMenuItem"; title = "Check for Updates…"; ObjectID = "1093"; */ "1093.title" = "Buscar actualizaciones…"; diff --git a/Bit Slicer/es.lproj/Search Document Window.strings b/Bit Slicer/es.lproj/Search Document Window.strings index e2079b651..b45b09221 100644 --- a/Bit Slicer/es.lproj/Search Document Window.strings +++ b/Bit Slicer/es.lproj/Search Document Window.strings @@ -62,6 +62,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "100889"; */ "100889.title" = "Copiar dirección"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "peg-wi-Uav"; */ +"peg-wi-Uav.title" = "Copy Raw Address"; + /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "0RQ-cA-Uk7"; */ "0RQ-cA-Uk7.title" = "Text Cell"; diff --git a/Bit Slicer/ru.lproj/Debugger Window.strings b/Bit Slicer/ru.lproj/Debugger Window.strings index 463490568..b556e25fb 100644 --- a/Bit Slicer/ru.lproj/Debugger Window.strings +++ b/Bit Slicer/ru.lproj/Debugger Window.strings @@ -17,6 +17,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "286"; */ "286.title" = "Скопировать адрес"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "Iwu-Sv-lDF"; */ +"Iwu-Sv-lDF.title" = "Copy Raw Address"; + /* Class = "NSMenuItem"; title = "Go to Call Address"; ObjectID = "292"; */ "292.title" = "Перейти к адресу вызова"; diff --git a/Bit Slicer/ru.lproj/MainMenu.strings b/Bit Slicer/ru.lproj/MainMenu.strings index 0c7a90d28..e9767e756 100644 --- a/Bit Slicer/ru.lproj/MainMenu.strings +++ b/Bit Slicer/ru.lproj/MainMenu.strings @@ -311,6 +311,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "1087"; */ "1087.title" = "Скопировать адрес"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "Y5k-Nh-cGe"; */ +"Y5k-Nh-cGe.title" = "Copy Raw Address"; + /* Class = "NSMenuItem"; title = "Check for Updates…"; ObjectID = "1093"; */ "1093.title" = "Проверить обновления…"; diff --git a/Bit Slicer/ru.lproj/Search Document Window.strings b/Bit Slicer/ru.lproj/Search Document Window.strings index 36e53731f..34996f1de 100644 --- a/Bit Slicer/ru.lproj/Search Document Window.strings +++ b/Bit Slicer/ru.lproj/Search Document Window.strings @@ -62,6 +62,9 @@ /* Class = "NSMenuItem"; title = "Copy Address"; ObjectID = "100889"; */ "100889.title" = "Скопировать Адрес"; +/* Class = "NSMenuItem"; title = "Copy Raw Address"; ObjectID = "peg-wi-Uav"; */ +"peg-wi-Uav.title" = "Copy Raw Address"; + /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "0RQ-cA-Uk7"; */ "0RQ-cA-Uk7.title" = "Текстовая ячейка";