Code Monkey home page Code Monkey logo

Comments (4)

dahall avatar dahall commented on July 24, 2024

That would be true if PROCESS_INFORMATION was defined as struct. It is a class and is therefore already passed by reference. Thus that application of the OutAttribute to inform the marshaler that the class is being updated on the way back. Are you getting an error? In my unit testing, it worked.

from vanara.

dahall avatar dahall commented on July 24, 2024

I found the problem. It is not in the signature of the function, it is in the implementation of the class PROCESS_INFORMATION. It will be corrected shortly.

from vanara.

slowik-marcin avatar slowik-marcin commented on July 24, 2024

The PROCESS_INFORMATION doesn't have a public constructor.

I have also reviewed it's usage and in Kernel32.CreateProcess (and other places) it is used with out specifier and internally instantiated using a struct recieved from the WinAPI.

PROCESS_INFORMATION is used with [Out] attribute in other places like, CreateProcessAsUser, CreateProcessWithLogonW, but none of them have unit tests.

Note: I was writing this message when your last answer popped out.

from vanara.

dahall avatar dahall commented on July 24, 2024

Thanks for pointing all this out. Turns out it was bad naming and some inconsistency between assemblies. It has been corrected now. I decided to make it a breaking change due to the immensity of my mistake. I need users to know it is broken so they fix it. This code now works for the function:

using (var pTok = SafeHTOKEN.FromProcess(GetCurrentProcess()))
using (var hTok = pTok.DuplicateImpersonate())
{
   var b = CreateProcessWithTokenW(hTok, 0, "notepad.exe", null, 0, default, default,
      STARTUPINFO.Default, out var pi);
   if (b) WaitForSingleObject(pi.hProcess, INFINITE);
}

I'll post all these changes to GitHub and then will include them in the next release early next week.

from vanara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.