From aa4ea8e27972be77a7295f208d3401e0631e14d8 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 4 Jul 2026 12:36:38 -0400 Subject: [PATCH] ipodpatcher: Correct use of FormatMessageA() for windows builds When called with FORMAT_MESSAGE_ALLOCATE_BUFFER you need to pass in a pointer to an LPSTR, not the LPSTR itself. Change-Id: Iecc6d79edceb2142d61034d61364262126957b46 --- utils/ipodpatcher/ipodio-win32.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/utils/ipodpatcher/ipodio-win32.c b/utils/ipodpatcher/ipodio-win32.c index 9ef1a9fa76..db0623a6dc 100644 --- a/utils/ipodpatcher/ipodio-win32.c +++ b/utils/ipodpatcher/ipodio-win32.c @@ -39,33 +39,34 @@ #include "ipodio.h" -static int lock_volume(HANDLE hDisk) -{ +static int lock_volume(HANDLE hDisk) +{ DWORD dummy; return DeviceIoControl(hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, - &dummy, NULL); + &dummy, NULL); } -static int unlock_volume(HANDLE hDisk) -{ +static int unlock_volume(HANDLE hDisk) +{ DWORD dummy; return DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, - &dummy, NULL); -} + &dummy, NULL); +} void ipod_print_error(char* msg) { LPSTR pMsgBuf = NULL; printf(msg); - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), pMsgBuf, - 0, NULL); - printf(pMsgBuf); - LocalFree(pMsgBuf); + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&pMsgBuf, + 0, NULL)) { + printf(pMsgBuf); + LocalFree(pMsgBuf); + } } int ipod_open(struct ipod_t* ipod, int silent) @@ -223,4 +224,3 @@ ssize_t ipod_write(struct ipod_t* ipod, int nbytes) } #endif -