The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => Miscellaneous Projects => Topic started by: whitegold on December 02, 2008, 06:38:13 PM

Title: Hooking Text output in a java application
Post by: whitegold on December 02, 2008, 06:38:13 PM
I've written a text hooking application which hooks TextOutA, TextOutW, ExtTextOutA, ExtTextOutW, DrawTextA, DrawTextW, DrawTextExA, DrawTextExW for a target process.  It overwrites the apis in gdi32.dll, and user32.dll, (not using the IAT table).

Works fine with most apps.  I tried it on a jar file chess program I've got. Ran programme.  Hooked javaw.exe - but no results.  Apparently none of these functions were being used.

Ran the programme again and attached Ollydbg to the process.  Set breakpoints on all the above.  None were used.  Set breakpoints on PolyTextOut functions.  Not being used.

So how does a java programme write text to a window?  Whilst Java is cross platform I would assume it would have to end up using the Windows Apis above at some point on Windows - and javaw.exe is the only process I can see.

So what's going on?  :dazzled:
Title: Re: Hooking Text output in a java application
Post by: Vortex on December 02, 2008, 06:48:16 PM
Hi whitegold,

Welcome to the board.

Why are you trying to hook those API functions?
Title: Re: Hooking Text output in a java application
Post by: whitegold on December 02, 2008, 07:59:04 PM
No reason at all. 

I happened to be looking at some hooking stuff a few weeks ago and saw a commercial set of tools for hooking text, and I thought 'I can write that', so I thought I would.  I'm puzzled why it works fine for everything but a java app.
Title: Re: Hooking Text output in a java application
Post by: BlackVortex on December 09, 2008, 03:57:41 PM
@ whitegold
Well, it's possible java apps don't use those APIs at all, maybe all those dlls that get loaded at runtime use the deep-down native win apis in the end (as in ntdll.dll just a wild guess)

You can try using output redirecting from the command line (for testing) by excuting
program.exe  >>  output.txt

I tried in a java application I have (frostwire) and it worked very nicely.
Title: Re: Hooking Text output in a java application
Post by: ecube on February 21, 2009, 02:39:18 AM
use nektra spy studio, free open source hooking studio and hook groups so you can see what apis it calls.