VirtualBox

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

最後變更 在這個檔案從40768是 35351,由 vboxsync 提交於 14 年 前

scm cleanups.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.4 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 _EXDLL_H_
22#define _EXDLL_H_
23
24#include <windows.h>
25
26#if defined(__GNUC__)
27#define UNUSED __attribute__((unused))
28#else
29#define UNUSED
30#endif
31
32// only include this file from one place in your DLL.
33// (it is all static, if you use it in two places it will fail)
34
35#define EXDLL_INIT() { \
36 g_stringsize=string_size; \
37 g_stacktop=stacktop; \
38 g_variables=variables; }
39
40typedef struct _stack_t {
41 struct _stack_t *next;
42 char text[1]; // this should be the length of string_size
43} stack_t;
44
45
46static unsigned int g_stringsize;
47static stack_t **g_stacktop;
48static char *g_variables;
49
50static int __stdcall popstring(char *str) UNUSED; // 0 on success, 1 on empty stack
51static void __stdcall pushstring(const char *str) UNUSED;
52static char * __stdcall getuservariable(const int varnum) UNUSED;
53static void __stdcall setuservariable(const int varnum, const char *var) UNUSED;
54
55enum
56{
57INST_0, // $0
58INST_1, // $1
59INST_2, // $2
60INST_3, // $3
61INST_4, // $4
62INST_5, // $5
63INST_6, // $6
64INST_7, // $7
65INST_8, // $8
66INST_9, // $9
67INST_R0, // $R0
68INST_R1, // $R1
69INST_R2, // $R2
70INST_R3, // $R3
71INST_R4, // $R4
72INST_R5, // $R5
73INST_R6, // $R6
74INST_R7, // $R7
75INST_R8, // $R8
76INST_R9, // $R9
77INST_CMDLINE, // $CMDLINE
78INST_INSTDIR, // $INSTDIR
79INST_OUTDIR, // $OUTDIR
80INST_EXEDIR, // $EXEDIR
81INST_LANG, // $LANGUAGE
82__INST_LAST
83};
84
85// utility functions (not required but often useful)
86static int __stdcall popstring(char *str)
87{
88 stack_t *th;
89 if (!g_stacktop || !*g_stacktop)
90 return 1;
91 th=(*g_stacktop);
92 lstrcpyA(str,th->text);
93 *g_stacktop = th->next;
94 GlobalFree((HGLOBAL)th);
95 return 0;
96}
97
98static void __stdcall pushstring(const char *str)
99{
100 stack_t *th;
101 if (!g_stacktop)
102 return;
103 th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
104 lstrcpynA(th->text,str,g_stringsize);
105 th->next=*g_stacktop;
106 *g_stacktop=th;
107}
108
109static char * __stdcall getuservariable(const int varnum)
110{
111 if (varnum < 0 || varnum >= __INST_LAST)
112 return NULL;
113 return g_variables+varnum*g_stringsize;
114}
115
116static void __stdcall setuservariable(const int varnum, const char *var)
117{
118 if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
119 lstrcpyA(g_variables + varnum*g_stringsize, var);
120}
121#endif//_EXDLL_H_
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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