00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 #ifndef __memory_t
00034 #define __memory_t
00035 
00036 #define         uint8   UCHAR
00037 #define         int8    CHAR
00038 #define         uint16  USHORT
00039 #define         int16   SHORT
00040 #define         uint32  ULONG
00041 #define         int32   LONG
00042 #define         uint64  ULONGLONG
00043 #define         int64   LONGLONG
00044 
00045 
00046 typedef struct __MEM_TYPE
00047 {
00048         uint8 *buffer;
00049         uint32 size;
00050 }  MEM_TYPE, *PMEM_TYPE;
00051 
00052 #define LONG_AT(base,offset) (*(int32*)((uint8*)base+(uint32)offset))
00053 
00054 #define ULONG_AT(base,offset) (*(uint32*)((uint8*)base+(uint32)offset))
00055 
00056 #define SHORT_AT(base,offset) (*(int16*)((uint8*)base+(uint32)offset))
00057 
00058 #define USHORT_AT(base,offset) (*(uint16*)((uint8*)base+(uint32)offset))
00059 
00060 __inline int32 SW_LONG_AT(void *b, uint32 c)
00061 {
00062         return  ((int32)*((uint8 *)b+c)<<24|
00063                  (int32)*((uint8 *)b+c+1)<<16|
00064                  (int32)*((uint8 *)b+c+2)<<8|
00065                  (int32)*((uint8 *)b+c+3)<<0);
00066 }
00067 
00068 
00069 __inline uint32 SW_ULONG_AT(void *b, uint32 c)
00070 {
00071         return  ((uint32)*((uint8 *)b+c)<<24|
00072                  (uint32)*((uint8 *)b+c+1)<<16|
00073                  (uint32)*((uint8 *)b+c+2)<<8|
00074                  (uint32)*((uint8 *)b+c+3)<<0);
00075 }
00076 
00077 __inline int16 SW_SHORT_AT(void *b, uint32 os)
00078 {
00079         return ((int16)
00080                 ((int16)*((uint8 *)b+os+0)<<8|
00081                  (int16)*((uint8 *)b+os+1)<<0));
00082 }
00083 
00084 __inline uint16 SW_USHORT_AT(void *b, uint32 os)
00085 {
00086         return ((uint16)
00087                 ((uint16)*((uint8 *)b+os+0)<<8|
00088                  (uint16)*((uint8 *)b+os+1)<<0));
00089 }
00090 
00091 __inline VOID SW_ULONG_ASSIGN(void *dst, uint32 src)
00092 {
00093         *((uint8*)dst+0)=*((uint8*)&src+3);
00094         *((uint8*)dst+1)=*((uint8*)&src+2);
00095         *((uint8*)dst+2)=*((uint8*)&src+1);
00096         *((uint8*)dst+3)=*((uint8*)&src+0);
00097 
00098 }
00099 
00100 #ifdef WIN_NT_DRIVER
00101 
00102 #define ALLOCATE_MEMORY(dest,type,amount) \
00103           (dest)=ExAllocatePool(NonPagedPool,sizeof(type)*(amount));
00104 #define ALLOCATE_ZERO_MEMORY(dest,type,amount) \
00105         { \
00106                 (dest)=ExAllocatePool(NonPagedPool,sizeof(type)*(amount)); \
00107                 if ((dest)!=NULL) \
00108                         RtlZeroMemory((dest),sizeof(type)*(amount)); \
00109         }       
00110 
00111 #define FREE_MEMORY(dest) ExFreePool(dest);
00112 #define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount);
00113 #define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount);
00114 
00115 #else
00116 
00117 #define ALLOCATE_MEMORY(dest,type,amount) \
00118           (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount));
00119 #define ALLOCATE_ZERO_MEMORY(dest,type,amount) \
00120           (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount));
00121 
00122 #define FREE_MEMORY(dest) GlobalFree(dest);
00123 #define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount);
00124 #define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount);
00125 
00126 
00127 #endif 
00128 
00129 
00130 
00131 #endif 
00132