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.

328 lines
6.5 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. Demoapp.h
  5. Abstract:
  6. Contains constants, function prototypes, and
  7. structures used by both applications.
  8. Notes:
  9. ANSI only - must run on Win9x.
  10. History:
  11. 01/30/01 rparsons Created
  12. 01/10/02 rparsons Revised
  13. 02/13/02 rparsons Use strsafe functions
  14. --*/
  15. #include <windows.h>
  16. #include <winspool.h>
  17. #include <commdlg.h>
  18. #include <shellapi.h>
  19. #include <process.h>
  20. #include <shlwapi.h>
  21. #include <shlobj.h>
  22. #include <stdio.h>
  23. #include "splash.h"
  24. #include "registry.h"
  25. #include "progress.h"
  26. #include "shortcut.h"
  27. #include "badfunc.h"
  28. #include "dialog.h"
  29. #include "resource.h"
  30. //
  31. // Everything we do will be in cch not in cb.
  32. //
  33. #define STRSAFE_NO_CB_FUNCTIONS
  34. #include <strsafe.h>
  35. //
  36. // Application titles and classes.
  37. //
  38. #define MAIN_APP_TITLE "Application Compatibility Demo"
  39. #define SETUP_APP_TITLE "Application Compatibility Demo Setup"
  40. #define MAIN_APP_CLASS "MAINAPP"
  41. #define SETUP_APP_CLASS "SETUPAPP"
  42. //
  43. // Our own control identifiers.
  44. //
  45. #define IDC_TIMER 100
  46. #define IDC_EDIT 1010
  47. //
  48. // Registry keys that we need to refer to.
  49. //
  50. #define REG_APP_KEY "Software\\Microsoft\\DemoApp"
  51. #define PRODUCT_OPTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\ProductOptions"
  52. #define CURRENT_VERSION_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
  53. //
  54. // The directory that we should install our files to.
  55. //
  56. #define COMPAT_DEMO_DIR "Compatibility Demo"
  57. //
  58. // Class for our extraction dialog.
  59. //
  60. #define DLGEXTRACT_CLASS "DLGEXTRACT"
  61. //
  62. // Custom menu items only displayed in 'extended' mode.
  63. //
  64. #define IDM_ACCESS_VIOLATION 5010
  65. #define IDM_EXCEED_BOUNDS 5011
  66. #define IDM_FREE_MEM_TWICE 5012
  67. #define IDM_FREE_INVALID_MEM 5013
  68. #define IDM_PRIV_INSTRUCTION 5014
  69. #define IDM_STACK_CORRUPTION 5015
  70. #define IDM_HEAP_CORRUPTION 5016
  71. //
  72. // Custom menu items only displayed in 'internal' mode.
  73. //
  74. #define IDM_PROPAGATION_TEST 6010
  75. //
  76. // Resource IDs for our bitmaps contained in demodll.dll.
  77. // Don't change!!!
  78. //
  79. #define IDB_XP_SPLASH_256 112
  80. #define IDB_XP_SPLASH 111
  81. #define IDB_W2K_SPLASH_256 106
  82. #define IDB_W2K_SPLASH 105
  83. //
  84. // Macros
  85. //
  86. #define MALLOC(h,s) HeapAlloc((h), HEAP_ZERO_MEMORY, (s))
  87. #define FREE(h,b) HeapFree((h), 0, (b))
  88. //
  89. // Function prototypes
  90. //
  91. void
  92. LoadFileIntoEditBox(
  93. void
  94. );
  95. void
  96. ShowSaveDialog(
  97. void
  98. );
  99. BOOL
  100. CenterWindow(
  101. IN HWND hWnd
  102. );
  103. void
  104. IsWindows9x(
  105. void
  106. );
  107. void
  108. IsWindowsXP(
  109. void
  110. );
  111. void
  112. DisplayFontDlg(
  113. IN HWND hWnd
  114. );
  115. BOOL
  116. CreateShortcuts(
  117. IN HWND hWnd
  118. );
  119. BOOL
  120. CopyAppFiles(
  121. IN HWND hWnd
  122. );
  123. BOOL
  124. DemoAppInitialize(
  125. IN LPSTR lpCmdLine
  126. );
  127. BOOL
  128. ModifyTokenPrivilege(
  129. IN LPCSTR lpPrivilege,
  130. IN BOOL fDisable
  131. );
  132. BOOL
  133. ShutdownSystem(
  134. IN BOOL fForceClose,
  135. IN BOOL fReboot
  136. );
  137. BOOL
  138. IsAppAlreadyInstalled(
  139. void
  140. );
  141. HWND
  142. CreateFullScreenWindow(
  143. void
  144. );
  145. HWND
  146. CreateExtractionDialog(
  147. IN HINSTANCE hInstance
  148. );
  149. UINT
  150. InitSetupThread(
  151. IN void* pArguments
  152. );
  153. BOOL
  154. InitMainApplication(
  155. IN HINSTANCE hInstance
  156. );
  157. BOOL
  158. InitSetupApplication(
  159. IN HINSTANCE hInstance
  160. );
  161. BOOL
  162. InitMainInstance(
  163. IN HINSTANCE hInstance,
  164. IN int nCmdShow
  165. );
  166. BOOL
  167. InitSetupInstance(
  168. IN HINSTANCE hInstance,
  169. IN int nCmdShow
  170. );
  171. LRESULT
  172. CALLBACK
  173. MainWndProc(
  174. IN HWND hWnd,
  175. IN UINT uMsg,
  176. IN WPARAM wParam,
  177. IN LPARAM lParam
  178. );
  179. LRESULT
  180. CALLBACK
  181. SetupWndProc(
  182. IN HWND hWnd,
  183. IN UINT uMsg,
  184. IN WPARAM wParam,
  185. IN LPARAM lParam
  186. );
  187. BOOL
  188. PrintDemoText(
  189. IN HWND hWnd,
  190. IN LPSTR lpTextOut
  191. );
  192. void
  193. AddExtendedItems(
  194. IN HWND hWnd
  195. );
  196. void
  197. AddInternalItems(
  198. IN HWND hWnd
  199. );
  200. void
  201. TestIncludeExclude(
  202. IN HWND hWnd
  203. );
  204. void
  205. AccessViolation(
  206. void
  207. );
  208. void
  209. ExceedArrayBounds(
  210. void
  211. );
  212. void
  213. FreeMemoryTwice(
  214. void
  215. );
  216. void
  217. FreeInvalidMemory(
  218. void
  219. );
  220. void
  221. PrivilegedInstruction(
  222. void
  223. );
  224. void
  225. HeapCorruption(
  226. void
  227. );
  228. void
  229. ExtractExeFromLibrary(
  230. IN DWORD cchSize,
  231. OUT LPSTR pszOutputFile
  232. );
  233. //
  234. // The number of files we're installing.
  235. //
  236. #define NUM_FILES 4
  237. //
  238. // The number of shortcuts we're creating.
  239. //
  240. #define NUM_SHORTCUTS (NUM_FILES - 1)
  241. //
  242. // Contains information about shortcuts to be created.
  243. //
  244. typedef struct _SHORTCUT {
  245. char szFileName[MAX_PATH]; // file name for shortcut
  246. char szDisplayName[MAX_PATH]; // display name for shortcut
  247. } SHORTCUT, *LPSHORTCUT;
  248. //
  249. // Contains all the information we'll need to access throughout the app.
  250. //
  251. typedef struct _APPINFO {
  252. HINSTANCE hInstance; // app instance handle
  253. HWND hWndExtractDlg; // extraction dialog handle
  254. HWND hWndMain; // main window handle
  255. HWND hWndEdit; // edit window handle
  256. BOOL fInternal; // indicates if internal behavior is enabled
  257. BOOL fInsecure; // indicates if we should do things that might not be secure
  258. BOOL fEnableBadFunc; // indicates if bad functionality should be enabled
  259. BOOL fRunApp; // indicates if we should run the app
  260. BOOL fClosing; // indicates if the app is closing
  261. BOOL fWin9x; // indicates if we're running on Win9x/ME (used internally)
  262. BOOL fWinXP; // indicates if we're running on XP (used internally)
  263. BOOL fExtended; // indicates if extended behavior is enabled
  264. UINT cFiles; // count of shortcuts to create
  265. char szDestDir[MAX_PATH]; // contains the full path where files will be stored
  266. char szCurrentDir[MAX_PATH]; // contains the path that we're currently running from
  267. char szWinDir[MAX_PATH]; // contains the path to %windir%
  268. char szSysDir[MAX_PATH]; // contains the path to %windir%\System(32)
  269. SHORTCUT shortcut[NUM_SHORTCUTS]; // struct that contains information about our shortcuts
  270. } APPINFO, *LPAPPINFO;