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

📄 rtl.c

📁 ndiswrapper工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  Copyright (C) 2003-2005 Pontus Fuchs, Giridhar Pemmasani * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *  GNU General Public License for more details. * */#include "ntoskernel.h"int rtl_init(void){	return 0;}/* called when module is being removed */void rtl_exit(void){	TRACEEXIT4(return);}wstdcall SIZE_T WIN_FUNC(RtlCompareMemory,3)	(const void *a, const void *b, SIZE_T len){	size_t i;	char *x, *y;	TRACEENTER1("");	x = (char *)a;	y = (char *)b;	/* MSDN says this should return number of bytes that compare as	 * equal. This can be interpretted as either all bytes that are	 * equal in 'len' bytes or that only until the bytes compare as	 * not equal. Initially we had it the former way, but Realtek driver	 * doesn't like it that way - it takes many attempts to associate	 * with WPA. ReactOS returns the number of bytes that are equal	 * upto when they compare as not equal.	 * According to lords at #reactos, that is the way it should be	 * and that msdn is wrong about it!	 */	for (i = 0; i < len && x[i] == y[i]; i++)		;	return i;}wstdcall void WIN_FUNC(RtlCopyMemory,3)	(void *dst, const void *src, SIZE_T length){	memcpy(dst, src, length);}wstdcall void WIN_FUNC(RtlZeroMemory,2)	(void *dst, SIZE_T length){	memset(dst, 0, length);}wstdcall void WIN_FUNC(RtlSecureZeroMemory,2)	(void *dst, SIZE_T length){	memset(dst, 0, length);}wstdcall void WIN_FUNC(RtlFillMemory,3)	(void *dest, SIZE_T length, UCHAR fill){	memset(dest, fill, length);}wstdcall void WIN_FUNC(RtlMoveMemory,3)	(void *dest, const void *src, SIZE_T length){	memmove(dest, src, length);}wstdcall LONG WIN_FUNC(RtlCompareString,3)	(const struct ansi_string *s1, const struct ansi_string *s2,	 BOOLEAN case_insensitive){	unsigned int len;	LONG ret = 0;	const char *p1, *p2;	TRACEENTER2("");	len = min(s1->length, s2->length);	p1 = s1->buf;	p2 = s2->buf;	if (case_insensitive)		while (!ret && len--)			ret = toupper(*p1++) - toupper(*p2++);	else		while (!ret && len--)			ret = *p1++ - *p2++;	if (!ret)		ret = s1->length - s2->length;	TRACEEXIT2(return ret);}wstdcall LONG WIN_FUNC(RtlCompareUnicodeString,3)	(const struct unicode_string *s1, const struct unicode_string *s2,	 BOOLEAN case_insensitive){	unsigned int len;	LONG ret = 0;	const wchar_t *p1, *p2;	TRACEENTER2("");	len = min(s1->length, s2->length) / sizeof(wchar_t);	p1 = s1->buf;	p2 = s2->buf;	if (case_insensitive)		while (!ret && len--)			ret = toupper((u8)*p1++) - toupper((u8)*p2++);	else		while (!ret && len--)			ret = (u8)*p1++ - (u8)*p2++;	if (!ret)		ret = s1->length - s2->length;	DBGTRACE2("len: %d, ret: %d", len, ret);	TRACEEXIT2(return ret);}wstdcall BOOLEAN WIN_FUNC(RtlEqualString,3)	(const struct ansi_string *s1, const struct ansi_string *s2,	 BOOLEAN case_insensitive){	TRACEENTER1("");	if (s1->length != s2->length)		return FALSE;	return !RtlCompareString(s1, s2, case_insensitive);}wstdcall BOOLEAN WIN_FUNC(RtlEqualUnicodeString,3)	(const struct unicode_string *s1, const struct unicode_string *s2,	 BOOLEAN case_insensitive){	if (s1->length != s2->length)		return FALSE;	return !RtlCompareUnicodeString(s1, s2, case_insensitive);}wstdcall void WIN_FUNC(RtlCopyUnicodeString,2)	(struct unicode_string *dst, struct unicode_string *src){	TRACEENTER1("%p, %p", dst, src);	if (src && src->buf && dst->buf) {		dst->length = min(src->length, dst->max_length);		memcpy(dst->buf, src->buf, dst->length);		if (dst->length < dst->max_length)			dst->buf[dst->length / sizeof(dst->buf[0])] = 0;	} else		dst->length = 0;	TRACEEXIT1(return);}wstdcall void WIN_FUNC(RtlCopyString,2)	(struct ansi_string *dst, struct ansi_string *src){	TRACEENTER1("%p, %p", dst, src);	if (src && src->buf && dst->buf) {		dst->length = min(src->length, dst->max_length);		memcpy(dst->buf, src->buf, dst->length);		if (dst->length < dst->max_length)			dst->buf[dst->length] = 0;	} else		dst->length = 0;	TRACEEXIT1(return);}wstdcall NTSTATUS WIN_FUNC(RtlAppendUnicodeToString,2)	(struct unicode_string *dst, wchar_t *src){	if (src) {		int len;		for (len = 0; src[len]; len++)			;		if (dst->length + (len * sizeof(dst->buf[0])) > dst->max_length)			return STATUS_BUFFER_TOO_SMALL;		memcpy(&dst->buf[dst->length], src, len * sizeof(dst->buf[0]));		dst->length += len * sizeof(dst->buf[0]);		if (dst->max_length > dst->length)			dst->buf[dst->length / sizeof(dst->buf[0])] = 0;	}	return STATUS_SUCCESS;}wstdcall NTSTATUS WIN_FUNC(RtlAppendUnicodeStringToString,2)	(struct unicode_string *dst, struct unicode_string *src){	if (dst->max_length < src->length + dst->length)		return STATUS_BUFFER_TOO_SMALL;	if (src->length) {		memcpy(&dst->buf[dst->length], src->buf, src->length);		dst->length += src->length;		if (dst->max_length > dst->length)			dst->buf[dst->length / sizeof(dst->buf[0])] = 0;	}	TRACEEXIT2(return STATUS_SUCCESS);}wstdcall ULONG WIN_FUNC(RtlxAnsiStringToUnicodeSize,1)	(const struct ansi_string *string){	int i;	for (i = 0; i < string->max_length && string->buf[i]; i++)		;	return (i * sizeof(wchar_t));}wstdcall ULONG WIN_FUNC(RtlxUnicodeStringToAnsiSize,1)	(const struct unicode_string *string){	int i;	for (i = 0; i < string->max_length && string->buf[i]; i++)		;	return i;}wstdcall NTSTATUS WIN_FUNC(RtlAnsiStringToUnicodeString,3)	(struct unicode_string *dst, const struct ansi_string *src,	 BOOLEAN alloc){	int i, n;	n = RtlxAnsiStringToUnicodeSize(src);	DBGTRACE2("%d, %d, %d, %d, %p", n, dst->max_length, src->length,		  src->max_length, src->buf);	if (alloc == TRUE) {#if 0		if (n == 0) {			dst->length = dst->max_length = 0;			dst->buf = NULL;			TRACEEXIT2(return STATUS_SUCCESS);		}#endif		dst->max_length = n + sizeof(dst->buf[0]);		dst->buf = ExAllocatePoolWithTag(NonPagedPool,						 dst->max_length, 0);		if (!dst->buf) {			dst->max_length = dst->length = 0;			TRACEEXIT2(return STATUS_NO_MEMORY);		}	} else if (dst->max_length < n)		TRACEEXIT2(return STATUS_BUFFER_TOO_SMALL);	dst->length = n;	n /= sizeof(dst->buf[0]);	for (i = 0; i < n; i++)		dst->buf[i] = src->buf[i];	if (i * sizeof(dst->buf[0]) < dst->max_length)		dst->buf[i] = 0;	DBGTRACE2("dst: length: %d, max_length: %d, string: %p",		  dst->length, dst->max_length, src->buf);	TRACEEXIT2(return STATUS_SUCCESS);}wstdcall NTSTATUS WIN_FUNC(RtlUnicodeStringToAnsiString,3)	(struct ansi_string *dst, const struct unicode_string *src,	 BOOLEAN alloc){	int i, n;	n = RtlxUnicodeStringToAnsiSize(src);	DBGTRACE2("%d, %d, %d, %d, %p", n, dst->max_length, src->length,		  src->max_length, src->buf);	if (alloc == TRUE) {#if 0		if (n == 0) {			dst->length = dst->max_length = 0;			dst->buf = NULL;			TRACEEXIT2(return STATUS_SUCCESS);		}#endif		dst->max_length = n + sizeof(dst->buf[0]);		dst->buf = ExAllocatePoolWithTag(NonPagedPool,						 dst->max_length, 0);		if (!dst->buf) {			dst->max_length = dst->length = 0;			TRACEEXIT1(return STATUS_NO_MEMORY);		}	} else if (dst->max_length < n)		TRACEEXIT2(return STATUS_BUFFER_TOO_SMALL);	dst->length = n;	for (i = 0; i < n; i++)		dst->buf[i] = src->buf[i];	if (i < dst->max_length)		dst->buf[i] = 0;	DBGTRACE2("string: %p, len: %d(%d)", dst->buf, dst->length,		  dst->max_length);	TRACEEXIT2(return STATUS_SUCCESS);}wstdcall NTSTATUS WIN_FUNC(RtlUnicodeStringToInteger,3)	(struct unicode_string *ustring, ULONG base, ULONG *value){	int i, negsign;	wchar_t *str;	*value = 0;	if (ustring->length == 0)		return STATUS_SUCCESS;	str = ustring->buf;	negsign = 0;	i = 0;	switch ((char)str[i]) {	case '-':		negsign = 1;		/* fall through */	case '+':		i++;		break;	}	if (base == 0 && i < ustring->length && str[i]) {		switch(tolower((char)str[i])) {		case 'x':			base = 16;			i++;

⌨️ 快捷键说明

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