saw rotivc thread and thought abt this

considering that the comp doesn't really know the diff between what you consider 'data' and 'code', does this mean that the data and code segments are really not necessary at all.

i mean we can always jump over the data definitions, right? so does this mean the data segment idea was only invented to make the code more...'sensible'? thats how its dun in com files anyway (no data section)
Posted on 2003-05-26 02:05:36 by AnotherWay83
It *does* know the difference, the code section is executable+readable, while the data section is readable and writable. That means the code section will never be written to and its pages stay clean. That's better for paging. Also, if the code section of a DLL was writable it couldn't be shared if it's used by several programs at the same time. So there is a difference, it's not just to make the code more 'sensible'.

Posted on 2003-05-26 02:21:16 by Thomas
You cannot write to .code section unless of course you change the section attribute to writable+excutable+readable. There is a need for data segment as it allows data to be stored and accessed. Thus if you have no data segment you would have a trouble stroing data and have to end up using the stack and such. And I recall Scali mentioning that data in code segment is not a good method of code.

Of course there is a reason for me to do away with data segment. I am just injecting another code section into a pe file and changing the entrypoint to the file to add some features to the pe file. Adding another data section is messy in my humble opinion.
Posted on 2003-05-26 02:56:29 by roticv
Can i make executable .data ? so i can fill memory with instructions and change it dynamically while running ???

It's something like jmp to array of instructions (hex of course) that ends another jmp back to my real .code.
Posted on 2003-05-26 13:59:05 by AceEmbler
yes, you can do that... an application is polymorphic code such as that used in some AI implementations. Also, self-modifying code.
Posted on 2003-05-26 14:33:44 by jademtech