Comments (4)
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.
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.
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.
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)
- ShellItemImages.GetImageAsync might throw NullReferenceException HOT 3
- Using char[] in place of StringBuilder HOT 2
- DPI_AWARENESS_CONTEXT enum values missing HOT 2
- Can't use the handle to read vhdx HOT 2
- `HRESULT.ToString()` is not thread-safe due to mutable global state. HOT 2
- Usage of `LibraryImport` instead of `DllImport` HOT 1
- RtlGetVersion not found in NtDll HOT 6
- A great project! HOT 1
- #nullableenabled brunch is not being merged into master HOT 4
- Kernel32.FILE_ID_128.Identifier returns incorrect values
- [Bug] MB_GetString make exe crashed and ExitCode is 3221226356 (0xc0000374) HOT 2
- RobiniaDocs API Explorer HOT 1
- Can not GetLastError HOT 1
- CM_REGISTER_NOTIFICATION callback: Incomplete eventData.u.DeviceInstance.InstanceId HOT 2
- FindNextPrinterChangeNotification SafePRINTER_NOTIFY_INFO is invalid HOT 2
- missing definition for StorageDeviceSeekPenalty. HOT 1
- [Bug] GetRawInputDeviceInfo can not use CharSet = CharSet.Auto HOT 4
- Interface not supported Exception while using the set operaiton in IMAPI HOT 2
- User32.GetWindowLongAuto throws an exception if result is 0 HOT 1
- OverlappedAsyncBaseResult does not make processed bytes available. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vanara.