2 /* only for getting the pe struct */
11 #include "From/ARM/ARM.h"
12 #include "From/m68k/m68k.h"
13 #include "From/PPC/PPC.h"
20 * 3 = can not open read file
21 * 4 = can not open write file
22 * 5 = can not seek to end of read file
23 * 6 = can not get the file size of the read file
24 * 7 = read file size is Zero
25 * 8 = can not alloc memory
26 * 9 = can not read file
27 *-------------------------
30 * type 2 : exe/dll/sys
35 /* Conveting bit array to a int byte */
36 CPU_UNINT
ConvertBitToByte(CPU_BYTE
*bit
)
45 Byte
= Byte
+ (bit
[size
-t
]<<t
);
50 /* Conveting bit array mask to a int byte mask */
51 CPU_UNINT
GetMaskByte(CPU_BYTE
*bit
)
53 CPU_UNINT MaskByte
= 0;
61 MaskByte
= MaskByte
+ ( (bit
[size
-t
]-1) <<t
);
67 /* Conveting bit array to a int byte */
68 CPU_UNINT
ConvertBitToByte32(CPU_BYTE
*bit
)
77 Byte
= Byte
+ (bit
[size
-t
]<<t
);
82 /* Conveting bit array mask to a int byte mask */
83 CPU_UNINT
GetMaskByte32(CPU_BYTE
*bit
)
85 CPU_UNINT MaskByte
= 0;
93 MaskByte
= MaskByte
+ ( (bit
[size
-t
]-1) <<t
);
101 CPU_UNINT
GetData32Le(CPU_BYTE
*cpu_buffer
)
109 cpuint
= *((CPU_UNINT
*) &cpu_buffer
[0]);
111 split1
= cpu_buffer
[0];
112 split2
= cpu_buffer
[1];
113 split3
= cpu_buffer
[2];
114 split4
= cpu_buffer
[3];
117 cpuint
= split4
+(split3
<<8 )+(split2
<<16 )+(split1
<<24 );
122 CPU_UNINT
GetData32Be(CPU_BYTE
*cpu_buffer
)
126 cpuint
= *((CPU_UNINT
*) &cpu_buffer
[0]);
135 if (pMyBrainAnalys
== NULL
)
137 pMyBrainAnalys
= (PMYBrainAnalys
) malloc(sizeof(MYBrainAnalys
));
138 if (pMyBrainAnalys
==NULL
)
142 ZeroMemory(pMyBrainAnalys
,sizeof(MYBrainAnalys
));
143 pStartMyBrainAnalys
= pMyBrainAnalys
;
148 tmp
= (PMYBrainAnalys
) malloc(sizeof(MYBrainAnalys
));
153 ZeroMemory(tmp
,sizeof(MYBrainAnalys
));
155 pMyBrainAnalys
->ptr_next
= (CPU_BYTE
*)tmp
;
156 tmp
->ptr_prev
= (CPU_BYTE
*)pMyBrainAnalys
;
158 pMyBrainAnalys
= tmp
;
165 PMYBrainAnalys tmp
= NULL
;
167 if (pMyBrainAnalys
== NULL
)
172 tmp
= (PMYBrainAnalys
)pMyBrainAnalys
->ptr_prev
;
174 while (pMyBrainAnalys
!= NULL
)
176 if (pMyBrainAnalys
== NULL
)
181 free(pMyBrainAnalys
);
183 if (pMyBrainAnalys
!= NULL
)
185 printf("fail to free memory");
189 pMyBrainAnalys
= tmp
;