News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Read, write execute memory demo.

Started by hutch--, August 29, 2017, 03:56:36 PM

Previous topic - Next topic

hutch--

The attached file is a demo of configuring VirtualAlloc() for read, write and execute attributes and it writes 2 simple algos in decimal notation to memory then executes both to show that it works correctly. I have a tool in the testing stage that converts assembler notation code into binary which is then converted to decimal notation and when I am happy with it, I will post it.

jj2007


Siekmanski

Quote from: jj2007 on August 29, 2017, 05:48:22 PM
Mr Hutchesson, I must remind you of the forum rules, point 3, Legality of content :eusa_naughty:

:biggrin:

Using this technique you can create optimum code in memory for each cpu type using a code preprocessor.
A good example for this is the FFT routine. Instead of having +/- 16 routines in your executable, you could create the fastest code for a specific cpu type from 1 basic routine by adjusting it in memory.
Easy aligning of the code for fast 64 byte L1 loops.
Or duplicate the FFT code in memory and adjust it to an IFFT routine. Create immediate compares, static memory pointers etc.
There are many legitimate reasons to reduce code size and speed up your code by this technique.  8)
Creative coders use backward thinking techniques as a strategy.

hutch--

 :biggrin:

No, there is nothing naughty in it, Marinus is right, there are many useful things that can be done with dynamically produced code, the one that immediately appealed to me was the capacity to put code in the data section and write it to memory on demand, if its not needed again you can simply overwrite it. To make life more difficult for the wannabee hackers of this world, encrypting the data section data is in fact no big deal to do and it would make it a nightmare to pull apart. If you write the code sequentially in the data section and put the pointers and length after them all, the data section becomes a jumbled mess that would be no joy to separate.

Siekmanski

This technique was part of one of my previous posts, if discussing SMC was allowed on the forum.
Next cool thing would be a code parser cruncher/decruncher routine.  8)
Creative coders use backward thinking techniques as a strategy.

Raistlin

This is Lovely in-fact ! No RPC issues, No DLL deployment (for network scenarios) - and the encryption idea is brilliant if not inspired !

@hutch: THANKS LOADS, I asked you about options for remote execution & message passing previously in a pm
             - this solves some niggly problems and provides alternatives to rpc, dll etc.  Great job. :t  I'am off to write a 32-bit version :biggrin:
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

hutch--

The only thing I would ask is don't post stuff that the cockroaches want after they come out of the woodwork.  :eusa_snooty:

Siekmanski

I wouldn't dare, I hate cockroaches.  :t
Creative coders use backward thinking techniques as a strategy.

hutch--