@@ -725,77 +725,83 @@ BOOL __stdcall hk_FreeLibrary(HMODULE hLibModule)
725
725
726
726
FARPROC __stdcall hk_GetProcAddress (HMODULE hModule, LPCSTR lpProcName)
727
727
{
728
- if (! lstrcmpA (lpProcName, " RegisterClassA " ))
728
+ __try
729
729
{
730
- if (oRegisterClassA == NULL )
731
- oRegisterClassA = (RegisterClassA_fn)GetProcAddress (hModule, lpProcName);
732
- return (FARPROC)hk_RegisterClassA;
733
- }
734
- if (!lstrcmpA (lpProcName, " RegisterClassW" ))
735
- {
736
- if (oRegisterClassW == NULL )
737
- oRegisterClassW = (RegisterClassW_fn)GetProcAddress (hModule, lpProcName);
738
- return (FARPROC)hk_RegisterClassW;
739
- }
740
- if (!lstrcmpA (lpProcName, " RegisterClassExA" ))
741
- {
742
- if (oRegisterClassExA == NULL )
743
- oRegisterClassExA = (RegisterClassExA_fn)GetProcAddress (hModule, lpProcName);
744
- return (FARPROC)hk_RegisterClassExA;
745
- }
746
- if (!lstrcmpA (lpProcName, " RegisterClassExW" ))
747
- {
748
- if (oRegisterClassExW == NULL )
749
- oRegisterClassExW = (RegisterClassExW_fn)GetProcAddress (hModule, lpProcName);
750
- return (FARPROC)hk_RegisterClassExW;
751
- }
752
- if (!lstrcmpA (lpProcName, " GetForegroundWindow" ))
753
- {
754
- if (oGetForegroundWindow == NULL )
755
- oGetForegroundWindow = (GetForegroundWindow_fn)GetProcAddress (hModule, lpProcName);
756
- return (FARPROC)hk_GetForegroundWindow;
757
- }
758
- if (!lstrcmpA (lpProcName, " GetActiveWindow" ))
759
- {
760
- if (oGetActiveWindow == NULL )
761
- oGetActiveWindow = (GetActiveWindow_fn)GetProcAddress (hModule, lpProcName);
762
- return (FARPROC)hk_GetActiveWindow;
763
- }
764
- if (!lstrcmpA (lpProcName, " GetFocus" ))
765
- {
766
- if (oGetFocus == NULL )
767
- oGetFocus = (GetFocus_fn)GetProcAddress (hModule, lpProcName);
768
- return (FARPROC)hk_GetFocus;
769
- }
770
- if (!lstrcmpA (lpProcName, " LoadLibraryA" ))
771
- {
772
- if (oLoadLibraryA == NULL )
773
- oLoadLibraryA = (LoadLibraryA_fn)GetProcAddress (hModule, lpProcName);
774
- return (FARPROC)hk_LoadLibraryA;
775
- }
776
- if (!lstrcmpA (lpProcName, " LoadLibraryW" ))
777
- {
778
- if (oLoadLibraryW == NULL )
779
- oLoadLibraryW = (LoadLibraryW_fn)GetProcAddress (hModule, lpProcName);
780
- return (FARPROC)hk_LoadLibraryW;
781
- }
782
- if (!lstrcmpA (lpProcName, " LoadLibraryExA" ))
783
- {
784
- if (oLoadLibraryExA == NULL )
785
- oLoadLibraryExA = (LoadLibraryExA_fn)GetProcAddress (hModule, lpProcName);
786
- return (FARPROC)hk_LoadLibraryExA;
787
- }
788
- if (!lstrcmpA (lpProcName, " LoadLibraryExW" ))
789
- {
790
- if (oLoadLibraryExW == NULL )
791
- oLoadLibraryExW = (LoadLibraryExW_fn)GetProcAddress (hModule, lpProcName);
792
- return (FARPROC)hk_LoadLibraryExW;
730
+ if (!lstrcmpA (lpProcName, " RegisterClassA" ))
731
+ {
732
+ if (oRegisterClassA == NULL )
733
+ oRegisterClassA = (RegisterClassA_fn)GetProcAddress (hModule, lpProcName);
734
+ return (FARPROC)hk_RegisterClassA;
735
+ }
736
+ if (!lstrcmpA (lpProcName, " RegisterClassW" ))
737
+ {
738
+ if (oRegisterClassW == NULL )
739
+ oRegisterClassW = (RegisterClassW_fn)GetProcAddress (hModule, lpProcName);
740
+ return (FARPROC)hk_RegisterClassW;
741
+ }
742
+ if (!lstrcmpA (lpProcName, " RegisterClassExA" ))
743
+ {
744
+ if (oRegisterClassExA == NULL )
745
+ oRegisterClassExA = (RegisterClassExA_fn)GetProcAddress (hModule, lpProcName);
746
+ return (FARPROC)hk_RegisterClassExA;
747
+ }
748
+ if (!lstrcmpA (lpProcName, " RegisterClassExW" ))
749
+ {
750
+ if (oRegisterClassExW == NULL )
751
+ oRegisterClassExW = (RegisterClassExW_fn)GetProcAddress (hModule, lpProcName);
752
+ return (FARPROC)hk_RegisterClassExW;
753
+ }
754
+ if (!lstrcmpA (lpProcName, " GetForegroundWindow" ))
755
+ {
756
+ if (oGetForegroundWindow == NULL )
757
+ oGetForegroundWindow = (GetForegroundWindow_fn)GetProcAddress (hModule, lpProcName);
758
+ return (FARPROC)hk_GetForegroundWindow;
759
+ }
760
+ if (!lstrcmpA (lpProcName, " GetActiveWindow" ))
761
+ {
762
+ if (oGetActiveWindow == NULL )
763
+ oGetActiveWindow = (GetActiveWindow_fn)GetProcAddress (hModule, lpProcName);
764
+ return (FARPROC)hk_GetActiveWindow;
765
+ }
766
+ if (!lstrcmpA (lpProcName, " GetFocus" ))
767
+ {
768
+ if (oGetFocus == NULL )
769
+ oGetFocus = (GetFocus_fn)GetProcAddress (hModule, lpProcName);
770
+ return (FARPROC)hk_GetFocus;
771
+ }
772
+ if (!lstrcmpA (lpProcName, " LoadLibraryA" ))
773
+ {
774
+ if (oLoadLibraryA == NULL )
775
+ oLoadLibraryA = (LoadLibraryA_fn)GetProcAddress (hModule, lpProcName);
776
+ return (FARPROC)hk_LoadLibraryA;
777
+ }
778
+ if (!lstrcmpA (lpProcName, " LoadLibraryW" ))
779
+ {
780
+ if (oLoadLibraryW == NULL )
781
+ oLoadLibraryW = (LoadLibraryW_fn)GetProcAddress (hModule, lpProcName);
782
+ return (FARPROC)hk_LoadLibraryW;
783
+ }
784
+ if (!lstrcmpA (lpProcName, " LoadLibraryExA" ))
785
+ {
786
+ if (oLoadLibraryExA == NULL )
787
+ oLoadLibraryExA = (LoadLibraryExA_fn)GetProcAddress (hModule, lpProcName);
788
+ return (FARPROC)hk_LoadLibraryExA;
789
+ }
790
+ if (!lstrcmpA (lpProcName, " LoadLibraryExW" ))
791
+ {
792
+ if (oLoadLibraryExW == NULL )
793
+ oLoadLibraryExW = (LoadLibraryExW_fn)GetProcAddress (hModule, lpProcName);
794
+ return (FARPROC)hk_LoadLibraryExW;
795
+ }
796
+ if (!lstrcmpA (lpProcName, " FreeLibrary" ))
797
+ {
798
+ if (oFreeLibrary == NULL )
799
+ oFreeLibrary = (FreeLibrary_fn)GetProcAddress (hModule, lpProcName);
800
+ return (FARPROC)hk_FreeLibrary;
801
+ }
793
802
}
794
- if (! lstrcmpA (lpProcName, " FreeLibrary " ) )
803
+ __except (( GetExceptionCode () == EXCEPTION_ACCESS_VIOLATION) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH )
795
804
{
796
- if (oFreeLibrary == NULL )
797
- oFreeLibrary = (FreeLibrary_fn)GetProcAddress (hModule, lpProcName);
798
- return (FARPROC)hk_FreeLibrary;
799
805
}
800
806
801
807
return GetProcAddress (hModule, lpProcName);
@@ -890,7 +896,8 @@ void HookImportedModules()
890
896
for (IMAGE_IMPORT_DESCRIPTOR* iid = img_import_desc; iid->Name != 0 ; iid++) {
891
897
char * mod_name = (char *)((size_t *)(iid->Name + (size_t )hModule));
892
898
hm = GetModuleHandleA (mod_name);
893
- if (hm) {
899
+ // ual check
900
+ if (hm && !(GetProcAddress (hm, " DirectInput8Create" ) != NULL && GetProcAddress (hm, " DirectSoundCreate8" ) != NULL && GetProcAddress (hm, " InternetOpenA" ) != NULL )) {
894
901
HookModule (hm);
895
902
}
896
903
}
0 commit comments