#!/usr/bin/env python3
"""Static import API categories for analysis."""

from __future__ import annotations

from ..domain.formats.import_analysis import NETWORK_CATEGORY

API_CATEGORIES: dict[str, list[str]] = {
    "Process/Thread Management": [
        "CreateProcess",
        "CreateProcessA",
        "CreateProcessW",
        "CreateThread",
        "CreateRemoteThread",
        "OpenProcess",
        "TerminateProcess",
        "ExitProcess",
        "GetCurrentProcess",
        "SetThreadContext",
        "GetThreadContext",
        "SuspendThread",
        "ResumeThread",
        "WaitForSingleObject",
    ],
    "Memory Management": [
        "VirtualAlloc",
        "VirtualAllocEx",
        "VirtualProtect",
        "VirtualProtectEx",
        "HeapAlloc",
        "HeapCreate",
        "MapViewOfFile",
        "UnmapViewOfFile",
        "VirtualFree",
        "VirtualFreeEx",
        "WriteProcessMemory",
        "ReadProcessMemory",
    ],
    "File System": [
        "CreateFile",
        "CreateFileA",
        "CreateFileW",
        "DeleteFile",
        "MoveFile",
        "CopyFile",
        "FindFirstFile",
        "FindNextFile",
        "GetFileAttributes",
        "SetFileAttributes",
        "WriteFile",
        "ReadFile",
        "CreateDirectory",
        "RemoveDirectory",
    ],
    "Registry": [
        "RegOpenKey",
        "RegOpenKeyEx",
        "RegCreateKey",
        "RegCreateKeyEx",
        "RegSetValue",
        "RegSetValueEx",
        "RegQueryValue",
        "RegQueryValueEx",
        "RegDeleteKey",
        "RegDeleteValue",
        "RegEnumKey",
        "RegEnumValue",
        "RegCloseKey",
    ],
    NETWORK_CATEGORY: [
        "WSAStartup",
        "WSACleanup",
        "socket",
        "connect",
        "bind",
        "listen",
        "accept",
        "send",
        "recv",
        "closesocket",
        "InternetOpen",
        "InternetConnect",
        "HttpOpenRequest",
        "HttpSendRequest",
        "InternetReadFile",
        "URLDownloadToFile",
        "WinHttpOpen",
        "WinHttpConnect",
    ],
    "Cryptography": [
        "CryptAcquireContext",
        "CryptCreateHash",
        "CryptHashData",
        "CryptDeriveKey",
        "CryptEncrypt",
        "CryptDecrypt",
        "CryptGenKey",
        "CryptReleaseContext",
        "CryptDestroyHash",
        "BCryptOpenAlgorithmProvider",
        "BCryptCreateHash",
    ],
    "Service Management": [
        "OpenSCManager",
        "CreateService",
        "OpenService",
        "StartService",
        "ControlService",
        "DeleteService",
        "CloseServiceHandle",
        "QueryServiceStatus",
    ],
    "Dynamic Loading": [
        "LoadLibrary",
        "LoadLibraryA",
        "LoadLibraryW",
        "LoadLibraryEx",
        "GetProcAddress",
        "FreeLibrary",
        "GetModuleHandle",
        "GetModuleFileName",
    ],
    "Anti-Analysis": [
        "IsDebuggerPresent",
        "CheckRemoteDebuggerPresent",
        "OutputDebugString",
        "GetTickCount",
        "QueryPerformanceCounter",
        "NtQueryInformationProcess",
        "ZwQueryInformationProcess",
    ],
    "Persistence": [
        "RegSetValueEx",
        "CreateService",
        "SetWindowsHookEx",
        "SetFileAttributes",
        "CopyFile",
        "MoveFile",
    ],
}


def get_api_categories() -> dict[str, list[str]]:
    """Return a fresh copy of API categories."""
    return {key: list(values) for key, values in API_CATEGORIES.items()}
