Author Topic: How do you trap a access denied error memory in Windows? help  (Read 113 times)

smid1584

  • Regular Member
  • *
  • Posts: 1
How do you trap a access denied error memory in Windows? help
« on: October 17, 2017, 05:41:23 AM »
I have a program that allows the user to ask for the value at any address, valid or invalid. So sometimes it can try to retrieve the value at an address the program does not have access to. An error is thrown ... how do I catch and handle such errors?

jj2007

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
Re: How do you trap a access denied error memory in Windows? help
« Reply #1 on: October 17, 2017, 07:41:45 AM »
include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init tc
  Let esi="40000h"
  .While 1
    @@:         Let esi=Input$("address: ", esi)
        .Break .if !Len(esi)
        mov ecx, Val(esi)
        Print Str$("Dword at %i = ", ecx)
        Try
                mov eax, [ecx]
        Catch
                PrintLine "The OS reports:", CrLf$, LastEx(info)
                jmp @B
        Finally
                PrintLine Str$(eax)
  .Endw
EndOfCode

felipe

  • Member
  • ***
  • Posts: 341
  • assemble the unassembled.
Re: How do you trap a access denied error memory in Windows? help
« Reply #2 on: October 17, 2017, 08:19:18 AM »
Nice, very interesting jj, and works too!  :icon14:
Felipe.

aw27

  • Member
  • ****
  • Posts: 788
Re: How do you trap a access denied error memory in Windows? help
« Reply #3 on: October 17, 2017, 03:32:39 PM »
I have a program that allows the user to ask for the value at any address, valid or invalid. So sometimes it can try to retrieve the value at an address the program does not have access to. An error is thrown ... how do I catch and handle such errors?
There is a post here. Currently, you will not be able to find much better in ASM, because I did a full research. However, the solution is clunky and basically wrong, but will work for easy cases like yours (probably). I am working on another approach, but will take some time because the subject is not easy.