Skip to content

Commit

Permalink
Add option to copy raw address without relativization
Browse files Browse the repository at this point in the history
  • Loading branch information
zorgiepoo committed Dec 21, 2023
1 parent d49895d commit 5b29d93
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 19 deletions.
34 changes: 20 additions & 14 deletions Bit Slicer/Base.lproj/Debugger Window.xib
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19158" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19158"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -38,6 +38,12 @@
<action selector="copyAddress:" target="-1" id="288"/>
</connections>
</menuItem>
<menuItem title="Copy Raw Address" id="Iwu-Sv-lDF">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="copyRawAddress:" target="-1" id="ci4-Pt-p8F"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="128"/>
<menuItem title="nop_instruction" id="155">
<modifierMask key="keyEquivalentModifierMask"/>
Expand Down Expand Up @@ -85,7 +91,7 @@
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="113" y="199" width="839" height="510"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
<value key="minSize" type="size" width="700" height="414"/>
<view key="contentView" id="6">
<rect key="frame" x="0.0" y="0.0" width="839" height="510"/>
Expand All @@ -100,7 +106,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" focusRingType="none" id="QCs-yF-iGW">
<rect key="frame" x="0.0" y="0.0" width="840" height="287"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnSelection="YES" autosaveColumns="NO" headerView="tpt-Jt-lnH" id="Ksp-7e-9HA" customClass="ZGTableView">
<rect key="frame" x="0.0" y="0.0" width="840" height="270"/>
Expand Down Expand Up @@ -132,7 +138,7 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="instruction" width="240.8359375" minWidth="40" maxWidth="10000" id="hhm-Yo-i9h">
<tableColumn identifier="instruction" width="241" minWidth="40" maxWidth="10000" id="hhm-Yo-i9h">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Instruction">
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -144,7 +150,7 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="symbols" editable="NO" width="155.9609375" minWidth="10" maxWidth="3.4028234663852886e+38" id="t9W-pd-V9s">
<tableColumn identifier="symbols" editable="NO" width="156" minWidth="10" maxWidth="3.4028234663852886e+38" id="t9W-pd-V9s">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Symbols">
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -216,7 +222,7 @@
<outlet property="delegate" destination="-2" id="248"/>
</connections>
</splitView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QFr-ST-Ct0" userLabel="Status Text Field">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QFr-ST-Ct0" userLabel="Status Text Field">
<rect key="frame" x="-3" y="2" width="824" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="mapped_file_path" id="36G-7f-7uB">
Expand Down Expand Up @@ -254,10 +260,6 @@
<nil key="toolTip"/>
<popUpButton key="view" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fpR-fU-ajG">
<rect key="frame" x="-3" y="-4" width="167" height="25"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="160" id="bEq-IZ-Wag"/>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="180" id="ngH-El-940"/>
</constraints>
<popUpButtonCell key="cell" type="roundTextured" title="Item_1" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" selectedItem="vAn-gJ-wjp" id="ohg-Gh-2fU">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
Expand All @@ -269,6 +271,10 @@
</items>
</menu>
</popUpButtonCell>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="160" id="bEq-IZ-Wag"/>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="180" id="ngH-El-940"/>
</constraints>
<connections>
<action selector="runningApplicationsPopUpButton:" target="-2" id="44z-bJ-smY"/>
</connections>
Expand Down Expand Up @@ -314,7 +320,7 @@
</toolbarItem>
<toolbarItem implicitItemIdentifier="306F877D-325E-4A4F-9705-FC98ED04464E" label="Address/Symbol" paletteLabel="Address/Symbol" sizingBehavior="auto" id="u3o-PN-adL">
<nil key="toolTip"/>
<textField key="view" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ztk-ei-XwG">
<textField key="view" focusRingType="none" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ztk-ei-XwG">
<rect key="frame" x="0.0" y="0.0" width="171" height="22"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="150" id="49z-Sq-ig3"/>
Expand Down Expand Up @@ -353,8 +359,8 @@
</window>
</objects>
<resources>
<image name="NSLeftFacingTriangleTemplate" width="10" height="14"/>
<image name="NSRightFacingTriangleTemplate" width="10" height="14"/>
<image name="NSLeftFacingTriangleTemplate" width="12" height="17"/>
<image name="NSRightFacingTriangleTemplate" width="12" height="17"/>
<image name="continue" width="38" height="38"/>
<image name="stepin" width="38" height="38"/>
<image name="stepout" width="38" height="38"/>
Expand Down
6 changes: 6 additions & 0 deletions Bit Slicer/Base.lproj/MainMenu.xib
Expand Up @@ -168,6 +168,12 @@
<action selector="copyAddress:" target="-1" id="1089"/>
</connections>
</menuItem>
<menuItem title="Copy Raw Address" keyEquivalent="c" id="Y5k-Nh-cGe">
<modifierMask key="keyEquivalentModifierMask" control="YES" option="YES" command="YES"/>
<connections>
<action selector="copyRawAddress:" target="-1" id="Mak-Wq-SeH"/>
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="203">
<connections>
<action selector="paste:" target="-1" id="226"/>
Expand Down
8 changes: 7 additions & 1 deletion Bit Slicer/Base.lproj/Search Document Window.xib
Expand Up @@ -48,6 +48,12 @@
<action selector="copyAddress:" target="-1" id="100891"/>
</connections>
</menuItem>
<menuItem title="Copy Raw Address" id="peg-wi-Uav">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="copyRawAddress:" target="-1" id="vIZ-Gl-Xqa"/>
</connections>
</menuItem>
<menuItem title="Paste" id="100803">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down Expand Up @@ -229,7 +235,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="4wx-3S-yE8">
<rect key="frame" x="0.0" y="0.0" width="762" height="194"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" alternatingRowBackgroundColors="YES" emptySelection="NO" autosaveColumns="NO" rowHeight="14" headerView="FQj-2P-but" id="HbN-z0-Vcf" customClass="ZGTableView">
<rect key="frame" x="0.0" y="0.0" width="762" height="177"/>
Expand Down
8 changes: 7 additions & 1 deletion Bit Slicer/ZGDebuggerController.m
Expand Up @@ -1454,7 +1454,7 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)userInterfa
return NO;
}
}
else if (userInterfaceItem.action == @selector(copyAddress:))
else if (userInterfaceItem.action == @selector(copyAddress:) || userInterfaceItem.action == @selector(copyRawAddress:))
{
if ([self selectedInstructions].count != 1)
{
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion Bit Slicer/ZGDocumentWindowController.m
Expand Up @@ -1323,7 +1323,7 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)userInterfa
}
}

else if (menuItem.action == @selector(copyAddress:))
else if (menuItem.action == @selector(copyAddress:) || menuItem.action == @selector(copyRawAddress:))
{
if ([self selectedVariables].count != 1)
{
Expand Down Expand Up @@ -1791,6 +1791,11 @@ - (IBAction)copyAddress:(id)__unused sender
[_variableController copyAddress];
}

- (IBAction)copyRawAddress:(id)sender
{
[_variableController copyRawAddress];
}

- (IBAction)paste:(id)__unused sender
{
[_variableController pasteVariables];
Expand Down
18 changes: 16 additions & 2 deletions Bit Slicer/ZGMemoryViewerController.m
Expand Up @@ -250,7 +250,7 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)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)
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Bit Slicer/ZGVariableController.h
Expand Up @@ -58,9 +58,11 @@ typedef struct

+ (void)copyVariablesToPasteboard:(NSArray<ZGVariable *> *)variables;
+ (void)copyVariableAddress:(ZGVariable *)variable;
+ (void)copyVariableRawAddress:(ZGVariable *)variable;

- (void)copyVariables;
- (void)copyAddress;
- (void)copyRawAddress;
- (void)pasteVariables;

- (void)clear;
Expand Down
19 changes: 19 additions & 0 deletions Bit Slicer/ZGVariableController.m
Expand Up @@ -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<ZGVariable *> *)variables
{
[NSPasteboard.generalPasteboard
Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/en.lproj/Debugger Window.strings
Expand Up @@ -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";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/en.lproj/MainMenu.strings
Expand Up @@ -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…";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/en.lproj/Search Document Window.strings
Expand Up @@ -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";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/es.lproj/Debugger Window.strings
Expand Up @@ -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";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/es.lproj/MainMenu.strings
Expand Up @@ -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…";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/es.lproj/Search Document Window.strings
Expand Up @@ -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";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/ru.lproj/Debugger Window.strings
Expand Up @@ -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" = "Перейти к адресу вызова";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/ru.lproj/MainMenu.strings
Expand Up @@ -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" = "Проверить обновления…";

Expand Down
3 changes: 3 additions & 0 deletions Bit Slicer/ru.lproj/Search Document Window.strings
Expand Up @@ -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" = "Текстовая ячейка";

Expand Down

0 comments on commit 5b29d93

Please sign in to comment.