DataSection access rights - Questions and one issue

Just starting out? Need help? Post your questions and find answers here.
User avatar
Controller
User
User
Posts: 29
Joined: Thu Jul 22, 2004 5:26 am
Location: Germany
Contact:

DataSection access rights - Questions and one issue

Post by Controller »

Is there any option for the datasections. How are they managed when mixed with regular code. Are they merged (to save data) and what access rights are there?

(Currently with 6.12 LTS Version, X64, Threadsafe):
I have a shared module using a DataSection, that I use for multiple projects with different info. Today on an older project, i get an error when error trying to write to the data. I tried other projects using the same code, no issues. I manually added code to change access mode to read+write, and it works now:

Code: Select all

Procedure DALAPI_LoadAll(*ptrData)
  Define.MEMORY_BASIC_INFORMATION MBI
  If VirtualQuery_(*ptrData, @MBI, SizeOf(MEMORY_BASIC_INFORMATION))
    Define.i xLong1
    If MBI\Protect = #PAGE_READONLY ; Or MBI\Protect = PAGE_WRITECOPY
;       Debug "Setting Memory Protection to read-write"
      VirtualProtect_(MBI\BaseAddress, MBI\RegionSize, #PAGE_READWRITE, @xLong1)
      ElseIf MBI\Protect = #PAGE_EXECUTE_READ ;  Or MBI\Protect = PAGE_EXECUTE_WRITECOPY
;       Debug "Setting Memory Protection to read-write"
      VirtualProtect_(MBI\BaseAddress, MBI\RegionSize, #PAGE_EXECUTE_READWRITE, @xLong1)
      EndIf
    EndIf

  (previous unmodified code)