Added GetKnownFolderPath
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7154 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1f355d992c
commit
68db5f04ee
10 changed files with 128 additions and 5 deletions
|
@ -1390,7 +1390,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
else if (which==EW_FPUTS)
|
||||
{
|
||||
GetStringFromParm(0x21); // load string in buf2, convert it to ANSI in buf1
|
||||
WideCharToMultiByte(CP_ACP, 0, buf2, -1, (LPSTR) buf1, NSIS_MAX_STRLEN, NULL, NULL);
|
||||
StrWideToACP(buf2, (LPSTR) buf1, NSIS_MAX_STRLEN);
|
||||
l=lstrlenA((LPCSTR)buf1);
|
||||
}
|
||||
#endif
|
||||
|
@ -1704,6 +1704,32 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
break;
|
||||
#endif//NSIS_CONFIG_COMPONENTPAGE
|
||||
|
||||
case EW_GETOSINFO:
|
||||
{
|
||||
//switch(parm0)
|
||||
{
|
||||
#ifdef NSIS_SUPPORT_FNUTIL
|
||||
//case 0:
|
||||
{
|
||||
TCHAR *outstr = var1;
|
||||
IID kfid;
|
||||
HRESULT(WINAPI*SHGKFP)(REFIID,DWORD,HANDLE,PWSTR*) = (HRESULT(WINAPI*)(REFIID,DWORD,HANDLE,PWSTR*)) myGetProcAddress(MGA_SHGetKnownFolderPath);
|
||||
TCHAR *buf2 = GetStringFromParm(0x22), succ = FALSE;
|
||||
if (SHGKFP && SUCCEEDED(ComIIDFromString(buf2, &kfid)))
|
||||
{
|
||||
PWSTR path;
|
||||
HRESULT hr = SHGKFP(&kfid, parm3, NULL, &path);
|
||||
if (SUCCEEDED(hr))
|
||||
strcpyWideToT(outstr, path), CoTaskMemFree(path), ++succ;
|
||||
}
|
||||
if (!succ)
|
||||
exec_error++, *outstr = _T('\0');
|
||||
}
|
||||
//break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
#ifdef NSIS_LOCKWINDOW_SUPPORT
|
||||
case EW_LOCKWINDOW:
|
||||
{
|
||||
|
|
|
@ -193,9 +193,8 @@ enum
|
|||
// InstTypeGetFlags: 3: [idx, 1, output]
|
||||
#endif
|
||||
|
||||
// instructions not actually implemented in exehead, but used in compiler.
|
||||
EW_GETLABELADDR, // both of these get converted to EW_ASSIGNVAR
|
||||
EW_GETFUNCTIONADDR,
|
||||
EW_GETOSINFO, // 1+ [operation, ...]
|
||||
EW_RESERVEDOPCODE, // Free slot, feel free to use it for something
|
||||
|
||||
#ifdef NSIS_LOCKWINDOW_SUPPORT
|
||||
EW_LOCKWINDOW,
|
||||
|
@ -207,6 +206,10 @@ enum
|
|||
EW_FGETWS, // FileReadUTF16LE: 4 [handle, output, maxlen, ?getchar:gets]
|
||||
#endif//NSIS_SUPPORT_FILEFUNCTIONS
|
||||
#endif
|
||||
|
||||
// Opcodes listed here are not actually used in exehead. No exehead opcodes should be present after these!
|
||||
EW_GETLABELADDR, // --> EW_ASSIGNVAR
|
||||
EW_GETFUNCTIONADDR, // --> EW_ASSIGNVAR
|
||||
};
|
||||
|
||||
#pragma pack(push, 1) // fileform.cpp assumes no padding/alignment
|
||||
|
|
|
@ -771,6 +771,30 @@ TCHAR * NSISCALL mystrcat(TCHAR *out, const TCHAR *concat)
|
|||
return lstrcat(out, concat);
|
||||
}
|
||||
|
||||
int StrWideToACP(LPCWSTR Src, char* Dst, int DstCap)
|
||||
{
|
||||
return WideCharToMultiByte(CP_ACP, 0, Src, -1, Dst, DstCap, NULL, NULL);
|
||||
}
|
||||
|
||||
#ifndef UNICODE
|
||||
void strcpyWideToT(TCHAR *out, LPCWSTR in)
|
||||
{
|
||||
StrWideToACP(in, out, NSIS_MAX_STRLEN);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNICODE)
|
||||
HRESULT ComIIDFromString(LPCTSTR str, IID*out)
|
||||
{
|
||||
WCHAR buf[130];
|
||||
signed char i;
|
||||
for (i = 0; i >= 0; ++i)
|
||||
if (!(buf[i] = str[i]))
|
||||
return IIDFromString(buf, out);
|
||||
return E_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
TCHAR ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
||||
|
||||
const TCHAR SYSREGKEY[] = _T("Software\\Microsoft\\Windows\\CurrentVersion");
|
||||
|
@ -1145,6 +1169,7 @@ struct MGA_FUNC MGA_FUNCS[] = {
|
|||
{"ADVAPI32", "RegDeleteKeyExW"},
|
||||
#endif
|
||||
{"ADVAPI32", "InitiateShutdownW"},
|
||||
{"SHELL32", "SHGetKnownFolderPath"},
|
||||
{"SHELL32", (CHAR*) 680}, // IsUserAnAdmin
|
||||
#ifndef _WIN64
|
||||
{"SHLWAPI", (CHAR*) 437}, // IsOS
|
||||
|
@ -1163,6 +1188,7 @@ struct MGA_FUNC MGA_FUNCS[] = {
|
|||
{"KERNEL32", "GetUserDefaultUILanguage"},
|
||||
{"ADVAPI32", "RegDeleteKeyExA"},
|
||||
{"ADVAPI32", "InitiateShutdownA"},
|
||||
{"SHELL32", "SHGetKnownFolderPath"},
|
||||
{"SHELL32", (CHAR*) 680}, // IsUserAnAdmin
|
||||
#ifndef _WIN64
|
||||
{"SHLWAPI", (CHAR*) 437}, // IsOS
|
||||
|
@ -1234,7 +1260,7 @@ void * NSISCALL NSISGetProcAddress(HANDLE dllHandle, TCHAR* funcName)
|
|||
{
|
||||
#ifdef _UNICODE
|
||||
char ansiName[256];
|
||||
if (WideCharToMultiByte(CP_ACP, 0, funcName, -1, ansiName, 256, NULL, NULL) != 0)
|
||||
if (StrWideToACP(funcName, ansiName, 256) != 0)
|
||||
return GetProcAddress(dllHandle, ansiName);
|
||||
return NULL;
|
||||
#else
|
||||
|
|
|
@ -40,7 +40,20 @@ TCHAR * NSISCALL mystrcpy(TCHAR *out, const TCHAR *in);
|
|||
int NSISCALL mystrlen(const TCHAR *in);
|
||||
TCHAR * NSISCALL mystrcat(TCHAR *out, const TCHAR *concat);
|
||||
TCHAR * NSISCALL mystrstr(TCHAR *a, TCHAR *b);
|
||||
int StrWideToACP(LPCWSTR Src, char* Dst, int DstCap);
|
||||
#ifdef UNICODE
|
||||
#define strcpyWideToT mystrcpy
|
||||
#else
|
||||
void strcpyWideToT(TCHAR *out, LPCWSTR in);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
#define ComIIDFromString(s,out) SHCLSIDFromString((s),(CLSID*)(out))
|
||||
#elif defined(UNICODE)
|
||||
#define ComIIDFromString(s,out) IIDFromString((s), (IID*)(out))
|
||||
#else
|
||||
HRESULT ComIIDFromString(LPCTSTR str, IID*out);
|
||||
#endif
|
||||
|
||||
#ifndef KEY_CREATE_LINK
|
||||
#define KEY_CREATE_LINK 0x0020
|
||||
|
@ -154,6 +167,7 @@ enum myGetProcAddressFunctions {
|
|||
MGA_RegDeleteKeyEx,
|
||||
#endif
|
||||
MGA_InitiateShutdown,
|
||||
MGA_SHGetKnownFolderPath,
|
||||
MGA_IsUserAnAdmin,
|
||||
#ifndef _WIN64
|
||||
MGA_IsOS,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue