Re: MiniDumpWriteDump
- From: "Robert" <noone@xxxxxxxxxxx>
- Date: Tue, 26 Jul 2005 09:30:17 +0200
I changed the structure to use pointers instead of using the types inline
(see previous posting).
Now, when an exception occurs, and is caught my me (see sample code in same
posting), I actually get valid pointers to memory locations where useful
data about the nature of the exception can be found, unlike before.
I still get the "Invalid memory location" error when calling
MemoryDumpWriteDump however, so the wrong structure declaration must not
have been the only problem.
(Please forget my last posting's question about whether the API can access
the structure when I hand it over ByRef. I was being stupid.)
Robert
"Sam Hobbs" <samuel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23%23djmsTkFHA.1372@xxxxxxxxxxxxxxxxxxxxxxx
> Please explain.
>
> If you are not sure what to explain, then you can understand the
frustration
> of trying to understand something that is not clear.
>
>
> "Robert" <noone@xxxxxxxxxxx> wrote in message
> news:u7fcPhPkFHA.2852@xxxxxxxxxxxxxxxxxxxxxxx
> > OK, seems like the structure I had was actually filled with memory
> > garbage.
> >
> > Here's my attempt to improve things:
> >
> > ' New declare
> > Private Type EXCEPTION_POINTERS
> > pExceptionRecord As Long
> > pContextRecord As Long
> > End Type
> >
> > Now my question: If I get the EXCEPTION_POINTERS structure as a ByRef
> > parameter to a function, can I hand over a pointer to that structure to
an
> > API call directly, or won't the API call be able to access it from
there?
> > Do
> > I have to copy the whole contents of the structure (following all
> > pointers...) to the heap so the API call can access it? Because I still
> > get
> > the "Invalid access to memory location" error.
> >
> > Robert
> >
> > "Robert" <noone@xxxxxxxxxxx> wrote in message
> > news:OY7ekXPkFHA.2904@xxxxxxxxxxxxxxxxxxxxxxx
> >> Good point, the two of you, although I took those declares from
existing
> > VB
> >> samples (see example from this AllAPI page:
> >> http://www.mentalis.org/apilist/SetUnhandledExceptionFilter.shtml)
> >>
> >> I'll take a closer look at those structures, however.
> >>
> >> And here's the code that will call my function:
> >>
> >> First part goes into a Form, with two buttons named cmdSetFilter and
> >> cmdException
> >> When starting the app, first press cmdSetFilter, then cmdException (and
> > make
> >> sure you've saved the project before!)
> >> '*******************************************************************
> >>
> >> Private Declare Sub CopyMemoryRead Lib "kernel32" Alias _
> >> "RtlMoveMemory" (Destination As Any, ByVal Source As Long, _
> >> ByVal Length As Long)
> >>
> >> Private Sub cmdException_Click()
> >> Dim lngDest As Long
> >>
> >> ' Cause an exception
> >> Call CopyMemoryRead(lngDest, 0&, 4)
> >> End Sub
> >>
> >> Private Sub cmdSetFilter_Click()
> >> Call InitExceptionHandling
> >> End Sub
> >>
> >> '*******************************************************************
> >> ' Second part goes into a module (the same module as for the previous
> >> example)
> >>
> >> Private Const EXCEPTION_EXECUTE_HANDLER As Long = 1
> >>
> >> Private Declare Function SetUnhandledExceptionFilter Lib "kernel32" ( _
> >> ByVal lpTopLevelExceptionFilter As Long) As Long
> >>
> >> Private Declare Function UnhandledExceptionFilter Lib "kernel32" ( _
> >> ExceptionInfo As EXCEPTION_POINTERS) As Long
> >>
> >> Public Sub InitExceptionHandling()
> >> Debug.Print SetUnhandledExceptionFilter(AddressOf TopLevelFilter)
> >> End Sub
> >>
> >> Public Function TopLevelFilter(ByRef pExc As EXCEPTION_POINTERS) As
Long
> >> Dim rc As Long
> >>
> >> ' My function call
> >> rc = WriteMiniDump(pExc)
> >>
> >> Call MsgBox("I caught an exception!" + vbCr + "Minidump result: " +
> >> CStr(Hex(rc)))
> >>
> >> TopLevelFilter = EXCEPTION_EXECUTE_HANDLER
> >> End Function
> >>
> >>
> >> Robert
> >>
> >> "Sam Hobbs" <samuel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
> >> message
> >> news:%232c2$oujFHA.3544@xxxxxxxxxxxxxxxxxxxxxxx
> >> > "Robert" <noone@xxxxxxxxxxx> wrote in message
> >> > news:e5xQMUrjFHA.1416@xxxxxxxxxxxxxxxxxxxxxxx
> >> > >I found a lot of MiniDumpWriteDump, too, but all for VC, not VB.
> >> >
> >> > Yes, it does seem that there are not any VB examples available.
> >> >
> >> > I have copied your code into a module, but I am not familiar with
this
> >> API.
> >> > It might not be easy for me to find the problem. However in order for
> >> > me
> >> to
> >> > try, I should learn enough to know how to use the code you have. I
> >> > might
> >> not
> >> > have the time but I hope someone does. However can you provide a
sample
> > of
> >> > how you are calling the functions?
> >> >
> >> > One thing I notice is that there are a lot of structs (UDTs). Are you
> >> > familiar with packing? Are you sure that is not a problem?
> >> >
> >> > > Private Type EXCEPTION_POINTERS
> >> > > pExceptionRecord As EXCEPTION_RECORD
> >> > > ContextRecord As CONTEXT
> >> > > End Type
> >> >
> >> > I think this is a problem. The C definition of EXCEPTION_POINTERS is:
> >> >
> >> > typedef struct _EXCEPTION_POINTERS {
> >> > PEXCEPTION_RECORD ExceptionRecord;
> >> > PCONTEXT ContextRecord;
> >> > } EXCEPTION_POINTERS;
> >> >
> >> > Note that ExceptionRecord and ContextRecord are pointers, whereas
your
> > UDT
> >> > has the UDTs/structs in your UDT for EXCEPTION_POINTERS. Check your
> > other
> >> > UDTs to ensure they are also correct.
> >> >
> >> > > Currently, I get the error
> >> > > -2147023898 (0x800703E6)
> >> > > Invalid access to memory location
> >> >
> >> > It helps to know where in the code the exception occurs. However that
> >> > exception might be caused by the problem I described above.
> >> >
> >> >
> >>
> >>
> >
> >
>
>
.
- Follow-Ups:
- Re: MiniDumpWriteDump
- From: Sam Hobbs
- Re: MiniDumpWriteDump
- References:
- MiniDumpWriteDump
- From: Robert
- Re: MiniDumpWriteDump
- From: Sam Hobbs
- Re: MiniDumpWriteDump
- From: Robert
- Re: MiniDumpWriteDump
- From: Sam Hobbs
- Re: MiniDumpWriteDump
- From: Robert
- Re: MiniDumpWriteDump
- From: Robert
- Re: MiniDumpWriteDump
- From: Sam Hobbs
- MiniDumpWriteDump
- Prev by Date: how to put formated RTF text onto a picbox?
- Next by Date: API function to determin "decimal seperator"
- Previous by thread: Re: MiniDumpWriteDump
- Next by thread: Re: MiniDumpWriteDump
- Index(es):
Relevant Pages
|