API Hooking Newbie

Discussion in 'C' started by yohaness, Nov 7, 2013.

  1. yohaness

    yohaness New Member

    Joined:
    Nov 7, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Ok i am new to API Hooking in C, so i wanted to try out something i have never done before, i have some knowledge of C so i wanted to see how good i can get with this

    here is my code
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    DWORD HookFunction(LPCSTR lpModule, LPCSTR lpFuncName, LPVOID lpFunction, unsigned char *lpBackup,LPCSTR LpProcess);
    BOOL UnHookFunction(LPCSTR lpModule, LPCSTR lpFuncName, unsigned char *lpBackup,LPCSTR LpProcess);
    int MyMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
    
    
    DWORD HookFunction(LPCSTR LpProcess)
    
    if (LpProcess == "notepad.exe")
    	{
    	   DWORD HookFunction(LPCSTR lpModule, LPCSTR lpFuncName, LPVOID lpFunction, unsigned char *lpBackup,LPCSTR LpProcess);
    	   DWORD dwAddr = (DWORD)GetProcAddress(GetModuleHandle(lpModule),lpFuncName);
    	   printf("I Have Hooked You!");
    	   return 0;
    	}
    
    Now i get this very alarming error

    Code:
    1>------ Build started: Project: StarProject, Configuration: Debug Win32 ------
    1>Build started 07/11/2013 13:11:37.
    1>InitializeBuildStatus:
    1>  Touching "Debug\StarProject.unsuccessfulbuild".
    1>ClCompile:
    1>  Hookme.c
    1>c:\users\spaxxxpc\desktop\formgrabproject\starproject\starproject\hookme.c(9): error C2059: syntax error : 'if'
    1>
    1>Build FAILED.
    1>
    1>Time Elapsed 00:00:01.60
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice