im building a flat load asm in raspberry pi works x86 dos version but not work, on linux , linux have protected mode diferent and data segment is procteted against runing in data segment ,
https://github.com/honeydatax/x86LibsAp ... n/flat.bas
can im afther load the flat code , protect the memory area as run mode as mprotect memory
Solved protection mode data segment
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
Solved protection mode data segment
Last edited by honeydatax on Aug 07, 2021 17:45, edited 1 time in total.
Re: protection mode data segment
Interesting. Looks like you got most of the way there.
From the mprotect man page, looks like page aligned memory is needed. Plus a translated sys/mmap.h => sys/mmap.bi header. Doesn't look too hard to translate the header, even by hand.
https://www.gnu.org/software/libc/manua ... ction.html
Though you should probably refer to the man page and mmap.h for your specific linux.
From the mprotect man page, looks like page aligned memory is needed. Plus a translated sys/mmap.h => sys/mmap.bi header. Doesn't look too hard to translate the header, even by hand.
https://www.gnu.org/software/libc/manua ... ction.html
Though you should probably refer to the man page and mmap.h for your specific linux.
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
Re: protection mode data segment
- probably need to use mmap() to get an aligned page instead of allocate() ( aka malloc() )man page wrote:On some systems, it may not be possible to specify additional flags which were not present when the mapping was first created. For example, an attempt to make a region of memory executable could fail if the initial protection flags were ‘PROT_READ | PROT_WRITE’.
In general, the mprotect function can be used to change any process memory, no matter how it was allocated. However, portable use of the function requires that it is only used with memory regions returned by mmap or mmap64.
- check the return value of your mprotect() call for failure and 'errno' on the C side for which error might give you a hint at why it's not working
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
Re: protection mode data segment
Thanks all by the help mmap it works thanks
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
Re: protection mode data segment
On my flat load ; as im call the system call function using bx r3 ; after return the stack point get out of control ; im used fbc -r sample.bas to see as basic call functions and return code assembly? ;tanks
Arm source
https://github.com/honeydatax/armlibapi ... ain/file.S
Arm source
https://github.com/honeydatax/armlibapi ... ain/file.S
-
- Posts: 26
- Joined: Jul 11, 2021 11:55
Re: protection mode data segment
Solved thanks