BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { int iMainStringSet = 0; popstring(buf); while (*(int*)buf == CHAR4_TO_DWORD('/','s','e','t') && !buf[4]) { unsigned int id; popstring(buf); id = myatou(buf); popstring(buf); SetDlgItemText(hwndDlg, id, buf); popstring(buf); if (id == IDC_STR) iMainStringSet++; } SetWindowText(hwndDlg, buf); if (!iMainStringSet) SetDlgItemText(hwndDlg, IDC_STR, buf); if (!*buf) SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW); } if (uMsg == WM_CLOSE) { DestroyWindow(hwndDlg); } return 0; }
void __declspec(dllexport) UpdateDriver(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { int retval; g_hwndParent=hwndParent; EXDLL_INIT(); { BOOL restart = 0; DWORD flags = 0;//INSTALLFLAG_NONINTERACTIVE DWORD lastErrorCode; char hardwareID[256]; char infFilePath[256]; popstring(hardwareID); popstring(infFilePath); retval = eIDUpdateDriver(hwndParent,hardwareID,infFilePath,flags,&restart, &lastErrorCode); if(retval != 0) { //on succes, let the caller know if a system reboot was requested pushint((int)restart); } else { //on failure, send the error code pushint((int)lastErrorCode); } pushint(retval); } }
BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { int iMainStringSet = 0; popstring(buf); while (lstrcmp(buf, _T("/set")) == 0) { unsigned int id; popstring(buf); id = myatou(buf); popstring(buf); SetDlgItemText(hwndDlg, id, buf); popstring(buf); if (id == IDC_STR) iMainStringSet++; } SetWindowText(hwndDlg, buf); if (!iMainStringSet) SetDlgItemText(hwndDlg, IDC_STR, buf); if (!*buf) SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW); } if (uMsg == WM_CLOSE) { DestroyWindow(hwndDlg); } return 0; }
static BOOL PopRegKeyArgs(TCHAR * path, BOOL *options) { TCHAR * param = (TCHAR *)GlobalAlloc(GPTR, g_string_size*sizeof(TCHAR)); int iRootKey; BOOL success = FALSE; if (!popstring(param)) { *options = FALSE; if (lstrcmpi(param, _T("/noinherit")) == 0) { *options = TRUE; popstring(param); } } else ABORT("Root key name missing"); iRootKey = ParseEnum(g_rootKeyNames, param); if (!ARRAY_CONTAINS(g_rootKeyPrefixes, iRootKey)) ABORT_s("Bad root key name (%s)", param); if (popstring(param)) ABORT("Registry key name missing"); path[0] = 0; lstrcat(path, g_rootKeyPrefixes[iRootKey]); lstrcat(path, param); success = TRUE; cleanup: GlobalFree(param); return success; }
static const SchemeType * PopFileArgs(TCHAR * path, BOOL *options) { if (popstring(path) == 0) { DWORD attr; *options = FALSE; if (lstrcmpi(path, _T("/noinherit")) == 0) { *options = TRUE; popstring(path); } attr = GetFileAttributes(path); if (INVALID_FILE_ATTRIBUTES != attr) return FILE_ATTRIBUTE_DIRECTORY & attr ? g_directoryScheme : g_fileScheme; else ABORT("Invalid filesystem path missing"); } else ABORT("Filesystem path missing"); cleanup: return NULL; }
int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height) { RECT dialogRect; int dialogWidth; int dialogHeight; char buf[1024]; GetClientRect(g_dialog.hwDialog, &dialogRect); dialogWidth = dialogRect.right; dialogHeight = dialogRect.bottom; if (popstring(buf, 1024)) return 1; *x = ConvertPlacement(buf, dialogWidth, 0); if (popstring(buf, 1024)) return 1; *y = ConvertPlacement(buf, dialogHeight, 1); if (popstring(buf, 1024)) return 1; *width = ConvertPlacement(buf, dialogWidth, 0); if (popstring(buf, 1024)) return 1; *height = ConvertPlacement(buf, dialogHeight, 1); ConvertPosToRTL(x, *width, dialogWidth); return 0; }
static void ChangeDACL(const SchemeType * scheme, TCHAR * path, DWORD mode, BOOL noinherit) { TCHAR * param = (TCHAR *)LocalAlloc(LPTR, g_string_size*sizeof(TCHAR)); TCHAR * trusteeName = NULL; PSID pSid = NULL; DWORD trusteeForm = TRUSTEE_IS_NAME; DWORD permissions = 0; PACL pOldAcl = NULL; PACL pNewAcl = NULL; EXPLICIT_ACCESS access; DWORD ret = 0; if (popstring(param)) ABORT("Trustee is missing"); if (NULL == (trusteeName = ParseTrustee(param, &trusteeForm))) ABORT_s("Bad trustee (%s)", param); if (popstring(param)) ABORT("Permission flags are missing"); if (0 == (permissions = ParsePermissions(scheme, param))) ABORT_s("Bad permission flags (%s)", param); ret = GetNamedSecurityInfo(path, scheme->type, DACL_SECURITY_INFORMATION, NULL, NULL, &pOldAcl, NULL, NULL); if (ret != ERROR_SUCCESS) ABORT_d("Cannot read access control list. Error code: %d", ret); BuildExplicitAccessWithName(&access, _T(""), permissions, (ACCESS_MODE)mode, scheme->defaultInheritance); access.Trustee.TrusteeForm = (TRUSTEE_FORM)trusteeForm; access.Trustee.ptstrName = trusteeName; if (noinherit) access.grfInheritance = NO_INHERITANCE; ret = SetEntriesInAcl(1, &access, pOldAcl, &pNewAcl); if (ret != ERROR_SUCCESS) ABORT_d("Cannot build new access control list. Error code: %d", ret); ret = SetNamedSecurityInfo(path, scheme->type, DACL_SECURITY_INFORMATION, NULL, NULL, pNewAcl, NULL); if (ret != ERROR_SUCCESS) ABORT_d("Cannot apply new access control list. Error code: %d", ret); cleanup: if (NULL != pNewAcl) LocalFree(pNewAcl); if (NULL != pOldAcl) LocalFree(pOldAcl); LocalFree(trusteeName); LocalFree(param); }
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int i, size; static HFONT font; switch (uMsg) { case WM_INITDIALOG: for (i = langs_num - 1; i >= 0; i--) { SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name); } SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext); SetWindowText(hwndDlg, g_wndtitle); SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0); for (i = 0; i < langs_num; i++) { if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) { SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, langs_num-i-1, 0); break; } } if (dofont && !popstring(temp)) { size = myatoi(temp); if (!popstring(temp)) { LOGFONT f = {0,}; if (lstrcmp(temp, "MS Shell Dlg")) { f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72); lstrcpy(f.lfFaceName, temp); font = CreateFontIndirect(&f); SendMessage(hwndDlg, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDOK, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDCANCEL, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1); } } } ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: pushstring(langs[langs_num-SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)-1].id); EndDialog(hwndDlg, 0); break; case IDCANCEL: pushstring("cancel"); EndDialog(hwndDlg, 1); break; } break; case WM_CLOSE: if (font) DeleteObject(font); pushstring("cancel"); EndDialog(hwndDlg, 1); break; default: return 0; } return 1; }
extern "C" void __declspec(dllexport) Sound(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { DWORD flags = SND_FILENAME|SND_NODEFAULT; g_stacktop=stacktop; popstring(temp); if (lstrcmp(temp, "/WAIT")) flags |= SND_ASYNC; else popstring(temp); PlaySound(temp, 0, flags); }
extern "C" void __declspec(dllexport) Set(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { g_stringsize = string_size; g_stacktop = stacktop; g_variables = variables; { IPropertyStore *m_pps = NULL; WCHAR wszPath[MAX_PATH]; WCHAR wszAppID[MAX_PATH]; TCHAR szPath[MAX_PATH]; TCHAR szAppID[MAX_PATH]; bool success = false; ZeroMemory(wszPath, sizeof(wszPath)); ZeroMemory(wszAppID, sizeof(wszAppID)); ZeroMemory(szPath, sizeof(szPath)); ZeroMemory(szAppID, sizeof(szAppID)); popstring(szPath, MAX_PATH); popstring(szAppID, MAX_PATH); #if !defined(UNICODE) MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, szAppID, -1, wszAppID, MAX_PATH); #else wcscpy(wszPath, szPath); wcscpy(wszAppID, szAppID); #endif ::CoInitialize(NULL); if (SUCCEEDED(SHGetPropertyStoreFromParsingName(wszPath, NULL, GPS_READWRITE, IID_PPV_ARGS(&m_pps)))) { PROPVARIANT propvar; if (SUCCEEDED(InitPropVariantFromString(wszAppID, &propvar))) { if (SUCCEEDED(m_pps->SetValue(PKEY_AppUserModel_ID, propvar))) { if (SUCCEEDED(m_pps->Commit())) { success = true; } } } } if (m_pps != NULL) m_pps->Release(); CoUninitialize(); pushstring(success == true ? TEXT("0") : TEXT("-1"), MAX_PATH); } }
void __declspec(dllexport) CalculateSha512Sum(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) { int i; TCHAR filename[1024]; Sha512Context context; HANDLE file; char buffer[512]; char comp[1024]; DWORD bytesread; SHA512_HASH sha512; int compout; EXDLL_INIT(); popstring(filename); popstring(comp); Sha512Initialise(&context); file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (!file) { filename[0] = '0'; filename[1] = 0; pushstring(comp); pushstring(filename); return; } while (1) { ReadFile(file, buffer, 512, &bytesread, NULL); if (!bytesread) break; Sha512Update(&context, buffer, bytesread); if (bytesread < 512) break; } Sha512Finalise(&context, &sha512); CloseHandle(file); for (i = 0; i < (512 / 8); i++) { buffer[i * 2] = hexdigit(sha512.bytes[i] >> 4); buffer[(i * 2) + 1] = hexdigit(sha512.bytes[i] & 0xF); } buffer[512 / 4] = 0; compout = memcmp(buffer, comp, 128); if (compout) { filename[0] = '0'; } else { filename[0] = '1'; } filename[1] = 0; pushstring(comp); pushstring(filename); }
void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { HWND hwCtl; struct nsControl* ctl; // get info from stack hwCtl = (HWND) popint(); if (!IsWindow(hwCtl)) { popint(); // remove user data from stack return; } // get descriptor ctl = GetControl(hwCtl); if (ctl == NULL) return; // set user data popstring(ctl->userData, USERDATA_SIZE); }
extern "C" void __declspec(dllexport) CreateMediaCenterShortcut( HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { EXDLL_INIT(); char *cBinPath = NULL; cBinPath = (char*)GlobalAlloc(GPTR, string_size); popstring( cBinPath ); char shortcutLink[MAX_PATH]; sprintf( shortcutLink, "\"%s\" -media", cBinPath ); HRESULT hr = CoInitialize(NULL); char *mediaCenterPath = (char*)GlobalAlloc(GPTR, string_size); hr = SHGetFolderPathA( NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, mediaCenterPath ); char shortcutPath[MAX_PATH]; char filename[MAX_PATH]; sprintf( shortcutPath, "%s\\Media Center Programs\\Darwinia", mediaCenterPath ); sprintf( filename, "%s\\darwinia.lnk", shortcutPath ); CreateLink( cBinPath, shortcutPath, filename, "", "-mediacenter" ); }
void __declspec(dllexport) GetFileMD5(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { g_hwndParent=hwndParent; EXDLL_INIT(); { TCHAR filename[MAX_PATH]; char md5_string[33]; HANDLE hFile; md5_byte_t digest[16]; popstring(filename); hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) { //pushstring("ERROR: Unable to open file for MD5 calculation"); pushstring(_T("")); return; } if (!FileMD5(hFile, digest)) { //pushstring("ERROR: Unable to calculate MD5"); pushstring(_T("")); } else { md5_string[32] = '\0'; MD5ToString(md5_string,digest); PushStringA(md5_string); } CloseHandle(hFile); } }
void __declspec(dllexport) GetFileCRC32(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { g_hwndParent=hwndParent; EXDLL_INIT(); { TCHAR filename[MAX_PATH]; char crc_string[9]; HANDLE hFile; unsigned long crc; popstring(filename); hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) { //pushstring("ERROR: Unable to open file for CRC32 calculation"); pushstring(_T("")); return; } if (!FileCRC(hFile, &crc)) { //pushstring("ERROR: Unable to calculate CRC32"); pushstring(_T("")); } else { crc_string[8] = '\0'; CRC32ToString(crc_string,crc); PushStringA(crc_string); } CloseHandle(hFile); } }
extern "C" void __declspec(dllexport) open_file_dialog( HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { EXDLL_INIT(); char szBuffer[1024]=""; popstring(szBuffer); HWND hWndParent = (HWND)atoi(szBuffer); CFileDialog dlg(TRUE, _T("lic"), NULL, OFN_FILEMUSTEXIST, _T("CrashFix License Files (*.lic)\0*.lic\0All Files (*.*)\0*.*\0\0"), hWndParent); INT_PTR nResult = dlg.DoModal(hWndParent); if(nResult==IDOK) { CStringA sFileName = dlg.m_szFileName; pushstring(sFileName.GetBuffer()); } else { pushstring(""); } }
int NSISCALL PopStringA(char* ansiStr) { wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t)); int rval = popstring(wideStr); WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL); GlobalFree((HGLOBAL)wideStr); return rval; }
// ANSI defs int NSISCALL PopStringW(wchar_t* wideStr) { char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize); int rval = popstring(ansiStr); MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize); GlobalFree((HGLOBAL)ansiStr); return rval; }
PUBLIC_FUNCTION_END PUBLIC_FUNCTION(IsUserTheAdministrator) { TCHAR * name = (TCHAR *)LocalAlloc(LPTR, string_size*sizeof(TCHAR)); TCHAR * sidstr = NULL; DWORD dwName = string_size; PSID pSid = NULL; DWORD sidLen = 0; DWORD domLen = 0; TCHAR * domain = NULL; SID_NAME_USE use; if (popstring(name)) ABORT("Missing user name plug-in parameter."); if ((LookupAccountName(NULL, name, NULL, &sidLen, NULL, &domLen, &use) || ERROR_INSUFFICIENT_BUFFER == GetLastError()) && NULL != (domain = (TCHAR *)LocalAlloc(LPTR, domLen*sizeof(TCHAR))) && NULL != (pSid = (PSID)LocalAlloc(LPTR, sidLen))) { if (!LookupAccountName(NULL, name, pSid, &sidLen, domain, &domLen, &use)) { LocalFree(pSid); pSid = NULL; ABORT_d("Couldn't lookup current user name. Error code %d: ", GetLastError()); } int uid; if (500 == (uid = *GetSidSubAuthority(pSid, *GetSidSubAuthorityCount(pSid) - 1))) pushstring(_T("yes")); else pushstring(_T("no")); sidstr = (TCHAR *)LocalAlloc(LPTR, string_size*sizeof(TCHAR)); ConvertSidToStringSid(pSid, &sidstr); int len = lstrlen(sidstr); TCHAR * strend = sidstr + len - 1; TCHAR * strstart = sidstr; while (*strend != '-' && len >= 0) { strend--; len--; } *strend = '\0'; lstrcat(strend, _T("-500")); pushstring(sidstr); } cleanup: if (NULL != sidstr) LocalFree(sidstr); LocalFree(name); }
void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { Init(hwndParent, string_size, variables, stacktop, extra); if (g_hwStartMenuSelect) { popstring(buf); Show(hwndParent, string_size, variables, stacktop); } }
} PLUGINFUNCTIONEND #endif /* __GNUC__ */ PLUGINFUNCTIONSHORT(Int64Op) { __int64 i1, i2 = 0, i3, i4; char *op, *o1, *o2; char buf[128]; // Get strings o1 = popstring(); op = popstring(); i1 = myatoi(o1); // convert first arg to int64 if ((*op != '~') && (*op != '!')) { // get second arg, convert it, free it o2 = popstring(); i2 = myatoi(o2); GlobalFree(o2); } // operation switch (*op) { case '+': i1 += i2; break; case '-': i1 -= i2; break; case '*': i1 *= i2; break; case '/': case '%': // It's unclear, but in this case compiler will use DivMod rountine // instead of two separate Div and Mod rountines. if (i2 == 0) { i3 = 0; i4 = i1; } else {i3 = i1 / i2; i4 = i1 % i2; } if (*op == '/') i1 = i3; else i1 = i4; break; case '|': if (op[1] == '|') i1 = i1 || i2; else i1 |= i2; break; case '&': if (op[1] == '&') i1 = i1 && i2; else i1 &= i2; break; case '^': i1 ^= i2; break; case '~': i1 = ~i1; break; case '!': i1 = !i1; break; case '<': if (op[1] == '<') i1 = i1 << i2; else i1 = i1 < i2; break; case '>': if (op[1] == '>') i1 = i1 >> i2; else i1 = i1 > i2; break; case '=': i1 = (i1 == i2); break; }
extern "C" void __declspec(dllexport) write_config_string( HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { EXDLL_INIT(); char szFileName[1024]=""; char szParamName[1024]=""; char szValue[1024]=""; popstring(szFileName); popstring(szParamName); popstring(szValue); //MessageBoxA(NULL, szFileName, szParamName, 0); bool bInit = false; CConfig config(szFileName, &bInit); int nResult = config.writeProfileString(szParamName, szValue); }
extern "C" void __declspec(dllexport) dialog(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { hMainWindow=hwndParent; EXDLL_INIT(); if (initCalled) { pushstring("error"); return; } if (createCfgDlg()) return; popstring(NULL); showCfgDlg(); }
extern "C" void __declspec(dllexport) read_config_string( HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { EXDLL_INIT(); char szFileName[1024]=""; char szParamName[1024]=""; char szValue[1024]=""; popstring(szFileName); popstring(szParamName); //MessageBoxA(NULL, szFileName, szParamName, 0); bool bInit = false; CConfig config(szFileName, &bInit); char* szResult = config.getProfileString(szParamName, szValue, 1024); if(szResult!=NULL) pushstring(szResult); else pushstring(""); }
static void ChangeOwner(const SchemeType * scheme, TCHAR * path, ChangeMode mode) { TCHAR * param = (TCHAR *)LocalAlloc(LPTR, g_string_size*sizeof(TCHAR)); SECURITY_INFORMATION what; PSID pSidOwner = NULL; PSID pSidGroup = NULL; PSID pSid = NULL; DWORD ret = 0; HANDLE hToken; if (popstring(param)) ABORT("Trustee is missing"); if (NULL == (pSid = ParseSid(param))) ABORT_s("Bad trustee (%s)", param); switch(mode) { case ChangeMode_Owner: what = OWNER_SECURITY_INFORMATION; pSidOwner = pSid; break; case ChangeMode_Group: what = GROUP_SECURITY_INFORMATION; pSidGroup = pSid; break; default: ABORT_d("Bug: Unsupported change mode: %d", mode); } if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) ABORT_d("Cannot open process token. Error code: %d", GetLastError()); if (!SetPrivilege(hToken, SE_RESTORE_NAME, TRUE)) ABORT("Unable to give SE_RESTORE_NAME privilege."); ret = SetNamedSecurityInfo(path, scheme->type, what, pSidOwner, pSidGroup, NULL, NULL); if (ret != ERROR_SUCCESS) ABORT_d("Cannot apply new ownership. Error code: %d", ret); cleanup: SetPrivilege(hToken, SE_RESTORE_NAME, FALSE); CloseHandle(hToken); LocalFree(param); }
extern "C" void __declspec(dllexport) SetImage(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { EXDLL_INIT(); popstring(temp); if (!lstrcmp(temp, "/FILLSCREEN")) { x = GetSystemMetrics(SM_CXSCREEN); y = GetSystemMetrics(SM_CYSCREEN); popstring(temp); } else x = y = 0; BITMAP bitmap; if (hBitmap) DeleteObject((HGDIOBJ)hBitmap); hBitmap = (HBITMAP)LoadImage(0, temp, IMAGE_BITMAP, x, y, LR_LOADFROMFILE); if (!hBitmap) { pushstring("can't load bitmap"); return; } GetObject(hBitmap, sizeof(bitmap), (LPSTR)&bitmap); x = x ? x : bitmap.bmWidth; y = y ? y : bitmap.bmHeight; if (hWndImage) { SetWindowPos( hWndImage, hWndParent, (GetSystemMetrics(SM_CXSCREEN)-x)/2, (GetSystemMetrics(SM_CYSCREEN)-y)/2, x, y, SWP_NOACTIVATE ); RedrawWindow(hWndImage, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } }
VerifyCertNameIssuer(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, void *extra) { TCHAR tmp1[MAX_PATH + 1] = { _T('\0') }; TCHAR tmp2[MAX_PATH + 1] = { _T('\0') }; TCHAR tmp3[MAX_PATH + 1] = { _T('\0') }; WCHAR filePath[MAX_PATH + 1] = { L'\0' }; WCHAR certName[MAX_PATH + 1] = { L'\0' }; WCHAR certIssuer[MAX_PATH + 1] = { L'\0' }; popstring(stacktop, tmp1, MAX_PATH); popstring(stacktop, tmp2, MAX_PATH); popstring(stacktop, tmp3, MAX_PATH); #if !defined(UNICODE) MultiByteToWideChar(CP_ACP, 0, tmp1, -1, filePath, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, tmp2, -1, certName, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, tmp3, -1, certIssuer, MAX_PATH); #else wcsncpy(filePath, tmp1, MAX_PATH); wcsncpy(certName, tmp2, MAX_PATH); wcsncpy(certIssuer, tmp3, MAX_PATH); #endif CertificateCheckInfo allowedCertificate = { certName, certIssuer, }; LONG retCode = CheckCertificateForPEFile(filePath, allowedCertificate); if (retCode == ERROR_SUCCESS) { pushstring(stacktop, TEXT("1"), 2); } else { pushstring(stacktop, TEXT("0"), 2); } }
extern "C" void __declspec(dllexport) UninstallPinnedItem(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { g_stringsize = string_size; g_stacktop = stacktop; g_variables = variables; IShellItem *pItem = NULL; IStartMenuPinnedList *pPinnedList = NULL; WCHAR wszPath[MAX_PATH]; TCHAR szPath[MAX_PATH]; bool success = false; ZeroMemory(wszPath, sizeof(wszPath)); ZeroMemory(szPath, sizeof(szPath)); popstring(szPath, MAX_PATH); #if !defined(UNICODE) MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH); #else wcscpy(wszPath, szPath); #endif CoInitialize(NULL); HRESULT hr; hr = SHCreateItemFromParsingName(wszPath, NULL, IID_PPV_ARGS(&pItem)); if (SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_StartMenuPin, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pPinnedList)); if (SUCCEEDED(hr)) { hr = pPinnedList->RemoveFromList(pItem); pPinnedList->Release(); success = true; } pItem->Release(); } CoUninitialize(); pushstring(success == true ? TEXT("0") : TEXT("-1"), MAX_PATH); }
void popfile(void) { struct parsefile *pf = parsefile; INTOFF; if (pf->fd >= 0) close(pf->fd); if (pf->buf) ckfree(pf->buf); while (pf->strpush) popstring(); parsefile = pf->prev; ckfree(pf); INTON; }
void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { g_hwndParent=hwndParent; EXDLL_INIT(); { int i; BOOL bPopOneMore = FALSE; if (popstring(g_wndtitle)) return; if (popstring(g_wndtext)) return; if (popstring(temp)) return; if (*temp == 'A') { stack_t *th; langs_num=0; th=(*g_stacktop); while (th && th->text[0]) { langs_num++; th = th->next; } if (!th) return; langs_num /= 2; bPopOneMore = TRUE; } else langs_num = myatoi(temp); { char *p=temp; while (*p) if (*p++ == 'F') dofont=1; } if (!langs_num) return; langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang)); for (i = 0; i < langs_num; i++) { if (popstring(temp)) return; langs[i].name = GlobalAlloc(GPTR, lstrlen(temp)+1); lstrcpy(langs[i].name, temp); if (popstring(temp)) return; langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1); lstrcpy(langs[i].id, temp); } if (bPopOneMore) { if (popstring(temp)) return; } DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc); } }