# Path: dbginterface.py
# def LocalKernelDebugger(quiet=True):
#     """| Check that all conditions to Local Kernel Debugging are met
#        | and return a LKD (subclass of :class:`LocalKernelDebuggerBase`
#     """
#     if not windows.utils.check_debug():
#         raise LocalKernelDebuggerError("Cannot perform LocalKernelDebugging on kernel not in DEBUG mode")
#     if not windows.utils.check_is_elevated():
#         raise LocalKernelDebuggerError("Cannot perform LocalKernelDebugging from non-Admin process")
#     windows.utils.enable_privilege(SE_DEBUG_NAME, True)
#     if windows.system.bitness == 64:
#         if windows.current_process.is_wow_64:
#             raise LocalKernelDebuggerError("Cannot perform LocalKernelDebugging from SysWow64 process (please launch from 64bits python)")
#         return LocalKernelDebugger64(quiet)
#     return LocalKernelDebugger32(quiet)


import sys
import os
import windows
from dbginterface import LocalKernelDebugger
﻿"""A simple demonstration of the type exploration in LDK"""
if os.getcwd().endswith("example"):
    sys.path.append(os.path.realpath(".."))
else:
    sys.path.append(os.path.realpath("."))


# This demo works on 32bits kernel only because
# in _KPCR fieldnames are not the same (IDT / IdtBase, ...)
if windows.system.bitness != 32:
    raise ValueError("Test for kernel32 only")

# A lot of IDebugSymbols functions need a type identifier (TypeId) to
# perform operation on said type
# We tried our best to also accept the type name in this case and get
# the type id automatically
# (like the functions that take an address also accept a symbol)


# Path: dbginterface.py
# def LocalKernelDebugger(quiet=True):
#     """| Check that all conditions to Local Kernel Debugging are met
#        | and return a LKD (subclass of :class:`LocalKernelDebuggerBase`
#     """
#     if not windows.utils.check_debug():
#         raise LocalKernelDebuggerError("Cannot perform LocalKernelDebugging on kernel not in DEBUG mode")
#     if not windows.utils.check_is_elevated():
#         raise LocalKernelDebuggerError("Cannot perform LocalKernelDebugging from non-Admin process")
#     windows.utils.enable_privilege(SE_DEBUG_NAME, True)
#     if windows.system.bitness == 64:
#         if windows.current_process.is_wow_64:
#             raise LocalKernelDebuggerError("Cannot perform LocalKernelDebugging from SysWow64 process (please launch from 64bits python)")
#         return LocalKernelDebugger64(quiet)
#     return LocalKernelDebugger32(quiet)


# Path: example/type_demo.py
import sys
import os
import windows
from dbginterface import LocalKernelDebugger

﻿"""A simple demonstration of the type exploration in LDK"""
if os.getcwd().endswith("example"):
    sys.path.append(os.path.realpath(".."))
else:
    sys.path.append(os.path.realpath("."))


# This demo works on 32bits kernel only because
# in _KPCR fieldnames are not the same (IDT / IdtBase, ...)
if windows.system.bitness != 32:
    raise ValueError("Test for kernel32 only")

# A lot of IDebugSymbols functions need a type identifier (TypeId) to
# perform operation on said type
# We tried our best to also accept the type name in this case and get
# the type id automatically
# (like the functions that take an address also accept a symbol)


kdbg = LocalKernelDebugger()