editing user32.dll to change behavior of a function

Posted on 2004-11-16
Last Modified: 2013-11-13
I want to make a copy my user32.dll but change the SendMessage function in it to first write info about the function call into a text file, and then do its normal thing. This way i can swap in and out my original user32.dll and modified one. This way i can monitor calls to the sendMessage function when i want. How would i go about doing this. Where in the user32.dll file would i insert my code for writing the function call's info. My thinking is to just insert my code at the top of the original SendMessage function body in user32.dll, but how do i find where the original SendMessage function body is? Any answers on how to go about doing this?
Question by:spines11
    LVL 23

    Accepted Solution

    Rather than modifying the DLL file, you fiddle with the loaded image in RAM.  Use GetProcAddress() to find where the desired entry point is and insert a call to your code there.  You'll also have to look at the code you're overlaying and figure out how much to save for later execution before you jump back into the DLL's code.
    LVL 23

    Expert Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Problem to adjust sheet 1 78
    matchUp  challenge 6 37
    Free AVI to DICOM converter 8 96
    stringclean challenge 26 43
    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now