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.

306 lines
8.6 KiB

  1. //=--------------------------------------------------------------------------=
  2. // astextmn.cpp
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1996 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // various globals which the framewrk requires
  7. //
  8. //
  9. #include "asctlpch.h"
  10. #define INITOBJECTS // define the descriptions for our objects
  11. #include "ipserver.h"
  12. #include "localsrv.h"
  13. #include "ctrlobj.h"
  14. #include "globals.h"
  15. #include "util.h"
  16. #include "asinsctl.h"
  17. /// for safe scripting
  18. #include "cathelp.h"
  19. const IID IID_ICatRegister = {0x0002E012,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  20. const CATID CATID_SafeForScripting = {0x7dd95801,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
  21. const CATID CATID_SafeForInitializing = {0x7dd95802,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
  22. // needed for ASSERTs and FAIL
  23. //
  24. SZTHISFILE
  25. //=--------------------------------------------------------------------------=
  26. // our Libid. This should be the LIBID from the Type library, or NULL if you
  27. // don't have one.
  28. //
  29. const CLSID *g_pLibid = &LIBID_ASControls;
  30. //=--------------------------------------------------------------------------=
  31. // Localization Information
  32. //
  33. // We need the following two pieces of information:
  34. // a. whether or not this DLL uses satellite DLLs for localization. if
  35. // not, then the lcidLocale is ignored, and we just always get resources
  36. // from the server module file.
  37. // b. the ambient LocaleID for this in-proc server. Controls calling
  38. // GetResourceHandle() will set this up automatically, but anybody
  39. // else will need to be sure that it's set up properly.
  40. //
  41. const VARIANT_BOOL g_fSatelliteLocalization = FALSE;
  42. LCID g_lcidLocale = MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT);
  43. //=--------------------------------------------------------------------------=
  44. // your license key and where under HKEY_CLASSES_ROOT_LICENSES it's sitting
  45. //
  46. const WCHAR g_wszLicenseKey [] = L"";
  47. const WCHAR g_wszLicenseLocation [] = L"";
  48. WNDPROC g_ParkingWindowProc = NULL;
  49. //=--------------------------------------------------------------------------=
  50. // This Table describes all the automatible objects in your automation server.
  51. // See AutomationObject.H for a description of what goes in this structure
  52. // and what it's used for.
  53. //
  54. OBJECTINFO g_ObjectInfo[] = {
  55. CONTROLOBJECT(InstallEngineCtl),
  56. EMPTYOBJECT
  57. };
  58. const char g_szLibName[] = "ASControls";
  59. //=--------------------------------------------------------------------------=
  60. // IntializeLibrary
  61. //=--------------------------------------------------------------------------=
  62. // called from DllMain:DLL_PROCESS_ATTACH. allows the user to do any sort of
  63. // initialization they want to.
  64. //
  65. // Notes:
  66. //
  67. void InitializeLibrary(void)
  68. {
  69. // TODO: initialization here. control window class should be set up in
  70. // RegisterClassData.
  71. }
  72. //=--------------------------------------------------------------------------=
  73. // UninitializeLibrary
  74. //=--------------------------------------------------------------------------=
  75. // called from DllMain:DLL_PROCESS_DETACH. allows the user to clean up anything
  76. // they want.
  77. //
  78. // Notes:
  79. //
  80. void UninitializeLibrary(void)
  81. {
  82. // TODO: uninitialization here. control window class will be unregistered
  83. // for you, but anything else needs to be cleaned up manually.
  84. // Please Note that the Window 95 DLL_PROCESS_DETACH isn't quite as stable
  85. // as NT's, and you might crash doing certain things here ...
  86. }
  87. //=--------------------------------------------------------------------------=
  88. // CheckForLicense
  89. //=--------------------------------------------------------------------------=
  90. // users can implement this if they wish to support Licensing. otherwise,
  91. // they can just return TRUE all the time.
  92. //
  93. // Parameters:
  94. // none
  95. //
  96. // Output:
  97. // BOOL - TRUE means the license exists, and we can proceed
  98. // FALSE means we're not licensed and cannot proceed
  99. //
  100. // Notes:
  101. // - implementers should use g_wszLicenseKey and g_wszLicenseLocation
  102. // from the top of this file to define their licensing [the former
  103. // is necessary, the latter is recommended]
  104. //
  105. BOOL CheckForLicense(void)
  106. {
  107. // TODO: decide whether or not your server is licensed in this function.
  108. // people who don't want to bother with licensing should just return
  109. // true here always. g_wszLicenseKey and g_wszLicenseLocation are
  110. // used by IClassFactory2 to do some of the licensing work.
  111. //
  112. return TRUE;
  113. }
  114. //=--------------------------------------------------------------------------=
  115. // RegisterData
  116. //=--------------------------------------------------------------------------=
  117. // lets the inproc server writer register any data in addition to that in
  118. // any other objects.
  119. //
  120. // Output:
  121. // BOOL - false means failure.
  122. //
  123. // Notes:
  124. //
  125. BOOL RegisterData(void)
  126. {
  127. //=--------------------------------------------------------------------------=
  128. // RegisterData
  129. //=--------------------------------------------------------------------------=
  130. // lets the inproc server writer register any data in addition to that in
  131. // any other objects.
  132. //
  133. // Output:
  134. // BOOL - false means failure.
  135. //
  136. // Notes:
  137. //
  138. /// For safe scripting
  139. HRESULT hr;
  140. hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable");
  141. if(SUCCEEDED(hr))
  142. hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data");
  143. if(SUCCEEDED(hr))
  144. hr = RegisterCLSIDInCategory(CLSID_InstallEngineCtl, CATID_SafeForScripting);
  145. if(SUCCEEDED(hr))
  146. hr = RegisterCLSIDInCategory(CLSID_InstallEngineCtl, CATID_SafeForInitializing);
  147. if(FAILED(hr))
  148. {
  149. DllUnregisterServer();
  150. }
  151. return (SUCCEEDED(hr) ? TRUE : FALSE);
  152. }
  153. //=--------------------------------------------------------------------------=
  154. // UnregisterData
  155. //=--------------------------------------------------------------------------=
  156. // inproc server writers should unregister anything they registered in
  157. // RegisterData() here.
  158. //
  159. // Output:
  160. // BOOL - false means failure.
  161. //
  162. // Notes:
  163. //
  164. BOOL UnregisterData(void)
  165. {
  166. /// For safe scripting
  167. HRESULT hr;
  168. hr = UnRegisterCLSIDInCategory(CLSID_InstallEngineCtl, CATID_SafeForScripting);
  169. hr = UnRegisterCLSIDInCategory(CLSID_InstallEngineCtl, CATID_SafeForInitializing);
  170. return TRUE;
  171. }
  172. BOOL CheckLicenseKey(LPWSTR wszCheckme)
  173. {
  174. return TRUE;
  175. }
  176. BSTR GetLicenseKey(void)
  177. {
  178. return SysAllocString(L"");
  179. }
  180. LPSTR MakeAnsiStrFromAnsi(LPSTR psz)
  181. {
  182. LPSTR pszTmp;
  183. if(psz == NULL)
  184. return NULL;
  185. pszTmp = (LPSTR) CoTaskMemAlloc(lstrlenA(psz) + 1);
  186. if(pszTmp)
  187. lstrcpyA(pszTmp, psz);
  188. return pszTmp;
  189. }
  190. LPSTR CopyAnsiStr(LPSTR psz)
  191. {
  192. LPSTR pszTmp;
  193. if(psz == NULL)
  194. return NULL;
  195. pszTmp = (LPSTR) new char[lstrlenA(psz) + 1];
  196. if(pszTmp)
  197. lstrcpyA(pszTmp, psz);
  198. return pszTmp;
  199. }
  200. //=--------------------------------------------------------------------------=
  201. // CRT stubs
  202. //=--------------------------------------------------------------------------=
  203. // these two things are here so the CRTs aren't needed. this is good.
  204. //
  205. // basically, the CRTs define this to pull in a bunch of stuff. we'll just
  206. // define them here so we don't get an unresolved external.
  207. //
  208. // TODO: if you are going to use the CRTs, then remove this line.
  209. //
  210. extern "C" int _fltused = 1;
  211. extern "C" int _cdecl _purecall(void)
  212. {
  213. FAIL("Pure virtual function called.");
  214. return 0;
  215. }
  216. #ifndef _X86_
  217. extern "C" void _fpmath() {}
  218. #endif
  219. void * _cdecl malloc(size_t n)
  220. {
  221. #ifdef _MALLOC_ZEROINIT
  222. void* p = HeapAlloc(g_hHeap, 0, n);
  223. if (p != NULL)
  224. memset(p, 0, n);
  225. return p;
  226. #else
  227. return HeapAlloc(g_hHeap, 0, n);
  228. #endif
  229. }
  230. void * _cdecl calloc(size_t n, size_t s)
  231. {
  232. #ifdef _MALLOC_ZEROINIT
  233. return malloc(n * s);
  234. #else
  235. void* p = malloc(n * s);
  236. if (p != NULL)
  237. memset(p, 0, n * s);
  238. return p;
  239. #endif
  240. }
  241. void* _cdecl realloc(void* p, size_t n)
  242. {
  243. if (p == NULL)
  244. return malloc(n);
  245. return HeapReAlloc(g_hHeap, 0, p, n);
  246. }
  247. void _cdecl free(void* p)
  248. {
  249. if (p == NULL)
  250. return;
  251. HeapFree(g_hHeap, 0, p);
  252. }