CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Casting error

  1. #1
    Join Date
    Aug 2003
    Posts
    938

    Casting error

    Hello.
    Does anyone see an error in the following code? it is prolly someting stupid but i can;t see it....here is the code:
    Code:
    #include <windows.h> 
    #define WINDOW_NAME "Test" 
    #define ADDY 0x41A788 
    DWORD OrigTick; 
    DWORD WINAPI GetTickCountHook(void); 
    DWORD WINAPI (*GetTickCountOrig)(void); 
    int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) 
    { 
        switch (reason) 
        { 
            case DLL_PROCESS_ATTACH: 
                HWND hpid; 
                DWORD pid; 
                FARPROC fp; 
                LPVOID addy; 
    
                GetTickCountOrig = (DWORD(*WINAPI)())GetTickCount; 
                OrigTick = GetTickCount(); 
    
                hpid = FindWindow(0, WINDOW_NAME); 
                GetWindowThreadProcessId(hpid, &pid); 
                (HANDLE)(hpid) = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); 
                addy = VirtualAllocEx(hpid, 0, 4, MEM_COMMIT, PAGE_READWRITE); 
                fp = (FARPROC)GetTickCountHook; 
                WriteProcessMemory(hpid, addy, &fp, 4, 0); 
                WriteProcessMemory(hpid, (void*)((DWORD)ADDY+2), &addy, 4, 0); 
            break; 
        } 
        return 1; 
    } 
    DWORD __export WINAPI GetTickCountHook(void) 
    { 
    }
    there error is in the
    Code:
    GetTickCountOrig = (DWORD(*WINAPI)())GetTickCount;
    line.
    Any ideas?
    Code:
    dllmain.cpp: In function `int DllEntryPoint(HINSTANCE__*, long unsigned int, 
       void*)':
    dllmain.cpp:17: error: invalid type modifier within pointer declarator
    
    make.exe: *** [dllmain.o] Error 1
    
    Execution terminated
    Here is the error code. I am using Dev Cpp v 5.
    Thx in Advance

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Casting error

    Code:
    typedef DWORD WINAPI (*GET_TICK_COUNT_ORIG)(void);
    
    GET_TICK_COUNT_ORIG GetTickCountOrig = (GET_TICK_COUNT_ORIG) GetTickCount;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured