Driver Problem

This is a discussion on Driver Problem within the C Programming forums, part of the General Programming Boards category; I am compiling with WINDDK Windows Server 2003 Build Environment and I get a lot of errors. I am so ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    10

    Driver Problem

    I am compiling with WINDDK Windows Server 2003 Build Environment and I get a lot of errors. I am so lost. Can anybody please tell me what I am doing wrong?

    Code:
    #include <ntddk.h>
    
    void DriverUnload(PDRIVER_OBJECT pDriverObject)
    {
        DbgPrint("DriverExit\n");
    }
    
    NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    {
        DriverObject->DriverUnload = DriverUnload;
    	
        DbgPrint("DriverEntry\n");
    
    	HANDLE gbHandle = FindWindow(0, "Calculator");
    
    	if (gbHandle != NULL) {
    		DWORD wtpID;
    		GetWindowThreadProcessId(hWnd, &wtpID);
    		HANDLE gbProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, wtpID); 
    		BYTE hdata[]={0x72, 0x6F};
    		DWORD sizehdata = sizeof(hdata);
    		WriteProcessMemory(gbProcess, (LPVOID)0x5C6600, &hdata, sizehdata, NULL));
    		CloseHandle(gbProcess);	
    	}
    
        return STATUS_SUCCESS;
    }

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Mind posting the errors ?

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    10
    Code:
    Compiling - main.c for i386
    errors in directory d:\winddk\3790~1.183\src\ddriver\devicedriver
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(14) : error C2143: syntax er
    ror : missing ';' before 'type'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(16) : error C2065: 'gbHandle
    ' : undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(16) : error C4047: '!=' : 'i
    nt' differs in levels of indirection from 'void *'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(20) : error C2065: 'DWORD' :
     undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(20) : error C2146: syntax er
    ror : missing ';' before identifier 'wtpID'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(20) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(20) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(20) : error C2143: syntax er
    ror : missing ';' before 'identifier'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(20) : error C2065: 'wtpID' :
     undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(22) : error C4013: 'GetWindo
    wThreadProcessId' undefined; assuming extern returning int
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(22) : error C2065: 'hWnd' :
    undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C2275: 'HANDLE'
    : illegal use of this type as an expression
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C2146: syntax er
    ror : missing ';' before identifier 'gbProcess'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C2143: syntax er
    ror : missing ';' before 'identifier'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C2065: 'gbProces
    s' : undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(23) : error C4013: 'OpenProc
    ess' undefined; assuming extern returning int
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2065: 'BYTE' :
    undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2146: syntax er
    ror : missing ';' before identifier 'hdata'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2143: syntax er
    ror : missing ';' before 'identifier'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2065: 'hdata' :
     undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(27) : error C2059: syntax er
    ror : ']'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(28) : error C2146: syntax er
    ror : missing ';' before identifier 'sizehdata'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(28) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(28) : error C2144: syntax er
    ror : '<Unknown>' should be preceded by '<Unknown>'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(28) : error C2143: syntax er
    ror : missing ';' before 'identifier'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(28) : error C2065: 'sizehdat
    a' : undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(30) : error C4013: 'WritePro
    cessMemory' undefined; assuming extern returning int
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(30) : error C2065: 'LPVOID'
    : undeclared identifier
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(30) : error C2143: syntax er
    ror : missing ')' before 'constant'
    d:\winddk\3790.1830\src\ddriver\devicedriver\main.c(34) : error C4013: 'CloseHan
    dle' undefined; assuming extern returning int
    BUILD: Compile errors: not linking d:\winddk\3790~1.183\src\ddriver\devicedriver
     directory
    BUILD: Done
    
        2 files compiled - 34 Errors -    38 LPS

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    > DbgPrint("DriverEntry\n");
    This is a statement

    > HANDLE gbHandle = FindWindow(0, "Calculator");
    This is a declaration and initialisation.

    In C (which is what main.c is), you can't mix declarations and statements.
    Maybe compile it as a C++ program?

    Also, is main.c something you've written, or does it come with the DDK?

    If it's your code, then it definitely needs to be in another directory. All the libraries / include files (and their directories) which you download should be maintained in their pristine state.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21