mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 09:58:34 +00:00
A non-char-array destination is sized from its pointee, and a 64-bit integer source (a pt_regs field) is the address to read from, as with (void *)ctx->si in C. Also export probe_read_kernel from pythonbpf.helper; it had an emitter but no importable name.
68 lines
1.3 KiB
Python
68 lines
1.3 KiB
Python
import ctypes
|
|
|
|
|
|
def ktime():
|
|
"""get current ktime"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def pid():
|
|
"""get current process id"""
|
|
return ctypes.c_int32(0)
|
|
|
|
|
|
def deref(ptr):
|
|
"""dereference a pointer"""
|
|
result = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_void_p)).contents.value
|
|
return result if result is not None else 0
|
|
|
|
|
|
def comm(buf):
|
|
"""get current process command name"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def probe_read_str(dst, src):
|
|
"""Safely read a null-terminated string from kernel memory"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def probe_read_kernel(dst, src):
|
|
"""Safely read sizeof(dst) bytes from kernel memory"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def random():
|
|
"""get a pseudorandom u32 number"""
|
|
return ctypes.c_int32(0)
|
|
|
|
|
|
def probe_read(dst, size, src):
|
|
"""Safely read data from kernel memory"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def smp_processor_id():
|
|
"""get the current CPU id"""
|
|
return ctypes.c_int32(0)
|
|
|
|
|
|
def uid():
|
|
"""get current user id"""
|
|
return ctypes.c_int32(0)
|
|
|
|
|
|
def skb_store_bytes(offset, from_buf, size, flags=0):
|
|
"""store bytes into a socket buffer"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def get_stack(buf, flags=0):
|
|
"""get the current stack trace"""
|
|
return ctypes.c_int64(0)
|
|
|
|
|
|
def get_current_cgroup_id():
|
|
"""Get the current cgroup ID"""
|
|
return ctypes.c_int64(0)
|