1
0
mirror of https://github.com/fumiama/go-hide-param.git synced 2026-06-05 07:20:25 +08:00
This commit is contained in:
fumiama
2021-09-19 21:38:29 +08:00
parent 2eaa75f6cf
commit 5bdf84cb62
2 changed files with 9 additions and 7 deletions

10
unix.go
View File

@@ -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))) = '*'
}
}
}

6
win.go
View File

@@ -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))
}
}