Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
7.6 KiB

  1. #ifndef _EDITOR_H
  2. #define _EDITOR_H
  3. /*++
  4. Copyright (c) 1999 Intel Corporation
  5. Module Name:
  6. Editor.h
  7. Abstract:
  8. Main include file for hex editor
  9. --*/
  10. #include "efi.h"
  11. #include "efilib.h"
  12. #include "shelle.h"
  13. #define EDITOR_NAME L"EFI Hex Editor\0"
  14. #define EDITOR_VERSION L"0.92\0"
  15. #define EE EFI_EDITOR
  16. typedef
  17. EFI_STATUS
  18. (*EE_INIT) (
  19. VOID
  20. );
  21. typedef
  22. EFI_STATUS
  23. (*EE_CLEANUP) (
  24. VOID
  25. );
  26. typedef
  27. EFI_STATUS
  28. (*EE_REFRESH) (
  29. VOID
  30. );
  31. typedef
  32. EFI_STATUS
  33. (*EE_HIDE) (
  34. VOID
  35. );
  36. typedef
  37. EFI_STATUS
  38. (*EE_INPUT) (
  39. VOID
  40. );
  41. typedef
  42. EFI_STATUS
  43. (*EE_HANDLE_INPUT) (
  44. IN OUT EFI_INPUT_KEY *Key
  45. );
  46. typedef
  47. EFI_STATUS
  48. (*EE_IMAGE_OPEN) (
  49. VOID
  50. );
  51. typedef
  52. EFI_STATUS
  53. (*EE_IMAGE_CLOSE) (
  54. VOID
  55. );
  56. typedef
  57. EFI_STATUS
  58. (*EE_IMAGE_READ) (
  59. VOID
  60. );
  61. typedef
  62. EFI_STATUS
  63. (*EE_IMAGE_WRITE) (
  64. VOID
  65. );
  66. typedef
  67. EFI_STATUS
  68. (*EE_IMAGE_CLEAN) (
  69. VOID
  70. );
  71. typedef struct {
  72. UINTN Row;
  73. UINTN Column;
  74. } EE_POSITION;
  75. typedef
  76. EFI_STATUS
  77. (*EFI_MENU_ITEM_FUNCTION) (VOID);
  78. typedef struct {
  79. CHAR16 Name[50];
  80. CHAR16 Key[3];
  81. EFI_MENU_ITEM_FUNCTION Function;
  82. } SubItems;
  83. #define EE_LINE_LIST 'eell'
  84. typedef struct _EE_LINE {
  85. UINTN Signature;
  86. UINT8 Buffer[0x10];
  87. UINTN Size;
  88. LIST_ENTRY Link;
  89. } EE_LINE;
  90. typedef struct {
  91. CHAR16 *Name;
  92. CHAR16 *FunctionKey;
  93. EFI_MENU_ITEM_FUNCTION Function;
  94. } EE_MENU_ITEM;
  95. typedef struct {
  96. EE_MENU_ITEM *MenuItems;
  97. EE_INIT Init;
  98. EE_CLEANUP Cleanup;
  99. EE_REFRESH Refresh;
  100. EE_HIDE Hide;
  101. EE_HANDLE_INPUT HandleInput;
  102. } EE_MENU_BAR;
  103. typedef struct {
  104. CHAR16 *Filename;
  105. EE_INIT Init;
  106. EE_CLEANUP Cleanup;
  107. EE_REFRESH Refresh;
  108. EE_HIDE Hide;
  109. EFI_STATUS (*SetTitleString) (CHAR16*);
  110. } EE_TITLE_BAR;
  111. typedef struct {
  112. CHAR16* StatusString;
  113. UINTN Offset;
  114. EE_INIT Init;
  115. EE_CLEANUP Cleanup;
  116. EE_REFRESH Refresh;
  117. EE_HIDE Hide;
  118. EFI_STATUS (*SetStatusString) (CHAR16*);
  119. EFI_STATUS (*SetOffset) (UINTN);
  120. } EE_STATUS_BAR;
  121. typedef struct {
  122. CHAR16 *Prompt;
  123. CHAR16 *ReturnString;
  124. UINTN StringSize;
  125. EE_INIT Init;
  126. EE_CLEANUP Cleanup;
  127. EE_REFRESH Refresh;
  128. EE_HIDE Hide;
  129. EFI_STATUS (*SetPrompt) (CHAR16*);
  130. EFI_STATUS (*SetStringSize) (UINTN);
  131. } EE_INPUT_BAR;
  132. typedef struct {
  133. EE_POSITION DisplayPosition;
  134. UINTN Offset;
  135. UINTN LowVisibleOffset;
  136. UINTN HighVisibleOffset;
  137. UINTN MaxVisibleBytes;
  138. LIST_ENTRY *CurrentLine;
  139. EE_INIT Init;
  140. EE_CLEANUP Cleanup;
  141. EE_REFRESH Refresh;
  142. EE_HIDE Hide;
  143. EE_HANDLE_INPUT HandleInput;
  144. EFI_STATUS (*ClearLine) (UINTN);
  145. EFI_STATUS (*SetPosition) (UINTN,UINTN);
  146. EFI_STATUS (*RestorePosition) (VOID);
  147. } EE_FILE_BUFFER;
  148. typedef struct {
  149. LIST_ENTRY *ListHead;
  150. EE_LINE *Lines;
  151. UINTN NumLines;
  152. EE_INIT Init;
  153. EE_CLEANUP Cleanup;
  154. EFI_STATUS (*Clear) (VOID);
  155. EFI_STATUS (*Cut) (UINTN,UINTN);
  156. EFI_STATUS (*Copy) (UINTN,UINTN);
  157. EFI_STATUS (*Paste)(VOID);
  158. } EE_CLIPBOARD;
  159. typedef struct {
  160. UINT32 Foreground:4;
  161. UINT32 Background:4;
  162. } EE_COLOR_ATTRIBUTES;
  163. typedef union {
  164. EE_COLOR_ATTRIBUTES Colors;
  165. UINT8 Data;
  166. } EE_COLOR_UNION;
  167. typedef struct {
  168. UINTN Columns;
  169. UINTN Rows;
  170. } EE_TEXT_MODE;
  171. typedef struct {
  172. EFI_BLOCK_IO *BlkIo;
  173. EFI_DEVICE_PATH *DevicePath;
  174. UINTN Size;
  175. UINT64 Offset;
  176. EE_INIT Init;
  177. EFI_STATUS (*SetDevice) (CHAR16*);
  178. EFI_STATUS (*SetOffset) (UINT64);
  179. EFI_STATUS (*SetSize) (UINTN);
  180. } EE_DISK_IMAGE;
  181. typedef struct {
  182. EFI_DEVICE_IO_INTERFACE *IoFncs;
  183. UINTN Offset;
  184. UINTN Size;
  185. EE_INIT Init;
  186. EFI_STATUS (*SetOffset)(UINTN);
  187. EFI_STATUS (*SetSize) (UINTN);
  188. } EE_MEM_IMAGE;
  189. typedef struct {
  190. CHAR16 *FileName;
  191. EFI_FILE_HANDLE FileHandle;
  192. EFI_FILE_HANDLE CurrentDir;
  193. EE_INIT Init;
  194. EFI_STATUS (*SetFilename) (CHAR16*);
  195. } EE_FILE_IMAGE;
  196. typedef enum {
  197. NO_BUFFER,
  198. DISK_BUFFER,
  199. MEM_BUFFER,
  200. FILE_BUFFER
  201. } EE_ACTIVE_BUFFER_TYPE;
  202. typedef struct {
  203. LIST_ENTRY *ListHead;
  204. EE_ACTIVE_BUFFER_TYPE BufferType;
  205. UINTN NumBytes;
  206. EE_INIT Init;
  207. EE_CLEANUP Cleanup;
  208. EE_IMAGE_OPEN Open;
  209. EE_IMAGE_CLOSE Close;
  210. EE_IMAGE_READ Read;
  211. EE_IMAGE_WRITE Write;
  212. EE_IMAGE_CLEAN ImageCleanup;
  213. EE_FILE_IMAGE *FileImage;
  214. EE_DISK_IMAGE *DiskImage;
  215. EE_MEM_IMAGE *MemImage;
  216. } EE_BUFFER_IMAGE;
  217. typedef struct {
  218. EFI_HANDLE *ImageHandle;
  219. EE_TITLE_BAR *TitleBar;
  220. EE_MENU_BAR *MenuBar;
  221. EE_STATUS_BAR *StatusBar;
  222. EE_INPUT_BAR *InputBar;
  223. EE_FILE_BUFFER *FileBuffer;
  224. EE_CLIPBOARD *Clipboard;
  225. EE_COLOR_UNION ColorAttributes;
  226. EE_POSITION *ScreenSize;
  227. EE_BUFFER_IMAGE *BufferImage;
  228. BOOLEAN FileModified;
  229. EFI_STATUS (*Init) (EFI_HANDLE*);
  230. EE_CLEANUP Cleanup;
  231. EE_INPUT KeyInput;
  232. EE_HANDLE_INPUT HandleInput;
  233. EE_REFRESH Refresh;
  234. } EE_EDITOR;
  235. extern EE_EDITOR MainEditor;
  236. #define TITLE_BAR_LOCATION 0
  237. #define STATUS_BAR_LOCATION (MainEditor.ScreenSize->Row - 4)
  238. #define INPUT_BAR_LOCATION STATUS_BAR_LOCATION
  239. #define MENU_BAR_LOCATION (MainEditor.ScreenSize->Row - 3)
  240. #define LAST_LINE_LOCATION (MainEditor.ScreenSize->Row - 1)
  241. #define TEXT_START_ROW 1
  242. #define TEXT_START_COLUMN 0
  243. #define TEXT_END_ROW (MainEditor.ScreenSize->Row - 4)
  244. #define MAX_TEXT_COLUMNS MainEditor.ScreenSize->Column
  245. #define MAX_TEXT_ROWS (TEXT_END_ROW - 1)
  246. #define DISP_START_ROW 1
  247. #define DISP_START_COLUMN 0
  248. #define DISP_END_ROW (MainEditor.ScreenSize->Row - 4)
  249. #define DISP_MAX_ROWS (DISP_END_ROW - 1)
  250. #define HEX_POSITION 10
  251. #define ASCII_POSITION (0x10*3)+2+HEX_POSITION
  252. #define MIN_POOL_SIZE 125
  253. #define MAX_STRING_LENGTH 127
  254. #define min(a,b) \
  255. (( a > b) ? b : a)
  256. #define max(a,b) \
  257. (( a > b) ? a : b)
  258. /* Global variables for input and output */
  259. #define Out ST->ConOut
  260. #define In ST->ConIn
  261. #define SCAN_CODE_NULL 0x00
  262. #define SCAN_CODE_UP 0x01
  263. #define SCAN_CODE_DOWN 0x02
  264. #define SCAN_CODE_RIGHT 0x03
  265. #define SCAN_CODE_LEFT 0x04
  266. #define SCAN_CODE_HOME 0x05
  267. #define SCAN_CODE_END 0x06
  268. #define SCAN_CODE_INS 0x07
  269. #define SCAN_CODE_DEL 0x08
  270. #define SCAN_CODE_PGUP 0x09
  271. #define SCAN_CODE_PGDN 0x0A
  272. #define SCAN_CODE_F1 0x0B
  273. #define SCAN_CODE_F2 0x0C
  274. #define SCAN_CODE_F3 0x0D
  275. #define SCAN_CODE_F4 0x0E
  276. #define SCAN_CODE_F5 0x0F
  277. #define SCAN_CODE_F6 0x10
  278. #define SCAN_CODE_F7 0x11
  279. #define SCAN_CODE_F8 0x12
  280. #define SCAN_CODE_F9 0x13
  281. #define SCAN_CODE_F10 0x14
  282. #define SCAN_CODE_F11 0x15
  283. #define SCAN_CODE_F12 0x16
  284. #define SCAN_CODE_ESC 0x17
  285. #define CHAR_BS 0x08
  286. #define CHAR_LF 0x0a
  287. #define CHAR_CR 0x0d
  288. #define IS_VALID_CHAR(x) \
  289. (x == SCAN_CODE_NULL)
  290. #define IS_DIRECTION_KEY(x) \
  291. ((x >= SCAN_CODE_UP) && (x <= SCAN_CODE_PGDN))
  292. #define IS_FUNCTION_KEY(x) \
  293. ((x >= SCAN_CODE_F1) && x <= (SCAN_CODE_F12))
  294. #define IS_ESCAPE(x) \
  295. (x == SCAN_CODE_ESC)
  296. extern VOID EditorError (EFI_STATUS,CHAR16*);
  297. #endif /* _EDITOR_H */