Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


weird driver errors

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 18, 2008 4:05 pm    Post subject: weird driver errors Reply with quote

I'm trying to make a little test driver and the compiler keeps getting errors that seem very unusual to me seeing as I don't see anything at all that's wrong in the code, or at least that's wrong pertaining to the errors. Here are the errors:

Quote:


C:\WinDDK\6001.18001>cd ..

C:\WinDDK>cd ..

C:\>cd Drivers

C:\Drivers>build
path contains nonexistant d:\fpc\2.0.4\bin\i386-win32, removing
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\6001.18001\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Fri Jul 18 14:19:34 2008
BUILD: Examining c:\drivers directory for files to compile.
BUILD: Saving c:\winddk\6001.18001\build.dat...
BUILD: Compiling and Linking c:\drivers directory
_NT_TARGET_VERSION SET TO WINXP
Compiling - drivermain.c
errors in directory c:\drivers
c:\drivers\drivermain.c(6) : error C2275: 'NTSTATUS' : illegal use of this type
as an expression
c:\drivers\drivermain.c(6) : error C2146: syntax error : missing ';' before iden
tifier 'NtStatus'
c:\drivers\drivermain.c(6) : error C2065: 'NtStatus' : undeclared identifier
c:\drivers\drivermain.c(7) : error C2275: 'PDEVICE_OBJECT' : illegal use of this
type as an expression
c:\drivers\drivermain.c(7) : error C2146: syntax error : missing ';' before iden
tifier 'pDeviceObject'
c:\drivers\drivermain.c(7) : error C2065: 'pDeviceObject' : undeclared identifie
r
c:\drivers\drivermain.c(Cool : error C2275: 'UNICODE_STRING' : illegal use of this
type as an expression
c:\drivers\drivermain.c(Cool : error C2146: syntax error : missing ';' before iden
tifier 'usDriverName'
c:\drivers\drivermain.c(Cool : error C2065: 'usDriverName' : undeclared identifier

c:\drivers\drivermain.c(Cool : error C2065: 'usDosDeviceName' : undeclared identif
ier
c:\drivers\drivermain.c(15) : error C2065: 'FILE_SECURE_OPEN' : undeclared ident
ifier
Linking Executable - release\i386\driver_test.sys
link : error LNK1181: cannot open input file 'c:\drivers\objfre_wxp_x86\i386\dri
vermain.obj'
BUILD: Finish time: Fri Jul 18 14:19:37 2008
BUILD: Done

3 files compiled - 11 Warnings - 11 Errors
1 executable built - 1 Error

C:\Drivers>
C:\Drivers>build -c
path contains nonexistant d:\fpc\2.0.4\bin\i386-win32, removing
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\6001.18001\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Fri Jul 18 14:19:51 2008
BUILD: Examining c:\drivers directory for files to compile.
BUILD: Saving c:\winddk\6001.18001\build.dat...
BUILD: Compiling and Linking c:\drivers directory
_NT_TARGET_VERSION SET TO WINXP
Compiling - drivermain.c
errors in directory c:\drivers
c:\drivers\drivermain.c(6) : error C2275: 'NTSTATUS' : illegal use of this type
as an expression
c:\drivers\drivermain.c(6) : error C2146: syntax error : missing ';' before iden
tifier 'NtStatus'
c:\drivers\drivermain.c(6) : error C2065: 'NtStatus' : undeclared identifier
c:\drivers\drivermain.c(7) : error C2275: 'PDEVICE_OBJECT' : illegal use of this
type as an expression
c:\drivers\drivermain.c(7) : error C2146: syntax error : missing ';' before iden
tifier 'pDeviceObject'
c:\drivers\drivermain.c(7) : error C2065: 'pDeviceObject' : undeclared identifie
r
c:\drivers\drivermain.c(Cool : error C2275: 'UNICODE_STRING' : illegal use of this
type as an expression
c:\drivers\drivermain.c(Cool : error C2146: syntax error : missing ';' before iden
tifier 'usDriverName'
c:\drivers\drivermain.c(Cool : error C2065: 'usDriverName' : undeclared identifier

c:\drivers\drivermain.c(Cool : error C2065: 'usDosDeviceName' : undeclared identif
ier
c:\drivers\drivermain.c(15) : error C2065: 'FILE_SECURE_OPEN' : undeclared ident
ifier
Linking Executable - release\i386\driver_test.sys
link : error LNK1181: cannot open input file 'c:\drivers\objfre_wxp_x86\i386\dri
vermain.obj'
BUILD: Finish time: Fri Jul 18 14:19:53 2008
BUILD: Done

3 files compiled - 11 Warnings - 11 Errors
1 executable built - 1 Error

C:\Drivers>


Here's my code:

Code:

//I know excessive DbgPrint() use, but I don't care
#include <ntddk.h>

NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath) {
   DbgPrint("DriverEntry called.");
   DbgPrint("Declaring variables...");
   NTSTATUS NtStatus;
   PDEVICE_OBJECT pDeviceObject;
   UNICODE_STRING usDriverName, usDosDeviceName;
   DbgPrint("Variables declared.");
   DbgPrint("Initializing strings...");
   RtlInitUnicodeString(&usDriverName, "\\Device\\Test");
   RtlInitUnicodeString(&usDosDeviceName, "\\DosDeviceName\\Test");
   DbgPrint("Strings initialized.");
   DbgPrint("Creating device object...");
   NtStatus = IoCreateDevice(pDriverObject, 0, &usDriverName, FILE_DEVICE_UNKNOWN, FILE_SECURE_OPEN, FALSE, pDeviceObject);
   if(NtStatus != STATUS_SUCCESS) {
      DbgPrint("IoCreateDevice failed with error: %i", NtStatus);
      DbgPrint("Unloading driver...");
      pDriverObject->DriverUnload;
      return NtStatus;
   }
   DbgPrint("Device object created.");
   DbgPrint("Creating symbolic link...");
   NtStatus = IoCreateSymbolicLink(&usDosDeviceName, &usDriverName);
   if(NtStatus != STATUS_SUCCESS) {
      DbgPrint("IoCreateSymbolicLink failed with error: %i", NtStatus);
      DbgPrint("Unloading driver...");
      pDriverObject->DriverUnload;
      return NtStatus;
   }
   DbgPrint("Symbolic link created.");
   DbgPrint("Deleting symbolic link...");
   NtStatus = IoDeleteSymbolicLink(&usDosDeviceName);
   if(NtStatus != STATUS_SUCCESS) {
      DbgPrint("IoDeleteSymbolicLink failed with error: %i", NtStatus);
      DbgPrint("Unloading driver...");
      pDriverObject->DriverUnload;
      return NtStatus;
   }
   DbgPrint("Symbolic link deleted.");
   DbgPrint("Unloading driver...");
   pDriverObject->DriverUnload;
   return STATUS_SUCCESS;
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Jul 18, 2008 4:43 pm    Post subject: Reply with quote

Learn to program in C.

All variable declarations have to be in the beginning of the function before anything else.
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Fri Jul 18, 2008 4:53 pm    Post subject: Reply with quote

Flyte wrote:
Learn to program in C.

All variable declarations have to be in the beginning of the function before anything else.


Uhh, since when?
Back to top
View user's profile Send private message AIM Address MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Fri Jul 18, 2008 4:56 pm    Post subject: Reply with quote

They do, I remember coming across this nuisance as well.
Back to top
View user's profile Send private message MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Fri Jul 18, 2008 5:01 pm    Post subject: Reply with quote

Remember, drivers aren't C++
_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 18, 2008 9:04 pm    Post subject: Reply with quote

Agh Mad I didn't expect it to be that different. Oh well, btw, is there anyway I could compile it as if it is C++? Do I just save it as a .cpp file or is there a compiler option?

EDIT:

New error... x_x

Quote:


C:\WinDDK\6001.18001>cd ..

C:\WinDDK>cd ..

C:\>cd Drivers

C:\Drivers>build
path contains nonexistant d:\fpc\2.0.4\bin\i386-win32, removing
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\6001.18001\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Fri Jul 18 19:28:16 2008
BUILD: Examining c:\drivers directory for files to compile.
BUILD: Saving c:\winddk\6001.18001\build.dat...
BUILD: Compiling and Linking c:\drivers directory
_NT_TARGET_VERSION SET TO WINXP
Compiling - drivermain.c
errors in directory c:\drivers
c:\drivers\drivermain.c(10) : error C2220: warning treated as error - no 'object
' file generated
Linking Executable - release\i386\driver_test.sys
link : error LNK1181: cannot open input file 'c:\drivers\objfre_wxp_x86\i386\dri
vermain.obj'
BUILD: Finish time: Fri Jul 18 19:28:17 2008
BUILD: Done

3 files compiled - 5 Warnings - 1 Error
1 executable built - 1 Error

C:\Drivers>

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Jul 18, 2008 9:28 pm    Post subject: Reply with quote

Find the buildfre_wxp_x86.log file and post whats inside of it.
_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 18, 2008 9:46 pm    Post subject: Reply with quote

Quote:

BUILD: Computing Include file dependencies:
BUILD: Examining c:\drivers directory for files to compile.
skipping post pass 0 command
Compiling and Linking c:\drivers *************
'nmake.exe /nologo BUILDMSG=Stop. -i BUILD_PASS=PASS2 LINKONLY=1 NOPASS0=1 MAKEDIR_RELATIVE_TO_BASEDIR='
c:\drivers: TARGETPATH is Release
BUILDMSG: _NT_TARGET_VERSION SET TO WINXP
cl.exe @c:\drivers\objfre_wxp_x86\i386\cl.rsp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.278 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl /Fo"c:\drivers\objfre_wxp_x86\i386/"
/FC
/Ii386
/I.
/Ic:\drivers\objfre_wxp_x86\i386
/IC:\WinDDK\6001.18001\inc\api
/IC:\WinDDK\6001.18001\inc\api
/IC:\WinDDK\6001.18001\inc\ddk
/IC:\WinDDK\6001.18001\inc\ddk
/IC:\WinDDK\6001.18001\inc\crt
/D_X86_=1
/Di386=1
/DSTD_CALL
/DCONDITION_HANDLING=1
/DNT_INST=0
/DWIN32=100
/D_NT1X_=100
/DWINNT=1
/D_WIN32_WINNT=0x0501
/DWINVER=0x0501
/D_WIN32_IE=0x0603
/DWIN32_LEAN_AND_MEAN=1
/DDEVL=1
/D__BUILDMACHINE__=WinDDK
/DFPO=0
/DNDEBUG
/D_DLL=1
/DNDEBUG
/DNTDDI_VERSION=0x05010200
/c
/Zc:wchar_t-
/Zl
/Zp8
/Gy
/Gm-
-cbstring
/W3
/WX
/Gz
/hotpatch
/EHs-c-
/GR-
/GF
/GS
/Z7
/Oxs
/Oy-
/Z7
/DKMDF_MAJOR_VERSION=01
/DKMDF_MINOR_VERSION=007
/FIC:\WinDDK\6001.18001\inc\api\warning.h
.\drivermain.c
drivermain.c
c:\drivers\drivermain.c(10) : error C2220: warning treated as error - no 'object' file generated
errors in directory c:\drivers
c:\drivers\drivermain.c(10) : error C2220: warning treated as error - no 'object' file generated
c:\drivers\drivermain.c(10) : warning C4133: 'function' : incompatible types - from 'char [13]' to 'PCWSTR'
warnings in directory c:\drivers
c:\drivers\drivermain.c(10) : warning C4133: 'function' : incompatible types - from 'char [13]' to 'PCWSTR'
c:\drivers\drivermain.c(11) : warning C4133: 'function' : incompatible types - from 'char [20]' to 'PCWSTR'
c:\drivers\drivermain.c(11) : warning C4133: 'function' : incompatible types - from 'char [20]' to 'PCWSTR'
c:\drivers\drivermain.c(14) : warning C4047: 'function' : 'PDEVICE_OBJECT *' differs in levels of indirection from 'PDEVICE_OBJECT'
c:\drivers\drivermain.c(14) : warning C4047: 'function' : 'PDEVICE_OBJECT *' differs in levels of indirection from 'PDEVICE_OBJECT'
c:\drivers\drivermain.c(14) : warning C4024: 'IoCreateDevice' : different types for formal and actual parameter 7
c:\drivers\drivermain.c(14) : warning C4024: 'IoCreateDevice' : different types for formal and actual parameter 7
link.exe /out:Release\i386\Driver_Test.sys /machine:ix86 @c:\drivers\objfre_wxp_x86\i386\lnk.rsp
Microsoft (R) Incremental Linker Version 8.00.50727.278
Copyright (C) Microsoft Corporation. All rights reserved.
/MERGE:_PAGE=PAGE
/MERGE:_TEXT=.text
/SECTION:INIT,d
/OPT:REF
/OPT:ICF
/IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221
/INCREMENTAL:NO
/release
/NODEFAULTLIB
/WX
/debug
/debugtype:cv,fixup,pdata
/version:6.0
/osversion:6.0
/functionpadmin:5
/safeseh
/pdbcompress
/STACK:0x40000,0x1000
/driver
/base:0x10000
/align:0x80 /stub:c:\winddk\6001.18001\lib\wxp\stub512.com
/subsystem:native,5.01
/entry:GsDriverEntry@8
/out:Release\i386\Driver_Test.sys
c:\drivers\objfre_wxp_x86\i386\drivermain.obj
c:\winddk\6001.18001\lib\wxp\i386\BufferOverflowK.lib
c:\winddk\6001.18001\lib\wxp\i386\ntoskrnl.lib
c:\winddk\6001.18001\lib\wxp\i386\hal.lib
c:\winddk\6001.18001\lib\wxp\i386\wmilib.lib
c:\winddk\6001.18001\lib\wxp\i386\sehupd.lib
LINK : fatal error LNK1181: cannot open input file 'c:\drivers\objfre_wxp_x86\i386\drivermain.obj'
link : error LNK1181: cannot open input file 'c:\drivers\objfre_wxp_x86\i386\drivermain.obj'

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Jul 18, 2008 9:50 pm    Post subject: Reply with quote

There is your answer right there:

Code:
c:\drivers\drivermain.c(10) : warning C4133: 'function' : incompatible types - from 'char [13]' to 'PCWSTR'
c:\drivers\drivermain.c(11) : warning C4133: 'function' : incompatible types - from 'char [20]' to 'PCWSTR'
c:\drivers\drivermain.c(11) : warning C4133: 'function' : incompatible types - from 'char [20]' to 'PCWSTR'
c:\drivers\drivermain.c(14) : warning C4047: 'function' : 'PDEVICE_OBJECT *' differs in levels of indirection from 'PDEVICE_OBJECT'
c:\drivers\drivermain.c(14) : warning C4047: 'function' : 'PDEVICE_OBJECT *' differs in levels of indirection from 'PDEVICE_OBJECT'
c:\drivers\drivermain.c(14) : warning C4024: 'IoCreateDevice' : different types for formal and actual parameter 7
c:\drivers\drivermain.c(14) : warning C4024: 'IoCreateDevice' : different types for formal and actual parameter 7


Needed unicode strings here:
Code:
RtlInitUnicodeString(&usDriverName, L"\\Device\\Test");
RtlInitUnicodeString(&usDosDeviceName, L"\\DosDeviceName\\Test");


Fixed last param here:
Code:
IoCreateDevice(pDriverObject, 0, &usDriverName, FILE_DEVICE_UNKNOWN, FILE_SECURE_OPEN, FALSE, &pDriverObject->DeviceObject);
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 18, 2008 11:23 pm    Post subject: Reply with quote

Thanks. Btw, is there anyway to code drivers with MBCS instead of Unicode?

EDIT:

IoCreateDevice failed during runtime x_x

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites