public static T InjectedNtQueryInformationProcess <T>(GameSharpProcess process, ProcessInformationClass pic) where T : struct { T returnResult = default; uint ntResult = InjectedNtQueryInformationProcessWrapper.Call(process.NativeHandle, pic, out IMemoryPointer returnPtr, Marshal.SizeOf <T>(), out IMemoryPointer _); // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55 if (ntResult == 0) { returnResult = returnPtr.Read <T>(); } else { LoggingService.Error( $"Flag: {pic.ToString()}" + $", Couldn't query NtQueryInformationProcess, Error code: {Marshal.GetLastWin32Error().ToString("X")}" + $", Return value of NtQueryInformationProcess function is 0x{ntResult.ToString("X")}"); } return(returnResult); }