Hi all,
I have reached a solution for my problem(bit compromising though). I wanted to achieve this in one document library only. I will explain the process here.
The permissions page is always "user.aspx" and add new permissions page is "aclinv.aspx".
I implemented an httpmodule url listener for "aclinv.aspx". So when this page is requested, I transfer it my custom permissions page. Interestingly, url's in sharepoint are the key to every operation. It had my folder name in url as an id, the document library name also an id.
The custom permissions page is exactly similar to "aclinv.aspx" except the fact that the application is listening for this page. When user is selected with proper permissions on this page, the application tracks the userid, selected permission, folder id, document library id everything through the url and the flow remains the same.
Thats it, job done. With all these values, the application can do whatever it wnats to the new request.
Thanks a lot to all for your guidance. It really helped a lot.
PS. If there is a better way to do this, I would be glad to know.
Sushant