Solved protection mode data segment

Linux specific questions.
Post Reply
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Solved protection mode data segment

Post by honeydatax »

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
Last edited by honeydatax on Aug 07, 2021 17:45, edited 1 time in total.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: protection mode data segment

Post by coderJeff »

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.
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: protection mode data segment

Post by honeydatax »

thanks
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: protection mode data segment

Post by honeydatax »

Im have something rong but im dont know wat

https://github.com/honeydatax/armlibapi
?
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: protection mode data segment

Post by coderJeff »

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.
- probably need to use mmap() to get an aligned page instead of allocate() ( aka malloc() )
- 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
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: protection mode data segment

Post by honeydatax »

Thanks
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: protection mode data segment

Post by honeydatax »

Thanks all by the help mmap it works thanks
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: protection mode data segment

Post by honeydatax »

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
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: protection mode data segment

Post by honeydatax »

Solved thanks
Post Reply