3 * Politecnico di Torino. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the Politecnico
13 * di Torino, and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31 #define uint64 ULONGLONG
32 #define int64 LONGLONG
35 typedef struct __MEM_TYPE
39 } MEM_TYPE
, *PMEM_TYPE
;
41 #define LONG_AT(base,offset) (*(int32*)((uint8*)base+(uint32)offset))
43 #define ULONG_AT(base,offset) (*(uint32*)((uint8*)base+(uint32)offset))
45 #define SHORT_AT(base,offset) (*(int16*)((uint8*)base+(uint32)offset))
47 #define USHORT_AT(base,offset) (*(uint16*)((uint8*)base+(uint32)offset))
50 #define __inline inline
51 #define _USE_SW_FUNCS_
56 inline int32
SW_LONG_AT(void *b
, uint32 c
);
57 inline uint32
SW_ULONG_AT(void *b
, uint32 c
);
58 inline int16
SW_SHORT_AT(void *b
, uint32 os
);
59 inline uint16
SW_USHORT_AT(void *b
, uint32 os
);
60 inline VOID
SW_ULONG_ASSIGN(void *dst
, uint32 src
);
62 #else /*_USE_SW_FUNCS_*/
64 __inline int32
SW_LONG_AT(void *b
, uint32 c
)
66 return ((int32
)*((uint8
*)b
+c
)<<24|
67 (int32
)*((uint8
*)b
+c
+1)<<16|
68 (int32
)*((uint8
*)b
+c
+2)<<8|
69 (int32
)*((uint8
*)b
+c
+3)<<0);
72 __inline uint32
SW_ULONG_AT(void *b
, uint32 c
)
74 return ((uint32
)*((uint8
*)b
+c
)<<24|
75 (uint32
)*((uint8
*)b
+c
+1)<<16|
76 (uint32
)*((uint8
*)b
+c
+2)<<8|
77 (uint32
)*((uint8
*)b
+c
+3)<<0);
80 __inline int16
SW_SHORT_AT(void *b
, uint32 os
)
83 ((int16
)*((uint8
*)b
+os
+0)<<8|
84 (int16
)*((uint8
*)b
+os
+1)<<0));
87 __inline uint16
SW_USHORT_AT(void *b
, uint32 os
)
90 ((uint16
)*((uint8
*)b
+os
+0)<<8|
91 (uint16
)*((uint8
*)b
+os
+1)<<0));
94 __inline VOID
SW_ULONG_ASSIGN(void *dst
, uint32 src
)
96 *((uint8
*)dst
+0)=*((uint8
*)&src
+3);
97 *((uint8
*)dst
+1)=*((uint8
*)&src
+2);
98 *((uint8
*)dst
+2)=*((uint8
*)&src
+1);
99 *((uint8
*)dst
+3)=*((uint8
*)&src
+0);
103 #endif /*_USE_SW_FUNCS_*/
107 #define ALLOCATE_MEMORY(dest,type,amount) \
108 (dest)=ExAllocatePool(NonPagedPool,sizeof(type)*(amount));
109 #define ALLOCATE_ZERO_MEMORY(dest,type,amount) \
111 (dest)=ExAllocatePool(NonPagedPool,sizeof(type)*(amount)); \
113 RtlZeroMemory((dest),sizeof(type)*(amount)); \
116 #define FREE_MEMORY(dest) ExFreePool(dest);
117 #define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount);
118 #define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount);
120 #endif /*WIN_NT_DRIVER*/