VirtualBox

Ignore:
Timestamp:
Dec 9, 2009 4:20:18 AM (15 years ago)
Author:
vboxsync
Message:

SUPDrv: Works on vista...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r25260 r25262  
    596596#ifdef VBOX_WITH_NATIVE_R0_LOADER
    597597
     598#define MY_SystemLoadGdiDriverInformation               26
     599#define MY_SystemLoadGdiDriverInSystemSpaceInformation  54
     600#define MY_SystemUnloadGdiDriverInformation             27
     601
     602typedef struct MYSYSTEMGDIDRIVERINFO
     603{
     604    UNICODE_STRING  Name;                   /**< In:  image file name. */
     605    PVOID           ImageAddress;           /**< Out: the load address. */
     606    PVOID           SectionPointer;         /**< Out: section object. */
     607    PVOID           EntryPointer;           /**< Out: entry point address. */
     608    PVOID           ExportSectionPointer;   /**< Out: export directory/section. */
     609    ULONG           ImageLength;            /**< Out: SizeOfImage. */
     610} MYSYSTEMGDIDRIVERINFO;
     611
     612extern "C" __declspec(dllimport) NTSTATUS NTAPI ZwSetSystemInformation(ULONG, PVOID, ULONG);
     613
    598614int  VBOXCALL   supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
    599615{
    600     NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename);
    601     return VERR_NOT_SUPPORTED;
     616    MYSYSTEMGDIDRIVERINFO Info;
     617
     618    /** @todo fix this horrible stuff. */
     619    WCHAR wszConv[192 + 32];
     620    unsigned i = 0;
     621    wszConv[i++] = '\\';
     622    wszConv[i++] = '?';
     623    wszConv[i++] = '?';
     624    wszConv[i++] = '\\';
     625    unsigned cchPref = i;
     626    char ch;
     627    do
     628    {
     629        ch = pszFilename[i - cchPref];
     630        wszConv[i++] = ch == '/' ? '\\' : ch;
     631    } while (ch);
     632    RtlInitUnicodeString(&Info.Name, wszConv);
     633
     634    Info.ImageAddress           = NULL;
     635    Info.SectionPointer         = NULL;
     636    Info.EntryPointer           = NULL;
     637    Info.ExportSectionPointer   = NULL;
     638    Info.ImageLength            = 0;
     639
     640    NTSTATUS rc = ZwSetSystemInformation(MY_SystemLoadGdiDriverInSystemSpaceInformation, &Info, sizeof(Info));
     641    if (NT_SUCCESS(rc))
     642    {
     643        pImage->pvImage = Info.ImageAddress;
     644        pImage->pvNtSectionObj = Info.SectionPointer;
     645        SUPR0Printf("ImageAddress=%p SectionPointer=%p ImageLength=%#x cbImageBits=%#x rc=%#x '%ws'\n",
     646                    Info.ImageAddress, Info.SectionPointer, Info.ImageLength, pImage->cbImageBits, rc, Info.Name.Buffer);
     647        if (pImage->cbImageBits == Info.ImageLength)
     648            return VINF_SUCCESS;
     649        supdrvOSLdrUnload(pDevExt, pImage);
     650        rc = STATUS_INFO_LENGTH_MISMATCH;
     651    }
     652    SUPR0Printf("rc=%#x '%ws'\n", rc, Info.Name.Buffer);
     653    //STATUS_OBJECT_NAME_NOT_FOUND == 0xc0000034 -> SUPR0
     654
     655    NOREF(pDevExt); NOREF(pszFilename);
     656    pImage->pvNtSectionObj = NULL;
     657    return VERR_INTERNAL_ERROR_5; /** @todo convert status, making sure it isn't NOT_SUPPORTED. */
    602658}
    603659
     
    606662{
    607663    NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits);
    608     return VERR_NOT_SUPPORTED;
     664    return VINF_SUCCESS;
    609665}
    610666
     
    613669{
    614670    NOREF(pDevExt); NOREF(pImage); NOREF(pbImageBits);
    615     return VERR_NOT_SUPPORTED;
     671    if (pImage->pvNtSectionObj)
     672    {
     673        /** @todo check that the two image versions matches. */
     674        return VINF_SUCCESS;
     675    }
     676    return VERR_INTERNAL_ERROR_4;
    616677}
    617678
     
    619680void VBOXCALL   supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
    620681{
    621     NOREF(pDevExt); NOREF(pImage);
     682    if (pImage->pvNtSectionObj)
     683    {
     684        NTSTATUS rc = ZwSetSystemInformation(MY_SystemUnloadGdiDriverInformation,
     685                                             &pImage->pvNtSectionObj, sizeof(pImage->pvNtSectionObj));
     686    }
     687    NOREF(pDevExt);
    622688}
    623689
Note: See TracChangeset for help on using the changeset viewer.

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