VirtualBox

Changeset 63089 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Aug 6, 2016 3:04:26 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
109703
Message:

VBoxGuestInstallHelper.cpp: @todo r=bird: fix the optimistically incorrect MZ/PE parsing. Fixed warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp

    r62679 r63089  
    2424#include <tchar.h>
    2525#include <strsafe.h>
     26#pragma warning(push)
     27#pragma warning(disable: 4995) /* warning C4995: 'lstrcpyA': name was marked as #pragma deprecated */
    2628#include "exdll.h"
     29#pragma warning(pop)
    2730
    2831#include <iprt/err.h>
     
    221224 * @param   stacktop            Pointer to a pointer to the current stack.
    222225 */
    223 VBOXINSTALLHELPER_EXPORT DisableWFP(HWND hwndParent, int string_size,
    224                                     TCHAR *variables, stack_t **stacktop)
    225 {
     226VBOXINSTALLHELPER_EXPORT DisableWFP(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
     227{
     228    NOREF(hwndParent);
    226229    EXDLL_INIT();
    227230
     
    252255            if (SUCCEEDED(hr))
    253256            {
    254                 if (g_pfnSfcFileException(0, pwszFile, -1) != 0)
     257                if (g_pfnSfcFileException(0, pwszFile, UINT32_MAX) != 0)
    255258                    hr = HRESULT_FROM_WIN32(GetLastError());
    256259                vboxChar2WCharFree(pwszFile);
     
    274277 * @param   stacktop            Pointer to a pointer to the current stack.
    275278 */
    276 VBOXINSTALLHELPER_EXPORT FileGetArchitecture(HWND hwndParent, int string_size,
    277                                              TCHAR *variables, stack_t **stacktop)
    278 {
     279VBOXINSTALLHELPER_EXPORT FileGetArchitecture(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
     280{
     281    NOREF(hwndParent);
    279282    EXDLL_INIT();
    280283
     
    290293            hr = __HRESULT_FROM_WIN32(ERROR_FILE_INVALID);
    291294
    292             BYTE byOffsetPE; /* Absolute offset of PE signature. */
     295            BYTE offPeHdr = 0; /* Absolute offset of PE signature. */
    293296
    294297            /* Do some basic validation. */
     
    302305                {
    303306                    /* Read actual offset of PE signature. */
    304                     if (fread(&byOffsetPE, sizeof(BYTE), 1, pFh) == 1)
     307/** @todo r=bird: You've obviously no clue about the structure you're messing with here.  The field is NOT a BYTE
     308 * field but a int32_t/uint32_t!  The MZ header is defined as IMAGE_DOS_HEADER by windows.h (well, winnt.h), and the
     309 * field you're accessing is e_lfanew.  Please rewrite this hack to use the structures!  (Also, the MZ structure is
     310 * OPTIONAL, just in case you didn't know.)  */
     311#ifdef DEBUG_andy
     312# error "Fix this"
     313#endif
     314                    if (fread(&offPeHdr, sizeof(BYTE), 1, pFh) == 1)
    305315                    {
    306316                        /* ... and seek to it. */
    307                         if (!fseek(pFh, byOffsetPE, SEEK_SET))
     317                        if (!fseek(pFh, offPeHdr, SEEK_SET))
    308318                        {
    309319                            /* Validate PE signature. */
     
    321331            if (SUCCEEDED(hr))
    322332            {
    323                 BYTE byOffsetCOFF = byOffsetPE + 0x4; /* Skip PE signature. */
     333                BYTE offFileHeaderMachineField = offPeHdr + 0x4; /* Skip PE signature. */
    324334
    325335                /** @todo When we need to do more stuff here, we probably should
     
    329339                /* Jump to machine type (first entry, 2 bytes):
    330340                 * Use absolute PE offset retrieved above. */
    331                 if (!fseek(pFh, byOffsetCOFF, SEEK_SET))
     341                if (!fseek(pFh, offFileHeaderMachineField, SEEK_SET))
    332342                {
    333343                    WORD wMachineType;
     
    376386 * @param   stacktop            Pointer to a pointer to the current stack.
    377387 */
    378 VBOXINSTALLHELPER_EXPORT FileGetVendor(HWND hwndParent, int string_size,
    379                                        TCHAR *variables, stack_t **stacktop)
    380 {
     388VBOXINSTALLHELPER_EXPORT FileGetVendor(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
     389{
     390    NOREF(hwndParent);
    381391    EXDLL_INIT();
    382392
     
    402412
    403413                        TCHAR szQuery[MAX_PATH];
     414#pragma warning(suppress:4995) /* warning C4995: '_sntprintf': name was marked as #pragma deprecated */
    404415                        _sntprintf(szQuery, sizeof(szQuery), _T("StringFileInfo\\%04X%04X\\CompanyName"),
    405416                                   wCodePage,wLanguageID);
     
    438449 * @param   stacktop            Pointer to a pointer to the current stack.
    439450 */
    440 VBOXINSTALLHELPER_EXPORT VBoxTrayShowBallonMsg(HWND hwndParent, int string_size,
    441                                                TCHAR *variables, stack_t **stacktop)
    442 {
     451VBOXINSTALLHELPER_EXPORT VBoxTrayShowBallonMsg(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
     452{
     453    NOREF(hwndParent);
    443454    EXDLL_INIT();
    444455
     
    505516}
    506517
    507 BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID lpReserved)
    508 {
     518BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID pReserved)
     519{
     520    RT_NOREF(uReason, pReserved);
    509521    g_hInstance = (HINSTANCE)hInst;
    510522    return TRUE;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette