-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCheckLang.cpp
More file actions
102 lines (82 loc) · 2.49 KB
/
CheckLang.cpp
File metadata and controls
102 lines (82 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* CheckLang plugin for NSIS
* Add and remove record from PATH environment variable
* Copyright (C) 2015 Victor Spirin <vvs13@mail.ru>
* some defintions I took from AccessControl plugin by Mathias Hasselmann
*/
/*
#define WIN32_LEAN_AND_MEAN
#ifdef _WIN64
#define WINVER 0x502
#else
#define WINVER 0x400
#endif
*/
#include <windows.h>
#ifdef UNICODE
#include "nsis_unicode/pluginapi.h"
#else
#include "nsis_ansi/pluginapi.h"
#endif
#include <aclapi.h>
#include <sddl.h>
//#include <winnls.h>
//#include <tchar.h>
/*****************************************************************************
GLOBAL VARIABLES
*****************************************************************************/
HINSTANCE g_hInstance = NULL;
int g_string_size = 1024;
extra_parameters* g_extra = NULL;
/*****************************************************************************
UTILITIES
*****************************************************************************/
#define SIZE_OF_ARRAY(Array) (sizeof((Array)) / sizeof(*(Array)))
#define ARRAY_CONTAINS(Array, Index) (Index >= 0 && Index < SIZE_OF_ARRAY(Array))
void* LocalAllocZero(size_t cb) { return LocalAlloc(LPTR, cb); }
inline void* LocalAlloc(size_t cb) { return LocalAllocZero(cb); }
/*****************************************************************************
PLUG-IN HANDLING
*****************************************************************************/
#define PUBLIC_FUNCTION(Name) \
extern "C" void __declspec(dllexport) __cdecl Name(HWND hWndParent, int string_size, TCHAR* variables, stack_t** stacktop, extra_parameters* extra) \
{ \
EXDLL_INIT(); \
g_string_size = string_size; \
g_extra = extra;
#define PUBLIC_FUNCTION_END \
}
//UILANGUAGE_ENUMPROCA UiLangProc;
static BOOL langFound = FALSE;
BOOL CALLBACK UiLangProc(LPSTR id, LONG_PTR userStr)
{
LPSTR find = (LPSTR)userStr;
if (!lstrcmp(find, id)){
langFound = 1;
return FALSE;
}
return TRUE;
}
BOOL isLangPresent(LPSTR langId)
{
langFound = FALSE;
EnumUILanguagesA(UiLangProc, 0, (LONG_PTR)langId);
return langFound;
}
PUBLIC_FUNCTION(CheckLang)
{
TCHAR *retstr = TEXT("0");
TCHAR* param = (TCHAR*)LocalAlloc(g_string_size*sizeof(TCHAR));
popstring(param);
if (param && isLangPresent(param)) retstr = TEXT("1");
LocalFree(param);
pushstring(retstr);
}
PUBLIC_FUNCTION_END
#ifdef _VC_NODEFAULTLIB
#define DllMain _DllMainCRTStartup
#endif
EXTERN_C BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
g_hInstance = (HINSTANCE)hInst;
return TRUE;
}