other-licenses/nsis/Contrib/ExDLL/exdllutil.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // Unicode support by Jim Park -- 08/23/2007
michael@0 2 // Jim Park: Should probably turn this into a nice class for C++ programs.
michael@0 3
michael@0 4 #pragma once
michael@0 5 #include <windows.h>
michael@0 6 #include <tchar.h>
michael@0 7 // only include this file from one place in your DLL.
michael@0 8 // (it is all static, if you use it in two places it will fail)
michael@0 9
michael@0 10 #define EXDLL_INIT() { \
michael@0 11 g_stringsize=string_size; \
michael@0 12 g_stacktop=stacktop; \
michael@0 13 g_variables=variables; }
michael@0 14
michael@0 15 // For page showing plug-ins
michael@0 16 #define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
michael@0 17 #define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
michael@0 18
michael@0 19 /* Jim Park: This char is compared as an int value and therefore
michael@0 20 it's fine as an ASCII. Do not need to change to wchar_t since
michael@0 21 it will get the same integer value. */
michael@0 22 #define NOTIFY_BYE_BYE _T('x')
michael@0 23
michael@0 24 typedef struct _stack_t {
michael@0 25 struct _stack_t *next;
michael@0 26 TCHAR text[1]; // this should be the length of string_size
michael@0 27 } stack_t;
michael@0 28
michael@0 29 static unsigned int g_stringsize;
michael@0 30 static stack_t **g_stacktop;
michael@0 31 static TCHAR *g_variables;
michael@0 32
michael@0 33
michael@0 34 enum
michael@0 35 {
michael@0 36 INST_0, // $0
michael@0 37 INST_1, // $1
michael@0 38 INST_2, // $2
michael@0 39 INST_3, // $3
michael@0 40 INST_4, // $4
michael@0 41 INST_5, // $5
michael@0 42 INST_6, // $6
michael@0 43 INST_7, // $7
michael@0 44 INST_8, // $8
michael@0 45 INST_9, // $9
michael@0 46 INST_R0, // $R0
michael@0 47 INST_R1, // $R1
michael@0 48 INST_R2, // $R2
michael@0 49 INST_R3, // $R3
michael@0 50 INST_R4, // $R4
michael@0 51 INST_R5, // $R5
michael@0 52 INST_R6, // $R6
michael@0 53 INST_R7, // $R7
michael@0 54 INST_R8, // $R8
michael@0 55 INST_R9, // $R9
michael@0 56 INST_CMDLINE, // $CMDLINE
michael@0 57 INST_INSTDIR, // $INSTDIR
michael@0 58 INST_OUTDIR, // $OUTDIR
michael@0 59 INST_EXEDIR, // $EXEDIR
michael@0 60 INST_LANG, // $LANGUAGE
michael@0 61 __INST_LAST
michael@0 62 };
michael@0 63
michael@0 64 typedef struct {
michael@0 65 int autoclose;
michael@0 66 int all_user_var;
michael@0 67 int exec_error;
michael@0 68 int abort;
michael@0 69 int exec_reboot;
michael@0 70 int reboot_called;
michael@0 71 int XXX_cur_insttype; // deprecated
michael@0 72 int XXX_insttype_changed; // deprecated
michael@0 73 int silent;
michael@0 74 int instdir_error;
michael@0 75 int rtl;
michael@0 76 int errlvl;
michael@0 77 int alter_reg_view;
michael@0 78 } exec_flags_type;
michael@0 79
michael@0 80 typedef struct {
michael@0 81 exec_flags_type *exec_flags;
michael@0 82 int (__stdcall *ExecuteCodeSegment)(int, HWND);
michael@0 83 void (__stdcall *validate_filename)(TCHAR *);
michael@0 84 } extra_parameters;
michael@0 85
michael@0 86 static int __stdcall popstring(TCHAR *str); // 0 on success, 1 on empty stack
michael@0 87 static void __stdcall pushstring(const TCHAR *str);
michael@0 88 static char * __stdcall getuservariable(const int varnum);
michael@0 89 static void __stdcall setuservariable(const int varnum, const TCHAR *var);
michael@0 90
michael@0 91 #ifdef _UNICODE
michael@0 92 #define PopStringW(x) popstring(x)
michael@0 93 #define PushStringW(x) pushstring(x)
michael@0 94 #define SetUserVariableW(x,y) setuservariable(x,y)
michael@0 95
michael@0 96 static int __stdcall PopStringA(char* ansiStr);
michael@0 97 static void __stdcall PushStringA(const char* ansiStr);
michael@0 98 static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
michael@0 99 static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
michael@0 100 static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr);
michael@0 101
michael@0 102 #else
michael@0 103 // ANSI defs
michael@0 104
michael@0 105 #define PopStringA(x) popstring(x)
michael@0 106 #define PushStringA(x) pushstring(x)
michael@0 107 #define SetUserVariableA(x,y) setuservariable(x,y)
michael@0 108
michael@0 109 static int __stdcall PopStringW(wchar_t* wideStr);
michael@0 110 static void __stdcall PushStringW(wchar_t* wideStr);
michael@0 111 static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
michael@0 112 static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
michael@0 113 static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr);
michael@0 114
michael@0 115 #endif
michael@0 116
michael@0 117 static BOOL __stdcall IsUnicode(void)
michael@0 118 static TCHAR* __stdcall AllocString();
michael@0 119

mercurial