Problème de débutant en codage de driver windows

Résolu
TorTukiTu Messages postés 31 Date d'inscription samedi 22 avril 2006 Statut Membre Dernière intervention 18 avril 2011 - 28 mars 2008 à 17:39
TorTukiTu Messages postés 31 Date d'inscription samedi 22 avril 2006 Statut Membre Dernière intervention 18 avril 2011 - 29 mars 2008 à 14:16
Bonjour les gens,

J'ai décidé de créer mon premier driver windows en C : le driver qui dit coucou. J'ai téléchargé le WDK chez microsoft et lancé l'environnement x86 Windows XP (Normal sui sous XP avec un amd64) . voici le code que j'essaye de compiler:

#include <ntifs.h>

NTSTATUS DriverEntry( IN DRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath)
{
    DbgPrint("Hello World");
    return STATUS_SUCCESS;
}

Voici le makefile:

! INCLUDE $(NTMAKEENV)\makefile.def

Et le fichier SOURCES

TARGETNAME=ROOTKIT
TARGETPATH=OBJ
TARGETTYPE=DRIVER
SOURCES=mydriver.c

****************************************************

Je compile avec build et la c'est le drame :

path contains nonexistant c:\program files\ati technologies\ati.ace\core-static,
 removing
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\6001.18001\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Fri Mar 28 17:24:09 2008
BUILD: Examining c:\rootkit directory for files to compile.
BUILD: Saving c:\winddk\6001.18001\build.dat...
BUILD: Compiling and Linking c:\rootkit directory
_NT_TARGET_VERSION SET TO WINXP
Compiling - mydriver.c
errors in directory c:\rootkit
c:\winddk\6001.18001\inc\api\winnt.h(466) : error C2054: expected '(' to follow
'BYTE'
c:\winddk\6001.18001\inc\api\winnt.h(467) : error C2085: 'WORD' : not in formal
parameter list
c:\winddk\6001.18001\inc\api\winnt.h(467) : error C2146: syntax error : missing
',' before identifier 'FSHORT'
c:\winddk\6001.18001\inc\api\winnt.h(468) : error C2085: 'DWORD' : not in formal
 parameter list
... ERREURS A GOGO....
c:\winddk\6001.18001\inc\api\winnt.h(3486) : error C1003: error count exceeds 10
0; stopping compilation
Linking Executable - objchk_wxp_x86\i386\rootkit.sys
link : error LNK1181: cannot open input file 'c:\rootkit\objchk_wxp_x86\i386\myd
river.obj'
BUILD: Finish time: Fri Mar 28 17:24:10 2008
BUILD: Done

    3 files compiled - 12 Warnings - 102 Errors
    1 executable built - 1 Error

J'ai cherché désespérément un moyen de résoudre ce problème sur la toile et sur la doc de WDK mais je n'ai pas réussi. Pourriez-vous m'aider plz

Ordinateur : moyen conçu pour accélérer et automatiser les erreurs.

4 réponses

racpp Messages postés 1909 Date d'inscription vendredi 18 juin 2004 Statut Modérateur Dernière intervention 14 novembre 2014 17
28 mars 2008 à 21:12
Salut,
Je n'ai pas encore travaillé avec le WDK mais généralement un code pour driver devrait commencer par:
#include <ntddk.h>
3
TorTukiTu Messages postés 31 Date d'inscription samedi 22 avril 2006 Statut Membre Dernière intervention 18 avril 2011 1
29 mars 2008 à 00:31
Salut merci de ta réponse rapide







Je sais j'y ait déja pensé, mais ça donne toujours autant d'erreurs.
Je crois que c'est du au compilateur.
J'y connais riens mais est-ce que ça pourrait pas être une histoire d'environnement?




Ordinateur : moyen conçu pour accélérer et automatiser les erreurs.
3
TorTukiTu Messages postés 31 Date d'inscription samedi 22 avril 2006 Statut Membre Dernière intervention 18 avril 2011 1
29 mars 2008 à 13:34
Re

Bon j'avance un peu . Deja mon header ntddk.h était pourri je sais pas pourquoi mais je l'ai retéléchargé et sa semble mieux marcher. J'ai cependant toujours les erreurs suivantes

C:\driver>build
path contains nonexistant c:\program files\ati technologies\ati.ace\core-static,
 removing
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\6001.18001\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Sat Mar 29 13:27:56 2008
BUILD: Examining c:\driver directory for files to compile.
BUILD: Saving c:\winddk\6001.18001\build.dat...
BUILD: Compiling and Linking c:\driver directory
_NT_TARGET_VERSION SET TO WINXP
Compiling - mydriver.c
Linking Executable - objchk_wxp_x86\i386\rootkit.sys
errors in directory c:\driver
c:\driver\bufferoverflowk.lib(gs_support.obj) : error LNK2019: unresolved extern
al symbol _DriverEntry@8 referenced in function _GsDriverEntry@8
c:\driver\objchk_wxp_x86\i386\rootkit.sys : error LNK1120: 1 unresolved external
s
BUILD: Finish time: Sat Mar 29 13:27:57 2008
BUILD: Done

    3 files compiled - 1 Warning
    1 executable built - 2 Errors
******************************************************************************
Est-ce que ça: error LNK2019: unresolved extern

al symbol _DriverEntry@8 referenced in function _GsDriverEntry@8 sa voudrait pas dire que j'ai mal nommé une fonction quelconque? Ou est-ce que c'est encore une histoire de header qu'il ne toruve pas ou qui est mal foutu? Un petit coup de pouce please?

Ordinateur : moyen conçu pour accélérer et automatiser les erreurs.
3
TorTukiTu Messages postés 31 Date d'inscription samedi 22 avril 2006 Statut Membre Dernière intervention 18 avril 2011 1
29 mars 2008 à 14:16
Re
J'ai galéré mais j'ai trouvé <3
Il y avait une faute dans le livre dans lequel j'aprend! Coquille au niveau de IN DRIVER_OBJECT  qui est en réalité IN PDRIVER_OBJECT Donc sayest sa marche

Ordinateur : moyen conçu pour accélérer et automatiser les erreurs.
3
Rejoignez-nous