flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to access the stack below 4k? |
Author |
|
revolution 21 Aug 2012, 11:41
Can we asusme you are coding for Windows? It looks as though you are. So based upon that assumption, you will have to play nicely with the stack guard mechanism used in Windows. You have to "touch" the stack somewhere in each page boundary to trigger the guard bit and allocate a new page from the reserved pool. And depending upon your assembly setting your reserved stack size can be as large as the memory system allows:
Code: format pe ... stack ??? ;put you stack size here if you want more or less than the default size ;... ;now touch the stack mov al,byte[esp-4096*1] ;or rsp for 64-bit mov al,byte[esp-4096*2] mov al,byte[esp-4096*3] mov al,byte[esp-4096*4] mov al,byte[esp-4096*5] mov al,byte[esp-4096*6] ;etc. |
|||
21 Aug 2012, 11:41 |
|
Overflowz 21 Aug 2012, 12:05
Hi, thanks for reply but I tried it and program still crashes.. used really huge value for stack, look example:
Code: stack 1000000h ... push ebp, mov ebp,esp sub esp,10000h mov dword[esp],1 ;<-- still crashes.. and yes, I'm working in Windows environment. |
|||
21 Aug 2012, 12:05 |
|
revolution 21 Aug 2012, 12:07
You have to touch the stack as in my example code above. You can't simply go straight to the lowest stack address, it will always crash as you found out.
|
|||
21 Aug 2012, 12:07 |
|
Overflowz 21 Aug 2012, 12:13
hmm, thanks revolution! still, one last question.
I'm using file directive in local variables and that's the reason of crashing program. Isn't there other way to define it there ? I'm just playing with stack and trying to understand it more deeper. |
|||
21 Aug 2012, 12:13 |
|
revolution 21 Aug 2012, 12:20
Overflowz wrote: I'm using file directive in local variables ... |
|||
21 Aug 2012, 12:20 |
|
AsmGuru62 21 Aug 2012, 13:37
stack directive has TWO parameters:
Code: stack 100000h,100000h The above will produce 1Mb stack without guard pages. |
|||
21 Aug 2012, 13:37 |
|
Overflowz 22 Aug 2012, 13:17
Thanks AsmGuru62! That's what I was looking for.
|
|||
22 Aug 2012, 13:17 |
|
bzdashek 23 Aug 2012, 15:07
revolution wrote:
Your profile's location states otherwise. |
|||
23 Aug 2012, 15:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.