網卡MACAddress 程式更改....

網卡MACAddress 程式更改....

請各位 專家 見到 原始碼....

請問 我要如何 寫出一個 常駐程式...

改成 我所指定 的 ...網卡MACAddress 範例 (A9-A9-A9-A8-A8-A8)

~~~~~~~~~~~~~~~~~~~~

也就是 執行 此常駐程式...後.....

網卡 測出來的...MACAddress ...會變成A9-A9-A9-A8-A8-A8...

而關閉 此常駐程式...後.....

網卡 測出來的...MACAddress ...又恢復 正常.......

謝謝 各位專家.....給一點 方向 ...跪求 高抬貴手.....

我就是 要用 寫程式的.....

我知道 網路上...有 修改軟體........

我就是 要用 寫程式的.....

#include <iostream>

#include <windows.h>

using namespace std;

int main(){

typedef char * (__stdcall *GetMAC)(int);

GetMAC getMAC;

HINSTANCE hInstDll = LoadLibrary("HWInfo.dll");

if (hInstDll != NULL){

getMAC = (GetMAC)GetProcAddress(hInstDll, "getMAC");

}

cout << "MAC Address: " << getMAC(0) << endl

<< endl << "Press \"Enter\" to exit...";

cin.get();

FreeLibrary(hInstDll);

return 0;

}

謝謝 各位專家.....給一點 方向 ...跪求 高抬貴手.....

1 個解答

評分
  • Chen
    Lv 6
    5 年前
    最佳解答

    I had coded program called netmon.exe ( using services run in user mode) and netmon.sys ( used by services to run in kernel mode ) ten years before.

    some ether card can be changed MAC address, but some can't.

    do you know NDIS version 5 or above driver in DDK ?

    KERNEL MODE:

    PacketBindAdapter provides NdisRegisterProtocol function

    PacketBindAdapter function:

    We must Create a symbolic link for use mode, so We need to replace Device from \Device\Packet_{GUID} with DosDevices to create a symbolic link of the form \DosDevices\Packet_{GUID}

    USER MODE:

    main( int argc, char **argv)

    {

    HANDLE dhandle;

    // open \DosDevices\Packet_{GUID}

    dhandle = CreateFile(dos_device_name,

    GENERIC_WRITE | GENERIC_READ,

    0,

    NULL,

    OPEN_EXISTING,

    FILE_FLAG_OVERLAPPED,

    0

    );

    if(dhandle != INVALID_HANDLE_VALUE)

    {

    char buffer[2048], address[6];

    int len, i;

    printf("open OK, please anykey to read\n" );

    /******** get MAC address **********************/

    if(packet_getaddress( dhandle, address))

    {

    printf("get physical address=");

    for(i= 0; i < 6; i++ )

    printf("%x", address[i] & 0xFF );

    printf("\n" );

    }

    else

    printf("get physical address error\n" );

    /******** Set MAC address **********************/

    address[0] = 0x00;

    address[1] = 0x50;

    address[2] = 0xBA;

    address[3] = 0x4A;

    address[4] = 0x39;

    address[5] = 0x0C;

    if(packet_setaddress( dhandle, address))

    {

    printf("set physical address Ok\n" );

    }

    else

    printf("set physical address error\n" );

    printf("Please anykey to continue\n" );

    /********* Get new MAC address ****************/

    if(packet_getaddress( dhandle, address))

    {

    printf("Get physical address=");

    for(i= 0; i < 6; i++ )

    printf("%x", address[i] & 0xFF );

    printf("\n" );

    }

    else

    printf("get physical address error\n" );

    }

還有問題?馬上發問,尋求解答。