source: trunk/include/custombuild.h@ 10420

Last change on this file since 10420 was 10420, checked in by sandervl, 22 years ago

* empty log message *

File size: 17.7 KB
RevLine 
[7061]1#ifndef __CUSTOMBUILD_H__
2#define __CUSTOMBUILD_H__
3
[10294]4#include <win\peexe.h>
5#include <initdll.h>
6
[7238]7//HKEY_LOCAL_MACHINE
8#define CUSTOM_BUILD_OPTIONS_KEY "System\\CustomBuild"
9#define DISABLE_AUDIO_KEY "DisableAudio"
[8095]10#define DISABLE_ASPI_KEY "DisableASPI"
[7238]11
[10327]12#define ODIN_WIN32_CDCLASS "Win32CDWindowClass"
13#define ODIN_WIN32_STDCLASS "Win32WindowClass"
14
[10294]15#define DUMMY_PREFIX "DUMMY_"
16
17#define MAX_FONT_MAPPINGS 8
18#define MAX_REGISTER_DLLS 64
19
[10379]20#define INNOWIN_DLLNAME "INNOWIN.DLL"
21
22#define MAKE_BUILDNR(major, minor) ((major << 16) | minor)
23#define MAJOR_BUILDNR(buildnr) (buildnr >> 16)
24#define MINOR_BUILDNR(buildnr) (buildnr & 0xffff)
25
26
[10294]27typedef BOOL (WIN32API *PFN_PRECUSTOMIZE)();
28typedef BOOL (WIN32API *PFN_POSTCUSTOMIZE)();
29typedef BOOL (WIN32API *PFN_ENDCUSTOMIZE)();
[10379]30typedef BOOL (WIN32API *PFN_ISPESTUBLOADER)(char *pszProgram);
[10294]31
32typedef struct {
33 char *szWindowsFont;
34 char *szPMFont;
35} CUSTOMBUILD_FONTMAP;
36
37typedef struct {
38 char *szName; //caps, including extension (e.g. "KERNEL32.DLL")
39 PIMAGE_FILE_HEADER pfh; //PE file header
[10379]40 PFN_INITDLL pfnInitterm;
[10294]41} CUSTOMBUILD_DLL;
42
43typedef struct {
44 char *szName;
45 PFN_INITDLL pfnInitterm;
46} CUSTOMBUILD_PRIVATE_INITTERM;
47
48typedef struct {
49 PFN_PRECUSTOMIZE pfnPreCustomize; //called after kernel32, user32 and gdi32 are initialized
50 PFN_POSTCUSTOMIZE pfnPostCustomize; //called at the end of dll load
51 PFN_ENDCUSTOMIZE pfnEndCustomize; //called when dll is unloaded
52
53 char *szCustomBuildDllName;
54
55 char *szRegistryBase;
56 char *szMemMapName;
57 char *szEnvExceptLogDisable;
58 char *szEnvExceptLogPath;
59 char *szPMWindowClassName;
60 char *szWindowHandleSemName;
61
62 //standard kernel32 settings
63 DWORD dwWindowsVersion;
64 BOOL fOdinIni;
[10379]65 BOOL fSMP;
[10294]66
67 //standard user32 settings
68 BOOL fDragDrop;
69 BOOL fOdinSysMenuItems;
70 DWORD dwWindowAppearance;
71 BOOL fMonoCursor;
72
[10379]73 //standard gdi32 settings
[10294]74 //font mappings (null terminated)
75 CUSTOMBUILD_FONTMAP fontMapping[MAX_FONT_MAPPINGS];
[10379]76 BOOL fFreeType;
77
[10294]78 //winmm
79 BOOL fDirectAudio;
80 BOOL fWaveAudio;
81
82 //first three important dlls (initialized in this order
83 CUSTOMBUILD_DLL dllNtdll;
84 CUSTOMBUILD_DLL dllKernel32;
85 CUSTOMBUILD_DLL dllUser32;
86 CUSTOMBUILD_DLL dllGdi32;
87
88 //list of remainder of registered dlls (order is important due to dependencies!!)
89 //(null terminated)
90 CUSTOMBUILD_DLL registeredDll[MAX_REGISTER_DLLS];
[10379]91
[10294]92 //list of dummy dlls (to prevent accidental load)
93 //(null terminated)
94 CUSTOMBUILD_DLL dummyDll[MAX_REGISTER_DLLS];
95
96} CUSTOMBUILD;
97
[10379]98typedef struct {
99 PFN_PRECUSTOMIZE pfnPreCustomize; //called after kernel32, user32 and gdi32 are initialized
100 PFN_POSTCUSTOMIZE pfnPostCustomize; //called at the end of dll load
101 PFN_ENDCUSTOMIZE pfnEndCustomize; //called when dll is unloaded
102 PFN_ISPESTUBLOADER pfnIsPeStubLoader;
103
104 char *szCustomBuildDllName;
105
106 char *szRegistryBase;
107 char *szEnvExceptLogDisable;
108 char *szEnvExceptLogPath;
109
110 //standard kernel32 settings
111 DWORD dwWindowsVersion;
112 BOOL fOdinIni;
113 BOOL fSMP;
114
115 //standard user32 settings
116 BOOL fDragDrop;
117 BOOL fOdinSysMenuItems;
118 DWORD dwWindowAppearance;
119 BOOL fMonoCursor;
120
121 //standard gdi32 settings
122 //font mappings (null terminated)
123 CUSTOMBUILD_FONTMAP fontMapping[MAX_FONT_MAPPINGS];
124 BOOL fFreeType;
125
126 //winmm
127 BOOL fDirectAudio;
128 BOOL fWaveAudio;
129
130 //list of remainder of registered dlls (order is important due to dependencies!!)
131 //(null terminated)
132 //(NTDLL, KERNEL32, USER32 and GDI32 are always registered)
133 CUSTOMBUILD_DLL registeredDll[MAX_REGISTER_DLLS];
134
135} CUSTOMBUILD_COMMON;
136
137BOOL WIN32API LoadCustomEnvironment(CUSTOMBUILD_COMMON *CustomBuild);
138BOOL WIN32API UnloadCustomEnvironment(BOOL fExitList);
139
140BOOL WIN32API InitExecutableEnvironment();
141BOOL WIN32API CheckCustomDllVersion(ULONG ulVersionMajor, ULONG ulVersionMinor);
142
143typedef BOOL (* WIN32API PFN_CHECKDLLVERSION)();
144BOOL WIN32API CheckDllVersion();
145
[7061]146extern BOOL fCustomBuild;
147
[10294]148void WIN32API SetRegistryRootKey(HKEY hRootkey, HKEY hKey);
[10379]149#ifdef __cplusplus
150void WIN32API SetCustomBuildName(char *lpszName, PIMAGE_FILE_HEADER pfh = NULL);
151#else
152void WIN32API SetCustomBuildName(char *lpszName, PIMAGE_FILE_HEADER pfh);
153#endif
[10294]154
[9596]155void WIN32API InitDirectoriesCustom(char *szSystemDir, char *szWindowsDir);
[7061]156
[9596]157void WIN32API DisableOdinIni();
[7061]158
[9596]159void WIN32API DisableOdinSysMenuItems();
[7246]160
[9596]161
[7763]162typedef HANDLE (* WIN32API PFNDRVOPEN)(LPVOID lpDriverData, DWORD dwAccess, DWORD dwShare, DWORD dwFlags, PVOID *ppHandleData);
163typedef void (* WIN32API PFNDRVCLOSE)(LPVOID lpDriverData, HANDLE hDevice, DWORD dwFlags, PVOID lpHandleData);
164typedef BOOL (* WIN32API PFNDRVIOCTL)(LPVOID lpDriverData, HANDLE hDevice, DWORD dwFlags, DWORD dwIoControlCode,
[7572]165 LPVOID lpInBuffer, DWORD nInBufferSize,
166 LPVOID lpOutBuffer, DWORD nOutBufferSize,
[7756]167 LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped,
[7763]168 LPVOID lpHandleData);
[7246]169
[9829]170typedef BOOL (* WIN32API PFNDRVREAD)(LPVOID lpDriverData,
[7763]171 HANDLE hDevice,
[7631]172 DWORD dwFlags,
[7572]173 LPCVOID lpBuffer,
174 DWORD nNumberOfBytesToRead,
175 LPDWORD lpNumberOfBytesRead,
176 LPOVERLAPPED lpOverlapped,
[7756]177 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
[7763]178 LPVOID lpHandleData);
[7572]179
[9829]180typedef BOOL (* WIN32API PFNDRVWRITE)(LPVOID lpDriverData,
[7763]181 HANDLE hDevice,
[7631]182 DWORD dwFlags,
[7572]183 LPCVOID lpBuffer,
184 DWORD nNumberOfBytesToWrite,
185 LPDWORD lpNumberOfBytesWrite,
186 LPOVERLAPPED lpOverlapped,
[7756]187 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
[7763]188 LPVOID lpHandleData);
[7572]189
[7763]190typedef BOOL (* WIN32API PFNDRVCANCELIO)(LPVOID lpDriverData, HANDLE hDevice, DWORD dwFlags, PVOID lpHandleData);
[9829]191typedef DWORD (* WIN32API PFNDRVGETOVERLAPPEDRESULT)(LPVOID lpDriverData,
[7763]192 HANDLE hDevice,
[7631]193 DWORD dwFlags,
[7629]194 LPOVERLAPPED lpOverlapped,
195 LPDWORD lpcbTransfer,
[7756]196 BOOL fWait,
[7763]197 LPVOID lpHandleData);
[7572]198
[9829]199BOOL WIN32API RegisterCustomDriver(PFNDRVOPEN pfnDriverOpen, PFNDRVCLOSE pfnDriverClose,
[7572]200 PFNDRVIOCTL pfnDriverIOCtl, PFNDRVREAD pfnDriverRead,
[7629]201 PFNDRVWRITE pfnDriverWrite, PFNDRVCANCELIO pfnDriverCancelIo,
202 PFNDRVGETOVERLAPPEDRESULT pfnDriverGetOverlappedResult,
[7763]203 LPCSTR lpDriverName, LPVOID lpDriverData);
[7246]204
[7763]205BOOL WIN32API UnRegisterCustomDriver(LPCSTR lpDriverName);
[7247]206
[7763]207
[7247]208//SetDialogHook can be used by a custom Odin build to register a hook procedure
209//that gets called before or after dialog creation
210
[8132]211#define HODIN_PREDIALOGCREATION 0
212#define HODIN_POSTDIALOGCREATION 1
213#define HODIN_WINDOWCREATED 2
[7247]214
[8132]215HHOOK WIN32API SetOdinHookA(HOOKPROC proc );
216BOOL WIN32API UnhookOdinHook(HHOOK hhook);
217LRESULT HOOK_CallOdinHookA(INT code, WPARAM wParam, LPARAM lParam );
[7247]218
[8112]219//Override LoadImage function
220typedef void (* WIN32API PFNLOADIMAGEW)(HINSTANCE *phinst, LPWSTR *lplpszName, UINT *lpuType);
[7251]221
[8112]222BOOL WIN32API SetCustomLoadImage(PFNLOADIMAGEW pfnLoadImageW);
[8012]223
[7251]224//Set the default language in kernel32
225void WIN32API SetDefaultLanguage(DWORD deflang);
226
[7621]227//Override pm keyboard hook dll name
228void WIN32API SetCustomPMHookDll(LPSTR pszKbdDllName);
[7251]229
[8736]230void WIN32API DisableDragDrop(BOOL fDisabled);
[8733]231
[7674]232//Turn off wave audio in winmm
233void WIN32API DisableWaveAudio();
[9980]234//Turn off usage of the Uniaud DirectAudio interface
235void WIN32API DisableDirectAudio();
[7674]236
[9829]237//Override shared semaphore name used to synchronize global window handle
[8656]238//array access (to avoid name clash with Odin)
239void WIN32API SetCustomWndHandleSemName(LPSTR pszSemName);
240
[9829]241//Override shared semaphore name used to synchronize global memory map
[8658]242//list access (to avoid name clash with Odin)
243void WIN32API SetCustomMMapSemName(LPSTR pszSemName);
244
[10379]245//Override std class names used in Odin
246void WIN32API SetCustomStdClassName(LPSTR pszStdClassName);
247char *WIN32API QueryCustomStdClassName();
[9964]248
[8095]249//Turn off ASPI
250void WIN32API DisableASPI();
251
[7943]252//force color to mono cursor conversion
253void WIN32API CustForceMonoCursor();
254
[8408]255//force GetVolumeInformation to tell the app all partitions are FAT
256void WIN32API CustForce2GBFileSize();
257
[8833]258//Logging of exceptions:
259//Override filename of exception log (expects full path)
260void WIN32API SetCustomExceptionLog(LPSTR lpszLogName);
261//Enable/disable exception logging
262void WIN32API SetExceptionLogging(BOOL fEnable);
263
[8929]264//Disable OS2CDROM.DMD aspi support
265void WIN32API DisableCDIo();
[8833]266
[8987]267//Force DirectDraw to report only one fullscreen mode
268void WIN32API SetCustomFullScreenMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP);
269
[9156]270//Force DirectSurface Lock & Unlock methods to hide & show the mouse cursor
271BOOL WIN32API SetCustomHideCursorOnLock(BOOL state);
272
[9302]273//Call to enable access to physical disks or volumes (default is disabled)
274void WIN32API EnablePhysicalDiskAccess(BOOL fEnable);
275
[9829]276//Override a system color without forcing a desktop repaint (which
[9444]277//SetSysColors does)
278BOOL WIN32API ODIN_SetSysColors(INT nChanges, const INT *lpSysColor,
279 const COLORREF *lpColorValues);
280
[9484]281//Override loader names (PEC, PE, W16ODIN)
282BOOL WIN32API ODIN_SetLoaders(LPCSTR pszPECmdLoader, LPCSTR pszPEGUILoader,
283 LPCSTR pszNELoader);
284
[9494]285//Returns path of loaders
286BOOL WIN32API ODIN_QueryLoaders(LPSTR pszPECmdLoader, INT cchPECmdLoader,
287 LPSTR pszPEGUILoader, INT cchPEGUILoader,
288 LPSTR pszNELoader, INT cchNELoader);
289
[9849]290//Checks whether program is LX or PE
291BOOL WIN32API ODIN_IsWin32App(LPSTR lpszProgramPath);
292
[9484]293//Custom build function to disable loading of LX dlls
294void WIN32API ODIN_DisableLXDllLoading();
295
[9829]296/**
297 * LoadLibrary*() callback function registered using ODIN_SetLxDllLoadCallback().
298 * This is called for all LX modules which are loaded by LoadLibrary.
299 *
300 * @returns TRUE loading should succeed. The DLL is now registered.
301 * @returns FALSE loading should fail.
302 * @param hmodOS2 The OS/2 module handle.
303 * @param hInstance The Odin instance handle.
304 * If not NULL this means that the DLL is registered.
305 */
306typedef BOOL (* WIN32API PFNLXDLLLOAD)(HMODULE hmodOS2, HINSTANCE hInstance);
[9616]307
[9829]308/** Custombuild API for registering a callback for LX Dll loading thru LoadLibrary*(). */
309BOOL WIN32API ODIN_SetLxDllLoadCallback(PFNLXDLLLOAD pfn);
310
311/**
312 * FreeLibrary*() callback function registered using ODIN_SetLxDllUnLoadCallback().
313 * This is called when an LX which was previously loaded using LoadLibrary*() is
314 * finally freed from Odin. The callback servers mainly the purpose of cleaning
315 * up any data associated with the DLL.
316 *
317 * It is called *AFTER* the module is freed from Odin but before it's actually
318 * unloaded from the OS/2 process. This means that the OS/2 handle is valid while
319 * the Odin handle is invalid.
320 *
321 * @param hmodOS2 The OS/2 module handle.
322 * @param hInstance The Odin instance handle (invalid!).
323 * @remark It likely that this callback will be called for more DLLs than the
324 * load callback. Do check handles properly.
325 */
326typedef void (* WIN32API PFNLXDLLUNLOAD)(HMODULE hmodOS2, HINSTANCE hInstance);
327
328BOOL WIN32API ODIN_SetLxDllUnLoadCallback(PFNLXDLLUNLOAD pfn);
329
330
[9616]331//******************************************************************************
332//Install a handler that is called before the entrypoint of a dll (DLL_PROCESS_ATTACH)
333//******************************************************************************
334typedef void (* WIN32API ODINPROC_DLLLOAD)(HMODULE hModule);
335
336BOOL WIN32API ODIN_SetDllLoadCallback(ODINPROC_DLLLOAD pfnMyDllLoad);
337
[9829]338
[9616]339//******************************************************************************
340// ODIN_SetProcAddress: Override a dll export
[9829]341//
[9616]342// Parameters:
343// HMODULE hModule Module handle
344// LPCSTR lpszProc Export name or ordinal
345// FARPROC pfnNewProc New export function address
346//
347// Returns: Success -> old address of export
348// Failure -> -1
349//
350//******************************************************************************
351FARPROC WIN32API ODIN_SetProcAddress(HMODULE hModule, LPCSTR lpszProc, FARPROC pfnNewProc);
352
[9798]353//******************************************************************************
354// ODIN_SetTIBSwitch: override TIB switching
[9829]355//
[9798]356// Parameters:
357// BOOL fSwitchTIB
358// FALSE -> no TIB selector switching
359// TRUE -> force TIB selector switching
360//
361//******************************************************************************
362void WIN32API ODIN_SetTIBSwitch(BOOL fSwitchTIB);
363
[9898]364//******************************************************************************
365// ODIN_DisableFolderShellLink
366//
[9909]367// Disable object creation in Odin folder. Desktop shortcuts will still be
[9898]368// created as WPS objects on the desktop.
369//
370//******************************************************************************
371void WIN32API ODIN_DisableFolderShellLink();
372
[9900]373//******************************************************************************
374// ODIN_waveOutSetFixedBuffers
375//
376// Tell WINMM to use DART buffers of the same size as the first buffer delivered
377// by waveOutWrite
378//
379// NOTE: This will only work in very specific cases; it is not a good general
380// purpose solution.
[9909]381//
[9900]382//******************************************************************************
383void WIN32API ODIN_waveOutSetFixedBuffers();
384
385#define SetFixedWaveBufferSize ODIN_waveOutSetFixedBuffers
386
387//******************************************************************************
388// ODIN_waveInSetFixedBuffers
389//
390// Tell WINMM to use DART buffers of the same size as the first buffer delivered
391// by waveInAddBuffer
392//
393// NOTE: This will only work in very specific cases; it is not a good general
394// purpose solution.
[9909]395//
[9900]396//******************************************************************************
397void WIN32API ODIN_waveInSetFixedBuffers();
398
[9909]399
400/** Enter odin context with this thread. */
401USHORT WIN32API ODIN_ThreadEnterOdinContext(void *pExceptionRegRec, BOOL fForceFSSwitch);
402/** Leave odin context with this thread. */
403void WIN32API ODIN_ThreadLeaveOdinContext(void *pExceptionRegRec, USHORT selFSOld);
404
405/** Leave odin context to call back into OS/2 code. */
406USHORT WIN32API ODIN_ThreadLeaveOdinContextNested(void *pExceptionRegRec, BOOL fRemoveOdinExcpt);
407/** Re-enter Odin context after being back in OS/2 code. */
408void WIN32API ODIN_ThreadEnterOdinContextNested(void *pExceptionRegRec, BOOL fRestoreOdinExcpt, USHORT selFSOld);
409
[10294]410void WIN32API ODIN_SetExceptionHandler(void *pExceptionRegRec);
411void WIN32API ODIN_UnsetExceptionHandler(void *pExceptionRegRec);
412
[10237]413/* Turn on CD Polling (window with 2 second timer to check CD disk presence) */
414void WIN32API CustEnableCDPolling();
[9909]415
[10379]416void WIN32API SetFreeTypeIntegration(BOOL fEnabled);
[10294]417
[10379]418
419//PE headers of system dlls
420#ifdef __cplusplus
[10294]421extern "C" {
[10379]422#endif
[10294]423extern IMAGE_FILE_HEADER nt_ntdll_header;
424extern IMAGE_FILE_HEADER nt_gdi32_header;
425extern IMAGE_FILE_HEADER nt_kernel32_header;
426extern IMAGE_FILE_HEADER nt_user32_header;
427extern IMAGE_FILE_HEADER nt_advapi32_header;
428extern IMAGE_FILE_HEADER nt_version_header;
429extern IMAGE_FILE_HEADER nt_wsock32_header;
430extern IMAGE_FILE_HEADER nt_ws2_32_header;
431extern IMAGE_FILE_HEADER nt_winmm_header;
432extern IMAGE_FILE_HEADER nt_ole32_header;
433extern IMAGE_FILE_HEADER nt_comctl32_header;
434extern IMAGE_FILE_HEADER nt_shell32_header;
435extern IMAGE_FILE_HEADER nt_comdlg32_header;
436extern IMAGE_FILE_HEADER nt_winspool_header;
437extern IMAGE_FILE_HEADER nt_ddraw_header;
438extern IMAGE_FILE_HEADER nt_oleaut32_header;
439extern IMAGE_FILE_HEADER nt_msvfw32_header;
440extern IMAGE_FILE_HEADER nt_imm32_header;
441extern IMAGE_FILE_HEADER nt_mpr_header;
442extern IMAGE_FILE_HEADER nt_iphlpapi_header;
443extern IMAGE_FILE_HEADER nt_olepro32_header;
444extern IMAGE_FILE_HEADER nt_msvcrt_header;
445extern IMAGE_FILE_HEADER nt_lz32_header;
446extern IMAGE_FILE_HEADER nt_oledlg_header;
447extern IMAGE_FILE_HEADER nt_riched32_header;
448extern IMAGE_FILE_HEADER nt_psapi_header;
449extern IMAGE_FILE_HEADER nt_rpcrt4_header;
450extern IMAGE_FILE_HEADER nt_shlwapi_header;
451extern IMAGE_FILE_HEADER nt_shfolder_header;
452extern IMAGE_FILE_HEADER nt_wininet_header;
[10379]453extern IMAGE_FILE_HEADER nt_olepro32_header;
454extern IMAGE_FILE_HEADER nt_avifil32_header;
455extern IMAGE_FILE_HEADER nt_dinput_header;
456extern IMAGE_FILE_HEADER nt_dsound_header;
457extern IMAGE_FILE_HEADER nt_uxtheme_header;
[10420]458extern IMAGE_FILE_HEADER nt_mciwave_header;
[10379]459#ifdef __cplusplus
460}
461#endif
[10294]462
[7061]463#endif /*__CUSTOMBUILD_H__*/
464
Note: See TracBrowser for help on using the repository browser.