Using Win32F as a Debugger?? 
Author Message
 Using Win32F as a Debugger??

Hi,

  I want to use Win32Forth (or others ..) to load a .EXE.
  And make it some words to run, step, break or ...
  just like a de{*filter*}.

  Is it possible to do that?
  Any related info can be refered?

  Thanks very much!

elf ?_?



Mon, 09 Feb 2004 10:28:22 GMT  
 Using Win32F as a Debugger??


Quote:
> Hi,

>   I want to use Win32Forth (or others ..) to load a .EXE.
>   And make it some words to run, step, break or ...
>   just like a de{*filter*}.

>   Is it possible to do that?
>   Any related info can be refered?

    Sure, it can be done, but it's *FAR* from easy!  The Win32 debugging
interface is complex, poorly documented, and buggy.

    What you have to do, is launch the program using CreateProcess with the
DEBUG_PROCESS flag set and then start processing debug events (look at
WaitForDebugEvent in MSDN).  You'll get events for each DLL loaded, for the
process and each additional thread, and so on.  To control the target
process, you have to use Read/WriteProcessMemory, Get/SetThreadContext,
Suspend/ResumeThread, etc.

--

-GJC

-Abolish Public Schools.



Mon, 09 Feb 2004 11:56:49 GMT  
 Using Win32F as a Debugger??
What i want to do is
load the .EXE image directly into Win32Forth execution space.
(the same process)
Then control the Forth execution to do the flow control.
For example, doing break --
we may just insert some instructions before break point.
After handing over the execution to the .EXE somewhere,
it should break at the point we set,
and then the instructions we insert will bring the
control back to Win32Forth.

Is it possible?
I have some bottlenecks here,
1. how to load .EXE image into forth execution space
  just like a create word
2. How to jump to exection them ...
..

Thanx very much!!

Quote:

> Hi,

>   I want to use Win32Forth (or others ..) to load a .EXE.
>   And make it some words to run, step, break or ...
>   just like a de{*filter*}.

>   Is it possible to do that?
>   Any related info can be refered?

>   Thanks very much!

> elf ?_?



Mon, 09 Feb 2004 13:34:16 GMT  
 Using Win32F as a Debugger??


Quote:
> What i want to do is
> load the .EXE image directly into Win32Forth execution space.
> (the same process)
> Then control the Forth execution to do the flow control.
> For example, doing break --
> we may just insert some instructions before break point.
> After handing over the execution to the .EXE somewhere,
> it should break at the point we set,
> and then the instructions we insert will bring the
> control back to Win32Forth.

> Is it possible?
> I have some bottlenecks here,
> 1. how to load .EXE image into forth execution space
>   just like a create word
> 2. How to jump to exection them ...

    This approach is not likely to work (although it's not totally
impossible).

    The first problem is address conflicts.  It's very likely that you will
not be able to load the program image at the address that it was linked for.
It might be possible to relocate it, but many programs do not contain
relocation information.  Even if it does, duplicating what the Win32 program
loader does is not trivial (and you won't be able to use it directly).

    Assuming you get past this, there are numerous ways that two programs
running in one process space are likely to trip over each other.  Off hand,
I don't know what problems you'll run into.  For instance, the OS will not
know that two programs are using the process stack.  You can create a second
stack, but it's very easy to get Win32 fouled up by switching stacks.

    I think it's probably a LOT easier to use the Win32 debugging interface
then what you're suggesting.

--

-GJC

-Abolish Public Schools.



Mon, 09 Feb 2004 18:14:13 GMT  
 Using Win32F as a Debugger??

Quote:

> What i want to do is
[...]
> 1. how to load .EXE image into forth execution space
>   just like a create word

I do that using my own Forth (a .OBJ) linked with my application.
Using "CreateRemoteThread...", you can check anything while
your application is running. But that's a complex system.

Perhaps you can do that using PFE?

Quote:
> 2. How to jump to exection them ...

The execution item have to be dynamicly linked at execution, in C.
The Forth data stack items have to transit to C stack.

Other easier solutions are:

- use a C DLL and import the needed fonctions in your Forth.

- use Forth to send registered windows messages to your application,
  use file mapping to exchange the data.

Charles Melice



Tue, 10 Feb 2004 22:40:57 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. using python debugger (pdb) inside emacs debugger mode ...

2. debugger problem using ##(...)

3. Anyone used Debugger ?

4. Using the CA-Clipper 5.2 Debugger

5. using tasms debugger. td

6. some problem in using masm debugger

7. Helo Using ADA Debugger

8. Using Turbo Debugger with Masm.

9. Using the Debugger

10. help using ldb (intel linux debugger)

11. Using emacs gud/pdb python debugger under windows

12. Fortran Debugger help for a newbie using Windows

 

 
Powered by phpBB® Forum Software