-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2827e1d
Showing
8 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# .gitignore for Go projects | ||
|
||
# Build artifacts | ||
_dist/ | ||
_build/ | ||
_out/ | ||
bin/ | ||
pkg/ | ||
target/ | ||
|
||
# Go specific build artifacts | ||
.obj/ | ||
.go-work/ | ||
.gopath/ | ||
.gotmp/ | ||
# go mod and go sum files are usually not ignored | ||
# but you might want to if you're not using them | ||
#go.mod | ||
#go.sum | ||
|
||
# IDEs and editors | ||
.idea/ | ||
*.swo | ||
*.swp | ||
*.swx | ||
*.log | ||
*.tmp | ||
*.bak | ||
*.rej | ||
*.orig | ||
*.synctex.gz | ||
*~ # Emacs and others temp files | ||
|
||
# OS generated | ||
.DS_Store | ||
Thumbs.db | ||
desktop.ini | ||
|
||
# Coverage profiles | ||
.coverprofile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Arguments Fetcher: argsfet | ||
|
||
A simple tool to fetch command line arguments. | ||
|
||
# Build | ||
|
||
```shell | ||
rsrc -manifest app.manifest -o app.syso | ||
go build -ldflags="-w -s" -o argsfet.exe | ||
``` | ||
|
||
# Usage | ||
|
||
Execute | ||
|
||
```shell | ||
argsfet.exe <ProcessName> | ||
``` | ||
|
||
then will show the command line arguments and output a file named `command_line_<ProcessName>.txt`. | ||
There into `<ProcessName>` is the process name which you want to fetch. | ||
|
||
# Reference | ||
|
||
[build - https://github.com/akavel/rsrc](https://github.com/akavel/rsrc) | ||
|
||
[argsfet.dll - https://github.com/Ninohana/argsfet](https://github.com/Ninohana/argsfet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<security> | ||
<requestedPrivileges> | ||
<requestedExecutionLevel level="requireAdministrator"/> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
</assembly> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func ObtainProcessCommandArgs(processName string) string { | ||
// 将进程名转换为UTF-16指针 | ||
processNameUTF16, _ := syscall.UTF16PtrFromString(processName) | ||
|
||
// 加载DLL以及函数 | ||
dll := syscall.MustLoadDLL("argsfet.dll") | ||
GetProcessIdByName := dll.MustFindProc("GetProcessIdByName") | ||
GetCommandLineByProcessId := dll.MustFindProc("GetCommandLineByProcessId") | ||
|
||
// 获取PID | ||
ret, _, _ := GetProcessIdByName.Call(uintptr(unsafe.Pointer(processNameUTF16))) | ||
|
||
// 获取命令行参数 | ||
ret, _, _ = GetCommandLineByProcessId.Call(ret) | ||
commandLine := syscall.UTF16ToString((*[1 << 16]uint16)(unsafe.Pointer(ret))[:]) | ||
|
||
// 释放DLL | ||
_ = dll.Release() | ||
return commandLine | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module argsfet | ||
|
||
go 1.23.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) > 1 { | ||
processName := os.Args[1] | ||
commandLine := ObtainProcessCommandArgs(processName) | ||
fmt.Print(commandLine) | ||
file, _ := os.Create(fmt.Sprintf("command_line_%s.txt", processName)) | ||
defer file.Close() | ||
writer := bufio.NewWriter(file) | ||
writer.WriteString(commandLine) | ||
writer.Flush() | ||
} | ||
} |