source: Daodan/MSVC/defs.h@ 591

Last change on this file since 591 was 589, checked in by gumby, 13 years ago

stuff

File size: 4.7 KB
RevLine 
[589]1/*
2
3 This file contains definitions used by the Hex-Rays decompiler output.
4 It has type definitions and convenience macros to make the
5 output more readable.
6
7 Copyright (c) 2007 Hex-Rays sprl
8
9*/
10
11#if defined(__GNUC__)
12#define FMT_64 "ll"
13typedef long long ll;
14typedef unsigned long long ull;
15#elif defined(_MSC_VER)
16typedef __int64 ll;
17typedef unsigned __int64 ull;
18#define FMT_64 "I64"
19#elif defined (__BORLANDC__)
20typedef __int64 ll;
21typedef unsigned __int64 ull;
22#define FMT_64 "L"
23#else
24#error "unknown compiler"
25#endif
26typedef unsigned int uint;
27typedef unsigned char uchar;
28typedef unsigned short ushort;
29typedef unsigned long ulong;
30
31// Partially defined types:
32#define _BYTE char
33#define _WORD short
34#define _DWORD long
35#define _QWORD ll
36#define _LONGLONG __int128
37
38#ifndef _WINDOWS_
39typedef char BYTE;
40typedef short WORD;
41typedef long DWORD;
42typedef long LONG;
43#endif
44typedef ll QWORD;
45#ifndef __cplusplus
46//typedef int bool; // we want to use bool in our C programs
47#endif
48
49// Some convenience macros to make partial accesses nicer
50// first unsigned macros:
51#define LOBYTE(x) (*((_BYTE*)&(x))) // low byte
52#define LOWORD(x) (*((_WORD*)&(x))) // low word
53#define LODWORD(x) (*((_DWORD*)&(x))) // low dword
54#define HIBYTE(x) (*((_BYTE*)&(x)+1))
55#define HIWORD(x) (*((_WORD*)&(x)+1))
56#define HIDWORD(x) (*((_DWORD*)&(x)+1))
57#define BYTEn(x, n) (*((_BYTE*)&(x)+n))
58#define WORDn(x, n) (*((_WORD*)&(x)+n))
59#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0)
60#define BYTE2(x) BYTEn(x, 2)
61#define BYTE3(x) BYTEn(x, 3)
62#define BYTE4(x) BYTEn(x, 4)
63#define BYTE5(x) BYTEn(x, 5)
64#define BYTE6(x) BYTEn(x, 6)
65#define BYTE7(x) BYTEn(x, 7)
66#define BYTE8(x) BYTEn(x, 8)
67#define BYTE9(x) BYTEn(x, 9)
68#define BYTE10(x) BYTEn(x, 10)
69#define BYTE11(x) BYTEn(x, 11)
70#define BYTE12(x) BYTEn(x, 12)
71#define BYTE13(x) BYTEn(x, 13)
72#define BYTE14(x) BYTEn(x, 14)
73#define BYTE15(x) BYTEn(x, 15)
74#define WORD1(x) WORDn(x, 1)
75#define WORD2(x) WORDn(x, 2) // third word of the object, unsigned
76#define WORD3(x) WORDn(x, 3)
77#define WORD4(x) WORDn(x, 4)
78#define WORD5(x) WORDn(x, 5)
79#define WORD6(x) WORDn(x, 6)
80#define WORD7(x) WORDn(x, 7)
81
82// now signed macros (the same but with sign extension)
83#define SLOBYTE(x) (*((char*)&(x)))
84#define SLOWORD(x) (*((short*)&(x)))
85#define SLODWORD(x) (*((long*)&(x)))
86#define SHIBYTE(x) (*((char*)&(x)+1))
87#define SHIWORD(x) (*((short*)&(x)+1))
88#define SHIDWORD(x) (*((long*)&(x)+1))
89#define SBYTEn(x, n) (*((char*)&(x)+n))
90#define SWORDn(x, n) (*((short*)&(x)+n))
91#define SBYTE1(x) SBYTEn(x, 1)
92#define SBYTE2(x) SBYTEn(x, 2)
93#define SBYTE3(x) SBYTEn(x, 3)
94#define SBYTE4(x) SBYTEn(x, 4)
95#define SBYTE5(x) SBYTEn(x, 5)
96#define SBYTE6(x) SBYTEn(x, 6)
97#define SBYTE7(x) SBYTEn(x, 7)
98#define SBYTE8(x) SBYTEn(x, 8)
99#define SBYTE9(x) SBYTEn(x, 9)
100#define SBYTE10(x) SBYTEn(x, 10)
101#define SBYTE11(x) SBYTEn(x, 11)
102#define SBYTE12(x) SBYTEn(x, 12)
103#define SBYTE13(x) SBYTEn(x, 13)
104#define SBYTE14(x) SBYTEn(x, 14)
105#define SBYTE15(x) SBYTEn(x, 15)
106#define SWORD1(x) SWORDn(x, 1)
107#define SWORD2(x) SWORDn(x, 2)
108#define SWORD3(x) SWORDn(x, 3)
109#define SWORD4(x) SWORDn(x, 4)
110#define SWORD5(x) SWORDn(x, 5)
111#define SWORD6(x) SWORDn(x, 6)
112#define SWORD7(x) SWORDn(x, 7)
113
114// Macros to represent some assembly instructions
115// Feel free to modify them
116
117#define __ROL__(x, y) __rotl__(x, y) // Rotate left
118#define __ROR__(x, y) __rotr__(x, y) // Rotate right
119#define __RCL__(x, y) invalid_operation // Rotate left thru carry
120#define __RCR__(x, y) invalid_operation // Rotate right thru carry
121#define __MKCADD__(x, y) invalid_operation // Generate carry flag for an addition
122#define __MKOADD__(x, y) invalid_operation // Generate overflow flag for an addition
123#define __MKCSHL__(x, y) invalid_operation // Generate carry flag for a shift left
124#define __MKCSHR__(x, y) invalid_operation // Generate carry flag for a shift right
125#define __MKCRCL__(x, y) invalid_operation // Generate carry flag for a RCL
126#define __MKCRCR__(x, y) invalid_operation // Generate carry flag for a RCR
127#define __SETO__(x, y) invalid_operation // Generate overflow flags for (x-y)
128
129
130// In the decompilation listing there are some objects declarared as _UNKNOWN
131// because we could not determine their types. Since the C compiler does not
132// accept void item declarations, we replace them by anything of our choice,
133// for example a char:
134
135#define _UNKNOWN char
136
137#ifdef _MSC_VER
138#define snprintf _snprintf
139#define vsnprintf _vsnprintf
140#endif
Note: See TracBrowser for help on using the repository browser.