首页
社区
课程
招聘
[旧帖] 请教 win7 64位 驱动如何取 CPU ID或网卡物理地址 0.00雪花
发表于: 2014-6-16 08:32 6361

[旧帖] 请教 win7 64位 驱动如何取 CPU ID或网卡物理地址 0.00雪花

2014-6-16 08:32
6361
收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 19
活跃值: (1086)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
__cupid();  MAC地址就自己枚举网卡 发送NDIS消息
2014-6-16 12:54
0
雪    币: 0
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
在开始菜单那里运行cmd,然后输入冒号里面的内容:"ipconfig /all",然后回车
2014-6-22 15:23
0
雪    币: 45
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
当一个应用程序在工作时,会不可避免地和操作系统发生数据交换,虽然在PB中提供了Environment对象来获得系统http://www.sytm.net/jiejuefangan/的一些信息,然而这些信息往往是不够的,比如CPU、本机IP地址等,这些内容只有用Windows API来获得了。
1、建立一个工作空间(workspace),取名为:systeminfo。

2、建立一个应用(application),取名为:systeminfo。

3、创建用户对象u_sysinfo,并添加Microsoft Winsock OCX控件。

4、定义u_sysinfo的实例变量。
public:
string cpuid,cpuprovider
string filesystem,volumename
ulong VolumeSerialNumber,MaxComponentLength,FileSystemFlags
long dlength,dmemoryload,dtotalphys,davailphys,dtotalpagefile
long davailpagefile,dtotalvirtual,davailvirtual
ulong dwoemid,dwpagesize,lpminappaddress,lpmaxappaddress,dwactiveprocessormask
ulong dwnumberofprocessors,dwprocessortype,dwallocationgranularity,dwreserved
ulong sectorspercluster,bytespersector,numberoffreeclusters,totalnumberofclusters
ulong mbtotal,mbfree

5、定义u_sysinfo的局部外部函数
PUBLIC FUNCTION ulong GetComputerName(ref string lpBuffer,ref ulong nSize) LIBRARY "kernel32.dll"
ALIAS FOR "GetComputerNameA"
PUBLIC FUNCTION ulong GetDriveType(string nDrive) LIBRARY "kernel32.dll" ALIAS FOR "GetDriveTypeA"
FUNCTION ulong GetDiskFreeSpace(ref string lpRootPathName,ref ulong  lpSectorsPerCluster,ref ulong
lpBytesPerSector,ref ulong  lpNumberOfFreeClusters,ref ulong lpTtoalNumberOfClusters)
LIBRARY "kernel32.dll" ALIAS FOR "GetDiskFreeSpaceA"
PUBLIC FUNCTION ulong GetTickCount() LIBRARY "kernel32.dll"
PUBLIC Subroutine GetSystemInfo(ref ws_info lpSystemInfo) LIBRARY "kernel32.dll"
PUBLIC FUNCTION ulong waveOutGetNumDevs() LIBRARY "winmm.dll"
PUBLIC FUNCTION ulong WNetGetUser(ref string lpName,ref string lpUserName,ref ulong lpnLength)
LIBRARY "mpr" ALIAS FOR "WNetGetUserA"
PUBLIC FUNCTION ulong GetSystemMetrics(ulong nIndex) LIBRARY "user32.dll"
PUBLIC FUNCTION ulong GetWindowsDirectory(ref string lpBuffer,ulong nSize) LIBRARY "kernel32.dll"
ALIAS FOR "GetWindowsDirectoryA"
PUBLIC FUNCTION ulong GetSystemDirectory(ref string lpBuffer,ulong nSize) LIBRARY "kernel32.dll"
ALIAS FOR "GetSystemDirectoryA"
PUBLIC FUNCTION ulong GetTempPath(ulong nBufferLength,ref string lpBuffer) LIBRARY "kernel32.dll"
ALIAS FOR "GetTempPathA"
PUBLIC FUNCTION ulong GetKeyboardType(ulong nTypeFlag) LIBRARY "user32.dll"
PUBLIC FUNCTION ulong QueryPerformanceFrequency(ref double lpFrequency) LIBRARY "kernel32.dll"
PUBLIC FUNCTION ulong QueryPerformanceCounter(ref ulong lpPerformanceCount) LIBRARY "kernel32.dll"
//PUBLIC FUNCTION ulong EnumPrinterDrivers(ref string pName,ref string pEnvironment,ulong Level,ref
Byte pDriverInfo,ulong cdBuf,ref ulong pcbNeeded,ref ulong pcRetruned) LIBRARY
"winspool.drv" ALIAS FOR "EnumPrinterDriversA"
PUBLIC Subroutine GlobalMemoryStatus(ref ws_memory lpBuffer) LIBRARY "kernel32.dll"
//FUNCTIONon ulong GlobalReAlloc(ulong hMem,ulong dwBytes,ulong wFlags) LIBRARY "kernel32.dll"
PUBLIC FUNCTION ulong RegOpenKey(ulong hKey,ref string lpSubKey,ref ulong phkResult) LIBRARY
"advapi32.dll" ALIAS FOR "RegOpenKeyA"
PUBLIC FUNCTION ulong RegCloseKey(ulong hKey) LIBRARY "advapi32.dll"
PUBLIC FUNCTION ulong RegQueryValueEx(ulong hKey,ref string lpValueName,ulong lpReserved,ref ulong
lpType,ref long lpData,ref ulong lpcbData) LIBRARY "advapi32.dll" ALIAS FOR
"RegQueryValueExA"
//Function ulong EnumDisplaySettingsA(ulong xx,ulong modenum,ref DEVMODE
lpdevmode)Library"kernel32.dll"
//PUBLIC FUNCTION ulong DeviceCapabilities(ref string lpDeviceName,ref string lpPort,ulong
iIndex,ref string lpOutput,ref DEVMODE lpDevMode) LIBRARY "winspool.drv" ALIAS FOR
"DeviceCapabilitiesA"
PUBLIC FUNCTION ulong GetVolumeInformation(string lpRootPathName,ref string lpVolumeNameBuffer,
ulong nVolumeNameSize,ref ulong lpVolumeSerialNumber,ref ulong lpMaximumComponentLength,
ref ulong lpFileSystemFlags,ref string lpFileSystemNameBuffer,ulong nFileSystemNameSize)
LIBRARY "kernel32.dll" ALIAS FOR "GetVolumeInformationA"
FUNCTION long GetMACAddress(long lana,ref long addr[6]) Library "utils.dll"
FUNCTION long GetLanaID(ref long lana[254]) LIBRARY "utils.dll"
Function ulong GetMHZ()Library"mydll.dll"

6、用户对象级函数
1)、of_GetComputerName(),获得计算机的标识(即计算机名)。

ulong ll_comsize
ulong ll_flag
ll_comsize = 256
string ls_computerName
//获得计算机的名称
ll_flag = GetComputerName(ls_computerName,ll_comsize)
If ll_flag<> 1 then
return "Get Computer Failure"
else
return ls_computerName
End if

2)、of_GetCpuInfo(),获得CPU一些基本信息。

ws_cpuinfo lstr_cpu
string ls_temp
RegistryGet("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0","Identifier",RegString!,ls_temp)
lstr_cpu.cpuid = ls_temp
cpuid = ls_temp
RegistryGet("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0","VendorIdentifier",RegString!,ls_temp)
lstr_cpu.cpuprovider = ls_temp
cpuprovider = ls_temp

3)、of_GetCpuStatus(),获得CPU当前的使用频率,是从0%到100%之间的一个常数。

ulong ls_username,lpcbData,lpType
lpcbData = 4
lpType = 4
ulong phkResult
ls_username = 0
string lbSubkey
long lpData
lbSubkey = "PerfStats\StatData"
ls_username =  RegOpenKey(16*16*16*16*16*16*16*8+6,lbSubKey,phkResult)//The first parameters is HKEY_DYN_DATA = &80000006(HANDLE)
string lpValueName
lpValueName = "KERNEL\CPUUsage"
ls_username = RegQueryValueEx(phkResult,lpValueName,0,lpType,lpData,lpcbData)
ls_username = RegCloseKey(phkResult)
return lpdata

4)、of_GetDiskVolume(),获得磁盘空间大小。

ulong ll_MBFree
ulong ll_MBTotal
ulong ll_sectorspercluster            //  Sectors/Cluster
ulong ll_bytespersector              //  Bytes/Sector
ulong ll_numberoffreeclusters    //  Number of Free Clusters
ulong ll_toalnumberofclusters    //  Total Number of Clusters
GetDiskFreeSpace(as_driver, ll_sectorspercluster, ll_bytespersector,ll_numberoffreeclusters,
ll_toalnumberofclusters)
sectorspercluster=ll_sectorspercluster
bytespersector=ll_bytespersector
numberoffreeclusters=ll_numberoffreeclusters
totalnumberofclusters=ll_toalnumberofclusters
mbfree = (ll_sectorspercluster * ll_bytespersector * (ll_numberoffreeclusters / 1024)) / 1024
mbtotal = (ll_sectorspercluster * ll_bytespersector * (ll_toalnumberofclusters / 1024)) / 1024

5)、of_GetDriverType(),获得各个磁盘的种类。

ulong ul_drivetype
string ls_drive
ul_drivetype = GetDriveType(a_drivename)
choose case ul_drivetype
case        0
ls_Drive = "Unknown Driver"
Case 1
ls_Drive = "Drive Does Not exist"
Case 2
ls_Drive = "Floppy driver"
Case 3
ls_Drive = "HardDisk driver"
Case 4
ls_Drive = "Network driver"
Case 5
ls_Drive = "CD-ROM driver"
Case 6
ls_Drive = "RAM driver"
End choose
Return ls_drive

6)、of_GetIPAddress(),获得本机IP地址。

return ole_1.object.localip

7)、of_GetKeyBoardType(),获得用户键盘种类。

return  GetKeyboardType(0)

8)、of_GetLongInID(),获得登陆的用户名称。

string ls_username,ls_cmpname
ulong ll_length,lul_runtime
ls_cmpname = ""
ls_username = space(64)
ll_length = 64
lul_runtime=WNetGetUser(ls_cmpName,ls_UserName,ll_Length)
If lul_runtime=0 then
return ls_UserName
else
return "Error"
End if

9)、of_GetMacAddress(),获得网卡的物理地址。

long lana[254],ll_lananum,mac[6]
long i,j
If Not FileExists("utils.dll") Then
MessageBox("错误","无法找到 utils.dll 文件")
Return ""
End If
j=1
String ls_macaddress[254]
ll_lananum = GetLanaID(lana)
for i=1 to ll_lananum
   if GetMacAddress(lana[i],mac) = 0 then
      ls_macaddress[j] =        string(mac[1])+"," +string(mac[2])+"," +  string(mac[3])+"," +
string(mac[4])+"," + string(mac[5])+"," + string(mac[6])   
           j++
   end if
next
string ls_return
For i = 1 to j
If ls_macaddress[i]="" Then exit
ls_return = ls_return+ls_macaddress[i]+"|"
next
return ls_return

10)、of_GetMemory(),获得内存的使用情况。

ws_memory str_memory
GlobalMemoryStatus(str_memory)
dlength = str_memory.dlength
dmemoryload = str_memory.dmemoryload
dtotalphys = str_memory.dtotalphys
davailphys = str_memory.davailphys
dtotalpagefile = str_memory.dtotalpagefile
davailpagefile = str_memory.davailpagefile
dtotalvirtual = str_memory.dtotalvirtual
davailvirtual = str_memory.davailvirtual
return

11)、of_GetMHZ()。

IF not Fileexists("Mydll.dll") Then
MessageBox("错误","无法找到 MyDll.dll !!!")
return 0
End If
ulong ul_mhz
ul_mhz = GetMhz()
return ul_mhz

12)、of_GetNetCard(),获得网卡的名称。

environment l_env
getenvironment(l_env)
Integer li_rtn
string ls_username
Choose case l_env.ostype
case Windows!
li_rtn =
RegistryGet("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Net\0000","DriverDesc",
RegString!,ls_username)
If li_rtn <> 1 Then
li_rtn =
RegistryGet("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Net\0001","DriverDesc",
RegString!,ls_username)
if li_rtn<> 1 Then
ls_username = "Ether Netword Card can not be detected"
End if
End if
case WindowsNT!
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\
CurrentVersion\NetworkCards\1","Title",RegString!,ls_username)
End choose
return ls_username
2014-6-25 11:47
0
雪    币: 8
活跃值: (277)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
驱动级的没有,有通过asm得到的不知可否需要。
2014-7-8 10:54
0
游客
登录 | 注册 方可回帖
返回
//