Changeset 37421 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jun 12, 2011 6:24:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp
r36570 r37421 16 16 */ 17 17 18 /******************************************************************************* 19 * Header Files * 20 *******************************************************************************/ 18 21 #include <windows.h> 19 22 #include <atlconv.h> … … 25 28 #include "../../VBoxTray/VBoxTrayMsg.h" 26 29 27 HINSTANCE g_hInstance; 28 HWND g_hwndParent; 29 30 typedef DWORD (WINAPI *fnSfcFileException) (DWORD param1, PWCHAR param2, DWORD param3); 31 fnSfcFileException g_pfnSfcFileException = NULL; 32 30 31 /******************************************************************************* 32 * Defined Constants And Macros * 33 *******************************************************************************/ 33 34 #define VBOXINSTALLHELPER_EXPORT extern "C" void __declspec(dllexport) 35 36 37 /******************************************************************************* 38 * Structures and Typedefs * 39 *******************************************************************************/ 40 typedef DWORD (WINAPI *PFNSFCFILEEXCEPTION)(DWORD param1, PWCHAR param2, DWORD param3); 41 42 43 /******************************************************************************* 44 * Global Variables * 45 *******************************************************************************/ 46 HINSTANCE g_hInstance; 47 HWND g_hwndParent; 48 PFNSFCFILEEXCEPTION g_pfnSfcFileException = NULL; 49 34 50 35 51 /** 36 52 * Pops (gets) a value from the internal NSIS stack. 37 53 * Since the supplied popstring() method easily can cause buffer 38 * overflows, use VBoxPopString() instead!54 * overflows, use vboxPopString() instead! 39 55 * 40 56 * @return HRESULT … … 42 58 * @param cchDest Size (in characters) of pre-allocated string. 43 59 */ 44 static HRESULT VBoxPopString(TCHAR *pszDest, size_t cchDest)60 static HRESULT vboxPopString(TCHAR *pszDest, size_t cchDest) 45 61 { 46 62 HRESULT hr = S_OK; … … 63 79 } 64 80 65 static HRESULT VBoxPopULong(ULONG *pulValue)81 static HRESULT vboxPopULong(PULONG pulValue) 66 82 { 67 83 HRESULT hr = S_OK; … … 82 98 } 83 99 84 voidChar2WCharFree(PWCHAR pwString)100 static void vboxChar2WCharFree(PWCHAR pwString) 85 101 { 86 102 if (pwString) … … 88 104 } 89 105 90 HRESULTChar2WCharAlloc(const char *pszString, PWCHAR *ppwString)106 static HRESULT vboxChar2WCharAlloc(const char *pszString, PWCHAR *ppwString) 91 107 { 92 108 HRESULT hr; 93 109 int iLen = strlen(pszString) + 2; 94 110 WCHAR *pwString = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, iLen * sizeof(WCHAR)); 95 111 if (!pwString) 96 112 hr = ERROR_NOT_ENOUGH_MEMORY; … … 111 127 } 112 128 113 HANDLE VBoIPCConnect()129 static HANDLE vboxIPCConnect(void) 114 130 { 115 131 HANDLE hPipe = NULL; … … 149 165 } 150 166 151 void VBoxIPCDisconnect(HANDLE hPipe)167 static void vboxIPCDisconnect(HANDLE hPipe) 152 168 { 153 169 CloseHandle(hPipe); 154 170 } 155 171 156 HRESULT VBoxIPCWriteMessage(HANDLE hPipe, BYTE *pMessage, DWORD cbMessage)172 static HRESULT vboxIPCWriteMessage(HANDLE hPipe, BYTE *pMessage, DWORD cbMessage) 157 173 { 158 174 HRESULT hr = S_OK; … … 182 198 183 199 VBOXTRAYIPCMSG_SHOWBALLOONMSG msg; 184 HRESULT hr = VBoxPopString(msg.szContent, sizeof(msg.szContent) / sizeof(TCHAR));185 if (SUCCEEDED(hr)) 186 hr = VBoxPopString(msg.szTitle, sizeof(msg.szTitle) / sizeof(TCHAR));187 if (SUCCEEDED(hr)) 188 hr = VBoxPopULong(&msg.ulType);189 if (SUCCEEDED(hr)) 190 hr = VBoxPopULong(&msg.ulShowMS);200 HRESULT hr = vboxPopString(msg.szContent, sizeof(msg.szContent) / sizeof(TCHAR)); 201 if (SUCCEEDED(hr)) 202 hr = vboxPopString(msg.szTitle, sizeof(msg.szTitle) / sizeof(TCHAR)); 203 if (SUCCEEDED(hr)) 204 hr = vboxPopULong(&msg.ulType); 205 if (SUCCEEDED(hr)) 206 hr = vboxPopULong(&msg.ulShowMS); 191 207 192 208 if (SUCCEEDED(hr)) … … 194 210 msg.ulFlags = 0; 195 211 196 HANDLE hPipe = VBoIPCConnect();212 HANDLE hPipe = vboxIPCConnect(); 197 213 if (hPipe) 198 214 { 199 hr = VBoxIPCWriteMessage(hPipe, (BYTE*)&hdr, sizeof(VBOXTRAYIPCHEADER));215 hr = vboxIPCWriteMessage(hPipe, (BYTE*)&hdr, sizeof(VBOXTRAYIPCHEADER)); 200 216 if (SUCCEEDED(hr)) 201 hr = VBoxIPCWriteMessage(hPipe, (BYTE*)&msg, sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG));202 VBoxIPCDisconnect(hPipe);217 hr = vboxIPCWriteMessage(hPipe, (BYTE*)&msg, sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG)); 218 vboxIPCDisconnect(hPipe); 203 219 } 204 220 } … … 229 245 230 246 TCHAR szFile[MAX_PATH + 1]; 231 HRESULT hr = VBoxPopString(szFile, sizeof(szFile) / sizeof(TCHAR));247 HRESULT hr = vboxPopString(szFile, sizeof(szFile) / sizeof(TCHAR)); 232 248 if (SUCCEEDED(hr)) 233 249 { … … 235 251 if (NULL != hSFC) 236 252 { 237 g_pfnSfcFileException = ( fnSfcFileException)GetProcAddress(hSFC, "SfcFileException");253 g_pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFC, "SfcFileException"); 238 254 if (g_pfnSfcFileException == NULL) 239 255 { 240 256 /* If we didn't get the proc address with the call above, try it harder with 241 257 * the (zero based) index of the function list. */ 242 g_pfnSfcFileException = ( fnSfcFileException)GetProcAddress(hSFC, (LPCSTR)5);258 g_pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFC, (LPCSTR)5); 243 259 if (g_pfnSfcFileException == NULL) 244 260 hr = HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND); … … 251 267 { 252 268 WCHAR *pwszFile; 253 hr = Char2WCharAlloc(szFile, &pwszFile);269 hr = vboxChar2WCharAlloc(szFile, &pwszFile); 254 270 if (SUCCEEDED(hr)) 255 271 { 256 272 if (g_pfnSfcFileException(0, pwszFile, -1) != 0) 257 273 hr = HRESULT_FROM_WIN32(GetLastError()); 258 Char2WCharFree(pwszFile);274 vboxChar2WCharFree(pwszFile); 259 275 } 260 276 }
Note:
See TracChangeset
for help on using the changeset viewer.