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.

224 lines
9.5 KiB

  1. /*++ BUILD Version: 0002 // Increment this if a change has global effects
  2. /****************************************************************************/
  3. /* */
  4. /* GRPTOREG.H - */
  5. /* */
  6. /* Include for the conversion of group files (.grp) to the registry. */
  7. /* Extracted from progman.h. */
  8. /* */
  9. /* Created: 4/10/92 JohanneC */
  10. /* */
  11. /****************************************************************************/
  12. #include <setjmp.h>
  13. #include <windows.h>
  14. #ifndef RC_INVOKED
  15. #include <port1632.h>
  16. #endif
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <errno.h>
  20. #include <ctype.h>
  21. #include <string.h>
  22. #include <io.h>
  23. #include <fcntl.h>
  24. /*--------------------------------------------------------------------------*/
  25. /* */
  26. /* Typedefs */
  27. /* */
  28. /*--------------------------------------------------------------------------*/
  29. typedef struct tagITEM {
  30. struct tagITEM *pNext; /* link to next item */
  31. int iItem; /* index in group */
  32. DWORD dwDDEId; /* id used for Apps querying Progman */
  33. /* for its properties via DDE */
  34. RECT rcIcon; /* icon rectangle */
  35. HICON hIcon; /* the actual icon */
  36. RECT rcTitle; /* title rectangle */
  37. } ITEM, *PITEM;
  38. typedef struct tagGROUP {
  39. struct tagGROUP *pNext; /* link to next group */
  40. HWND hwnd; /* hwnd of group window */
  41. HANDLE hGroup; /* global handle of group object */
  42. PITEM pItems; /* pointer to first item */
  43. LPSTR lpKey; /* name of group key */
  44. WORD wIndex; /* index in PROGMAN.INI of group */
  45. BOOL fRO; /* group file is readonly */
  46. FILETIME ftLastWriteTime;
  47. HBITMAP hbm; /* bitmap 'o icons */
  48. WORD fLoaded;
  49. } GROUP, *PGROUP;
  50. /*
  51. * .GRP File format structures -
  52. */
  53. typedef struct tagGROUPDEF {
  54. DWORD dwMagic; /* magical bytes 'PMCC' */
  55. WORD wCheckSum; /* adjust this for zero sum of file */
  56. WORD cbGroup; /* length of group segment */
  57. RECT rcNormal; /* rectangle of normal window */
  58. POINT ptMin; /* point of icon */
  59. WORD nCmdShow; /* min, max, or normal state */
  60. WORD pName; /* name of group */
  61. /* these four change interpretation */
  62. WORD cxIcon; /* width of icons */
  63. WORD cyIcon; /* hieght of icons */
  64. WORD wIconFormat; /* planes and BPP in icons */
  65. WORD wReserved; /* This word is no longer used. */
  66. WORD cItems; /* number of items in group */
  67. WORD rgiItems[1]; /* array of ITEMDEF offsets */
  68. } GROUPDEF, *PGROUPDEF;
  69. typedef GROUPDEF *LPGROUPDEF;
  70. //
  71. // New format for UNICODE groups for Windows NT 1.0a
  72. //
  73. typedef struct tagGROUPDEF_U {
  74. DWORD dwMagic; /* magical bytes 'PMCC' */
  75. DWORD cbGroup; /* length of group segment */
  76. RECT rcNormal; /* rectangle of normal window */
  77. POINT ptMin; /* point of icon */
  78. WORD wCheckSum; /* adjust this for zero sum of file */
  79. WORD nCmdShow; /* min, max, or normal state */
  80. DWORD pName; /* name of group */
  81. /* these four change interpretation */
  82. WORD cxIcon; /* width of icons */
  83. WORD cyIcon; /* hieght of icons */
  84. WORD wIconFormat; /* planes and BPP in icons */
  85. WORD wReserved; /* This word is no longer used. */
  86. WORD cItems; /* number of items in group */
  87. WORD Reserved1;
  88. DWORD Reserved2;
  89. DWORD rgiItems[1]; /* array of ITEMDEF offsets */
  90. } GROUPDEF_U, *PGROUPDEF_U;
  91. typedef GROUPDEF_U *LPGROUPDEF_U;
  92. /* the pointers in the above structures are short pointers relative to the
  93. * beginning of the segments. This macro converts the short pointer into
  94. * a long pointer including the proper segment/selector value. It assumes
  95. * that its argument is an lvalue somewhere in a group segment, for example,
  96. * PTR(lpgd->pName) returns a pointer to the group name, but k=lpgd->pName;
  97. * PTR(k) is obviously wrong as it will use either SS or DS for its segment,
  98. * depending on the storage class of k.
  99. */
  100. #define PTR(base, offset) (LPSTR)((PBYTE)base + offset)
  101. /*--------------------------------------------------------------------------*/
  102. /* */
  103. /* Tag Stuff */
  104. /* */
  105. /*--------------------------------------------------------------------------*/
  106. typedef struct _tag
  107. {
  108. WORD wID; // tag identifier
  109. WORD dummy1; // need this for alignment!
  110. int wItem; // (unde the covers 32 bit point!)item the tag belongs to
  111. WORD cb; // size of record, including id and count
  112. WORD dummy2; // need this for alignment!
  113. BYTE rgb[1];
  114. } PMTAG, FAR * LPPMTAG;
  115. #define TAG_MAGIC GROUP_MAGIC
  116. /* range 8000 - 80FF > global
  117. * range 8100 - 81FF > per item
  118. * all others reserved
  119. */
  120. #define ID_MAGIC 0x8000
  121. /* data: the string 'TAGS'
  122. */
  123. #define ID_LASTTAG 0xFFFF
  124. /* the last tag in the file
  125. */
  126. /*--------------------------------------------------------------------------*/
  127. /* */
  128. /* Defines */
  129. /* */
  130. /*--------------------------------------------------------------------------*/
  131. /* magic number for .GRP file validation
  132. */
  133. #define GROUP_MAGIC 0x43434D50L /* 'PMCC' */
  134. #define GROUP_UNICODE 0x43554D50L /* 'PMUC' */
  135. #define CCHGROUP 5 // length of the string "Group"
  136. #define CGROUPSMAX 40 // The max number of groups allowed.
  137. #define MAXGROUPNAMELEN 30
  138. #define MAX_MESSAGE_LENGTH 100
  139. /*--------------------------------------------------------------------------*/
  140. /* */
  141. /* Globals */
  142. /* */
  143. /*--------------------------------------------------------------------------*/
  144. BOOL bMinOnRun = FALSE;
  145. BOOL bArranging = FALSE;
  146. BOOL bAutoArrange = FALSE;
  147. BOOL bSaveSettings = TRUE;
  148. BOOL fNoRun = FALSE;
  149. BOOL fNoClose = FALSE;
  150. BOOL fNoSave = FALSE;
  151. BOOL fNoFileMenu = FALSE;
  152. DWORD dwEditLevel = 0;
  153. char szINIFile[] = "PROGMAN.INI";
  154. char szNULL[] = "";
  155. char szStartup[] = "startup";
  156. char szGroups[] = "UNICODE Groups";
  157. char szOrder[] = "UNICODE Order";
  158. char szWindow[] = "Window";
  159. char szAutoArrange[] = "AutoArrange";
  160. char szSaveSettings[] = "SaveSettings";
  161. char szMinOnRun[] = "MinOnRun";
  162. char szSettings[] = "Settings";
  163. char szNoRun[] = "NoRun";
  164. char szNoClose[] = "NoClose";
  165. char szEditLevel[] = "EditLevel";
  166. char szRestrict[] = "Restrictions";
  167. char szNoFileMenu[] = "NoFileMenu";
  168. char szNoSave[] = "NoSaveSettings";
  169. char szSystemBoot[] = "Boot";
  170. char szSystemDisplay[] = "display.drv";
  171. char szPMWindowSetting[160];
  172. char szStartupGroup[MAXGROUPNAMELEN+1];
  173. char szGroupsOrder[CGROUPSMAX*3+7];
  174. WORD pGroupIndexes[CGROUPSMAX+1];
  175. CHAR szProgramManager[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Program Manager"; // registry key for groups
  176. CHAR szProgramGroups[] = "UNICODE Program Groups"; // registry key for groups
  177. CHAR szCommonGroups[] = "SOFTWARE\\Program Groups"; // registry key for common groups
  178. CHAR szMessage[MAX_MESSAGE_LENGTH];
  179. BOOL bNoError = TRUE;
  180. HKEY hkeyCommonGroups = NULL;
  181. HKEY hkeyProgramGroups = NULL;
  182. HKEY hkeyProgramManager = NULL;
  183. HKEY hkeyPMSettings = NULL;
  184. HKEY hkeyPMRestrict = NULL;
  185. HKEY hkeyPMGroups = NULL;
  186. SECURITY_ATTRIBUTES PGrpSecAttr; // for personal groups
  187. PSECURITY_ATTRIBUTES pPGrpSecAttr = NULL;
  188. SECURITY_ATTRIBUTES CGrpSecAttr; // for common groups
  189. PSECURITY_ATTRIBUTES pCGrpSecAttr = NULL;
  190. #include "secdesc.h"
  191. #include "security.h"