flat assembler
Message board for the users of flat assembler.
Index
> Main > how to check if i have access to memory |
Author |
|
vid 10 Sep 2006, 07:39
is there some way (instruction) how to find out if i can access to some portion of memory, without utilizing SEH / other such techniques???
|
|||
10 Sep 2006, 07:39 |
|
halyavin 10 Sep 2006, 07:49
See VirtualQuery function is kernel32.dll. There is no such instruction in assembler.
|
|||
10 Sep 2006, 07:49 |
|
velox 10 Sep 2006, 07:56
this function may also help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/isbadreadptr.asp |
|||
10 Sep 2006, 07:56 |
|
MazeGen 10 Sep 2006, 08:51
Well, there are two user-mode instructions, LSL and LAR, but not much of use in flat memory model.
|
|||
10 Sep 2006, 08:51 |
|
vid 10 Sep 2006, 09:50
that means i can check if [eax] is accessible with:
Code: lsl (anything), [eax] jnz .not_accessible |
|||
10 Sep 2006, 09:50 |
|
RedGhost 10 Sep 2006, 11:49
vid you haven't moved this to Windows, you're slipping
|
|||
10 Sep 2006, 11:49 |
|
MazeGen 10 Sep 2006, 14:25
vid wrote: that means i can check if [eax] is accessible with: No, under Windows flat memory model it should work this way (not tested): Code: mov eax, ds lsl eax, eax jz .really_weird_error ; "ZF is set if the segment limit is loaded successfully" EAX holds the segment limit now. From my experience, the limit is 0xFFFF (or a little less) and the segment is growing down (you get it using LSL instruction), what means the segment is accessible from 0xFFFF to 0xFFFFFFFF. [EDIT] It seems it was true only in my Win98, now under Win XP SP2 it seems much different (limit is 0xFFFFFFFF, growing up, what means the segment is accessible anywhere - from 0x0 to 0xFFFFFFFF). [/EDIT] Note that paging is another layer of the protection scheme and there is probably no user-mode instructions how to get if any address is paged and therefore accessible Long time ago, I wrote simple tool to show limits and attributes of all segment descriptors in Windows. It doesn't call any OS functions, it uses just LAR and LSL instructions. Let me know if anyone is interested, I can prepare it and upload it here with its MASM source code. Quote: vid you haven't moved this to Windows, you're slipping I bet vid ask this question in general, not only for Windows |
|||
10 Sep 2006, 14:25 |
|
vid 10 Sep 2006, 15:30
mazegen is right bout slippiness
seems i will have to utilize my own SEH (( |
|||
10 Sep 2006, 15:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.