Skip to content

Instantly share code, notes, and snippets.

@sredna
sredna / ManifestDPIAwareness.nsi
Created September 27, 2017 13:52
NSIS ManifestDPIAwareness PerMonitorV2
ManifestDPIAware System ; System DPI on Vista/7/8/8.1/10(<10.1607(AU))
ManifestDPIAwareness "PerMonitorV2,System" ; PMv2 on 10.1703(CU)+, System on 10.1607(AU) with NSIS 3.03+
Page Custom DPIInfoPage
Page InstFiles
!include nsDialogs.nsh
Function DPIInfoPage
nsDialogs::Create 1018
Pop $0
@sredna
sredna / BinInterop_VXD.cxx
Last active October 16, 2017 19:57
NSIS VXD version interop
#include <string.h> // strlen
#pragma pack(push, 1)
typedef struct tagMINI_IMAGE_VXD_HEADER {
WORD e32_magic, endian;
BYTE padding[180];
DWORD e32_winresoff, e32_winreslen;
WORD e32_devid, e32_ddkver;
} MINI_IMAGE_VXD_HEADER, *PMINI_IMAGE_VXD_HEADER;
#pragma pack(pop)
!ifndef FSContainerExists
!macro _FSContainerExists _a _b _t _f ; Directory, UNC share or drive root
IfFileExists `${_b}\*` `${_t}` `${_f}`
!macroend
!define FSContainerExists `"" FSContainerExists`
!endif
!ifndef FSDirectoryExists
!macro _FSDirectoryExists _a _b _t _f ; Directory or UNC share
IfFileExists `${_b}\?` `${_t}` `${_f}`
@sredna
sredna / PubTemp.nsi
Last active August 20, 2019 18:39
Temp
System::Get '(m.r1)ir2r0'
Pop $9
Var /global tries
again:
intop $tries $tries + 1
System::Call 'kernel32::EnumSystemLocalesA(k r9, i 0)i.r0' ; K$9 will be Cloned. PrepareProc:PT_NOTHING changes proc from K$9 to clone
loop:
StrCpy $2 $0 8 ; v2 callback id hack
StrCmp $2 "callback" 0 done
@sredna
sredna / build_zlib.cmd
Last active June 11, 2018 20:58
build_zlib.cmd
@echo off
setlocal ENABLEEXTENSIONS
if not "%~1" == "" set MACHINE=%~1
if "%MACHINE%" == "" (
set MACHINE=AMD64
echo.WARN: MACHINE target not set, defaulting to %MACHINE%
)
set _win=win32
@echo off
REM
REM This "installer/uninstaller" is supposed
REM to demostrate a issue with the
REM "Automated application uninstall" part
REM of WACK. The issue is that WACK
REM just uses the UninstallString command
REM and this command usually displays a UI
REM that requires user interaction.
REM It would be nice if WACK could use the
# https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page
# Unicode False
ManifestAppendCustomString '/assembly/application/windowsSettings' '<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>'
Section
SetDetailsView show
System::Call 'KERNEL32::GetACP()i.r0'
DetailPrint GetACP=$0
@sredna
sredna / RichEd_EditorStatistics.h
Last active August 2, 2021 14:12
RichEdit editor statistics proposal
#define EM_GETEDITORSTATISTICS (WM_USER + ?) // LPARAM=EDITORSTATISTICS*. Returns ESM_* successfully retrieved
#define ESM_IPPOS 0x01 // IP row/col
#define ESM_LINECOUNT 0x02 // LineCount & EndNL
#define ESM_CHARCOUNT 0x04
#define ESM_SELLEN 0x08
#define ESM_STATE 0x10
#define ESM_LANGUAGE 0x20
#define ESS_OVERSTRIKE 0x01 // Insert/overstrike mode
@sredna
sredna / toast.ps1
Created August 8, 2021 00:31 — forked from dend/toast.ps1
Toast Notification in PowerShell
function Show-Notification {
[cmdletbinding()]
Param (
[string]
$ToastTitle,
[string]
[parameter(ValueFromPipeline)]
$ToastText
)
@sredna
sredna / CollapseFolder.ps1
Created January 31, 2022 19:51
Add Collapse/Flatten context menu items to a directory
<#
powershell -ExecutionPolicy RemoteSigned -NoProfile -File "CollapseFolder.ps1" Install
#>
Add-Type @"
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public class X
{