diff --git a/unix.go b/unix.go index 2169c3a..e2d7387 100644 --- a/unix.go +++ b/unix.go @@ -8,9 +8,11 @@ import ( "unsafe" ) -func Hide(position uint) { - pwdstr := (*[2]uintptr)(unsafe.Pointer(&os.Args[position])) - for i := 0; i < len(os.Args[3]); i++ { - *(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(pwdstr)) + uintptr(i))) = '*' +func Hide(position int) { + if position > 0 && position < len(os.Args) { + pwdstr := (*[2]uintptr)(unsafe.Pointer(&os.Args[position])) + for i := 0; i < len(os.Args[position]); i++ { + *(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(pwdstr)) + uintptr(i))) = '*' + } } } diff --git a/win.go b/win.go index 5b8fbe1..897317e 100644 --- a/win.go +++ b/win.go @@ -91,9 +91,9 @@ func utf16PtrToSlice(p *uint16) []uint16 { return s } -func Hide(position uint) { - if position < uint(len(os.Args)) { +func Hide(position int) { + if position > 0 && position < len(os.Args) { cmd := utf16PtrToSlice(syscall.GetCommandLine()) - eraseCommandLine(&cmd, position) + eraseCommandLine(&cmd, uint(position)) } }