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

from dbginterface import LocalKernelDebugger


# 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()

type_id = kdbg.get_type_id("nt", "_KPCR")
print('type_id for "nt!_KPCR" is {0}'.format(hex(type_id)))

name = kdbg.get_type_name("nt", type_id)<commit_msg>Not released already fixed, add 32bits only test verification<commit_after>﻿"""A simple demonstration of the type exploration in LDK"""
import sys
import os
if os.getcwd().endswith("example"):
    sys.path.append(os.path.realpath(".."))
else:
    sys.path.append(os.path.realpath("."))

from dbginterface import LocalKernelDebugger
import windows

# 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()

type_id = kdbg.get_type_id("nt", "_KPCR")
print('type_id for "nt!_KPCR" is {0}'.format(hex(type_id)))

name = kdbg.get_type_name("nt", type_id)
{'fraction_non_alphanumeric': 0.11098062243100411, 'fraction_numerical': 0.005871990604815032, 'mean_word_length': 4.937282229965157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2316734', 'n_tokens_mistral': 543, 'n_tokens_neox': 530, 'n_words': 196}