nothunk.c
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 11k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /*++
  2. Copyright (c) 1994  Microsoft Corporation
  3. Module Name:
  4.     nothunk.c
  5. Abstract:
  6.     Code to handle routines which are being thunked down to 16 bits or
  7.     exported from the Windows 95 kernel.
  8. Author:
  9.     Bob Day   (bobday)
  10. Revision History:
  11.     Sunil Pai (sunilp) 28-Oct-1994. Removed SHRestartWindows,
  12.                                     SHGetAboutInformation to start.c, deleted
  13.                                     Shl1632_Thunk* and Shl3216_Thunk* routines,
  14.                                     Removed pifmgr routines to pifmgr.c.
  15. --*/
  16. #include "shellprv.h"
  17. #pragma  hdrstop
  18. //---------------------------------------------------------------------------
  19. //
  20. // PURPOSE:  This is to support 16 bit control panel applets.
  21. //
  22. // EXPORTED: Internal export.
  23. //
  24. // DEFINED:  wincorelibrarycpl16.c.
  25. //
  26. // USED:     By display and driver applets.
  27. //
  28. // DETAILS:  The implementation of this thunks the cplinfo returned from the
  29. //           16 bit applet to the 32 bit cplinfo.
  30. //
  31. //           NT doesn't support 16 bit applets.  We need to decide if we do
  32. //           need to support this, accordingly this can be just a stub or
  33. //           we need to import this.  Also no 32 corresponding 32 bit API
  34. //           exposed.
  35. //
  36. // HISTORY:  BUGBUG - SUNILP
  37. //
  38. //----------------------------------------------------------------------------
  39. LRESULT WINAPI CallCPLEntry16(
  40.     HINSTANCE hinst,
  41.     FARPROC16 lpfnEntry,
  42.     HWND hwndCPL,
  43.     UINT msg,
  44.     LPARAM lParam1,
  45.     LPARAM lParam2
  46. ) {
  47.     return 0L;      // BUGBUG - 0L appears to mean un-handled, is this true?
  48. }
  49. //---------------------------------------------------------------------------
  50. //
  51. // PURPOSE:
  52. //
  53. //---------------------------------------------------------------------------
  54. void RunDll_CallEntry16(
  55.     RUNDLLPROC pfn,
  56.     HWND hwndStub,
  57.     HINSTANCE hinst,
  58.     LPSTR pszParam,
  59.     int nCmdShow)
  60. {
  61.     return;
  62. }
  63. VOID WINAPI UninitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
  64. {
  65.     DeleteCriticalSection(lpCriticalSection);
  66. }
  67. // BUGBUG Do we want to handle this on NT? (\talmsdoswincoreshelllibrarycbthook.c)
  68. BOOL CheckResourcesBeforeExec(void)
  69. {
  70.     return TRUE;
  71. }
  72. // BUGBUG See SanfordS about the need to provide this
  73. void SHGlobalDefect(DWORD lpVoid) {};
  74. //---------------------------------------------------------------------------
  75. //
  76. // PURPOSE:  This is to add property pages from a 16 bit dll.
  77. //
  78. // EXPORTED: Not exported
  79. //
  80. // DEFINED:  wincorelibraryprt16.c
  81. //
  82. // USED:     internally by the shelldll.
  83. //
  84. // DETAILS:  The implements adding of prop pages from a 16 bit dll to a
  85. //           property page array. The function passed in is a 16 bit fn.
  86. //
  87. //           We need to find out what to do about these.  We probably won't
  88. //           support any 16 bit prop pages..
  89. //
  90. // HISTORY:  BUGBUG - SUNILP
  91. //
  92. //----------------------------------------------------------------------------
  93. VOID WINAPI CallAddPropSheetPages16(
  94.     LPFNADDPROPSHEETPAGES lpfn16,
  95.     LPVOID hdrop,
  96.     LPPAGEARRAY papg
  97. ) {
  98.     // Can't return error condition...
  99. }
  100. //---------------------------------------------------------------------------
  101. // add the pages for a given 16bit dll specified
  102. //
  103. // hDrop        list of files to add pages for
  104. // pszDllEntry  DLLNAME,EntryPoint string
  105. // lpfnAddPage  32bit add page callback
  106. // lParam       data for 32bit page callback
  107. //
  108. UINT WINAPI SHAddPages16(HGLOBAL hGlobal, LPCTSTR pszDllEntry, LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
  109. {
  110.     return 0;
  111. }
  112. // BUGBUG - BobDay -
  113. //
  114. HMODULE WINAPI NoThkGetModuleHandle16(
  115.     LPCTSTR lpModuleName
  116.     )
  117. {
  118.     return 0;           // Return an error condition for now
  119. }
  120. //---------------------------------------------------------------------------
  121. //
  122. // PURPOSE:  To get the filename from and hinst for a 16 bit module.
  123. //
  124. // EXPORTED: Not Exported
  125. //
  126. // DEFINED:  wincorelibrarycpl16.c
  127. //
  128. // USED:     internally by the shelldll.
  129. //
  130. // DETAILS:  This cannot be supported by the 32 bit GetModuleFileName call.
  131. //           This is being used by the shell to support:
  132. //           1) 16 bit cpls (in control1.c)  [We may not support 16 bit cpls]
  133. //           2) In ShellExecuteNormal (in shlexec.c) a new Win32 error may be
  134. //              returned from CreateProcess (ERROR_SINGLE_INSTANCE_APP). For
  135. //              this error ShellExecuteNormal examines all top level windows
  136. //              , gets the instance handle for the window and uses this
  137. //              function to get the exe name and sees if it matches.  Once
  138. //              the top level window which refers to the same exe is found,
  139. //              it switches this window to be the foreground window and
  140. //              returns the handle of this.
  141. //
  142. //           Investigation Needed:  - a) When is an app a single instance app,
  143. //           how does CreateProcess know.  b) Can CreateProcess on NT return
  144. //           the same behaviour. c) Is this important for us to support, why
  145. //           is this needed.
  146. //
  147. // HISTORY:  BUGBUG - SUNILP
  148. //
  149. //----------------------------------------------------------------------------
  150.  // BUGBUG - BobDay - Don't know what this is for or why, needs to be removed
  151. int WINAPI GetModuleFileName16(
  152.     HINSTANCE hinst,
  153.     LPTSTR szFileName,
  154.     int cchMax
  155. ) {
  156.     return 0;           // Return an error condition for now
  157. }
  158. // BUGBUG - BobDay - I think this comes from KERNEL32, its prototype is in
  159. // krnlcmn.h
  160. DWORD WINAPI GetProcessDword( DWORD idProcess, LONG iIndex )
  161. {
  162.     //
  163.     // We only ever use - GPD_HINST, GPD_FLAGS (for WPF_WIN16_PROCESS),
  164.     // GPD_EXP_WINVER
  165.     //
  166.     // In IsWin16Process (GPD_FLAGS) we could look at the WOWWORDs via
  167.     // GetWindowLong, or we could look at the GWL_HINST and see if the
  168.     // highword is zero.
  169.     //
  170.     // Window_GetInstance (GPD_HINST) couldn't we just call GetWindowLong
  171.     // with GWL_HINST?
  172.     //
  173.     // ShellExecuteNormal (GPD_HINST) I don't think we can fix this easily.
  174.     // can we get the pei to just have a process id instead?
  175.     //
  176.     // Window_IsLFNAware (GPD_FLAGS & GPD_EXPWINVER):  Should use
  177.     // IsWin16Process technique for GPD_FLAGS; should use GetProcessVersion
  178.     // instead of GPD_EXP_WINVER.
  179.     //
  180.     ASSERTMSG(iIndex != GPD_EXP_WINVER,
  181.               "Use GetProcessVersion instead of GPD_EXP_WINVER");
  182.     return 0;
  183. }
  184. // BUGBUG - BobDay - I think this comes from KERNEL32, its prototype is in
  185. // krnlcmn.h
  186. BOOL WINAPI SetProcessDword( DWORD idProcess, LONG iIndex, DWORD dwValue )
  187. {
  188.     return 0;
  189. }
  190. // BUGBUG - BobDay - This function needs to be added to KERNEL32. NOPE,
  191. // according to markl we only need this because the critical section
  192. // was located in shared memory.  Possible solution here might be to create
  193. // a named event or mutex and synchronize via it. Another possible solution
  194. // might be to move each of the objects for which there is a critical section
  195. // out of the shared memory segment and maintain a per-process data structure.
  196. // normally: ReinitializeCriticalSection
  197. VOID WINAPI NoThkReinitializeCriticalSection(
  198.     LPCRITICAL_SECTION lpCriticalSection
  199. ) {
  200.     InitializeCriticalSection( lpCriticalSection );
  201. }
  202. // BUGBUG - BobDay - Some hidden function in KERNEL (16 or 32, I can't determine)
  203. int WINAPI PK16FNF(
  204.     char *szBuffer
  205. ) {
  206.     return 0;
  207. }
  208. // BUGBUG - BobDay - One of the 32-bit control panel applets needs to get
  209. // the list of drivers.  This was a thunk down into the 16-bit world to call
  210. // the GetNextDriver function.  We need to do the right 32-bit thing.
  211. HANDLE WINAPI ShellGetNextDriverName(
  212.     HANDLE hdrv,
  213.     LPSTR pszName,
  214.     int cbName
  215. ) {
  216.     return 0;
  217. }
  218. //---------------------------------------------------------------------------
  219. //
  220. // PURPOSE:  This is to load 16 bit dlls
  221. //
  222. // EXPORTED: Not implemented in shelldll
  223. //
  224. // DEFINED:  wincorewin32kernelkrnlutil.asm
  225. //
  226. // USED:     Shell, applets, printer..
  227. //
  228. // DETAILS:  This is used to support:
  229. //
  230. //           1) 16 bit cpls. (control1.c, cpls)
  231. //           2) 16 bit dlls with property sheet extensions. (binder.c)
  232. //           3) 16 bit printer drivers.
  233. //
  234. //           We most probably won't support 16 bit cpls and 16 bit printer
  235. //           drivers.  Need to investigate 16 bit property sheet extensions.
  236. //
  237. // HISTORY:  BUGBUG - SUNILP
  238. //
  239. //----------------------------------------------------------------------------
  240. // BUGBUG - BobDay - This function is probably used for something we don't want.
  241. // normally LoadLibrary16
  242. HINSTANCE WINAPI NoThkLoadLibrary16(
  243.     LPCTSTR lpLibFileName
  244. ) {
  245.     return 0;
  246. }
  247. //---------------------------------------------------------------------------
  248. //
  249. // PURPOSE:  This is to free the loaded 16 bit dlls
  250. //
  251. // EXPORTED: Not implemented in shelldll
  252. //
  253. // DEFINED:  wincorewin32kernelkrnlutil.asm
  254. //
  255. // USED:     Shell, applets, printer..
  256. //
  257. // DETAILS:  This is used to support:
  258. //
  259. //           1) 16 bit cpls. (control1.c, cpls)
  260. //           2) 16 bit dlls with property sheet extensions. (binder.c)
  261. //           3) 16 bit printer drivers.
  262. //
  263. //           We most probably won't support 16 bit cpls and 16 bit printer
  264. //           drivers.  Need to investigate 16 bit property sheet extensions.
  265. //
  266. // HISTORY:  BUGBUG - SUNILP
  267. //
  268. //----------------------------------------------------------------------------
  269. // BUGBUG - BobDay - This function is probably used for something we don't want.
  270. //normally: FreeLibrary16
  271. BOOL WINAPI NoThkFreeLibrary16(
  272.     HINSTANCE hLibModule
  273. ) {
  274.     return FALSE;
  275. }
  276. //---------------------------------------------------------------------------
  277. //
  278. // PURPOSE:  To get addresses of procedures in 16 bit dlls
  279. //
  280. // EXPORTED: Not implemented in shelldll
  281. //
  282. // DEFINED:  wincorewin32kernelkrnlutil.asm
  283. //
  284. // USED:     Shell, applets, printer..
  285. //
  286. // DETAILS:  This is used to support:
  287. //
  288. //           1) 16 bit cpls. (control1.c, cpls)
  289. //           2) 16 bit dlls with property sheet extensions. (binder.c)
  290. //           3) 16 bit printer drivers.
  291. //
  292. //           We most probably won't support 16 bit cpls and 16 bit printer
  293. //           drivers.  Need to investigate 16 bit property sheet extensions.
  294. //
  295. //
  296. // HISTORY:  BUGBUG - SUNILP
  297. //
  298. //----------------------------------------------------------------------------
  299. // BUGBUG - BobDay - This function is probably used for something we don't want.
  300. // normally: GetProcAddress16
  301. FARPROC WINAPI NoThkGetProcAddress16(
  302.     HINSTANCE hModule,
  303.     LPCSTR lpProcName
  304. ) {
  305.     return NULL;
  306. }