Skip to content

Instantly share code, notes, and snippets.

@sredna
sredna / DbgCheckRegisters.nsh
Created May 21, 2023 18:42
NSIS DbgCheckRegisters.nsh
/*
** DbgCheckRegisters.nsh
** =====================
** A header for validating that functions have not touched the registers.
*/
!macro _DbgRegisters_For pre pos list
!if "${list}" == ""
!define /ReDef list "$0$1$2$3$4$5$6$7$8$9$R0$R1$R2$R3$R4$R5$R6$R7$R8$R9"
!endif
@sredna
sredna / FontInstall.nsi
Last active October 13, 2022 22:57
NSIS FontInstall
; FontInstall.nsh >8 >8 >8 >8 >8 >8 >8 >8
!include LogicLib.nsh
!include WinMessages.nsh
!macro FontInstallHelper FontFileSrc FontFileDst FontInternalName Resource RegSuffix RegRoot
ClearErrors
${IfNot} ${FileExists} "${FontFileDst}"
File "/oname=${FontFileDst}" "${FontFileSrc}"
${EndIf}
${IfNot} ${Errors}
@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
{
@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 / 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
# 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
@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
@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
@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
!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}`