News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

make .CODE section able to be modified

Started by joemc, April 20, 2010, 03:29:47 AM

Previous topic - Next topic

joemc


  jmp OverData
    TheData dword 0
  OverData:
  mov TheData,eax 


Causes problems. that is just simplified version of what i am trying to accomplish. I am still searching but the words to describe the situation are very common with many topics that are not related.

hutch--

Joe, writing data in the code section is OK, it is read only but just be careful of forward referencing, if its inserted in the code section after the location to call that data you may get errors.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

you can use the VirtualProtect API call to alter access rights to pages of the code section
what Hutch says is true, and can be very tricky with newer processors, as they cache quite a bit of code
if the "data" gets altered after it has been loaded into the prefetch queue, then accessed,
the processor may see the unaltered data from the queue - not the altered data as you might expect or require

donkey

Dave's hit the nail on the head here, the processor will sometimes not see modifications in the code section, you should consider using FlushInstructionCache when you modify anything in the code section.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

redskull

Code pages are mapped as read only by default, and will throw an access violation if you try to fuss with them.  You can override this in the linker through the use of the SECTION switch:

link /SUBSYSTEM:WINDOWS /SECTION:.text,W MyProg.obj

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government