The MASM Forum

General => The Campus => Topic started by: jj2007 on October 17, 2017, 07:41:45 AM

Title: How do you trap a access denied error memory in Windows? help
Post by: jj2007 on October 17, 2017, 07:41:45 AM
include \masm32\MasmBasic\MasmBasic.inc         ; download (http://masm32.com/board/index.php?topic=94.0)
  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
Title: Re: How do you trap a access denied error memory in Windows? help
Post by: felipe on October 17, 2017, 08:19:18 AM
Nice, very interesting jj, and works too!  :icon14:
Title: Re: How do you trap a access denied error memory in Windows? help
Post by: aw27 on October 17, 2017, 03:32:39 PM
Quote from: smid1584 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?
There is a post here (http://masm32.com/board/index.php?topic=6614.msg70934#msg70934). 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.