Contribute  :  Web Resources  :  Past Polls  :  Site Statistics  :  Downloads  :  Forum  
    BiW ReversingThe challenge is yours    
 Welcome to BiW Reversing
 Sunday, March 24 2019 @ 10:24 AM CET

Creating your own virtual drive from a directory in WinXP


CodingLevel : intermediate

OS : windows
Language : C

The code speaks for its self no need for more explaining to be done.Use win32api.hlp if you need any informations about the API's used.
Code was compiled in Dev-CPP.
Best regards.

/* VDrive (C) Tanatos
Date:15.12.2007 */

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

int aux=0;
char cmd[1024];
int main(int argc,char *argv[])
if(argc <3)
printf("The syntax is:ntvdrive new_drive_letter dir_pathnt- to create a new virtual driventvdrive drive_letter /Dnt- to delete an existing virtual drive");
sprintf(cmd, "subst %s: %c%s%c", argv[1],34,argv[2],34);
sprintf(cmd, "subst %s: %s", argv[1],argv[2]);
int err=system(cmd);
if(err == 0 && aux==1)
printf("Drive %s was succesfully created!n",argv[1]);
FILE *f = fopen("C:autoexec.bat","w");
char reg_name[16];
HKEY key,key2;
if(RegCreateKey(HKEY_LOCAL_MACHINE,"SoftwareMicrosoftWindowsCurrentVersionRun",&key) == ERROR_SUCCESS)
RegSetValueEx(key,"VDrive",0,REG_SZ,(BYTE *)reg_name,sizeof(reg_name)-1);
char ans;
printf("You need to restart your PC for fully results (Y/N):");scanf("%c",&ans);
if(ans == 'Y' || ans == 'y')
HANDLE hToken;
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL, 0);
ExitWindowsEx(EWX_REBOOT , 0);
if(err==0 && aux == 0)
printf("Drive %s was succesfully deleted!n",argv[1]);
FILE *f = fopen("C:autoexec.bat","w");fclose(f);
HKEY key;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionRun", 0, KEY_ALL_ACCESS , &key);
return 0;

What's Related

Story Options

Creating your own virtual drive from a directory in WinXP | 3 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Creating your own virtual drive from a directory in WinXP
Authored by: detten on Wednesday, December 19 2007 @ 06:56 PM CET
What is the difference with the 'subst' command?
Creating your own virtual drive from a directory in WinXP
Authored by: thorpe on Monday, December 24 2007 @ 07:32 AM CET
thanks tanatos
 Copyright © 2019 BiW Reversing
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.06 seconds