Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. am i calling it right, this was just a test no errors compile time or run time, it just closes, why isent that function hooking them? Nothing happens, and i know for a fact all the dlls i need are being loaded via symbols. its pissing me off DEAD!!!! Help me brother. If so you can come on my teamviewer and take a look. But id rather not, if you can see a error or something?
  2.  
  3. #include "ntStructures.h"
  4.  
  5. typedef BOOL(__stdcall *waBeep)(unsigned int);
  6.  
  7. int _tmain(int argc, wchar_t* argv[]) {
  8.  
  9. waBeep hook;
  10. waLoadLibandGetProcAddrHook(L"User32.dll", "MessageBeep", NULL, (void *)hook);
  11.  
  12. hook(0xFFFFFFFF);
  13. getchar();
  14. return 0;
  15. }
  16.  
  17.  
  18. .h
  19. //WINAPI Hooks -TODO: WriteProcessMemory or NT WriteVirtualMemory
  20. typedef HINSTANCE (__stdcall *waLoadLib)(LPCTSTR);
  21. typedef HINSTANCE (__stdcall *waGetModH)(LPCTSTR);
  22.  
  23.  
  24. VOID waLoadLibandGetProcAddrHook(LPCTSTR dllName, LPCSTR functionName, LPCTSTR libName, PVOID hookName) {
  25.  
  26. waLoadLib LoadLibHook = (waLoadLib)GetProcAddress(LoadLibrary(L"Kernel32.dll"), "LoadLibrary");
  27. waGetModH GetProcHook = (waGetModH)GetProcAddress(LoadLibHook(L"Kernel32.dll"), "GetModuleHandle");
  28.  
  29. if(LoadLibHook == NULL) {
  30. printf("Error - %d - Function Failed..Returning..", GetLastError());
  31. return;
  32. }
  33. if(GetProcHook == NULL) {
  34. printf("Error - %d - Function Failed..Returning..", GetLastError());
  35. return;
  36. }
  37.  
  38. if(libName != NULL) {
  39. void *activateHookWithLoadLib = GetProcAddress(LoadLibHook(libName), functionName);
  40. hookName = activateHookWithLoadLib;
  41. if(hookName == NULL) {
  42. printf("Hook Failed");
  43. return;
  44. }
  45. return hookName;
  46. }
  47. else if(libName == NULL) {
  48. void *activateHookWithGetModH = GetProcAddress(GetProcHook(dllName), functionName);
  49. hookName = activateHookWithGetModH;
  50. if(hookName == NULL) {
  51. printf("Hook Failed!");
  52. return;
  53. }
  54. return hookName;
  55. }
  56. return hookName;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement