Skip to content

Instantly share code, notes, and snippets.

View DJm00n's full-sized avatar

Dimitriy Ryazantcev DJm00n

View GitHub Profile
@DJm00n
DJm00n / full_align_test.cpp
Created July 3, 2026 12:01
Test CreateIconFromResource/LookupIconIdFromDirectory
// full_align_test.cpp
//
// Сравнивает поведение старых (non-Ex) и новых (Ex) версий функций работы
// с иконками на предмет чувствительности к выравниванию входного буфера:
// - CreateIconFromResource vs CreateIconFromResourceEx
// - LookupIconIdFromDirectory vs LookupIconIdFromDirectoryEx
//
// Гипотеза: возможно, именно старые (non-Ex) версии реально требуют
// DWORD-aligned буфер, а Ex-версии — просто унаследовали формулировку
// в документации по инерции, хотя внутри используют более терпимый код.
@DJm00n
DJm00n / setlocale.md
Created July 1, 2026 12:32
The Curious Case of `%ls`, `setlocale()`, and UTF-8 on Windows

The Curious Case of %ls, setlocale(), and UTF-8 on Windows

While debugging an issue with _vsnprintf_s() on Windows, I discovered that the behavior of %ls depends on the CRT locale, not on the Windows code page.

Consider this example:

std::string Log(const char* fmt, ...)
{
    char buffer[1024];
@DJm00n
DJm00n / LSW5_AT_Commands.md
Created June 22, 2026 16:34
LSW5 AT Command Reference

LSW5 AT Command Reference

Firmware: LSW5_32_5406_SS_04_00.00.00.11 (2025-02-06)
SoC: BL602 RISC-V, flash base 0x23000000
Decompiled source: LSW5_32_5406_SS_04_decompressed.bin.c


Authentication

@DJm00n
DJm00n / ev_charger_logger_notes.md
Created June 22, 2026 16:33
Deye EV Charger → SolarMan Wi-Fi Logger Firmware Analysis

Deye EV Charger → SolarMan Wi-Fi Logger Firmware Analysis

File: MW4_01_5429_SS_04_00.00.00.0B


Device Identification

Field Value
Module HiFlying HF-LPx70 (Bouffalo Lab BL602, RISC-V RV32IMACF)
@DJm00n
DJm00n / MW4_AT_Commands.md
Created June 22, 2026 16:15
MW4 AT Command Reference

MW4 AT Command Reference

Firmware: MW4_01_5429_SS_04_00.00.00.0B (2025-02-06)
SoC: BL602 RISC-V, flash base 0x23000000
Decompiled source: MW4_01_5429_SS_04_decompressed.bin.c


AT Command Interface (Cloud → Device)

@DJm00n
DJm00n / deye_inverter_logger_notes.md
Created June 22, 2026 16:11
Deye Inverter Logger (LSW5) Firmware Analysis Notes

Deye Inverter Logger (LSW5) Firmware Analysis Notes

Firmware: LSW5_32_5406_SS_04_00.00.00.11-u.bin
Decompressed: LSW5_32_5406_SS_04_decompressed.bin (1,062,168 bytes)
Build date: 2025-02-06 17:00
Version string: 3.00.16 (2025-02-06 17:00 8M) (L13558)
Module: HiFlying HF-LPx70 (Bouffalo Lab BL602 SoC, RISC-V RV32IMACF)
Flash base: 0x23000000 (XIP)
Container: HF-LPx70x1 Image — 256-byte header + LZMA at offset 0x100

@DJm00n
DJm00n / deye_evse.yaml
Created June 12, 2026 17:31
Deye ha-ev-smart-charger integration
deye_evse:
logger:
logs:
custom_components.ev_smart_charger: debug
template:
- sensor:
- name: "EV Charger Status Mapped"
unique_id: ev_charger_status_mapped
state: >
@DJm00n
DJm00n / GetLanguageTagFromHKL.cpp
Created April 17, 2026 20:13
Returns a BCP-47 language tag (e.g. "en-US", "uk-UA", "jv-Java") for the given HKL (keyboard layout handle).
#include <windows.h>
#include <string>
#include <vector>
/*
* Returns a BCP-47 language tag (e.g. "en-US", "uk-UA", "jv-Java")
* for the given HKL (keyboard layout handle).
*
* WM_INPUTLANGCHANGE provides HKL, whose low word is LANGID. However,
* for transient keyboard layouts (LOCALE_TRANSIENT_KEYBOARD*), LANGID
@DJm00n
DJm00n / GetLanguageAbbrev.cpp
Created April 17, 2026 20:01
Returns a 3-letter uppercase language abbreviation (e.g. ENG, РУС, УКР) derived from the language autonym using winlangdb.dll.
#include <windows.h>
#include <string>
/*
* Returns a 3-letter uppercase language abbreviation (e.g. ENG, РУС, УКР)
* derived from the language autonym using winlangdb.dll.
*
* This matches Windows UI behavior (language indicator in taskbar):
* - Uses GetLanguageNames (undocumented, WinRT language database)
* - Takes the first 3 characters of the autonym
using System;
class klGDIBitmapConversion
{
public static System.Drawing.Bitmap MainConv(System.Drawing.Bitmap img)
{
System.Drawing.Bitmap b = img;// new System.Drawing.Bitmap("test.jpg");
SplashImage(b, 0, 0);
DateTime dtFaq = DateTime.Now;
System.Drawing.Bitmap b0 = CopyToBpp(b, 8);
TimeSpan tsFaq = DateTime.Now - dtFaq;