Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Canread
Gopsutil
提交
456cd82a
G
Gopsutil
项目概览
Canread
/
Gopsutil
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gopsutil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
456cd82a
编写于
4月 25, 2014
作者:
W
WAKAYAMA Shirou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add get_proc_info which get information via NtQuerySystemInformation. but not worked(yet)
上级
665ddbd7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
14 deletion
+38
-14
common_windows.go
common_windows.go
+1
-0
process_windows.go
process_windows.go
+37
-14
未找到文件。
common_windows.go
浏览文件 @
456cd82a
...
...
@@ -8,6 +8,7 @@ import (
var
(
modKernel32
=
syscall
.
NewLazyDLL
(
"kernel32.dll"
)
modNt
=
syscall
.
NewLazyDLL
(
"ntdll.dll"
)
)
type
FILETIME
struct
{
...
...
process_windows.go
浏览文件 @
456cd82a
...
...
@@ -13,6 +13,7 @@ var (
procCreateToolhelp32Snapshot
=
modKernel32
.
NewProc
(
"CreateToolhelp32Snapshot"
)
procProcess32First
=
modKernel32
.
NewProc
(
"Process32FirstW"
)
procProcess32Next
=
modKernel32
.
NewProc
(
"Process32NextW"
)
procNtQuerySystemInformation
=
modNt
.
NewProc
(
"NtQuerySystemInformation"
)
)
const
(
...
...
@@ -33,22 +34,20 @@ type PROCESSENTRY32 struct {
SzExeFile
[
MAX_PATH
]
uint16
}
/*
type
SYSTEM_PROCESS_INFORMATION
struct
{
ULONG NextEntryOffset;
ULONG NumberOfThreads;
BYTE Reserved1[48];
PVOID Reserved2[3];
HANDLE UniqueProcessId;
PVOID Reserved3;
ULONG HandleCount;
BYTE Reserved4[4];
PVOID Reserved5[11];
SIZE_T PeakPagefileUsage;
SIZE_T PrivatePageCount;
LARGE_INTEGER Reserved6[6];
NextEntryOffset
uint64
NumberOfThreads
uint64
Reserved1
[
48
]
byte
Reserved2
[
3
]
byte
UniqueProcessId
uintptr
Reserved3
uintptr
HandleCount
uint64
Reserved4
[
4
]
byte
Reserved5
[
11
]
byte
PeakPagefileUsage
uint64
PrivatePageCount
uint64
Reserved6
[
6
]
uint64
}
*/
// Memory_info_ex is different between OSes
type
Memory_info_exStat
struct
{
...
...
@@ -82,6 +81,12 @@ func NewProcess(pid int32) (*Process, error) {
if
(
pid
==
0
)
||
(
pid
==
4
)
{
p
.
Cmdline
=
""
}
r
,
err
:=
get_proc_info
(
pid
)
if
r
==
nil
{
return
p
,
err
}
return
p
,
nil
}
...
...
@@ -143,3 +148,21 @@ func processes() ([]*Process, error) {
return
results
,
nil
}
func
get_proc_info
(
pid
int32
)
(
*
SYSTEM_PROCESS_INFORMATION
,
error
)
{
initialBufferSize
:=
uint64
(
0x4000
)
bufferSize
:=
initialBufferSize
buffer
:=
make
([]
byte
,
bufferSize
)
var
sys_proc_info
SYSTEM_PROCESS_INFORMATION
ret
,
_
,
_
:=
procNtQuerySystemInformation
.
Call
(
uintptr
(
unsafe
.
Pointer
(
&
sys_proc_info
)),
uintptr
(
unsafe
.
Pointer
(
&
buffer
[
0
])),
uintptr
(
unsafe
.
Pointer
(
&
bufferSize
)),
uintptr
(
unsafe
.
Pointer
(
&
bufferSize
)))
if
ret
!=
0
{
return
nil
,
syscall
.
GetLastError
()
}
return
&
sys_proc_info
,
nil
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录