Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Fork Implementation using the native API RtlCloneUserProcess

Fork Implementation using the native API RtlCloneUserProcess

Scheduled Pinned Locked Moved Windows API
c++comlinuxjsonhelp
4 Posts 2 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    akhilmv88
    wrote on last edited by
    #1

    Hi, I tried to port the fork API in Linux to Windows (Windows 7 and Windows 8) using the native API RtlCloneUserProcess as discussed in the following link. http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/afdf1b68-1f3e-47f5-94cf-51e397afe073/ With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc. The solution is to inform the CSR /win32 subsystem about the new process. But I could not able to do that. Please help me to re link the child process to the CSR.

    L 1 Reply Last reply
    0
    • A akhilmv88

      Hi, I tried to port the fork API in Linux to Windows (Windows 7 and Windows 8) using the native API RtlCloneUserProcess as discussed in the following link. http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/afdf1b68-1f3e-47f5-94cf-51e397afe073/ With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc. The solution is to inform the CSR /win32 subsystem about the new process. But I could not able to do that. Please help me to re link the child process to the CSR.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      akhilmv88 wrote:

      With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc.

      I see more risks; an app locking a file that gets forked, will be in trouble.

      akhilmv88 wrote:

      The solution is to inform the CSR /win32 subsystem about the new process.

      I did not see that "solution" in the thread you linked.

      akhilmv88 wrote:

      But I could not able to do that.

      Include the error-message, or at least the return-value.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      A 1 Reply Last reply
      0
      • L Lost User

        akhilmv88 wrote:

        With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc.

        I see more risks; an app locking a file that gets forked, will be in trouble.

        akhilmv88 wrote:

        The solution is to inform the CSR /win32 subsystem about the new process.

        I did not see that "solution" in the thread you linked.

        akhilmv88 wrote:

        But I could not able to do that.

        Include the error-message, or at least the return-value.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

        A Offline
        A Offline
        akhilmv88
        wrote on last edited by
        #3

        In the link it is given that “For the console, you do need to re-establish a link to csrss, but the setup is only done in ntdll if the CsrPort handle is NULL. This isn't the case in the forked process which of course, has the parent processes handle value. Nowhere in ntdll sets it to back to NULL so there's no chance of getting that to work unless you d/l the ntdll symbols, find where the handle is, and NULL it out yourself.” Also on further analysis on the CRS, it is understood that CSRSS is responsible for Win32 console handling. The link, http://translate.google.co.in/translate?hl=en&sl=ru&u=http://www.wasm.ru/forum/viewtopic.php%3Fid%3D42246&prev=/search%3Fq%3DCsrClientCallServer%26hl%3Den%26tbo%3Dd%26biw%3D991%26bih%3D598&sa=X&ei=e17FUNP7NMrtrQeA7IFo&ved=0CGAQ7gEwBg , gave some idea to manually notify the CSR about the new process, but I could not able to do that in windows 7. The CsrClientCallServer function returns a negative value and the data buffer to the api CsrClientCallServer got corrupted after the call.

        L 1 Reply Last reply
        0
        • A akhilmv88

          In the link it is given that “For the console, you do need to re-establish a link to csrss, but the setup is only done in ntdll if the CsrPort handle is NULL. This isn't the case in the forked process which of course, has the parent processes handle value. Nowhere in ntdll sets it to back to NULL so there's no chance of getting that to work unless you d/l the ntdll symbols, find where the handle is, and NULL it out yourself.” Also on further analysis on the CRS, it is understood that CSRSS is responsible for Win32 console handling. The link, http://translate.google.co.in/translate?hl=en&sl=ru&u=http://www.wasm.ru/forum/viewtopic.php%3Fid%3D42246&prev=/search%3Fq%3DCsrClientCallServer%26hl%3Den%26tbo%3Dd%26biw%3D991%26bih%3D598&sa=X&ei=e17FUNP7NMrtrQeA7IFo&ved=0CGAQ7gEwBg , gave some idea to manually notify the CSR about the new process, but I could not able to do that in windows 7. The CsrClientCallServer function returns a negative value and the data buffer to the api CsrClientCallServer got corrupted after the call.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Not a word on that function in MSDN. CsrClientCallServer is an undocumented (internal) function, and it's fingerprint may vary without warning. Sorry, can't help here.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups