VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/exdll.h

Last change on this file was 96451, checked in by vboxsync, 21 months ago

Add/NT/Inst,Add/NT/VBoxTray,Add/VBoxService: Cleaned up VBoxGuestInstallHelper.cpp (tested) and the VBoxTray IPC interface (not tested). The motivation for the former was to make it compile in no-CRT mode, the latter was buggy code. The IPC interface is not backwards compatible, this is intentional to avoid buggy code. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/*
2 * Copyright (C) 1995-2009 Contributors
3 * More detailed copyright information can be found in the individual source code files.
4 *
5 * This software is provided 'as-is', without any express or implied warranty.
6 * In no event will the authors be held liable for any damages arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter
9 * it and redistribute it freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
12 * If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14 * 3. This notice may not be removed or altered from any source distribution.
15 */
16
17/** Taken from:
18 * http://nsis.sourceforge.net/Examples/Plugin/exdll.h
19 */
20
21#ifndef GA_INCLUDED_SRC_WINNT_Installer_InstallHelper_exdll_h
22#define GA_INCLUDED_SRC_WINNT_Installer_InstallHelper_exdll_h
23#ifndef RT_WITHOUT_PRAGMA_ONCE
24# pragma once
25#endif
26
27#include <iprt/win/windows.h>
28
29#if defined(__GNUC__)
30#define UNUSED __attribute__((unused))
31#else
32#define UNUSED
33#endif
34
35// Starting with NSIS 2.42, you can check the version of the plugin API in exec_flags->plugin_api_version
36// The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x))
37// When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {}
38
39#define NSISPIAPIVER_1_0 0x00010000
40#define NSISPIAPIVER_CURR NSISPIAPIVER_1_0
41
42// NSIS Plug-In Callback Messages
43enum NSPIM
44{
45 NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
46 NSPIM_GUIUNLOAD, // Called after .onGUIEnd
47};
48
49/** Defines the maximum string length NSIS can handle.
50 * Note: This depends on the NSIS build being used, e.g. there are different builds which can also handle larger strings.
51 * So to play safe go with the minimum (default) string length here. */
52#define NSIS_MAX_STRLEN 1024
53
54// Prototype for callbacks registered with extra_parameters->RegisterPluginCallback()
55// Return NULL for unknown messages
56// Should always be __cdecl for future expansion possibilities
57typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM);
58
59#ifndef NSISCALL
60# define NSISCALL __stdcall
61#endif
62
63#ifndef VBOX
64// only include this file from one place in your DLL.
65// (it is all static, if you use it in two places it will fail)
66
67#define EXDLL_INIT() { \
68 g_stringsize=string_size; \
69 g_stacktop=stacktop; \
70 g_variables=variables; }
71#endif /* !VBOX */
72
73typedef struct _stack_t
74{
75 struct _stack_t *next;
76 TCHAR text[1]; // this should be the length of string_size
77} stack_t;
78
79// extra_parameters data structures containing other interesting stuff
80// but the stack, variables and HWND passed on to plug-ins.
81typedef struct
82{
83 int autoclose;
84 int all_user_var;
85 int exec_error;
86 int abort;
87 int exec_reboot; // NSIS_SUPPORT_REBOOT
88 int reboot_called; // NSIS_SUPPORT_REBOOT
89 int XXX_cur_insttype; // depreacted
90 int plugin_api_version; // see NSISPIAPIVER_CURR
91 // used to be XXX_insttype_changed
92 int silent; // NSIS_CONFIG_SILENT_SUPPORT
93 int instdir_error;
94 int rtl;
95 int errlvl;
96 int alter_reg_view;
97 int status_update;
98} exec_flags_t;
99
100typedef struct
101{
102 exec_flags_t *exec_flags;
103 int (NSISCALL *ExecuteCodeSegment)(int, HWND);
104 void (NSISCALL *validate_filename)(TCHAR *);
105 BOOL (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK);
106} extra_parameters;
107
108#ifndef VBOX
109static unsigned int g_stringsize;
110static stack_t **g_stacktop;
111static TCHAR *g_variables;
112#endif
113
114enum
115{
116INST_0, // $0
117INST_1, // $1
118INST_2, // $2
119INST_3, // $3
120INST_4, // $4
121INST_5, // $5
122INST_6, // $6
123INST_7, // $7
124INST_8, // $8
125INST_9, // $9
126INST_R0, // $R0
127INST_R1, // $R1
128INST_R2, // $R2
129INST_R3, // $R3
130INST_R4, // $R4
131INST_R5, // $R5
132INST_R6, // $R6
133INST_R7, // $R7
134INST_R8, // $R8
135INST_R9, // $R9
136INST_CMDLINE, // $CMDLINE
137INST_INSTDIR, // $INSTDIR
138INST_OUTDIR, // $OUTDIR
139INST_EXEDIR, // $EXEDIR
140INST_LANG, // $LANGUAGE
141__INST_LAST
142};
143
144#ifndef VBOX
145
146// utility functions (not required but often useful)
147int popstringn(TCHAR *str, int maxlen)
148{
149 stack_t *th;
150 if (!g_stacktop || !*g_stacktop) return 1;
151 th=(*g_stacktop);
152 if (str) lstrcpyn(str,th->text,maxlen?maxlen:g_stringsize);
153 *g_stacktop = th->next;
154 GlobalFree((HGLOBAL)th);
155 return 0;
156}
157
158static void __stdcall pushstring(const TCHAR *str)
159{
160 stack_t *th;
161 if (!g_stacktop)
162 return;
163 th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
164 lstrcpyn(th->text,str,g_stringsize);
165 th->next=*g_stacktop;
166 *g_stacktop=th;
167}
168
169static TCHAR* __stdcall getuservariable(const int varnum)
170{
171 if (varnum < 0 || varnum >= __INST_LAST)
172 return NULL;
173 return g_variables+varnum*g_stringsize;
174}
175
176static void __stdcall setuservariable(const int varnum, const TCHAR *var)
177{
178 if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
179 lstrcpy(g_variables + varnum*g_stringsize, var);
180}
181
182#endif /* ! VBOX */
183
184#endif /* !GA_INCLUDED_SRC_WINNT_Installer_InstallHelper_exdll_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use