📄 myopensource.h
字号:
#ifndef _EYRONUTILSOPENSOURCE_H
#define _EYRONUTILSOPENSOURCE_H
// From OpenSource
#define ERRFALSE(exp) extern char __ERRXX[(exp)!=0]
#define KINFO_OFFSET 0x300
#if defined(ARM)
#define PUserKData ((LPBYTE)0xFFFFC800)
#else
#define PUserKData ((LPBYTE)0x00005800)
#endif
#define UserKInfo ((long *)(PUserKData+KINFO_OFFSET))
#define KINX_PROCARRAY 0 /* address of process array */
#define KINX_PAGESIZE 1 /* system page size */
#define KINX_PFN_SHIFT 2 /* shift for page # in PTE */
#define KINX_PFN_MASK 3 /* mask for page # in PTE */
#define KINX_PAGEFREE 4 /* # of free physical pages */
#define KINX_SYSPAGES 5 /* # of pages used by kernel */
#define KINX_KHEAP 6 /* ptr to kernel heap array */
#define KINX_SECTIONS 7 /* ptr to SectionTable array */
#define KINX_MEMINFO 8 /* ptr to system MemoryInfo struct */
#define KINX_MODULES 9 /* ptr to module list */
#define KINX_DLL_LOW 10 /* lower bound of DLL shared space */
#define KINX_NUMPAGES 11 /* total # of RAM pages */
#define KINX_PTOC 12 /* ptr to ROM table of contents */
#define KINX_KDATA_ADDR 13 /* kernel mode version of KData */
#define KINX_GWESHEAPINFO 14 /* Current amount of gwes heap in use */
#define KINX_TIMEZONEBIAS 15 /* Fast timezone bias info */
#define KINX_PENDEVENTS 16 /* bit mask for pending interrupt events */
#define KINX_KERNRESERVE 17 /* number of kernel reserved pages */
#define KINX_API_MASK 18 /* bit mask for registered api sets */
#define KINX_NLS_OCP 19 /* Current OEM code page */
#define KINX_NLS_ACP 20 /* Current ANSI code page */
#define KINX_NLS_LOC 21 /* Current NLS locale */
#define KINX_HEAP_WASTE 22 /* Kernel heap wasted space */
#define KINX_DEBUGGER 23 /* For use by debugger for protocol communication */
#define KINX_APISETS 24 /* APIset pointers */
//#include <NTCOMPAT.H>
// Mem_ARM.h:
//
// The user mode virtual address space is 2GB split into 64 sections
// of 512 blocks of 16 4K pages. For some platforms, the # of blocks in
// a section may be limited to fewer than 512 blocks to reduce the size
// of the intermeditate tables. E.G.: Since the PeRP only has 5MB of total
// RAM, the sections are limited to 4MB. This results in 64 block sections.
//
// Virtual address format:
// 3322222 222221111 1111 110000000000
// 1098765 432109876 5432 109876543210
// zSSSSSS BBBBBBBBB PPPP oooooooooooo
#define BLOCK_MASK 0x1FF
#define SECTION_MASK 0x03F
#define RESERVED_SECTIONS 1 // reserve section 0 for current process
// Bit offsets of page, block & section in a virtual address:
#define VA_BLOCK 16
#define VA_SECTION 25
// For SA1100 Only!!!
#define VA_PAGE 12
#define L2_MASK 0xFF // For a 4K page size (small pages)
#define PAGE_SIZE 4096
#define PAGE_MASK 0x00F
#define PAGES_PER_BLOCK (0x10000 / PAGE_SIZE)
/* Page permission bits */
#define PG_PERMISSION_MASK 0x00000FFF
#define PG_PHYS_ADDR_MASK 0xFFFFF000
#define PG_VALID_MASK 0x00000002
#define PG_1K_MASK 0x00000001
#define PG_CACHE_MASK 0x0000000C
#define PG_GUARD 0x0000000C
#define PG_CACHE 0x0000000C
#define PG_MINICACHE 0x00000008
#define PG_NOCACHE 0x00000000
#define PG_DIRTY_MASK 0x00000010
#define PG_EXECUTE_MASK 0x00000000 /* not supported by HW */
#define PG_PROTECTION 0x00000FF0
#define PG_PROT_READ 0x00000000
#define PG_PROT_WRITE 0x00000FF0
#define PG_PROT_URO_KRW 0x00000AA0
#define PG_SIZE_MASK 0x00000000
// For SA1100 Only!!!
#define PG_READ_WRITE (PG_VALID_MASK | PG_DIRTY_MASK | PG_CACHE | PG_PROT_WRITE)
#define INVALID_POINTER_VALUE 0xD0000000
#define UNKNOWN_BASE (~0)
#define BAD_PAGE (~0x0fUL)
#ifndef VERIFY_READ_FLAG
#define VERIFY_READ_FLAG 0
#define VERIFY_EXECUTE_FLAG 0
#define VERIFY_WRITE_FLAG 1
#define VERIFY_KERNEL_OK 2
#endif
/* Test the write access on a page table entry */
#define IsPageWritable(entry) (((entry)&(PG_PROTECTION|PG_DIRTY_MASK)) \
== (PG_PROT_WRITE|PG_DIRTY_MASK))
#define IsPageReadable(entry) (((entry)&PG_VALID_MASK) == PG_VALID_MASK)
#define SETAKY(pth,val) (CurAKey = (pth)->aky = (val))
#define PFN_INCR PAGE_SIZE
/* Find the page frame # from a GPINFO pointer */
#define GetPFN(pgpi) ((FirstPT[(ulong)(pgpi)>>20]&0xFFF00000) \
| ((ulong)(pgpi)&0x000FF000))
#define NextPFN(pfn) ((pfn) + PFN_INCR)
#define PFNfromEntry(entry) ((entry) & 0xFFFFF000)
#define PFNfrom256(pg256) ((ulong)(pg256)<<8 & ~(PAGE_SIZE-1))
PVOID Phys2Virt(DWORD pfn);
// End Mem_ARM.h
typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; // windbgkd
typedef struct FreeInfo {
PHYSICAL_ADDRESS paStart; /* start of available region */
PHYSICAL_ADDRESS paEnd; /* end of region (last byte + 1) */
PBYTE pUseMap; /* ptr to page usage count map */
} FREEINFO; /* FreeInfo */
typedef FREEINFO *PFREEINFO;
typedef struct MemoryInfo {
PVOID pKData; /* start of kernel's data */
PVOID pKEnd; /* end of kernel's data & bss */
uint cFi; /* # of entries in free memory array */
FREEINFO *pFi; /* Pointer to cFi FREEINFO entries */
} MEMORYINFO; /* MemoryInfo */
#define PRIORITY_LEVELS_HASHSIZE 32
#define MAX_PROCESSES 32
#define IsHandle(v) (((int)(v) & 0x02) != 0)
#define LITE_EXTRA 6 /* Only first 6 used by NK */
#define EXP 0 /* Export table position */
#define IMP 1 /* Import table position */
#define RES 2 /* Resource table position */
#define EXC 3 /* Exception table position */
#define SEC 4 /* Security table position */
#define FIX 5 /* Fixup table position */
#define DEB 6 /* Debug table position */
#define IMD 7 /* Image description table position */
#define MSP 8 /* Machine specific table position */
#define TLS 9 /* Thread Local Storage */
#define CBK 10 /* Callbacks */
#define RS1 11 /* Reserved */
#define RS2 12 /* Reserved */
#define RS3 13 /* Reserved */
#define RS4 14 /* Reserved */
#define RS5 15 /* Reserved */
#define SYSINTR_MAX_DEVICES 32
#define HANDLE_ADDRESS_MASK 0x1ffffffc
#define IsValidKPtr(p) ((char *)(p) >= (char *)MemoryInfo.pKData \
&& (char *)(p) < (char *)MemoryInfo.pKEnd)
#define IsValidModule(p) (IsValidKPtr(p) && ((p)->lpSelf == (p)))
#define h2p(h, phdRet) \
do { \
if ((ulong)h < NUM_SYS_HANDLES+SYS_HANDLE_BASE && (ulong)h >= SYS_HANDLE_BASE) \
h = KData.ahSys[(uint)h-SYS_HANDLE_BASE]; \
if (h) { \
phdRet = (PHDATA)(((ulong)h & HANDLE_ADDRESS_MASK) + KData.handleBase); \
if (!IsValidKPtr(phdRet) || phdRet->hValue != h) \
phdRet = 0; \
} else \
phdRet = 0; \
} while (0)
typedef struct Thread THREAD;
typedef THREAD *PTHREAD;
typedef struct Process PROCESS;
typedef PROCESS *PPROCESS;
typedef struct PROXY *LPPROXY;
typedef void (*RETADDR)();
typedef struct CRIT *LPCRIT;
typedef struct Module MODULE;
typedef MODULE *PMODULE, *LPMODULE;
typedef struct MemBlock MEMBLOCK;
typedef MEMBLOCK *SECTION[BLOCK_MASK+1];
typedef SECTION *PSECTION;
typedef struct EVENT *LPEVENT;
typedef ulong ACCESSKEY;
typedef ulong ACCESSLOCK;
/**
* Data structures and functions for handle manipulations
*/
typedef struct cinfo {
char acName[4]; /* 00: object type ID string */
uchar disp; /* 04: type of dispatch */
uchar type; /* 05: api handle type */
ushort cMethods; /* 06: # of methods in dispatch table */
const PFNVOID *ppfnMethods;/* 08: ptr to array of methods (in server address space) */
const DWORD *pdwSig; /* 0C: ptr to array of method signatures */
PPROCESS pServer; /* 10: ptr to server process */
} CINFO; /* cinfo */
typedef CINFO *PCINFO;
// DList - double linked list
//
// WARNING: The double list routine are NOT preemtion safe. The list must
// be protected with a critical section or the functions should be invoked
// via KCall().
typedef struct _DList DList;
struct _DList {
DList *fwd;
DList *back;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -