home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / os2 / vmm / vmm.h < prev    next >
C/C++ Source or Header  |  1999-05-11  |  14KB  |  310 lines

  1. /*static char *SCCSID = "@(#)vmm.h      6.16 92/02/18";*/
  2. /*==============================================================*\
  3.  *                                                              *
  4.  *  VMM.H - Sample PM application header file                   *
  5.  *      (C) Copyright IBM Corporation 1992                      *
  6.  *                                                              *
  7.  *--------------------------------------------------------------*
  8.  *                                                              *
  9.  *  This header file contains the application wide constants    *
  10.  *  and structure definitions.                                  *
  11.  *                                                              *
  12. \*==============================================================*/
  13. /*--------------------------------------------------------------*\
  14.  *  Include files, macros, defined constants, and externs       *
  15. \*--------------------------------------------------------------*/
  16. #define  INCL_WIN
  17. #define  INCL_HELP
  18. #define  INCL_WINDIALOGS
  19. #define  INCL_WINMENU
  20. #define  INCL_GPI
  21. #define  INCL_DOSEXCEPTIONS
  22. #define  INCL_DOSPROCESS
  23. #define  INCL_DOSSIGNALS
  24. #define  INCL_DOSMISC
  25. #define  INCL_DOSMEMMGR
  26. #define  INCL_DOSERRORS
  27. #include <os2.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31.  
  32. /*--------------------------------------------------------------*\
  33.  * Resource IDs                                                 *
  34. \*--------------------------------------------------------------*/
  35. #define IDR_RESOURCE                        1000  /* resource identifier */
  36. #define ID_NULL                               -1
  37. #define IDR_BITMAP                             2
  38. #define IDC_BITMAP                             3
  39.  
  40. /*--------------------------------------------------------------*\
  41.  *  Menu item ids                                               *
  42. \*--------------------------------------------------------------*/
  43. #define IDM_VMMALLOC                        1011
  44. #define IDM_VMMFREE                         1012
  45. #define IDM_VMMSET                          1013
  46. #define IDM_VMMWRITE                        1014
  47. #define IDM_VMMREAD                         1015
  48. #define IDM_MSGBOX                          1016
  49.  
  50. #define IDM_HELPINDEX                       1020
  51. #define IDM_GENERALHELP                     1021
  52. #define IDM_TUTORIAL                        1022
  53. #define IDM_USINGHELP                       1023
  54. #define IDM_HELPPRODUCTINFO                 1024
  55.  
  56. /*--------------------------------------------------------------*\
  57.  *  Help table and subtables                                    *
  58. \*--------------------------------------------------------------*/
  59. #define VMM_HELP_TABLE                      4000
  60.  
  61. /*--------------------------------------------------------------*\
  62.  *  Main window help panels                                     *
  63. \*--------------------------------------------------------------*/
  64. #define SUBTABLE_MAIN                       4100
  65. #define PANEL_MAIN                          4110
  66. #define PANEL_HELP                          4120
  67. #define PANEL_GENERALHELP                   4130
  68. #define PANEL_USINGHELP                     4140
  69. #define PANEL_TUTORIAL                      4150
  70. #define PANEL_HELPINDEX                     4160
  71. #define PANEL_HELPPRODUCTINFO               4170
  72. #define PANEL_KEYSHELP                      4180
  73.  
  74. #define PANEL_HELPALLOC                     4190
  75. #define PANEL_HELPFREE                      4191
  76. #define PANEL_HELPSET                       4192
  77. #define PANEL_HELPWRITE                     4193
  78. #define PANEL_HELPREAD                      4194
  79.  
  80. /*--------------------------------------------------------------*\
  81.  *  Enter text dialog help subtable                             *
  82. \*--------------------------------------------------------------*/
  83. #define SUBTABLE_PRODUCTINFODLG             4200
  84. #define PANEL_PRODUCTINFODLG                4210
  85. #define PANEL_PRODUCTINFO_OK                4220
  86.  
  87. #define SUBTABLE_ALLOCBOXDLG                4230
  88. #define PANEL_ALLOCBOXDLG                   4231
  89. #define PANEL_ALLOCBOX_OK                   4232
  90.  
  91. #define SUBTABLE_SETBOXDLG                  4235
  92. #define PANEL_SETBOXDLG                     4236
  93. #define PANEL_SETBOX_OK                     4237
  94.  
  95. /*--------------------------------------------------------------*\
  96.  *  Stringtable ids                                             *
  97. \*--------------------------------------------------------------*/
  98.          /* for help menu module */
  99. #define IDS_APPNAME                          101
  100. #define IDS_HELPLIBRARYNAME                  102
  101. #define IDS_HELPWINDOWTITLE                  103
  102. #define IDS_TITLE                            104
  103. #define IDS_UNTITLED                         105
  104.  
  105. /*--------------------------------------------------------------*\
  106.  *  Message item ids
  107. \*--------------------------------------------------------------*/
  108. #define IDD_PRODUCTINFO                      152
  109. #define IDD_EDITTEXT                         153
  110. #define IDD_EDITSIZE                         154
  111. #define IDD_EDITUNIT                         155
  112. #define IDD_ACCESS                           156
  113. #define IDD_READ                             157
  114. #define IDD_WRITE                            158
  115. #define IDD_EXECUTE                          159
  116. #define IDD_GUARD                            160
  117. #define IDD_ATTRIBUTES                       161
  118. #define IDD_TILE                             162
  119. #define IDD_COMMIT                           163
  120. #define IDD_DECOMMIT                         164
  121. #define IDD_DEFAULT                          165
  122.  
  123. #define IDD_ALLOCMEM                         166
  124. #define IDD_SETMEM1                          167
  125. #define IDD_SETMEM2                          168
  126. #define IDD_FREEMEM                          169
  127. #define IDD_WRITEMEM                         170
  128. #define IDD_READMEM                          171
  129. #define IDD_ADDRESS                          172
  130. #define IDD_ADDRESSTEXT                      173
  131. #define IDD_DATA                             174
  132. #define IDD_TITLE                            175
  133.  
  134. /*--------------------------------------------------------------*\
  135.  *  Messagetable ids                                            *
  136. \*--------------------------------------------------------------*/
  137. #define IDMSG_INITFAILED                     301
  138. #define IDMSG_MAINWINCREATEFAILED            302
  139. #define IDMSG_CANNOTGETHPS                   303
  140. #define IDMSG_CANNOTLOADSTRING               304
  141. #define IDMSG_CANNOTLOADEXITLIST             305
  142. #define IDMSG_HELPLOADERROR                  306
  143. #define IDMSG_HELPDISPLAYERROR               307
  144. #define IDMSG_ACCESSGUARDPAGE                308
  145. #define IDMSG_COMMITTTOWRITE                 309
  146. #define IDMSG_PROTECTIONERROR                310
  147. #define IDMSG_SUCCESSFREE                    311
  148. #define IDMSG_UNSETREADERROR                 312
  149. #define IDMSG_UNSETREADERROR2                313
  150. #define IDMSG_ERRORADDRESS                   314
  151.  
  152. /*--------------------------------------------------------------*\
  153.  *  Error Constants                                             *
  154. \*--------------------------------------------------------------*/
  155. #define VMERR_MAX_ALLOCATED             0xFF10
  156. #define VMERR_ZERO_ALLOCATED            0xFF11
  157. #define VMERR_TILE_ONLY                 0xFF12
  158. #define VMERR_COMMIT_AND_TILE_ONLY      0xFF13
  159. #define VMERR_ALREADY_FREED             0xFF20
  160. #define VMERR_NOT_BASEPAGE              0xFF21
  161. #define VMERR_DECOMMIT_RESERVED         0xFF30
  162. #define VMERR_ACCESS_AND_DECOMMIT       0xFF31
  163. #define VMERR_ACCESS_ON_RESERVED        0xFF32
  164. #define VMERR_COMMIT_ON_COMMITTED       0xFF33
  165. #define VMERR_COMMIT_ONLY               0xFF34
  166. #define VMERR_SET_NO_PARMS              0xFF35
  167. #define VMERR_SET_ZERO_SIZE             0xFF36
  168. #define VMERR_SET_ON_FREE               0xFF37
  169. #define VMERR_DEFAULT                   0xFFFF
  170.  
  171. /*--------------------------------------------------------------*\
  172.  *  Other constants                                             *
  173. \*--------------------------------------------------------------*/
  174. #define MAXTEXTLEN               40    /* maximum text length for window */
  175. #define HELPLIBRARYNAMELEN       20    /* The length of library name     */
  176. #define MESSAGELEN              150       /* maximum length for messages */
  177. #define MAXAPPNAMELEN            15
  178. #define MAXPAGES                 10
  179. #define PAGESIZE               4096
  180. #define BUFF_SIZE               200 /* size of buffers for various stuff */
  181. #define MAXHOSIZE               256   /* siae of buffers for dlgbox text */
  182.        /* size and positioning of boxes in 0.1 millimeters (PU_LOMETRIC) */
  183. #define BOX_WIDTH               450
  184. #define BOX_HEIGHT              180
  185. #define SMALL_BOX_HEIGHT         90
  186. #define VERT_INDENT              30
  187. #define HORZ_INDENT              30
  188. #define HORZ_SPACING             50
  189. #define VERT_SPACING             50
  190.  
  191. #define RETURN_SUCCESS            0      /* successful return in DosExit */
  192. #define RETURN_ERROR              1           /* error return in DosExit */
  193. #define BEEP_WARN_FREQ           60         /* frequency of warning beep */
  194. #define BEEP_WARN_DUR           100          /* duration of warning beep */
  195. #define MAX_EDIT_BUFF            21    /* length of string to query size */
  196.  
  197. #define SZDEFAULT_SIZE          "1"       /* default number of bytes to set
  198.                      attributes for when setting attributes of a block, this
  199.                         will cause the attributes to be set for one page */
  200.  
  201. /*--------------------------------------------------------------*\
  202.  *  Data structures and typedefs                                *
  203. \*--------------------------------------------------------------*/
  204. struct _WINDOWDATA  {
  205.     LONG clrFore;
  206.     LONG clrBack;
  207.     UCHAR *szText[MAXTEXTLEN + 1];
  208. };
  209.  
  210. typedef struct _OBJSTRUCT{
  211.     ULONG ulSize;
  212.     ULONG ulAttr;
  213.     PVOID pvAddress;
  214.     } OBJSTRUCT;
  215.  
  216. typedef OBJSTRUCT FAR * POBJSTRUCT;
  217.  
  218. typedef struct _WINDOWDATA WINDOWDATA;
  219. /* hungarian notation: wdata */
  220. typedef WINDOWDATA * PWINDOWDATA;
  221.  
  222. typedef struct _PAGEENTRY {
  223.     PVOID   pvAddress;
  224.     BOOL    fBaseAddr;
  225.     } PAGEENTRY;
  226. /* hungarian notation: pgentry */
  227.  
  228. typedef struct _MSGENTRY {
  229.     ULONG   ulMsgNum;
  230.     CHAR    szMsgText[BUFF_SIZE];
  231.     USHORT  usMsgIcon;
  232.     } MSGENTRY;
  233. /* hungarian notation: msgentry */
  234.  
  235. /*--------------------------------------------------------------*\
  236.  *  Global variables                                            *
  237. \*--------------------------------------------------------------*/
  238. CHAR  szWindowText[MAXTEXTLEN];                  /* text drawn in window */
  239. HWND  hwndMainFrame;                  /* handle to the main frame window */
  240. HWND  hwndMain;                      /* handle to the main client window */
  241. HWND  hwndVscroll;                  /* handle to the vertical scroll bar */
  242. HAB   hab;                               /* anchor block for the process */
  243. HMQ   hmq;                       /* handle to the process' message queue */
  244. CHAR  szAppName[MAXAPPNAMELEN];    /* buffer for application name string */
  245. ULONG       ulFreePage;        /* First free page entry in array; same as
  246.                                   the number of data pages existed       */
  247. CHAR        szBuffer[BUFF_SIZE];
  248. OBJSTRUCT   ObjAlloc;
  249. CHAR        szUntitled[MESSAGELEN];      /* buffer for "Untitled" string */
  250.       /* for help menu module */
  251. BOOL   fHelpEnabled;             /* flag to determine if help is enabled */
  252. static CHAR szLibName[HELPLIBRARYNAMELEN];
  253. static CHAR szWindowTitle[HELPLIBRARYNAMELEN];
  254. static HWND hwndHelpInstance;
  255. static LONG sVscrollPos;
  256. PAGEENTRY   apgentry[MAXPAGES];                /* Application page table */
  257.  
  258. /*--------------------------------------------------------------*\
  259.  *  Entry point declarations                                    *
  260. \*--------------------------------------------------------------*/
  261. /* from vmm_main.c */
  262. INT     main(VOID);
  263. ULONG   GPFHandler(PEXCEPTIONREPORTRECORD);
  264. VOID    MessageBox(HWND, LONG, PSZ, LONG, BOOL);
  265. MRESULT EXPENTRY MainWndProc(HWND, ULONG, MPARAM, MPARAM);
  266. VOID    MainCommand(MPARAM, MPARAM);
  267. VOID    MainPaint(HWND);
  268. VOID    DisplayPage(HPS, PPOINTL, ULONG);
  269. VOID    EnableMenuItem(HWND, LONG, BOOL);
  270.  
  271. /* from vmm_init.c */
  272. BOOL Init(VOID);
  273. VOID APIENTRY ExitProc(ULONG);
  274.  
  275. /* from vmm_user.c */
  276. VOID UserCommand(MPARAM, MPARAM);
  277. VOID VMM_Error(PSZ, ULONG);
  278. VOID CleanUpArray(PVOID);
  279. VOID StoreInArray(PVOID, ULONG);
  280.  
  281.       /* for help menu module */
  282. VOID  InitHelp(VOID);
  283. VOID  HelpHelpForHelp(MPARAM);
  284. VOID  HelpExtended(MPARAM);
  285. VOID  HelpKeys(MPARAM);
  286. VOID  HelpIndex(MPARAM);
  287. VOID  HelpAbout(MPARAM);
  288. VOID  DisplayHelpPanel(LONG);
  289. VOID  DestroyHelpInstance(VOID);
  290. VOID  FixSysMenu(HWND);
  291. MRESULT EXPENTRY AboutDlgProc(HWND, ULONG, MPARAM, MPARAM);
  292.  
  293. /* from vmm_dlg.c */
  294. MRESULT EXPENTRY AllocMemDlgProc(HWND, ULONG, MPARAM, MPARAM);
  295. MRESULT EXPENTRY SetMem1DlgProc( HWND, ULONG, MPARAM, MPARAM);
  296. MRESULT EXPENTRY SetMem2DlgProc( HWND, ULONG, MPARAM, MPARAM);
  297. MRESULT EXPENTRY ReadMemDlgProc( HWND, ULONG, MPARAM, MPARAM);
  298. MRESULT EXPENTRY WriteMemDlgProc(HWND, ULONG, MPARAM, MPARAM);
  299. MRESULT EXPENTRY FreeMemDlgProc( HWND, ULONG, MPARAM, MPARAM);
  300.  
  301. #ifndef max
  302. #define max(a,b) (((a) > (b))?(a):(b))
  303. #endif
  304.  
  305. #ifndef min
  306. #define min(a,b) (((a) < (b))?(a):(b))
  307. #endif
  308.  
  309. #define     VER630
  310.