⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntoskernel.h

📁 改文件可以安装无线网卡在linux下的驱动,大家可以在网站上查找一下用法
💻 H
📖 第 1 页 / 共 2 页
字号:
struct pe_image {	char name[MAX_DRIVER_NAME_LEN];	void *entry;	void *image;	int size;	int type;	IMAGE_NT_HEADERS *nt_hdr;	IMAGE_OPTIONAL_HEADER *opt_hdr;};extern KSPIN_LOCK atomic_lock;extern KSPIN_LOCK cancel_lock;#define DEBUG_IRQL 1#define WRAPPER_TIMER_MAGIC 47697249struct wrapper_timer {	struct list_head list;	struct timer_list timer;#ifdef DEBUG_TIMER	unsigned long wrapper_timer_magic;#endif	long repeat;	int active;	struct ktimer *ktimer;	struct kdpc *kdpc;	KSPIN_LOCK lock;};typedef struct mdl ndis_buffer;int ntoskernel_init(void);void ntoskernel_exit(void);STDCALL void *ExAllocatePoolWithTag(enum pool_type pool_type, SIZE_T size,				    ULONG tag);STDCALL void ExFreePool(void *p);STDCALL ULONG MmSizeOfMdl(void *base, ULONG length);STDCALL void KeInitializeEvent(struct kevent *kevent,			       enum event_type type, BOOLEAN state);STDCALL LONG KeSetEvent(struct kevent *kevent, KPRIORITY incr, BOOLEAN wait);STDCALL LONG KeResetEvent(struct kevent *kevent);STDCALL NTSTATUS KeWaitForSingleObject(void *object, KWAIT_REASON reason,					KPROCESSOR_MODE waitmode,					BOOLEAN alertable,					LARGE_INTEGER *timeout);struct mdl *allocate_init_mdl(void *virt, ULONG length);void free_mdl(struct mdl *mdl);STDCALL struct mdl *IoAllocateMdl(void *virt, ULONG length, BOOLEAN second_buf,				  BOOLEAN charge_quota, struct irp *irp);STDCALL void IoFreeMdl(struct mdl *mdl);STDCALL void NdisFreeBuffer(ndis_buffer *buffer);ULONGLONG ticks_1601(void);STDCALL KIRQL KeGetCurrentIrql(void);STDCALL void KeInitializeSpinLock(KSPIN_LOCK *lock);STDCALL void KeAcquireSpinLock(KSPIN_LOCK *lock, KIRQL *irql);STDCALL void KeReleaseSpinLock(KSPIN_LOCK *lock, KIRQL oldirql);STDCALL KIRQL KeAcquireSpinLockRaiseToDpc(KSPIN_LOCK *lock);_FASTCALL KIRQL KfRaiseIrql(FASTCALL_DECL_1(KIRQL newirql));_FASTCALL void KfLowerIrql(FASTCALL_DECL_1(KIRQL oldirql));_FASTCALL KIRQL KfAcquireSpinLock(FASTCALL_DECL_1(KSPIN_LOCK *lock));_FASTCALL voidKfReleaseSpinLock(FASTCALL_DECL_2(KSPIN_LOCK *lock, KIRQL oldirql));_FASTCALL voidIofCompleteRequest(FASTCALL_DECL_2(struct irp *irp, CHAR prio_boost));_FASTCALL voidKefReleaseSpinLockFromDpcLevel(FASTCALL_DECL_1(KSPIN_LOCK *lock));STDCALL NTSTATUS RtlUnicodeStringToAnsiString(struct ansi_string *dst,					       struct unicode_string *src,					       BOOLEAN dup);STDCALL NTSTATUS RtlAnsiStringToUnicodeString(struct unicode_string *dst,					       struct ansi_string *src,					       BOOLEAN dup);STDCALL void RtlInitAnsiString(struct ansi_string *dst, CHAR *src);STDCALL void RtlInitString(struct ansi_string *dst, CHAR *src);STDCALL void RtlFreeUnicodeString(struct unicode_string *string);STDCALL void RtlFreeAnsiString(struct ansi_string *string);unsigned long lin_to_win1(void *func, unsigned long);unsigned long lin_to_win2(void *func, unsigned long, unsigned long);unsigned long lin_to_win3(void *func, unsigned long, unsigned long,			  unsigned long);unsigned long lin_to_win4(void *func, unsigned long, unsigned long,			  unsigned long, unsigned long);unsigned long lin_to_win5(void *func, unsigned long, unsigned long,			  unsigned long, unsigned long, unsigned long);unsigned long lin_to_win6(void *func, unsigned long, unsigned long,			  unsigned long, unsigned long, unsigned long,			  unsigned long);#define MSG(level, fmt, ...)				\	printk(level "ndiswrapper (%s:%d): " fmt "\n",	\	       __FUNCTION__, __LINE__ , ## __VA_ARGS__)#define WARNING(fmt, ...) MSG(KERN_WARNING, fmt, ## __VA_ARGS__)#define ERROR(fmt, ...) MSG(KERN_ERR, fmt , ## __VA_ARGS__)#define INFO(fmt, ...) MSG(KERN_INFO, fmt , ## __VA_ARGS__)static inline KIRQL current_irql(void){	if (in_atomic() || irqs_disabled())		return DISPATCH_LEVEL;	else		return PASSIVE_LEVEL;}static inline KIRQL raise_irql(KIRQL newirql){	KIRQL irql = current_irql();	if (irql < DISPATCH_LEVEL && newirql == DISPATCH_LEVEL) {		local_bh_disable();		preempt_disable();	}	return irql;}static inline void lower_irql(KIRQL oldirql){	KIRQL irql = current_irql();	if (oldirql < DISPATCH_LEVEL && irql == DISPATCH_LEVEL) {		preempt_enable();		local_bh_enable();	}}/* Windows spinlocks are of type ULONG_PTR which is not big enough to * store Linux spinlocks; so we implement Windows spinlocks using * ULONG_PTR space with our own functions/macros *//* the reason for value of unlocked spinlock to be 0, instead of 1 * (which is what linux spinlocks use), is that some drivers don't * first call to initialize spinlock; in those case, the value of the * lock seems to be 0 (presumably in Windows value of unlocked * spinlock is 0). */#define KSPIN_LOCK_UNLOCKED 0#define KSPIN_LOCK_LOCKED 1#define kspin_lock_init(lock) *(lock) = KSPIN_LOCK_UNLOCKED#ifdef CONFIG_SMP#ifdef __HAVE_ARCH_CMPXCHG#define kspin_lock(lock)						\	while (cmpxchg(lock, KSPIN_LOCK_UNLOCKED, KSPIN_LOCK_LOCKED) != \	       KSPIN_LOCK_UNLOCKED)#elseextern spinlock_t spinlock_kspin_lock;#define kspin_lock(lock)				\do {							\	while (1) {					\		spin_lock(&spinlock_kspin_lock);	\		if (*(lock) == KSPIN_LOCK_UNLOCKED)	\			break;				\		spin_unlock(&spinlock_kspin_lock);	\	}						\	*(lock) = KSPIN_LOCK_LOCKED;			\	spin_unlock(&spinlock_kspin_lock);		\} while (0)		#endif // __HAVE_ARCH_CMPXCHG#define kspin_unlock(lock) xchg(lock, KSPIN_LOCK_UNLOCKED)#else#define kspin_lock(lock) *(lock) = KSPIN_LOCK_LOCKED#define kspin_unlock(lock) *(lock) = KSPIN_LOCK_UNLOCKED#endif // CONFIG_SMP/* raise IRQL to given (higher) IRQL if necessary after locking */#define kspin_lock_irql(lock, newirql)					\({									\	KIRQL _cur_irql_ = current_irql();				\	KSPIN_LOCK _val_ = *(lock);					\	if (_val_ > KSPIN_LOCK_LOCKED)					\		ERROR("illegal spinlock: %p(%lu)", lock, _val_);	\	if (_cur_irql_ < DISPATCH_LEVEL && newirql == DISPATCH_LEVEL) {	\		local_bh_disable();					\		preempt_disable();					\	}								\	kspin_lock(lock);						\	_cur_irql_;							\})/* lower IRQL to given (lower) IRQL if necessary after unlocking */#define kspin_unlock_irql(lock, oldirql)				\do {									\	KIRQL _cur_irql_ = current_irql();				\	KSPIN_LOCK _val_ = *(lock);					\	if (_val_ > KSPIN_LOCK_LOCKED)					\		ERROR("illegal spinlock: %p(%lu)", lock, _val_);	\	kspin_unlock(lock);						\	if (oldirql < DISPATCH_LEVEL && _cur_irql_ == DISPATCH_LEVEL) {	\		preempt_enable();					\		local_bh_enable();					\	}								\} while (0)#define kspin_lock_irqsave(lock, flags)					\do {									\	KSPIN_LOCK _val_ = *(lock);					\	if (_val_ > KSPIN_LOCK_LOCKED)					\		ERROR("illegal spinlock: %p(%lu)", lock, _val_);	\	local_irq_save(flags);						\	preempt_disable();						\	kspin_lock(lock);						\} while (0)#define kspin_unlock_irqrestore(lock, flags)				\do {									\	KSPIN_LOCK _val_ = *(lock);					\	if (_val_ > KSPIN_LOCK_LOCKED)					\		ERROR("illegal spinlock: %p(%lu)", lock, _val_);	\	kspin_unlock(lock);						\	local_irq_restore(flags);					\	preempt_enable();						\} while (0)static inline void wrapper_set_timer_dpc(struct wrapper_timer *wrapper_timer,                                         struct kdpc *kdpc){	wrapper_timer->kdpc = kdpc;}static inline void init_dpc(struct kdpc *kdpc, void *func, void *ctx){	kdpc->func = func;	kdpc->ctx  = ctx;}static inline ULONG SPAN_PAGES(ULONG_PTR ptr, SIZE_T length){	ULONG n;	n = (((ULONG_PTR)ptr & (PAGE_SIZE - 1)) +	     length + (PAGE_SIZE - 1)) >> PAGE_SHIFT;	return n;}/* DEBUG macros */#define DBGTRACE(fmt, ...) do { } while (0)#define DBGTRACE1(fmt, ...) do { } while (0)#define DBGTRACE2(fmt, ...) do { } while (0)#define DBGTRACE3(fmt, ...) do { }  while (0)#define DBGTRACE4(fmt, ...) do { } while (0)#define DBGTRACE5(fmt, ...) do { } while (0)/* for a block of code */#define DBG_BLOCK() while (0)extern int debug;#if defined DEBUG#undef DBGTRACE#define DBGTRACE(level, fmt, ...) do {					\		if (level <= debug)					\			printk(KERN_INFO "%s (%s:%d): " fmt "\n",	\			       DRIVER_NAME, __FUNCTION__,		\			       __LINE__ , ## __VA_ARGS__);		\	} while (0)#undef DBG_BLOCK#define DBG_BLOCK()#endif#if defined DEBUG && DEBUG >= 1#undef DBGTRACE1#define DBGTRACE1(fmt, ...) DBGTRACE(1, fmt , ## __VA_ARGS__)#endif#if defined DEBUG && DEBUG >= 2#undef DBGTRACE2#define DBGTRACE2(fmt, ...) DBGTRACE(2, fmt , ## __VA_ARGS__)#endif#if defined DEBUG && DEBUG >= 3#undef DBGTRACE3#define DBGTRACE3(fmt, ...) DBGTRACE(3, fmt , ## __VA_ARGS__)#endif#if defined DEBUG && DEBUG >= 4#undef DBGTRACE4#define DBGTRACE4(fmt, ...) DBGTRACE(4, fmt , ## __VA_ARGS__)#endif#if defined DEBUG && DEBUG >= 5#undef DBGTRACE5#define DBGTRACE5(fmt, ...) DBGTRACE(5, fmt , ## __VA_ARGS__)#endif#define TRACEENTER(fmt, ...) DBGTRACE("Enter " fmt , ## __VA_ARGS__)#define TRACEENTER1(fmt, ...) DBGTRACE1("Enter " fmt , ## __VA_ARGS__)#define TRACEENTER2(fmt, ...) DBGTRACE2("Enter " fmt , ## __VA_ARGS__)#define TRACEENTER3(fmt, ...) DBGTRACE3("Enter " fmt , ## __VA_ARGS__)#define TRACEENTER4(fmt, ...) DBGTRACE4("Enter " fmt , ## __VA_ARGS__)#define TRACEENTER5(fmt, ...) DBGTRACE5("Enter " fmt , ## __VA_ARGS__)#define TRACEEXIT(stmt) do { DBGTRACE("Exit"); stmt; } while(0)#define TRACEEXIT1(stmt) do { DBGTRACE1("Exit"); stmt; } while(0)#define TRACEEXIT2(stmt) do { DBGTRACE2("Exit"); stmt; } while(0)#define TRACEEXIT3(stmt) do { DBGTRACE3("Exit"); stmt; } while(0)#define TRACEEXIT4(stmt) do { DBGTRACE4("Exit"); stmt; } while(0)#define TRACEEXIT5(stmt) do { DBGTRACE5("Exit"); stmt; } while(0)#ifdef USB_DEBUG#define USBTRACE(fmt, ...) DBGTRACE1(fmt, ## __VA_ARGS__)#define USBTRACEENTER(fmt, ...) TRACEENTER1(fmt, ## __VA_ARGS__)#define USBTRACEEXIT(stmt) TRACEEXIT1(stmt)#else#define USBTRACE(fmt, ...)#define USBTRACEENTER(fmt, ...)#define USBTRACEEXIT(stmt) stmt#endif#if defined DEBUG#define ASSERT(expr) do {						\		if (!(expr)) {						\			ERROR("Assertion failed! %s", (#expr));		\		}							\	} while (0)#else#define ASSERT(expr)#endif#endif // _NTOSKERNEL_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -