26 #include "../tapctl/error.h"
32 #pragma comment(lib, "msi.lib")
46 _In_ HINSTANCE hinstDLL,
48 _In_ LPVOID lpReserved)
50 UNREFERENCED_PARAMETER(hinstDLL);
51 UNREFERENCED_PARAMETER(lpReserved);
55 case DLL_PROCESS_ATTACH:
64 case DLL_THREAD_ATTACH:
77 case DLL_PROCESS_DETACH:
86 case DLL_THREAD_DETACH:
99 UNREFERENCED_PARAMETER(flags);
106 x_msg_va(
const unsigned int flags,
const char *format, va_list arglist)
109 DWORD dwResult = (flags &
M_ERRNO) != 0 ? GetLastError() : ERROR_SUCCESS;
119 MSIHANDLE hRecordProg = MsiCreateRecord(4);
123 char szBufStack[128];
124 int iResultLen = vsnprintf(szBufStack, _countof(szBufStack), format, arglist);
125 if (iResultLen < _countof(szBufStack))
128 MsiRecordSetStringA(hRecordProg, 2, szBufStack);
133 char *szMessage = (
char *)malloc(++iResultLen *
sizeof(
char));
134 if (szMessage != NULL)
136 vsnprintf(szMessage, iResultLen, format, arglist);
137 MsiRecordSetStringA(hRecordProg, 2, szMessage);
143 szBufStack[_countof(szBufStack) - 1] = 0;
144 MsiRecordSetStringA(hRecordProg, 2, szBufStack);
160 MsiRecordSetInteger(hRecordProg, 3, dwResult);
163 LPTSTR szErrMessage = NULL;
165 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
169 (LPTSTR)&szErrMessage,
171 NULL) && szErrMessage)
174 for (
size_t i = 0, i_last = 0;; i++)
178 if (!_istspace(szErrMessage[i]))
185 szErrMessage[i_last] = 0;
189 MsiRecordSetString(hRecordProg, 4, szErrMessage);
190 LocalFree(szErrMessage);
194 MsiProcessMessage(s->
hInstall, (flags &
M_WARN) ? INSTALLMESSAGE_INFO : INSTALLMESSAGE_ERROR, hRecordProg);
195 MsiCloseHandle(hRecordProg);