Skip to content

Instantly share code, notes, and snippets.

@Donpedro13
Donpedro13 / power_etw.bat
Created March 28, 2025 14:46
Windows Power ETW tracing
xperf -on PROC_THREAD+LOADER -start user -on Microsoft-Windows-Kernel-Power:::'stack'
@rem Repro the problem here
xperf -d k.etl
xperf -stop user
xperf -merge k.etl C:\user.etl merged.etl
@Donpedro13
Donpedro13 / powercfg.txt
Last active March 19, 2025 09:06
powercfg example output
> powercfg /requests
DISPLAY:
[PROCESS] \Device\HarddiskVolume2\Product.exe
@Donpedro13
Donpedro13 / pwrtest.txt
Last active March 19, 2025 09:06
pwrtest output example
> pwrtest.exe /requests
15:52:56 Create: \Device\HarddiskVolume2\Product.exe
Type:Application ProcessID:34712 SessionID:14
Allow: System Display AwayMode PerfBoost ExecutionRequired FullScreenVideo
Count: System:0 Display:0 AwayMode:0 PerfBoost:0
ExecutionRequired:0 FullScreenVideo:0
-------------------------------------------------------------------------------
15:52:56 Change: \Device\HarddiskVolume2\Product.exe
Count: System:0 *Display:1 AwayMode:0 PerfBoost:0
import os
import sys
def usage():
print("Usage: readfolder.py [folder]")
def doread(dir):
for root, dirs, files in os.walk(dir):
for file in files:
fpath = os.path.join(root, file)
#ifdef _WIN32
using nchar = wchar_t;
using nstring = std::wstring;
#define NSTRLITERAL(str) L##str
#define nfopen _wfopen
/* ... */
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2011/WindowsSettings">
<printerDriverIsolation>true</printerDriverIsolation>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
#include <iostream>
#include <windows.h>
#include <wingdi.h>
int main ()
{
PRINTDLGW dialogResult = {};
dialogResult.lStructSize = sizeof dialogResult;
dialogResult.Flags = PD_RETURNDEFAULT;
// Compile with MSVC, *Release* configuration
#include <iostream>
#include <new>
#include <windows.h>
LONG WINAPI MyVEH (PEXCEPTION_POINTERS pExp)
{
if (pExp->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION) {
std::cout << "Heap corruption detected!" << std::endl;
// Compile with MSVC, *Release* configuration
#include <iostream>
#include <new>
#include <windows.h>
LONG WINAPI MyUEF (PEXCEPTION_POINTERS pExp)
{
if (pExp->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION) {
std::cout << "Heap corruption detected!" << std::endl;
/* ... */
PEXCEPTION_RECORDS pExc = __rax;
if (pExc->ExceptionCode == EXCEPTION_STACK_OVERFLOW ||
(pExc->ExceptionCode == EXCEPTION_ACCESS_VIOLATION &&
pExc.ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT))
{
return E_NOTIMPL;
}
/* ... */