0

DeviceIOControlドライバーに 128 バイトのバッファーを配置するのに問題があります。次のコードを使用します。

int Initialize(unsigned char* public_signature, int size)
{
    int ret = DeviceIoControl( 
    DeviceFileHandle,
    2236440,
    public_signature,
    size,
    NULL,
    0,
    NULL,
    NULL);



    if(ret != 0)
        return 0;

    wprintf(L"Format message failed with 0x%x\n", GetLastError()); // always error 0x6!

    return 1;

}

常に 0x6 エラーが発生します。何が間違っているのでしょうか?

upd 私のハンドル作成関数:

int CreateFileHandle()
{
    DeviceFileHandle = CreateFile( L"\Device\test",
    GENERIC_WRITE,
    GENERIC_READ | GENERIC_WRITE,
    NULL,
    OPEN_EXISTING,
    0,
    0);
    if(DeviceFileHandle)
        return 0;
    return 1;
}
4

1 に答える 1

2

The error is in the 1st parameter of CreateFile. In your example, it would try to open a file, not a device. In addition, you didn't escape backslashes in the string. \t and similar are interpreted as special characters in C++.

The device name should be "\\\\.\\Device\\test".

于 2012-10-09T13:18:09.207 に答える