Leaked source code of windows server 2003
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.

219 lines
7.3 KiB

  1. #ifdef __cplusplus
  2. extern "C" {
  3. #endif
  4. // comtutil.h
  5. // ioctl.h
  6. // product_id codes
  7. #define PRODUCT_UNKNOWN 0
  8. #define NT_VS1000 1
  9. #define NT_ROCKET 2
  10. #define NT_RPSHSI 3
  11. //---------------
  12. // we setup our structure arrays with one of these things at the
  13. // foot of the array as a standard header. When we request data
  14. // from the driver, this tells the driver what structure type and
  15. // size follows.
  16. typedef struct
  17. {
  18. ULONG struct_type;
  19. ULONG struct_size;
  20. ULONG num_structs;
  21. ULONG var1; // reserve
  22. } PortMonBase;
  23. typedef struct
  24. {
  25. DWORD PlatformId; // ioctl_open() will set this up.
  26. ULONG ctl_code; // ioctl_open() will set this up.
  27. HANDLE hcom; // handle to driver for ioctl calls. ioctl_open sets up.
  28. TCHAR *driver_name; // ioctl_open() will set this up.
  29. int product_id; // ioctl_open() will set this up.
  30. PortMonBase *pm_base; // base ptr to data buffer header
  31. // application needs to set this up prior to call.
  32. int buf_size; // byte size of buffer data to send/rec to/from driver
  33. // application needs to set this up prior to call.
  34. int ret_bytes; // number of bytes returned from call into driver.
  35. // includes size of pmn header
  36. } IoctlSetup;
  37. //#define IOCTL_DEVSTAT 9 // device/link status(not used anymore)
  38. #define IOCTL_PORTNAMES 10 // name array [12] bytes
  39. #define IOCTL_PORTSTATUS 11 // port stats, array
  40. #define IOCTL_DEBUGLOG 13 // driver debug log
  41. #define IOCTL_OPTION 14 // option setup
  42. #define IOCTL_MACLIST 15 // mac-scan list
  43. #define IOCTL_NICSTAT 16 // nic status
  44. #define IOCTL_DEVICESTAT 17 // device/link status
  45. #define IOCTL_KICK_START 18 // get system going
  46. #define IOCTL_PORT_RESET 19 // port reset -- mkm --
  47. //---------------
  48. // we get the port names from the driver once at startup.
  49. typedef struct
  50. {
  51. char port_name[12]; // port name(0=end of port list),("."=not assigned)
  52. } PortMonNames;
  53. //---------------
  54. // this is the raw data we continually get from from the driver.
  55. typedef struct
  56. {
  57. DWORD TxTotal; // total number of sent bytes
  58. DWORD RxTotal; // total number of receive bytes
  59. WORD TxPkts; // number of write() packets
  60. WORD RxPkts; // number of read() packets
  61. WORD overrun_errors; // receive over-run errors
  62. WORD framing_errors; // receive framing errors
  63. WORD parity_errors; // receive parity errors
  64. WORD status_flags; // opened/close, flow-ctrl, out/in pin signals, etc
  65. } PortMonStatus;
  66. int APIENTRY ioctl_call(IoctlSetup *ioctl_setup);
  67. int APIENTRY ioctl_open(IoctlSetup *ioctl_setup, int product_id);
  68. #define ioctl_close(_ioctl_setup) \
  69. { if ((_ioctl_setup)->hcom != NULL) \
  70. CloseHandle((_ioctl_setup)->hcom); }
  71. // reg.h
  72. int APIENTRY reg_key_exists(HKEY handle, const TCHAR * keystr);
  73. int APIENTRY reg_create_key(HKEY handle, const TCHAR * keystr);
  74. int APIENTRY reg_set_str(HKEY handle,
  75. const TCHAR * child_key,
  76. const TCHAR * str_id,
  77. const char *src,
  78. int str_type); // REG_SZ, REG_EXPAND_SZ
  79. int APIENTRY reg_set_dword_del(HKEY handle,
  80. const TCHAR * child_key,
  81. const TCHAR * str_id,
  82. DWORD new_value,
  83. DWORD del_value);
  84. int APIENTRY reg_delete_key(HKEY handle,
  85. const TCHAR * child_key,
  86. const TCHAR * str_id);
  87. int APIENTRY reg_delete_value(HKEY handle,
  88. const TCHAR * child_key,
  89. const TCHAR * str_id);
  90. int APIENTRY reg_set_dword(HKEY handle,
  91. const TCHAR * child_key,
  92. const TCHAR * str_id,
  93. DWORD new_value);
  94. int APIENTRY reg_get_str(HKEY handle,
  95. const TCHAR * child_key,
  96. const TCHAR * str_id,
  97. char *dest,
  98. int str_len);
  99. int APIENTRY reg_get_dword(HKEY handle,
  100. const TCHAR * child_key,
  101. const TCHAR * str_id,
  102. DWORD *dest);
  103. int APIENTRY reg_open_key(HKEY handle,
  104. HKEY *new_handle,
  105. const TCHAR *keystr,
  106. DWORD attribs); // KEY_READ, KEY_ALL_ACCESS
  107. #define reg_close_key(handle) \
  108. { if (handle) {RegCloseKey(handle); handle = NULL;} }
  109. //----- setuppm.h
  110. int APIENTRY make_progman_group(char **list,char *dest_dir);
  111. int APIENTRY delete_progman_group(char **list, char *dest_dir);
  112. //---- cutil.h
  113. #define D_Error 0x00001
  114. #define D_Warn 0x00002
  115. #define D_Init 0x00004
  116. #define D_Test 0x00008
  117. #if DBG
  118. extern int DebugLevel;
  119. #define DbgPrintf(_Mask_,_Msg_) \
  120. { if (_Mask_ & DebugLevel) { OurDbgPrintf _Msg_;} }
  121. #define DbgPrint(s) OutputDebugString(s)
  122. #else
  123. #define DbgPrintf(_Mask_,_Msg_)
  124. #define DbgPrint(s)
  125. #endif
  126. void APIENTRY ascii_string(unsigned char *str);
  127. void APIENTRY normalize_string(char *str);
  128. int APIENTRY getstr(char *instr, char *outstr, int max_size);
  129. int APIENTRY getnumbers(char *str, int *nums, int max_nums);
  130. int APIENTRY listfind(char *str, char **list);
  131. int APIENTRY my_lstricmp(char *str1, char *str2);
  132. int APIENTRY my_substr_lstricmp(char far *str1, char far *str2);
  133. int APIENTRY getint(char *textptr, int *countptr);
  134. unsigned int APIENTRY gethint(char *bufptr, int *countptr);
  135. int APIENTRY my_toupper(int c);
  136. int APIENTRY my_lstrimatch(char *find_str, char *str_to_search);
  137. void APIENTRY OurDbgPrintf(TCHAR *format, ...);
  138. // ourfile.h
  139. typedef struct {
  140. HANDLE hfile;
  141. ULONG dwDesiredAccess;
  142. ULONG dwCreation;
  143. int flags; // 1h = eof, 2=error
  144. } OUR_FILE;
  145. void APIENTRY our_remove(TCHAR *name);
  146. OUR_FILE * APIENTRY our_fopen(TCHAR *name, char *attr);
  147. void APIENTRY our_fclose(OUR_FILE *fp);
  148. int APIENTRY our_feof(OUR_FILE *fp);
  149. int APIENTRY our_ferror(OUR_FILE *fp);
  150. unsigned int APIENTRY our_fseek(OUR_FILE *fp, int pos, int relative);
  151. void APIENTRY our_fputs(char *str, OUR_FILE *fp);
  152. char * APIENTRY our_fgets(char *str, int maxlen, OUR_FILE *fp);
  153. int APIENTRY our_fwrite(void *buffer, int size, int count, OUR_FILE *fp);
  154. int APIENTRY our_fread(void *buffer, int size, int count, OUR_FILE *fp);
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #ifdef __cplusplus
  159. // ttywin.h
  160. /* text window memory */
  161. #define TROWS 35
  162. #define TCOLS 86
  163. class TTYwin {
  164. public:
  165. HWND hwnd; // handle of our port window
  166. HFONT hfont;
  167. TCHAR text_buf[TROWS+2][TCOLS+3];
  168. int screen_update_flag; // need to update the screen.
  169. int display_cur_row;
  170. int cur_row;
  171. int cur_col;
  172. int scr_size_x;
  173. int scr_size_y;
  174. int show_crlf;
  175. int caret_on;
  176. unsigned long text_color;
  177. HBRUSH hbrush_window; // for painting background
  178. TTYwin();
  179. ~TTYwin();
  180. void TTYwin::init(HWND owner_hwnd);
  181. void TTYwin::set_color(int color_rgb);
  182. void TTYwin::set_size(int x, int y);
  183. void TTYwin::show_caret(int on);
  184. void TTYwin::mess_str(TCHAR *str, int len=0);
  185. void TTYwin::update_screen(int all_flag);
  186. void TTYwin::mess_line(TCHAR *str, int line_num);
  187. void TTYwin::mess_num(int num);
  188. void TTYwin::clear_scr(void);
  189. };
  190. #endif