type listmode uintptr
const (
list_modules_default listmode =0x0 //檢視預設的模組
list_modules_32bit =0x01 //檢視32-bit的模組
list_modules_64bit =0x02 //檢視64-bit的模組
list_modules_all =0x03 //檢視所有的模組
)//windows上實現
psapi = syscall.newlazydll("psapi.dll")
enumprocessmodule*** = psapi.newproc("enumprocessmodule***")
getmodulefilenameexw = psapi.newproc("getmodulefilenameexw")
func listdynamicmodule(pid uint32, mode listmode) (string, error)
//注意關閉控制代碼
defer syscall.closehandle(hprocess)
var (
cbneeded uint32
hmods [1024]uintptr
)//獲取程序開啟的模組數
r, _, err := enumprocessmodule***.call(uintptr(hprocess), uintptr(unsafe.pointer(&hmods[0])), unsafe.sizeof(hmods), uintptr(unsafe.pointer(&cbneeded)), uintptr(mode))
if r ==0
//計算模組數量
var modelength = int(cbneeded) / int(unsafe.sizeof(hmods[0]))
var szmodname [260]uint16
var list = make(string,0, modelength)
for i :=0; i < modelength; i++
}return list, nil
}//linux實現
//linux下mode不生效
func listdynamicmodule(pid uint32, mode listmode) (string, error)
return
nil, err
}file, err := os.open(fmt.sprintf("/proc/%d/maps", pid))
if err != nil
return
nil, err
}defer file.close()
var maps = make(map[string]struct{})
buf := bufio.newreader(file)
for
if !bytes.contains(line, byte(".so"))
lines := bytes.fields(line)
iflen(lines) <6
maps[string(lines[5])] = struct{}{}
}var list = make(string,0, len(maps))
for k, _ := range maps
return list, nil
}
go語言獲取傳送訊號的程序pid
今天在發布乙個程式之前,給qa提測的時候,qa反饋程式執行10幾分鐘之後,退出了 在程式中加日誌,發現程式捕獲到了乙個sigterm訊號,然後做了一些退出前的清理工作 在退出之前,該傳送的資料還是需要傳送的 然後就需要知道到底是那個程序向我傳送sigterm訊號 查了一下,貌似go語言沒有直接的傳送...
python使用標準庫 獲取程序的pid
python有一套很有用的標準庫 standard library 標準庫會隨著python直譯器,一起安裝在你的電腦中的,所以下面這篇文章主要給大家介紹了關於python使用標準庫根據程序名如何獲取程序pid的相關資料,需要的朋友可以參考下。前言標準庫是python的乙個組成部分。這些標準庫是py...
Oracle資料庫的開啟與關閉 後台程序
資料庫啟動 startup nomount 建立並啟動例項 startup mount 建立例項並裝載資料庫 startup open 建立例項 裝載資料庫 開啟資料庫 startup 預設為startup open 資料庫關閉 shutdown normal 不允許新使用者連線到資料庫,不允許已連...