VirtualBox

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

最後變更 在這個檔案從82615是 82615,由 vboxsync 提交於 5 年 前

Windows Additions/Installer: Added a new testcase for the GuestInstallHelper DLL, to check whether the NSIS-specified API (still) works. Added more code to make the DLL compatible with NSIS v3.x, which in turn should make the file vendor / architecture detection work again.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.6 KB
 
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// only include this file from one place in your DLL.
64// (it is all static, if you use it in two places it will fail)
65
66#define EXDLL_INIT() { \
67 g_stringsize=string_size; \
68 g_stacktop=stacktop; \
69 g_variables=variables; }
70
71typedef struct _stack_t
72{
73 struct _stack_t *next;
74 char text[1]; // this should be the length of string_size
75} stack_t;
76
77// extra_parameters data structures containing other interesting stuff
78// but the stack, variables and HWND passed on to plug-ins.
79typedef struct
80{
81 int autoclose;
82 int all_user_var;
83 int exec_error;
84 int abort;
85 int exec_reboot; // NSIS_SUPPORT_REBOOT
86 int reboot_called; // NSIS_SUPPORT_REBOOT
87 int XXX_cur_insttype; // depreacted
88 int plugin_api_version; // see NSISPIAPIVER_CURR
89 // used to be XXX_insttype_changed
90 int silent; // NSIS_CONFIG_SILENT_SUPPORT
91 int instdir_error;
92 int rtl;
93 int errlvl;
94 int alter_reg_view;
95 int status_update;
96} exec_flags_t;
97
98typedef struct
99{
100 exec_flags_t *exec_flags;
101 int (NSISCALL *ExecuteCodeSegment)(int, HWND);
102 void (NSISCALL *validate_filename)(TCHAR *);
103 BOOL (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK);
104} extra_parameters;
105
106static unsigned int g_stringsize;
107static stack_t **g_stacktop;
108static char *g_variables;
109
110static int __stdcall popstring(char *str) UNUSED; // 0 on success, 1 on empty stack
111static void __stdcall pushstring(const char *str) UNUSED;
112static char * __stdcall getuservariable(const int varnum) UNUSED;
113static void __stdcall setuservariable(const int varnum, const char *var) UNUSED;
114
115enum
116{
117INST_0, // $0
118INST_1, // $1
119INST_2, // $2
120INST_3, // $3
121INST_4, // $4
122INST_5, // $5
123INST_6, // $6
124INST_7, // $7
125INST_8, // $8
126INST_9, // $9
127INST_R0, // $R0
128INST_R1, // $R1
129INST_R2, // $R2
130INST_R3, // $R3
131INST_R4, // $R4
132INST_R5, // $R5
133INST_R6, // $R6
134INST_R7, // $R7
135INST_R8, // $R8
136INST_R9, // $R9
137INST_CMDLINE, // $CMDLINE
138INST_INSTDIR, // $INSTDIR
139INST_OUTDIR, // $OUTDIR
140INST_EXEDIR, // $EXEDIR
141INST_LANG, // $LANGUAGE
142__INST_LAST
143};
144
145// utility functions (not required but often useful)
146static int __stdcall popstring(char *str)
147{
148 stack_t *th;
149 if (!g_stacktop || !*g_stacktop)
150 return 1;
151 th=(*g_stacktop);
152 lstrcpyA(str,th->text);
153 *g_stacktop = th->next;
154 GlobalFree((HGLOBAL)th);
155 return 0;
156}
157
158static void __stdcall pushstring(const char *str)
159{
160 stack_t *th;
161 if (!g_stacktop)
162 return;
163 th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
164 lstrcpynA(th->text,str,g_stringsize);
165 th->next=*g_stacktop;
166 *g_stacktop=th;
167}
168
169static char * __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 char *var)
177{
178 if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
179 lstrcpyA(g_variables + varnum*g_stringsize, var);
180}
181#endif /* !GA_INCLUDED_SRC_WINNT_Installer_InstallHelper_exdll_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette