FANDOM


In order to make the devices accessable, you need to mount them first. Here's the code to do it.

SourceEdit

/*
List of physical drives
   
   "\\Device\\Flash"
   "\\Device\\Mu1"
   "\\Device\\Mu0"
   "\\Device\\Cdrom0"
   "\\Device\\Harddisk0\\Partition0"
   "\\Device\\Harddisk0\\Partition1"
   "\\Device\\Harddisk0\\Partition2"
   "\\Device\\Harddisk0\\Partition3"
   "\\Device\\Mass0"
   "\\Device\\Mass1"
   "\\Device\\Mass2"
*/ 
   #define DEVICE_NAND_FLASH 0
   #define DEVICE_MEMORY_UNIT0 1
   #define DEVICE_MEMORY_UNIT1 2
   #define DEVICE_CDROM0 3
   #define DEVICE_HARDISK0_PART0 4
   #define DEVICE_HARDISK0_PART1 5
   #define DEVICE_HARDISK0_PART2 6
   #define DEVICE_HARDISK0_PART3 7
   #define DEVICE_USB0 8
   #define DEVICE_USB1 9
   #define DEVICE_USB2 10
   
   typedef struct _STRING {
       USHORT Length;
       USHORT MaximumLength;
       PCHAR Buffer;
   } STRING;
   
   extern "C" int __stdcall ObCreateSymbolicLink( STRING*, STRING*);
   extern "C" int __stdcall ObDeleteSymbolicLink( STRING* );
   
   HRESULT Monter( int periphPhys, char* lettreLecteur )
    {
        char lecteurCible[16];
        sprintf_s( lecteurCible,"\\??\\%s", lettreLecteur );
   
        char * periphOriginal;
        switch( periphPhys )
        {
        case DEVICE_NAND_FLASH:
            periphOriginal = "\\Device\\Flash";
        break;
        case DEVICE_MEMORY_UNIT0:
            periphOriginal = "\\Device\\Mu0";
        break;
        case DEVICE_MEMORY_UNIT1:
            periphOriginal = "\\Device\\Mu1";
        break;
        case DEVICE_CDROM0:
            periphOriginal = "\\Device\\Cdrom0";
        break;
        case DEVICE_HARDISK0_PART0:
            periphOriginal = "\\Device\\Harddisk0\\Partition0";
        break;
        case DEVICE_HARDISK0_PART1:
            periphOriginal = "\\Device\\Harddisk0\\Partition1";
        break;
        case DEVICE_HARDISK0_PART2:
            periphOriginal = "\\Device\\Harddisk0\\Partition2";
        break;
        case DEVICE_HARDISK0_PART3:
            periphOriginal = "\\Device\\Harddisk0\\Partition3";
        break;
        case DEVICE_USB0:
            periphOriginal = "\\Device\\Mass0";
        break;
        case DEVICE_USB1:
            periphOriginal = "\\Device\\Mass1";
        break;
        case DEVICE_USB2:
            periphOriginal = "\\Device\\Mass2";
        break;

        }

        STRING PeriphOriginal = { strlen( periphOriginal ), strlen( periphOriginal ) + 1, periphOriginal };
        STRING LienSymbolique = { strlen( lecteurCible ), strlen( lecteurCible ) + 1, lecteurCible };
      return ( HRESULT )   ObCreateSymbolicLink( &LienSymbolique, &PeriphOriginal );
    }
   
   HRESULT Demonter( char* lettreLecteur )
   {
       char lecteurCible[16];
       sprintf_s( lecteurCible,"\\??\\%s", lettreLecteur );
   
       STRING LienSymbolique = { strlen(lecteurCible), strlen(lecteurCible) + 1, lecteurCible };
     return ( HRESULT )  ObDeleteSymbolicLink( &LienSymbolique );
   }
   
   Monter(DEVICE_HARDISK0_PART1, "hdd1:");

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.