| 1 |
#ifndef ___PLUGIN__H___ |
| 2 |
#define ___PLUGIN__H___ |
| 3 |
|
| 4 |
#include <nsis/pluginapi.h> // nsis plugin |
| 5 |
|
| 6 |
// Always use system* functions to keep the size down |
| 7 |
#define pushstring error(use system_pushstring) |
| 8 |
#undef pushint |
| 9 |
#define pushint error(use system_pushint) |
| 10 |
#define pushintptr error(use system_pushintptr) |
| 11 |
|
| 12 |
#undef myatoi |
| 13 |
#define myatoi(str) ( (int) myatoi64(str) ) |
| 14 |
#define system_pushint(v) system_pushintptr((INT_PTR)(v)) |
| 15 |
#define popintptr system_popintptr |
| 16 |
#ifdef _WIN64 |
| 17 |
# define StrToIntPtr(str) ( (INT_PTR)myatoi64((str)) ) |
| 18 |
# define IntPtrToStr(p,buf) myitoa64((p),(buf)) |
| 19 |
#else |
| 20 |
# define StrToIntPtr(str) ( (INT_PTR)myatoi((str)) ) |
| 21 |
# define IntPtrToStr(p,buf) myitoa64((p),(buf)) |
| 22 |
#endif |
| 23 |
|
| 24 |
#define BUGBUG64(brokencast) (brokencast) // Cast that needs fixing on x64 |
| 25 |
|
| 26 |
#define PLUGINFUNCTION(name) \ |
| 27 |
void __declspec(dllexport) name( \ |
| 28 |
HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) { \ |
| 29 |
/*g_hwndParent=hwndParent;*/ \ |
| 30 |
EXDLL_INIT(); \ |
| 31 |
extra->RegisterPluginCallback(g_hInstance, NSISCallback); |
| 32 |
#define PLUGINFUNCTIONEND } |
| 33 |
|
| 34 |
#define PLUGINFUNCTIONSHORT(name) void __declspec(dllexport) name(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { \ |
| 35 |
g_stringsize=string_size; \ |
| 36 |
g_stacktop=stacktop; |
| 37 |
|
| 38 |
extern TCHAR *AllocStr(TCHAR *str); |
| 39 |
extern void myitoa64(__int64 i, TCHAR *buffer); |
| 40 |
extern TCHAR *AllocString(); |
| 41 |
#define system_getuservariableptr(varnum) ( (g_variables)+(varnum)*(g_stringsize) ) |
| 42 |
extern TCHAR *system_getuservariable(int varnum); // NOTE: This dupes with GlobalAlloc! |
| 43 |
extern TCHAR *system_setuservariable(int varnum, TCHAR *var); |
| 44 |
extern TCHAR* system_popstring(); // NULL - stack empty |
| 45 |
extern TCHAR* system_pushstring(TCHAR *str); |
| 46 |
extern __int64 myatoi64(TCHAR *s); |
| 47 |
extern INT_PTR system_popintptr(); // -1 -> stack empty |
| 48 |
extern void system_pushintptr(INT_PTR value); |
| 49 |
|
| 50 |
extern HANDLE GlobalCopy(HANDLE Old); |
| 51 |
extern void *copymem(void *output, void *input, size_t cbSize); |
| 52 |
|
| 53 |
extern UINT_PTR NSISCallback(enum NSPIM); |
| 54 |
|
| 55 |
extern HWND g_hwndParent; |
| 56 |
extern HINSTANCE g_hInstance; |
| 57 |
|
| 58 |
#endif |