Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   API Hooking Newbie (http://www.go4expert.com/forums/api-hooking-newbie-t29895/)

yohaness 7Nov2013 19:30

API Hooking Newbie
 
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 ==========



All times are GMT +5.5. The time now is 21:59.