Vic Posted March 24, 2011 Posted March 24, 2011 (edited) Hi,I need you help me. I want to use SetWindowsHookEx to hook a function exported from a dll to a run a process but it did not work. Detail: I'm have 3 files: Audition.exe, Hooker.exe & DllHook.dll, I'm using Hooker.exe to load that dll & execute function SetHook (exported in dll for Hooker.exe use it). SetHook function in dll will excute to use SetWindowsHookEx to hook a other function in dll into Audition.exe. If hook success it'll show a nag is the PID of Audition.exe process is running. But it's hook isn't success. I want to you help me.This is code in DllHook:library DllHook;usesSysUtils,Windows,Classes;{$R *.res}Procedure Thread;beginMessageBox(0,PChar(IntToStr(GetCurrentProcessId)),PChar('PID '),MB_OK);end;Procedure Main;varnul: Cardinal;beginCreateThread(nil,0,@Thread,nil,0,nul);end;Procedure SetHook;varPID: Cardinal;beginGetWindowThreadProcessId(FindWindow(nil,'Audition'),@PID);if SetWindowsHookEx(WH_CBT,@Main,0,PID) = 0 thenMessageBox(0,PChar('Hook is error...'),PChar('Error'),MB_OK);end;exportsSetHook;beginend.Project:http://www.mediafire.com/?88fdkodfssyik3cThis is project of it, i uploaded in attachment file. I hope yous hlp me right now. Tkz vzy much! Edited November 29, 2014 by vic4key
kao Posted March 25, 2011 Posted March 25, 2011 <irony>1) Error handling is for sissies. Your code is so perfect that you will never need to know what went wrong. Oh, wait..2) Who cares about calling conventions? Code compiles, so it should be fine..3) ThreadId is the same as ProcessId. After all, it's just a number, right?..4) nil, nul, NULL. Sounds the same, so they will work the same..</irony>Sorry, your code is broken in so many ways that nobody can help you. Go back to school, read a lot, learn a lot and start again from scratch.
Vic Posted March 25, 2011 Author Posted March 25, 2011 (edited) Tkz kao, but i tried vzy much to find error into it but dont know where wrong. In my school after year learn Pascal. Not learn Delphi. Now we're learning Office. I'm vzy stupid. U can hlp me edit to hook successful? Tkz Edited March 25, 2011 by vic4key
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now