subr_ntoskrnl.c (124094) | subr_ntoskrnl.c (124122) |
---|---|
1/* 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ntoskrnl.c 124094 2004-01-03 02:25:21Z wpaul $"); | 34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ntoskrnl.c 124122 2004-01-04 07:47:33Z wpaul $"); |
35 36#include <sys/param.h> 37#include <sys/types.h> 38#include <sys/errno.h> 39#include <sys/systm.h> 40#include <sys/malloc.h> 41#include <sys/lock.h> 42#include <sys/mutex.h> --- 66 unchanged lines hidden (view full) --- 109__stdcall static void ntoskrnl_lock_dpc(/*kspin_lock * */ void); 110__stdcall static void ntoskrnl_unlock_dpc(/*kspin_lock * */ void); 111__stdcall static void ntoskrnl_interlock_inc(/*volatile uint32_t * */ void); 112__stdcall static void ntoskrnl_interlock_dec(/*volatile uint32_t * */ void); 113__stdcall static void ntoskrnl_freemdl(ndis_buffer *); 114__stdcall static void *ntoskrnl_mmaplockedpages(ndis_buffer *, uint8_t); 115__stdcall static void ntoskrnl_create_lock(kspin_lock *); 116__stdcall static void dummy(void); | 35 36#include <sys/param.h> 37#include <sys/types.h> 38#include <sys/errno.h> 39#include <sys/systm.h> 40#include <sys/malloc.h> 41#include <sys/lock.h> 42#include <sys/mutex.h> --- 66 unchanged lines hidden (view full) --- 109__stdcall static void ntoskrnl_lock_dpc(/*kspin_lock * */ void); 110__stdcall static void ntoskrnl_unlock_dpc(/*kspin_lock * */ void); 111__stdcall static void ntoskrnl_interlock_inc(/*volatile uint32_t * */ void); 112__stdcall static void ntoskrnl_interlock_dec(/*volatile uint32_t * */ void); 113__stdcall static void ntoskrnl_freemdl(ndis_buffer *); 114__stdcall static void *ntoskrnl_mmaplockedpages(ndis_buffer *, uint8_t); 115__stdcall static void ntoskrnl_create_lock(kspin_lock *); 116__stdcall static void dummy(void); |
117__stdcall static size_t ntoskrnl_memcmp(const void *, const void *, size_t); |
|
117 118static struct mtx ntoskrnl_interlock; | 118 119static struct mtx ntoskrnl_interlock; |
119static int ntoskrnl_inits = 0; | |
120 121int 122ntoskrnl_libinit() 123{ | 120 121int 122ntoskrnl_libinit() 123{ |
124 if (ntoskrnl_inits) { 125 ntoskrnl_inits++; 126 return(0); 127 } 128 | |
129 mtx_init(&ntoskrnl_interlock, "ntoskrnllock", MTX_NETWORK_LOCK, 130 MTX_DEF | MTX_RECURSE); 131 | 124 mtx_init(&ntoskrnl_interlock, "ntoskrnllock", MTX_NETWORK_LOCK, 125 MTX_DEF | MTX_RECURSE); 126 |
132 ntoskrnl_inits++; | |
133 return(0); 134} 135 136int 137ntoskrnl_libfini() 138{ | 127 return(0); 128} 129 130int 131ntoskrnl_libfini() 132{ |
139 if (ntoskrnl_inits != 1) { 140 ntoskrnl_inits--; 141 return(0); 142 } 143 | |
144 mtx_destroy(&ntoskrnl_interlock); | 133 mtx_destroy(&ntoskrnl_interlock); |
145 ntoskrnl_inits--; | |
146 147 return(0); 148} 149 150__stdcall static uint32_t 151ntoskrnl_unicode_equal(str1, str2, casesensitive) 152 ndis_unicode_string *str1; 153 ndis_unicode_string *str2; --- 493 unchanged lines hidden (view full) --- 647 mtx_init(mtx, "ntoslock", "ntoskrnl spinlock", 648 MTX_DEF | MTX_RECURSE | MTX_DUPOK); 649 650 *lock = (kspin_lock)mtx; 651 652 return; 653} 654 | 134 135 return(0); 136} 137 138__stdcall static uint32_t 139ntoskrnl_unicode_equal(str1, str2, casesensitive) 140 ndis_unicode_string *str1; 141 ndis_unicode_string *str2; --- 493 unchanged lines hidden (view full) --- 635 mtx_init(mtx, "ntoslock", "ntoskrnl spinlock", 636 MTX_DEF | MTX_RECURSE | MTX_DUPOK); 637 638 *lock = (kspin_lock)mtx; 639 640 return; 641} 642 |
643__stdcall static size_t 644ntoskrnl_memcmp(s1, s2, len) 645 const void *s1; 646 const void *s2; 647 size_t len; 648{ 649 size_t i, total = 0; 650 uint8_t *m1, *m2; 651 652 m1 = __DECONST(char *, s1); 653 m2 = __DECONST(char *, s2); 654 655 for (i = 0; i < len; i++) { 656 if (m1[i] == m2[i]) 657 total++; 658 } 659 return(total); 660} 661 |
|
655__stdcall static void 656dummy() 657{ 658 printf ("ntoskrnl dummy called...\n"); 659 return; 660} 661 662 663image_patch_table ntoskrnl_functbl[] = { | 662__stdcall static void 663dummy() 664{ 665 printf ("ntoskrnl dummy called...\n"); 666 return; 667} 668 669 670image_patch_table ntoskrnl_functbl[] = { |
671 { "RtlCompareMemory", (FUNC)ntoskrnl_memcmp }, |
|
664 { "RtlEqualUnicodeString", (FUNC)ntoskrnl_unicode_equal }, 665 { "RtlCopyUnicodeString", (FUNC)ntoskrnl_unicode_copy }, 666 { "RtlUnicodeStringToAnsiString", (FUNC)ntoskrnl_unicode_to_ansi }, 667 { "sprintf", (FUNC)sprintf }, 668 { "DbgPrint", (FUNC)printf }, 669 { "strncmp", (FUNC)strncmp }, 670 { "strcmp", (FUNC)strcmp }, 671 { "strncpy", (FUNC)strncpy }, --- 53 unchanged lines hidden --- | 672 { "RtlEqualUnicodeString", (FUNC)ntoskrnl_unicode_equal }, 673 { "RtlCopyUnicodeString", (FUNC)ntoskrnl_unicode_copy }, 674 { "RtlUnicodeStringToAnsiString", (FUNC)ntoskrnl_unicode_to_ansi }, 675 { "sprintf", (FUNC)sprintf }, 676 { "DbgPrint", (FUNC)printf }, 677 { "strncmp", (FUNC)strncmp }, 678 { "strcmp", (FUNC)strcmp }, 679 { "strncpy", (FUNC)strncpy }, --- 53 unchanged lines hidden --- |