Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1059265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:08:41+00:00 2026-05-16T18:08:41+00:00

I would like to write a C++ function, on Microsoft Windows, that spawns a

  • 0

I would like to write a C++ function, on Microsoft Windows, that spawns a process and returns, in addition to the process’s termination status, a list of all the files the process read or wrote. It should not require any cooperation from the spawned application.

For example, if the program spawned is the Visual Studio C++ compiler, the function would produce a list containing the source file the compiler opened, all header files it read, and the .OBJ file it created. If it also contained things like .DLL files the program contained, that would be fine. But again, it should work regardless of the program spawned; the compiler is just an example.

A twist: if the process creates subprocesses, I need to monitor their file accesses as well.

A second twist: if the process tries to open a file, I would like to be able to make it wait until I can create that file—and only then let it resume and open the file. (I think this rules out ETW.)

I know this probably sounds like an ingredient for some horrible kludge. But if I can get this working, the end result will be really cool.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:08:42+00:00Added an answer on May 16, 2026 at 6:08 pm

    A second twist: if the process tries to open a file, I would like to be able to make it wait until I can create that file—and only then let it resume and open the file

    You just put yourself into Hack City with that requirement – you’re right that ETW would’ve been a far easier solution, but it also has no way to block the file call.

    Basically, here’s what you’re going to have to do:

    1. Create the process suspended
    2. Create two named pipes in opposite directions whose names are well known (perhaps containing the PID of the process)
    3. Hook LoadModule, and the hook will watch for Kernel32 to get loaded
    4. When Kernel32 gets loaded, hook CreateFileW and CreateFileA – also hook CreateProcessEx and ShellExecute
    5. When your CreateFile hook hits, you write the name to one of the named pipes, then execute a ReadFile on the other one until the parent process signals you to continue.
    6. When your CreateProcessEx hook hits, you get to do the same process all over again from inside the current process (remember that you can’t have the parent process do the CreateProcess’ing because it’ll mess up inherited handles).
    7. Start the child process.

    Keep in mind that you’ll be injecting code and making fixups to an in-memory image that may be a different bitness than yours (i.e. your app is 64-bit, but it’s starting a 32-bit process), so you’ll have to have both x86 and amd64 versions of your shim code to inject. I hope by writing this lengthy diatribe you have convinced yourself that this is actually an awful idea that is very difficult to get right and that people who hook Win32 functions make Windows OS developers sad.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a function that will process formulas that are comprised
I would like to write a function that creates a plot of a set
The following is for Python 3.2.3. I would like to write a function that
I would like to write a cross-platform function in C++ that contains system calls.
In clojure, I would like to write a tail-recursive function that memoizes its intermediate
I'd like to write a function that would have some optional code to be
In Python, I'd like to write a function that would pretty-print its results to
I would like to write a function that takes a 3d triangle (as 3
I would like to write a function that takes a function f as an
I would like to write a function that (amongst other things) accepts a variable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.