Salut a tous !

Je développe un " driver " , permettant de cacher un processus dans le Task Manager.

Mon problème est que je n'arrive pas a envoyer un IOCTL a mon driver , avec la fonction DeviceIoControl. Cette fonction me renvoie une erreur 87,
ceux qui correspond a: ERROR_INVALID_PARAMETER.

J'ai tous vérifier plein de fois et je vois vraiment pas où je me suis trompé... :/

Donc si quelqu'un pourrais m'aider ça serait cool .
J'espère avoir bien expliqué mon problème, sinon dite le moi...

Voila le code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <winioctl.h>
 
#define SIOCTL_TYPE 40000
#define IOCTL_NAME_PROCESS CTL_CODE(SIOCTL_TYPE, 0x801, METHOD_BUFFERED, FILE_READ_DATA|FILE_WRITE_DATA)
 
static void purger( void )
{
    int c;
 
    while( ( c = getchar() ) != '\n' && c != EOF )
    {
    }
}
 
static void clean( char *string )
{
    char *p = strchr( string , '\n' );
 
    if( p )
    {
        *p = 0;
    }
    else
    {
        purger();
    }
}
 
int __cdecl main(int argc, char* argv[])
{
    char *process = ( char* )malloc( sizeof( char ) * 50 );
 
    HANDLE hDevice;
    DWORD d;
    DWORD size = sizeof( process );
 
    BOOL test;
 
    printf("Process name: ");
    fgets( process , sizeof( process ) , stdin );
    clean( process );
 
 
    //hDevice = CreateFile( "\\\\.\\ProcessHide.sys" , GENERIC_READ | GENERIC_WRITE , FILE_SHARE_READ | FILE_SHARE_WRITE , 0 , OPEN_EXISTING ,  FILE_ATTRIBUTE_NORMAL , 0 );
 
    //hDevice = CreateFile( "C:\\Users\\Raphaël\\Documents\\DriverProject\\ProcessHide\\ProcessHide.sys" , GENERIC_READ | GENERIC_WRITE , FILE_SHARE_READ | FILE_SHARE_WRITE , 0 , OPEN_EXISTING ,  FILE_ATTRIBUTE_NORMAL , 0 );
 
    hDevice = CreateFile( ".\\ProcessHide.sys" , GENERIC_READ | GENERIC_WRITE , FILE_SHARE_READ | FILE_SHARE_WRITE , 0 , OPEN_EXISTING ,  FILE_ATTRIBUTE_NORMAL , 0 );
 
    if( hDevice == INVALID_HANDLE_VALUE )
    {
        printf("Error Open Device");
        printf("\nError %d", GetLastError() );
 
        Sleep(1000);
    }
    else
    {
 
        printf("Works ! ");
        Sleep(1000);
    }
 
    test = (BOOL)DeviceIoControl( hDevice , IOCTL_NAME_PROCESS , process , size , NULL , 0 , &d , (LPOVERLAPPED) NULL );
 
    if( test == 0 )
    {
        printf("\nError DeviceIoControl");
        printf("\nErro %d", GetLastError() );
 
        Sleep(1000);
    }
 
 
    CloseHandle( hDevice );
 
    return 0;
 
}
Merci d'avance !

PS: Le prototype de DeviceIoControl est disponible ici => http://msdn.microsoft.com/en-us/librar [...] VS.85%29.aspx

Et je compile avec gcc ( inclus dans la dernière version de codeblocks )