VD编程头API函数
成功穿透VD,包括易游2006。采用的方法是调用VDRIVESDK.dll中的VdvireQuery、VdirveMount和VdriveUnmount函数。VD的UP.exe、易游2006的stsUG.exe也是调用这三个函数实现更新的。
另外它们也采用了DosDefineDevice让其出现所谓的S盘。
AddDriveLetter()
VdirveQuery()
Unit1.h
RemoveDriveLetter()
RegService()
UnregService()
VdriveUnmount()
Vdrivemount()
在C++Builder下,增加一个按纽,输入下列代码:
LPVOID lpMsgBuf; int t = 1; t = AddDriveLetter('T', 0); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, t, 0, // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK); LocalFree(lpMsgBuf); if(t == 0) Application->MessageBoxA("AddDriveLetter成功", "提示", MB_OK); 运行后,即可在我的电脑中出现T盘。
以下代码是VdirveQuery()函数的用法:
void __fastcall TForm1::Button1Click(TObject *Sender) { LPVOID lpMsgBuf; char strPath[MAX_PATH]; int t = 0; t = VdriveQuery(0, vdrive); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, t, 0, // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK); LocalFree(lpMsgBuf); t = 0; strPath[0] = vdrive[0]; strPath[1] = ':'; strPath[2] = 0; t = DefineDosDevice(DDD_RAW_TARGET_PATH, strPath, "\\device\\harddiskvolume2"); if(t != 0) Application->MessageBoxA("DefineDosDevice成功","提示",MB_OK);
}
以下是头文件Unit1.h的内容:
#ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TButton *Button1; TButton *Button2; TButton *Button3; TButton *Button4; TButton *Button5; TButton *Button6; TButton *Button7; void __fastcall Button1Click(TObject *Sender); void __fastcall Button2Click(TObject *Sender); void __fastcall Button3Click(TObject *Sender); void __fastcall Button4Click(TObject *Sender); void __fastcall Button5Click(TObject *Sender); void __fastcall Button6Click(TObject *Sender); void __fastcall Button7Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); char vdrive[424]; }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif
输入以下代码,可以移走添加的驱动器: LPVOID lpMsgBuf; int t = 1; t = RemoveDriveLetter('T'); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, t, 0, // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK); LocalFree(lpMsgBuf); if(t == 0) Application->MessageBoxA("RemoveDriveLetter成功", "提示", MB_OK);
RegService()函数的调用方法:
LPVOID lpMsgBuf; int t = 1; t = RegService("P1","P2","P3","P4"); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, t, 0, // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK); LocalFree(lpMsgBuf); if(t == 0) Application->MessageBoxA("RegService成功", "提示", MB_OK);
UnregService()函数的调用方法:
LPVOID lpMsgBuf;
int t = 1;
t = UnregService(0, 0, 0, 0);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
t,
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK);
LocalFree(lpMsgBuf);
if(t == 0) Application->MessageBoxA("UnregService成功", "提示", MB_OK);
以下是VdriveUnmount()函数的调用方法:
LPVOID lpMsgBuf;
int t = 0;
t = VdriveUnmount(0, -1);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
t,
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK);
LocalFree(lpMsgBuf);
以下是Vdrivemount()函数的调用方法:
LPVOID lpMsgBuf;
char strPath[MAX_PATH];
int t = 0;
t = VdriveMount(vdrive,0);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
t,
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK);
LocalFree(lpMsgBuf);
t = 0;
strPath[0] = vdrive[0];
strPath[1] = ':';
strPath[2] = 0;
t = DefineDosDevice(DDD_REMOVE_DEFINITION, strPath, NULL);
if(t != 0) Application->MessageBoxA("DefineDosDevice成功", "提示", MB_OK); |