News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Unhandled application exception

Started by Magnum, November 27, 2012, 03:09:21 PM

Previous topic - Next topic

Magnum

I am testing Intel Inspector XE and came up with this when I run my code below it.

I will be reading up on error handlers.

ID      Problem   Sources   Modules   Object Size   State
P1      Unhandled application exception   [Unknown]   kernel32.dll      New
          Unhandled application exception   kernel32.dll:0x438f5   kernel32.dll      New
P2      Invalid memory access   [Unknown]   Virtual_Prot.exe      New
          Invalid memory access   Virtual_Prot.exe:0x1001   Virtual_Prot.exe      New
P3      Invalid memory access   [Unknown]   Virtual_Prot.exe      New
          Invalid memory access   Virtual_Prot.exe:0x1001   Virtual_Prot.exe      New


INCLUDE \masm32\include\masm32rt.inc

.DATA?

Alt dd ? ; address of variable to get old protection

.CODE

Andern:

mov ebx,041h

print uhex$(ebx),13,10

inkey
invoke ExitProcess,0

Start:

  invoke VirtualProtect,Andern,10,PAGE_EXECUTE_READWRITE,addr Alt
  mov ebx,41h
  mov dword ptr Andern,ebx
  mov byte ptr Andern+4,bl
jmp Andern

END Start
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

the bytes 41h,0,0,0,41h don't make any sense as code   :P
:004012C6 41                      inc ecx
:004012C7 0000                    add [eax], al   ;<----- crash
:004012C9 004133                  add [ecx+33], al


the code
mov ebx,41h
is
db 0BBh,41h,0,0,0

qWord

Magnum,
why are you not using OllyDbg to answer such question yourself?
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

try this...
INCLUDE \masm32\include\masm32rt.inc

.DATA?

Alt dd ? ; address of variable to get old protection

.CODE

Andern:
mov ebx,0FFFFFFFFh
print uhex$(ebx),13,10
inkey
invoke ExitProcess,0

Start:
  invoke VirtualProtect,Andern,2048,PAGE_EXECUTE_READWRITE,addr Alt
mov byte ptr Andern,0BBh
mov dword ptr Andern+1,41h
jmp Andern

END Start

when you alter the attribute for a byte, you alter it for the whole page, which is 2048 bytes

EDIT: oops - had to add MOV EBX,0FFFFFFFFh to make room for the code

MichaelW

Unless it's changed recently, a page is 4096 bytes.
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

right - my mistake   :t
don't know why i was thinking 2 k

Magnum

Quote from: qWord on November 27, 2012, 03:30:51 PM
Magnum,
why are you not using OllyDbg to answer such question yourself?

I am using Ollydbg.

I would like to change some lines of my code based on a specific condition being met and write those to my code to be saved.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Magnum

I will load it in Olly again and step thru it and look at each step.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

this is Jeremy Gordon's "Except1" program adapted for MASM

give it a try, Andy...

Magnum

I have managed to mangle bldall.bat.

The other build bats work ok.

@echo off
; COPY /B c:\masm32\source\bak.bat +,,
; f:
; cd f:\z_keep
; COPY /B F:\z_keep\IMPT_Quickies.txt +,,

if exist %1.obj del %1.obj > nul
if exist %1.exe del %1.exe > nul

if not exist rsrc.rc goto over1

\masm32\bin\rc /v rsrc.rc
\masm32\bin\cvtres /machine:ix86 rsrc.res

:over1

\masm32\bin\ml /c /coff %1.asm
if errorlevel 1 goto errasm

pause

if not exist rsrc.obj goto nores

\masm32\bin\Link /SUBSYSTEM:WINDOWS /OPT:NOREF %1.obj rsrc.obj
if errorlevel 1 goto errlink

pause

dir %1.*
goto TheEnd

:nores
\masm32\bin\Link /SUBSYSTEM:WINDOWS /OPT:NOREF %1.obj
if errorlevel 1 goto errlink
pause
dir %1.*
goto TheEnd

:errlink
echo _
echo Link error
goto TheEnd

:errasm
echo _
echo Assembly Error
goto TheEnd

:TheEnd

if exist *.udd del *.udd
::if exist *.obj del *.obj
if exist *.res del *.res

PING localhost -n 3 > nul


Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

for one thing, semicolon doesn't seem to make a comment
try double colon - it has worked since DOS days "::"
the way it is, it switches to the F: drive, where i do not have a masm32\bin folder   :biggrin:

not sure why you have a PING in there   :P

Magnum

Thanks.

That ping command is a 3 second delay that I learned from the batch gurus at https://groups.google.com
alt.msdos.batch.nt

I use it to see view any error messages etc. before closing out.
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

CommonTater

Quote from: Magnum on November 29, 2012, 11:44:47 PM
Thanks.

That ping command is a 3 second delay that I learned from the batch gurus at https://groups.google.com
alt.msdos.batch.nt

I use it to see view any error messages etc. before closing out.

Comments are either :: or REM
The ping at the end could easily be replaced by PAUSE which will cause it to wait for you to press Enter...


Magnum

I didn't want to press Enter.

(I worked for 25 years in  laboratories doing a lot of hand work, my joints are sore.)
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

you have 2 pauses in there - of course, those may be temporary to debug the batch file

i put one pause at the end of the file
when a console app is waiting for a key press, closing the console window will close the app
before the pause, i do a DIR %1.* /O-D     (/O = ordered list, -D = by date/time, reversed)
if all went well, the EXE and LST files will be at the top of the list
if it did not assemble, the ASM file is usually at the top - i read further to see the errors
if it assembled without errors, i click on the X to close the window - not press a key   :P

if you want to add a delay, you could also use NIRCMD
http://www.nirsoft.net/utils/nircmd.html