|  |  | @ -155,54 +155,50 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |  * Misc terminal codes * |  |  |  |  * Misc terminal codes * | 
			
		
	
		
		
			
				
					
					|  |  |  |  ***********************/ |  |  |  |  ***********************/ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #define TERM_HOME     "\x1b[H" |  |  |  |  // 定义一些额外的终端控制代码
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #define TERM_CLEAR    TERM_HOME "\x1b[2J" |  |  |  | #define TERM_HOME     "\x1b[H"     // 移动光标到终端左上角
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #define cEOL          "\x1b[0K" |  |  |  | #define TERM_CLEAR    TERM_HOME "\x1b[2J" // 清除终端屏幕
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #define CURSOR_HIDE   "\x1b[?25l" |  |  |  | #define cEOL          "\x1b[0K"    // 清除当前行从光标位置到行尾的内容
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #define CURSOR_SHOW   "\x1b[?25h" |  |  |  | #define CURSOR_HIDE   "\x1b[?25l"  // 隐藏光标
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #define CURSOR_SHOW   "\x1b[?25h"  // 显示光标
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /************************
 |  |  |  | /************************
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  * Debug & error macros * |  |  |  |  * Debug & error macros * | 
			
		
	
		
		
			
				
					
					|  |  |  |  ************************/ |  |  |  |  ************************/ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Just print stuff to the appropriate stream. */ |  |  |  |  // 定义一些宏用于调试和错误处理
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  // 如果配置中定义了MESSAGES_TO_STDOUT,则使用printf,否则使用fprintf(stderr, ...)
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #ifdef MESSAGES_TO_STDOUT |  |  |  | #ifdef MESSAGES_TO_STDOUT | 
			
		
	
		
		
			
				
					
					|  |  |  | #  define SAYF(x...)    printf(x) |  |  |  | #  define SAYF(x...)    printf(x) | 
			
		
	
		
		
			
				
					
					|  |  |  | #else  |  |  |  | #else  | 
			
		
	
		
		
			
				
					
					|  |  |  | #  define SAYF(x...)    fprintf(stderr, x) |  |  |  | #  define SAYF(x...)    fprintf(stderr, x) | 
			
		
	
		
		
			
				
					
					|  |  |  | #endif /* ^MESSAGES_TO_STDOUT */ |  |  |  | #endif /* ^MESSAGES_TO_STDOUT */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Show a prefixed warning. */ |  |  |  | // 显示带前缀的警告信息
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define WARNF(x...) do { \ |  |  |  | #define WARNF(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cYEL "[!] " cBRI "WARNING: " cRST x); \ |  |  |  |     SAYF(cYEL "[!] " cBRI "WARNING: " cRST x); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cRST "\n"); \ |  |  |  |     SAYF(cRST "\n"); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Show a prefixed "doing something" message. */ |  |  |  | // 显示带前缀的“正在执行”信息
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define ACTF(x...) do { \ |  |  |  | #define ACTF(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cLBL "[*] " cRST x); \ |  |  |  |     SAYF(cLBL "[*] " cRST x); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cRST "\n"); \ |  |  |  |     SAYF(cRST "\n"); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Show a prefixed "success" message. */ |  |  |  | // 显示带前缀的成功信息
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define OKF(x...) do { \ |  |  |  | #define OKF(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cLGN "[+] " cRST x); \ |  |  |  |     SAYF(cLGN "[+] " cRST x); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cRST "\n"); \ |  |  |  |     SAYF(cRST "\n"); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Show a prefixed fatal error message (not used in afl). */ |  |  |  | // 显示带前缀的严重错误信息(不在afl中使用)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define BADF(x...) do { \ |  |  |  | #define BADF(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cLRD "\n[-] " cRST x); \ |  |  |  |     SAYF(cLRD "\n[-] " cRST x); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(cRST "\n"); \ |  |  |  |     SAYF(cRST "\n"); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Die with a verbose non-OS fatal error message. */ |  |  |  | // 以详细非操作系统致命错误消息退出程序
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define FATAL(x...) do { \ |  |  |  | #define FATAL(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \ |  |  |  |     SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \ | 
			
		
	
		
		
			
				
					
					|  |  |  |          cBRI x); \ |  |  |  |          cBRI x); \ | 
			
		
	
	
		
		
			
				
					|  |  | @ -211,8 +207,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |     exit(1); \ |  |  |  |     exit(1); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Die by calling abort() to provide a core dump. */ |  |  |  | // 通过调用abort()退出程序,以便提供core dump
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define ABORT(x...) do { \ |  |  |  | #define ABORT(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \ |  |  |  |     SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \ | 
			
		
	
		
		
			
				
					
					|  |  |  |          cBRI x); \ |  |  |  |          cBRI x); \ | 
			
		
	
	
		
		
			
				
					|  |  | @ -221,8 +216,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |     abort(); \ |  |  |  |     abort(); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Die while also including the output of perror(). */ |  |  |  | // 以包含perror()输出的方式退出程序
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define PFATAL(x...) do { \ |  |  |  | #define PFATAL(x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     fflush(stdout); \ |  |  |  |     fflush(stdout); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-]  SYSTEM ERROR : " \ |  |  |  |     SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-]  SYSTEM ERROR : " \ | 
			
		
	
	
		
		
			
				
					|  |  | @ -233,16 +227,12 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |     exit(1); \ |  |  |  |     exit(1); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Die with FAULT() or PFAULT() depending on the value of res (used to
 |  |  |  | // 根据res的值调用FAULT()或PFAULT(),用于解释read()、write()等的不同失败模式
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |    interpret different failure modes for read(), write(), etc). */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define RPFATAL(res, x...) do { \ |  |  |  | #define RPFATAL(res, x...) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (res < 0) PFATAL(x); else FATAL(x); \ |  |  |  |     if (res < 0) PFATAL(x); else FATAL(x); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |   } while (0) |  |  |  |   } while (0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /* Error-checking versions of read() and write() that call RPFATAL() as
 |  |  |  | // 定义ck_write和ck_read宏,用于检查write和read操作是否成功,并在失败时调用RPFATAL
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |    appropriate. */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #define ck_write(fd, buf, len, fn) do { \ |  |  |  | #define ck_write(fd, buf, len, fn) do { \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     u32 _len = (len); \ |  |  |  |     u32 _len = (len); \ | 
			
		
	
		
		
			
				
					
					|  |  |  |     s32 _res = write(fd, buf, _len); \ |  |  |  |     s32 _res = write(fd, buf, _len); \ | 
			
		
	
	
		
		
			
				
					|  |  | 
 |