mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
Add a few functions used in newer drivers. Fix RtlCompareMemory() while
here. Submitted by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
6c7e719d84
commit
191385fb0e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=215779
@ -1282,6 +1282,7 @@ typedef struct driver_object driver_object;
|
||||
#define STATUS_PENDING 0x00000103
|
||||
#define STATUS_FAILURE 0xC0000001
|
||||
#define STATUS_NOT_IMPLEMENTED 0xC0000002
|
||||
#define STATUS_ACCESS_VIOLATION 0xC0000005
|
||||
#define STATUS_INVALID_PARAMETER 0xC000000D
|
||||
#define STATUS_INVALID_DEVICE_REQUEST 0xC0000010
|
||||
#define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
|
||||
|
@ -254,6 +254,7 @@ static uint8_t
|
||||
void *, void *);
|
||||
static void NdisGetCurrentSystemTime(uint64_t *);
|
||||
static void NdisGetSystemUpTime(uint32_t *);
|
||||
static uint32_t NdisGetVersion(void);
|
||||
static void NdisInitializeString(unicode_string *, char *);
|
||||
static void NdisInitAnsiString(ansi_string *, char *);
|
||||
static void NdisInitUnicodeString(unicode_string *, uint16_t *);
|
||||
@ -274,6 +275,7 @@ static void NdisMapFile(ndis_status *, void **, ndis_handle);
|
||||
static void NdisUnmapFile(ndis_handle);
|
||||
static void NdisCloseFile(ndis_handle);
|
||||
static uint8_t NdisSystemProcessorCount(void);
|
||||
static void NdisGetCurrentProcessorCounts(uint32_t *, uint32_t *, uint32_t *);
|
||||
static void NdisMIndicateStatusComplete(ndis_handle);
|
||||
static void NdisMIndicateStatus(ndis_handle, ndis_status,
|
||||
void *, uint32_t);
|
||||
@ -2067,6 +2069,12 @@ NdisInterlockedDecrement(addend)
|
||||
return (*addend);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
NdisGetVersion(void)
|
||||
{
|
||||
return (0x00050001);
|
||||
}
|
||||
|
||||
static void
|
||||
NdisInitializeEvent(event)
|
||||
ndis_event *event;
|
||||
@ -2950,6 +2958,20 @@ NdisSystemProcessorCount()
|
||||
return (mp_ncpus);
|
||||
}
|
||||
|
||||
static void
|
||||
NdisGetCurrentProcessorCounts(idle_count, kernel_and_user, index)
|
||||
uint32_t *idle_count;
|
||||
uint32_t *kernel_and_user;
|
||||
uint32_t *index;
|
||||
{
|
||||
struct pcpu *pcpu;
|
||||
|
||||
pcpu = pcpu_find(curthread->td_oncpu);
|
||||
*index = pcpu->pc_cpuid;
|
||||
*idle_count = pcpu->pc_cp_time[CP_IDLE];
|
||||
*kernel_and_user = pcpu->pc_cp_time[CP_INTR];
|
||||
}
|
||||
|
||||
typedef void (*ndis_statusdone_handler)(ndis_handle);
|
||||
typedef void (*ndis_status_handler)(ndis_handle, ndis_status,
|
||||
void *, uint32_t);
|
||||
@ -3207,6 +3229,7 @@ image_patch_table ndis_functbl[] = {
|
||||
IMPORT_SFUNC(NdisMIndicateStatusComplete, 1),
|
||||
IMPORT_SFUNC(NdisMIndicateStatus, 4),
|
||||
IMPORT_SFUNC(NdisSystemProcessorCount, 0),
|
||||
IMPORT_SFUNC(NdisGetCurrentProcessorCounts, 3),
|
||||
IMPORT_SFUNC(NdisUnchainBufferAtBack, 2),
|
||||
IMPORT_SFUNC(NdisGetFirstBufferFromPacket, 5),
|
||||
IMPORT_SFUNC(NdisGetFirstBufferFromPacketSafe, 6),
|
||||
@ -3224,6 +3247,7 @@ image_patch_table ndis_functbl[] = {
|
||||
IMPORT_SFUNC(NdisFreeString, 1),
|
||||
IMPORT_SFUNC(NdisGetCurrentSystemTime, 1),
|
||||
IMPORT_SFUNC(NdisGetSystemUpTime, 1),
|
||||
IMPORT_SFUNC(NdisGetVersion, 0),
|
||||
IMPORT_SFUNC(NdisMSynchronizeWithInterrupt, 3),
|
||||
IMPORT_SFUNC(NdisMAllocateSharedMemoryAsync, 4),
|
||||
IMPORT_SFUNC(NdisInterlockedInsertHeadList, 3),
|
||||
|
@ -128,6 +128,7 @@ static kspin_lock ntoskrnl_intlock;
|
||||
|
||||
static uint8_t RtlEqualUnicodeString(unicode_string *,
|
||||
unicode_string *, uint8_t);
|
||||
static void RtlCopyString(ansi_string *, const ansi_string *);
|
||||
static void RtlCopyUnicodeString(unicode_string *,
|
||||
unicode_string *);
|
||||
static irp *IoBuildSynchronousFsdRequest(uint32_t, device_object *,
|
||||
@ -181,6 +182,7 @@ static uint64_t _aullshr(uint64_t, uint8_t);
|
||||
static uint64_t _aullshl(uint64_t, uint8_t);
|
||||
static slist_entry *ntoskrnl_pushsl(slist_header *, slist_entry *);
|
||||
static slist_entry *ntoskrnl_popsl(slist_header *);
|
||||
static void ExFreePoolWithTag(void *, uint32_t);
|
||||
static void ExInitializePagedLookasideList(paged_lookaside_list *,
|
||||
lookaside_alloc_func *, lookaside_free_func *,
|
||||
uint32_t, size_t, uint32_t, uint16_t);
|
||||
@ -210,6 +212,10 @@ static void *MmMapLockedPagesSpecifyCache(mdl *,
|
||||
static void MmUnmapLockedPages(void *, mdl *);
|
||||
static device_t ntoskrnl_finddev(device_t, uint64_t, struct resource **);
|
||||
static void RtlZeroMemory(void *, size_t);
|
||||
static void RtlSecureZeroMemory(void *, size_t);
|
||||
static void RtlFillMemory(void *, size_t, uint8_t);
|
||||
static void RtlMoveMemory(void *, const void *, size_t);
|
||||
static ndis_status RtlCharToInteger(const char *, uint32_t, uint32_t *);
|
||||
static void RtlCopyMemory(void *, const void *, size_t);
|
||||
static size_t RtlCompareMemory(const void *, const void *, size_t);
|
||||
static ndis_status RtlUnicodeStringToInteger(unicode_string *,
|
||||
@ -537,6 +543,20 @@ RtlEqualUnicodeString(unicode_string *str1, unicode_string *str2,
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
RtlCopyString(dst, src)
|
||||
ansi_string *dst;
|
||||
const ansi_string *src;
|
||||
{
|
||||
if (src != NULL && src->as_buf != NULL && dst->as_buf != NULL) {
|
||||
dst->as_len = min(src->as_len, dst->as_maxlen);
|
||||
memcpy(dst->as_buf, src->as_buf, dst->as_len);
|
||||
if (dst->as_len < dst->as_maxlen)
|
||||
dst->as_buf[dst->as_len] = 0;
|
||||
} else
|
||||
dst->as_len = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
RtlCopyUnicodeString(dest, src)
|
||||
unicode_string *dest;
|
||||
@ -650,6 +670,14 @@ ExAllocatePoolWithTag(pooltype, len, tag)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static void
|
||||
ExFreePoolWithTag(buf, tag)
|
||||
void *buf;
|
||||
uint32_t tag;
|
||||
{
|
||||
ExFreePool(buf);
|
||||
}
|
||||
|
||||
void
|
||||
ExFreePool(buf)
|
||||
void *buf;
|
||||
@ -2056,6 +2084,13 @@ ntoskrnl_pushsl(head, entry)
|
||||
return (oldhead);
|
||||
}
|
||||
|
||||
static void
|
||||
InitializeSListHead(head)
|
||||
slist_header *head;
|
||||
{
|
||||
memset(head, 0, sizeof(*head));
|
||||
}
|
||||
|
||||
static slist_entry *
|
||||
ntoskrnl_popsl(head)
|
||||
slist_header *head;
|
||||
@ -2725,6 +2760,59 @@ ntoskrnl_workitem_thread(arg)
|
||||
return; /* notreached */
|
||||
}
|
||||
|
||||
static ndis_status
|
||||
RtlCharToInteger(src, base, val)
|
||||
const char *src;
|
||||
uint32_t base;
|
||||
uint32_t *val;
|
||||
{
|
||||
int negative = 0;
|
||||
uint32_t res;
|
||||
|
||||
if (!src || !val)
|
||||
return (STATUS_ACCESS_VIOLATION);
|
||||
while (*src != '\0' && *src <= ' ')
|
||||
src++;
|
||||
if (*src == '+')
|
||||
src++;
|
||||
else if (*src == '-') {
|
||||
src++;
|
||||
negative = 1;
|
||||
}
|
||||
if (base == 0) {
|
||||
base = 10;
|
||||
if (*src == '0') {
|
||||
src++;
|
||||
if (*src == 'b') {
|
||||
base = 2;
|
||||
src++;
|
||||
} else if (*src == 'o') {
|
||||
base = 8;
|
||||
src++;
|
||||
} else if (*src == 'x') {
|
||||
base = 16;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
} else if (!(base == 2 || base == 8 || base == 10 || base == 16))
|
||||
return (STATUS_INVALID_PARAMETER);
|
||||
|
||||
for (res = 0; *src; src++) {
|
||||
int v;
|
||||
if (isdigit(*src))
|
||||
v = *src - '0';
|
||||
else if (isxdigit(*src))
|
||||
v = tolower(*src) - 'a' + 10;
|
||||
else
|
||||
v = base;
|
||||
if (v >= base)
|
||||
return (STATUS_INVALID_PARAMETER);
|
||||
res = res * base + v;
|
||||
}
|
||||
*val = negative ? -res : res;
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
ntoskrnl_destroy_workitem_threads(void)
|
||||
{
|
||||
@ -2904,6 +2992,32 @@ RtlZeroMemory(dst, len)
|
||||
bzero(dst, len);
|
||||
}
|
||||
|
||||
static void
|
||||
RtlSecureZeroMemory(dst, len)
|
||||
void *dst;
|
||||
size_t len;
|
||||
{
|
||||
memset(dst, 0, len);
|
||||
}
|
||||
|
||||
static void
|
||||
RtlFillMemory(dst, len, c)
|
||||
void *dst;
|
||||
size_t len;
|
||||
uint8_t c;
|
||||
{
|
||||
memset(dst, c, len);
|
||||
}
|
||||
|
||||
static void
|
||||
RtlMoveMemory(dst, src, len)
|
||||
void *dst;
|
||||
const void *src;
|
||||
size_t len;
|
||||
{
|
||||
memmove(dst, src, len);
|
||||
}
|
||||
|
||||
static void
|
||||
RtlCopyMemory(dst, src, len)
|
||||
void *dst;
|
||||
@ -2919,17 +3033,14 @@ RtlCompareMemory(s1, s2, len)
|
||||
const void *s2;
|
||||
size_t len;
|
||||
{
|
||||
size_t i, total = 0;
|
||||
size_t i;
|
||||
uint8_t *m1, *m2;
|
||||
|
||||
m1 = __DECONST(char *, s1);
|
||||
m2 = __DECONST(char *, s2);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (m1[i] == m2[i])
|
||||
total++;
|
||||
}
|
||||
return (total);
|
||||
for (i = 0; i < len && m1[i] == m2[i]; i++);
|
||||
return (i);
|
||||
}
|
||||
|
||||
void
|
||||
@ -4124,7 +4235,12 @@ dummy()
|
||||
|
||||
image_patch_table ntoskrnl_functbl[] = {
|
||||
IMPORT_SFUNC(RtlZeroMemory, 2),
|
||||
IMPORT_SFUNC(RtlSecureZeroMemory, 2),
|
||||
IMPORT_SFUNC(RtlFillMemory, 3),
|
||||
IMPORT_SFUNC(RtlMoveMemory, 3),
|
||||
IMPORT_SFUNC(RtlCharToInteger, 3),
|
||||
IMPORT_SFUNC(RtlCopyMemory, 3),
|
||||
IMPORT_SFUNC(RtlCopyString, 2),
|
||||
IMPORT_SFUNC(RtlCompareMemory, 3),
|
||||
IMPORT_SFUNC(RtlEqualUnicodeString, 3),
|
||||
IMPORT_SFUNC(RtlCopyUnicodeString, 2),
|
||||
@ -4211,6 +4327,7 @@ image_patch_table ntoskrnl_functbl[] = {
|
||||
IMPORT_SFUNC(ExInitializeNPagedLookasideList, 7),
|
||||
IMPORT_SFUNC(ExDeleteNPagedLookasideList, 1),
|
||||
IMPORT_FFUNC(InterlockedPopEntrySList, 1),
|
||||
IMPORT_FFUNC(InitializeSListHead, 1),
|
||||
IMPORT_FFUNC(InterlockedPushEntrySList, 2),
|
||||
IMPORT_SFUNC(ExQueryDepthSList, 1),
|
||||
IMPORT_FFUNC_MAP(ExpInterlockedPopEntrySList,
|
||||
@ -4220,6 +4337,7 @@ image_patch_table ntoskrnl_functbl[] = {
|
||||
IMPORT_FFUNC(ExInterlockedPopEntrySList, 2),
|
||||
IMPORT_FFUNC(ExInterlockedPushEntrySList, 3),
|
||||
IMPORT_SFUNC(ExAllocatePoolWithTag, 3),
|
||||
IMPORT_SFUNC(ExFreePoolWithTag, 2),
|
||||
IMPORT_SFUNC(ExFreePool, 1),
|
||||
#ifdef __i386__
|
||||
IMPORT_FFUNC(KefAcquireSpinLockAtDpcLevel, 1),
|
||||
|
Loading…
Reference in New Issue
Block a user