Keaz, I got the 'MAKE MEMORY' command working!
!
The app will only crash if you try to write to a location outside of the 'MAKE MEMORY' range. I've put dwords in, and you should be able to easily implement these commands into your API code
Here is the source. Simply cut and paste this into the editor for a great demo!
global dim internal_core_mem_data(32) as dword
make_core_mem(1,32*4)
for i = 1 to 32
write_core_mem_dword(1,4*i-3,1000000+i) `4*i-3 is because a dword is 4 bytes
next i
for i = 1 to 32
print read_core_mem_dword(1,4*i-3)
next i
suspend for key
end
function make_core_mem(core_memblock_num as dword,size as dword)
internal_core_mem_data(core_memblock_num) = make memory(size)
endfunction
function write_core_mem_byte(core_memblock_num as dword,position as dword,value as byte)
pointer = internal_core_mem_data(core_memblock_num)+position-1
*pointer = value
endfunction
function read_core_mem_byte(core_memblock_num as dword,position as dword)
value as byte
pointer = internal_core_mem_data(core_memblock_num)+position-1
value = *pointer
endfunction value
function write_core_mem_dword(core_memblock_num as dword,position as dword,value as dword)
write_core_mem_byte(core_memblock_num,position,get_byte_from_dword(value,1))
write_core_mem_byte(core_memblock_num,position+1,get_byte_from_dword(value,2))
write_core_mem_byte(core_memblock_num,position+2,get_byte_from_dword(value,3))
write_core_mem_byte(core_memblock_num,position+3,get_byte_from_dword(value,4))
endfunction
function read_core_mem_dword(core_memblock_num as dword,position as dword)
value as dword
value = make_dword_from_bytes(read_core_mem_byte(core_memblock_num,position),read_core_mem_byte(core_memblock_num,position+1),read_core_mem_byte(core_memblock_num,position+2),read_core_mem_byte(core_memblock_num,position+3))
endfunction value
function make_dword_from_bytes(byteA as byte,byteB as byte,byteC as byte,byteD as byte)
returnval as dword
returnval = (byteA*16777216)+(byteB*65536)+(byteC*256)+byteD
endfunction returnval
function get_byte_from_dword(dwordValue as dword,byteIndex as byte)
returnval as dword
byteA as byte
byteB as byte
byteC as byte
byteD as byte
byteA = int(dwordValue/16777216)
byteB = int((dwordValue-16777216*byteA)/65536)
byteC = int((dwordValue-16777216*byteA-65536*byteB)/256)
byteD = int(dwordValue-16777216*byteA-65536*byteB-256*byteC)
select byteIndex
case 1
returnval = byteA
endcase
case 2
returnval = byteB
endcase
case 3
returnval = byteC
endcase
case 4
returnval = byteD
endcase
case default
returnval = 2
endcase
endselect
endfunction returnval
[EDIT] I'll try to get rebars to work with this - should be easy
- I can't afford the 9MBs added to my EXE from using memblocks for so simple tasks as writing DWORDs. [/EDIT]
-Xol