Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
fix bug: when we saved a database, the previous tick was still in the…
Browse files Browse the repository at this point in the history
… idb so further open of the saved snapshot would have a wrong tick since we needed it to be reset to 0
  • Loading branch information
Cedric Halbronn committed Mar 3, 2020
1 parent 38e261b commit 4dc5c10
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
10 changes: 6 additions & 4 deletions idarling/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, plugin):
self._group = None
self._project = None
self._database = None
self._tick = 0
self._tick = -1
self._users = {}

self._idb_hooks = None
Expand Down Expand Up @@ -241,8 +241,8 @@ def unhook_all(self):
def load_netnode(self):
"""
Load data from our custom netnode. Netnodes are the mechanism used by
IDA to load and save information into a database. IDArling uses its own
netnode to remember which project and database a database belongs to.
IDA to load and save information into an idb. IDArling uses its own
netnode to remember which group, project and database an idb belongs to.
"""
node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)

Expand All @@ -269,7 +269,9 @@ def save_netnode(self):
node.hashset_buf("project", str(self._project))
if self._database:
node.hashset_buf("database", str(self._database))
if self._tick:
# We need the test to be non-zero as we need to reset and save tick=0
# when saving an IDB to a new snapshot
if self._tick != -1:
node.hashset_buf("tick", str(self._tick))

self._plugin.logger.debug(
Expand Down
3 changes: 2 additions & 1 deletion idarling/core/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ def extra_cmt_changed(self, ea, line_idx, cmt):
return 0

def item_color_changed(self, ea, color):
self._plugin.logger.debug("item_color_changed() not implemented yet")
# See #31 on fidgetingbits/IDArling
#self._plugin.logger.debug("item_color_changed() not implemented yet")
return 0

def callee_addr_changed(self, ea, callee):
Expand Down
3 changes: 2 additions & 1 deletion idarling/interface/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ class SaveActionHandler(ActionHandler):

@staticmethod
def upload_file(plugin, packet):
# Save the current database
# Save the current database with a tick=0 since it is a new snapshot
plugin.core.tick = 0
plugin.core.save_netnode()
input_path = ida_loader.get_path(ida_loader.PATH_TYPE_IDB)
ida_loader.save_database(input_path, 0)
Expand Down
8 changes: 6 additions & 2 deletions idarling/shared/sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from PyQt5.QtCore import QCoreApplication, QEvent, QObject, QSocketNotifier

from .packets import Container, Packet, PacketDeferred, Query, Reply

from ..shared.commands import (
UpdateLocation,
)

class PacketEvent(QEvent):
"""
Expand Down Expand Up @@ -324,7 +326,9 @@ def send_packet(self, packet):
self._logger.warning("Sending packet while disconnected")
return None

self._logger.debug("Sending packet: %s" % packet)
# UpdateLocation are sent very often so not logging
if not isinstance(packet, UpdateLocation):
self._logger.debug("Sending packet: %s" % packet)

# Enqueue the packet
self._outgoing.append(packet)
Expand Down

0 comments on commit 4dc5c10

Please sign in to comment.