1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- using Microsoft . Win32 . SafeHandles ;
1615using System ;
16+ using System . Runtime . InteropServices ;
1717
1818namespace NtApiDotNet
1919{
2020#pragma warning disable 1591
21-
22- public sealed class SafeProcessParametersHandle : SafeHandleZeroOrMinusOneIsInvalid
21+ public sealed class SafeProcessParametersBuffer : SafeBuffer
2322 {
24- public SafeProcessParametersHandle ( IntPtr proc_params , bool owns_handle ) : base ( owns_handle )
23+ public SafeProcessParametersBuffer ( IntPtr proc_params , bool owns_handle ) : base ( owns_handle )
2524 {
2625 SetHandle ( proc_params ) ;
26+ uint size = 0 ;
27+ if ( proc_params != IntPtr . Zero )
28+ size = ( uint ) Marshal . ReadInt32 ( proc_params ) ;
29+ Initialize ( size ) ;
2730 }
2831
29- public SafeProcessParametersHandle ( ) : base ( true )
30- {
31- }
32-
33- public static SafeProcessParametersHandle Null
32+ public static SafeProcessParametersBuffer Null
3433 {
35- get => new SafeProcessParametersHandle ( IntPtr . Zero , false ) ;
34+ get => new SafeProcessParametersBuffer ( IntPtr . Zero , false ) ;
3635 }
3736
3837 protected override bool ReleaseHandle ( )
@@ -50,7 +49,7 @@ private static UnicodeString GetString(string s)
5049 return s != null ? new UnicodeString ( s ) : null ;
5150 }
5251
53- public static NtResult < SafeProcessParametersHandle > Create (
52+ public static NtResult < SafeProcessParametersBuffer > Create (
5453 string image_path_name ,
5554 string dll_path ,
5655 string current_directory ,
@@ -65,10 +64,10 @@ public static NtResult<SafeProcessParametersHandle> Create(
6564 {
6665 return NtRtl . RtlCreateProcessParametersEx ( out IntPtr ret , GetString ( image_path_name ) , GetString ( dll_path ) , GetString ( current_directory ) ,
6766 GetString ( command_line ) , environment , GetString ( window_title ) , GetString ( desktop_info ) , GetString ( shell_info ) ,
68- GetString ( runtime_data ) , flags ) . CreateResult ( throw_on_error , ( ) => new SafeProcessParametersHandle ( ret , true ) ) ;
67+ GetString ( runtime_data ) , flags ) . CreateResult ( throw_on_error , ( ) => new SafeProcessParametersBuffer ( ret , true ) ) ;
6968 }
7069
71- public static SafeProcessParametersHandle Create (
70+ public static SafeProcessParametersBuffer Create (
7271 string image_path_name ,
7372 string dll_path ,
7473 string current_directory ,
0 commit comments