Friday, April 4, 2014

Loops in Assembly

There are 3 types of loops in most programming languages:

1. for loop
2. while loop
3. do-while loop

For loop looks something like this:
(JS example)

for (var x=0;x<10;x++){
 doSomething();
}

While loop:

while (x<10) {
  doSomething();
  x += 2;
}


 Do-while loop:
do{
  doSomething();
  x += 3; 
} while (x<10); 

So how do we construct the loops in assembly?
Well, assembly relies on branches (jumps).
Essentially to "loop" the CPU jumps back to a specific instruction and resume running from that point again.

Following are examples of how to construct a loop in assembly:
For loop:

push ecx
mov ecx, 0x00000000
->
//doSomething()
inc ecx
cmp ecx, 0x0000000a
jl short ->
pop ecx

While loop:

push ecx
jmp short =>
->
//doSomething()
add ecx, 0x00000002
=>
cmp ecx, 0x0000000a
jl short ->
pop ecx

Do-while loop:

push ecx
->
//doSomething()
add ecx, 0x00000003
cmp ecx, 0x0000000a
jl short ->
pop ecx

Please remember stack balance. . . STACK BALANCE!!!!!! 

Ready for Easter

[placeholder for an Easter surprise]
heheheh. . .

Oh dear I seem not to be working on my Flash Engine anymore. . . :(

Friday, February 7, 2014

Globeriz's BS Talk (2)

There are attributes that some people covet but they are never able to acquire in their life, whereas for others they are inborn.

Is it something I should work towards in my life? Or am I pursuing a chimera asininely?

I abhor myself for having an idiosyncratic benchmark of fortune.

Life is for enjoying not for suffering.

Saturday, January 25, 2014

Flash Engine - Update (2)

Update:
Displays the instruction size of push commands
Working raw hex assembly (single-line)
Fixed alignment bugs in obtaining addresses (for constant pool)
Attempts to resolve some operations on push stack
Added number of unique variables as result
Obtain corresponding bytecode from selected instruction (double-click)

Scan/disassemble speed:
(from picture) 24260 entries at 55.79seconds
=> 434.8 entries/s

Todo:
resolve multi-line push stack operations

Friday, January 24, 2014

Flash Engine - Update (1)

Added:
Actually scans memory of Flash plugin(FireFox only)
Scans for constant pool and resolve to variable names
Scans for push instructions and resolve to variable names using result from constant pool

Todo:
Single-line push instruction assembling

Thursday, January 23, 2014

Announcing New Project - FlashEngine

So everyone has heard of Cheat Engine. . .
However, Cheat Engine is rather limited when it comes to Flash games.
The variables are stored differently and the instructions are obfuscated with Adobe Virtual Machine for Flash.
Owing to this, I am looking to develop a Cheat Engine-styled Memory Scanner exclusively for Flash games. (VC++)
The engine scraps ActionScript bytecode loaded to the Flash module in memory and analyzes it.
It attempts to resolve variable names and value assignments to the variables.

The project is still in a very beginning state. . .
I may also look into the possibility of dynamically debugging variables. . .

Monday, January 20, 2014

Intractability (1)

Problems that can be solved in theory (e.g., given infinite time), but which in practice take too long for their solutions to be useful, are known as intractable problems.

Foundations for the theory of
NP-completeness
NP: Non-deterministic Polynomial-time

1. Polynomial Time Reducibility
If there exist a polynomial time reduction from one problem to another, existence of any polynomial time algorithm for the second problem implies existence of a corresponding polynomial time algorithm for the first problem.

Given a function f(n) is O(g(n)) i.e. there exists some constant c such that |f(n)|<=c|g(n)| for all n>=0.
A polynomial time algorithm is then defined to be the one whose time complexity function is O(p(n)) for some polynomial function p, where n is the input length.

2. Most of the apparently intractable problems encountered belong to the class NP of decision ("yes-no") problems that can be solved in polynomial time by a nondeterministic computer.

3. There is one particular problem in NP known as the "satisfiability" problem which every other problem in NP can be polynomially reduced to.
This implies:
Showing how solvable is the satisfiability problem means how solvable is every problem in NP as well.
Therefore, the satisfiability problem is the "hardest" problem in NP.


All the provably intractable problems known to date are either undecidable or "non-deterministically" intractable.