Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hooks into PR_Write and PR_Read

625 views
Skip to first unread message

danut...@yahoo.com

unread,
Dec 6, 2009, 10:16:32 AM12/6/09
to dev-te...@lists.mozilla.org

Hello,

I'm developing an application that will hook into Mozilla Firefox PR_Read and PR_Write, which will be able to tamper requests and responses. Hooking works fine, but I'm having troubles.

The hook for PR_Write works in a way that will collect all the output for an request, tamper it and do the real send, using another call to original PR_Write. My problem is that I need to write and read all the data before I return it to Firefox. I know that the sockets are in non-blocking mode, so if I get -1 as return code and last error would block, then I just pause a bit and retry sending or reading, so I return to Firefox only when all the request was sent or all the response was read.

Is this the right approach? Because on some websites, I keep getting -1 and would block forever, and I get stuck in my sending or receiving loop.

Any help would be greatly appreciated,
Thanks.


gregory boyle

unread,
Dec 7, 2009, 8:57:26 PM12/7/09
to
On Dec 6, 9:16 am, "danut00...@yahoo.com" <danut00...@yahoo.com>
wrote:

Hello,

It's me again. I've passed this problem but now I got another one.
After I receive the entire response, and I start outputing it using my
PR_Recv hook, Firefox reads 4096 bytes a few times but after that it
stops reading, and after a little while around 20 seconds, it reads
again. Why is this behaviour? Even if I don't modify the response at
all, it still does the same.

Thanks !

info....@gmail.com

unread,
Sep 30, 2012, 7:56:47 PM9/30/12
to dev-te...@lists.mozilla.org
Hi Gregory,

This post looks fairly old, but I try to ask for a hand anyway maybe someone will reply.

I am trying hooking PR_Write and PR_Read too, however my hooks don't work that good with Mozilla's PR_Write and PR_Read.

I am using the code shown at the first section of this link:
http://www.codeproject.com/Articles/30140/API-Hooking-with-MS-Detours

The first example does not use detour. It just shows how to hook a MessageBox.

Can I reuse this code for PR_Write and PR_Read ?

How do I define PR_Write? Is the following the right method?

typedef int (WINAPI *pPr_Write)(HWND, const void *, int);
int WINAPI MyPR_Write(HWND, const void *, int);


Thanks in advance,

- dome
0 new messages