Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole André Vadla Ravnås committed Aug 16, 2014
1 parent 4279399 commit be13891
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 25 deletions.
6 changes: 5 additions & 1 deletion cryptoshark.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ TEMPLATE = app

QT += qml quick widgets

SOURCES += main.cpp
SOURCES += main.cpp \
nativepointer.cpp

RESOURCES += qml.qrc

Expand All @@ -11,3 +12,6 @@ QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

HEADERS += \
nativepointer.h
8 changes: 1 addition & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ var gutil = require('gulp-util');

var $ = require('gulp-load-plugins')();

gulp.task('build-app', function () {
gulp.src(['node_modules/big-integer/BigInteger.min.js'])
.pipe($.rename('vendor.js'))
.pipe(gulp.dest('./'));
});

gulp.task('build-agent', function () {
var production = gutil.env.type === 'production';

Expand All @@ -31,6 +25,6 @@ gulp.task('watch', function () {
gulp.watch('agent/**/*.js', ['lint']);
});

gulp.task('build', ['build-app', 'build-agent']);
gulp.task('build', ['build-agent']);

gulp.task('default', ['build']);
13 changes: 13 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#include "nativepointer.h"

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>

static QObject *createNativePointerSingleton(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);

return new NativePointer();
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

qmlRegisterSingletonType<NativePointer>("CryptoShark", 1, 0, "NativePointer", createNativePointerSingleton);

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));

Expand Down
14 changes: 3 additions & 11 deletions models.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.import CryptoShark 1.0 as CS
.import QtQuick.LocalStorage 2.0 as QLS
.import "vendor.js" as Vendor

var scheduler = new IOScheduler();
var modules = new Modules();
Expand Down Expand Up @@ -271,7 +271,7 @@ function Functions(modules, scheduler) {
function createFunction(name, offset, calls) {
return {
name: name,
address: bigInt(module.base).add(bigInt(offset)).toString(),
address: CS.NativePointer.fromBaseAndOffset(module.base, offset),
module: module.id,
offset: offset,
exported: false,
Expand All @@ -287,7 +287,7 @@ function Functions(modules, scheduler) {
return {
id: data.id,
name: data.name,
address: bigInt(module.base).add(bigInt(data.offset)).toString(),
address: CS.NativePointer.fromBaseAndOffset(module.base, data.offset),
module: data.module,
offset: data.offset,
exported: data.exported,
Expand All @@ -299,14 +299,6 @@ function Functions(modules, scheduler) {
};
}

function bigInt(value) {
if (typeof value === 'string' && value.indexOf("0x") === 0) {
return Vendor.bigInt(value.substr(2), 16);
} else {
return Vendor.bigInt(value);
}
}

function functionName(module, offset) {
return functionPrefix(module) + "_" + offset.toString(16);
}
Expand Down
13 changes: 13 additions & 0 deletions nativepointer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "nativepointer.h"

NativePointer::NativePointer(QObject *parent) :
QObject(parent)
{
}

QString NativePointer::fromBaseAndOffset(QString base, int offset)
{
int numericBase = base.startsWith("0x") ? 16 : 10;
qlonglong result = base.toLongLong(0, numericBase) + offset;
return (numericBase == 16 ? "0x" : "") + QString::number(result, numericBase);
}
20 changes: 20 additions & 0 deletions nativepointer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef NATIVEPOINTER_H
#define NATIVEPOINTER_H

#include <QObject>

class NativePointer : public QObject
{
Q_OBJECT
public:
explicit NativePointer(QObject *parent = 0);

Q_INVOKABLE QString fromBaseAndOffset(QString base, int offset);

signals:

public slots:

};

#endif // NATIVEPOINTER_H
1 change: 0 additions & 1 deletion qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
<file>components/DisassemblyView.qml</file>
<file>components/ProcessDialog.qml</file>
<file>models.js</file>
<file>vendor.js</file>
</qresource>
</RCC>
20 changes: 15 additions & 5 deletions session/Attached.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1

import "../components"

SplitView {
property var agentService: null
property alias threadsModel: threadsView.model
Expand Down Expand Up @@ -43,7 +44,7 @@ SplitView {
functionsView.currentRow = 0;
functionsView.selection.clear();
functionsView.selection.select(0);
currentFunction = functions.get(0);
currentFunction = _functionsObservable.items[0];
} else {
functionsView.currentRow = -1;
functionsView.selection.clear();
Expand Down Expand Up @@ -74,7 +75,9 @@ SplitView {
var index = partialUpdate[0];
var property = partialUpdate[1];
var value = partialUpdate[2];
setProperty(index, property, value);
if (property === 'name' || property === 'calls') {
setProperty(index, property, value);
}

var func = items[index];
if (currentFunction && func.id === currentFunction.id) {
Expand All @@ -83,18 +86,25 @@ SplitView {
} else {
clear();
for (var i = 0; i !== items.length; i++) {
append(items[i]);
append(modelObject(items[i]));
}
}
}

function onFunctionsAdd(index, func) {
insert(index, func);
insert(index, modelObject(func));
}

function onFunctionsMove(oldIndex, newIndex) {
move(oldIndex, newIndex, 1);
}

function modelObject(func) {
return {
name: func.name,
calls: func.calls
};
}
}

Item {
Expand Down Expand Up @@ -198,7 +208,7 @@ SplitView {
id: functionsView

onCurrentRowChanged: {
currentFunction = model.get(currentRow) || null;
currentFunction = _functionsObservable.items[currentRow] || null;
}

model: functions
Expand Down

0 comments on commit be13891

Please sign in to comment.