int
do_hook(char *hook_type, int hook_type_sz) {
	char *ptr, app_exe[1024], hook_method[1024];
	int resolution[2];
	//
	if(CoInitializeEx(NULL, COINIT_MULTITHREADED) != S_OK) {
		ga_error("*** CoInitializeEx failed.\n");
	}
	//
	if(ga_hook_init() < 0)
		return -1;
	// handle ga-hook specific configurations
	if((ptr = ga_conf_readv("game-exe", app_exe, sizeof(app_exe))) == NULL) {
		ga_error("*** no game executable specified.\n");
		return -1;
	}
	if((ptr = ga_conf_readv("hook-type", hook_type, hook_type_sz)) == NULL) {
		ga_error("*** no hook type specified.\n");
		return -1;
	}
	if((ptr = ga_conf_readv("hook-method", hook_method, sizeof(hook_method))) != NULL) {
		ga_error("*** hook method specified: %s\n", hook_method);
	}
	//
	ga_error("[start-hook] exe=%s; type=%s\n", app_exe, hook_type);
	//
	if(hook_input() < 0)
		return -1;
	// ---
	if(strcasecmp(hook_type, "sdl") == 0) {
		return hook_sdl12(hook_type, hook_method);
	}
	// d9?
	if(strcasecmp(hook_type, "d9") == 0) {
		return hook_d9(hook_type, hook_method);
	}
	// dxgi?
	if(strcasecmp(hook_type, "dxgi") == 0) {
	//if(strstr(hook_method, "GetDXGIFactoryAddress") != NULL)
		return hook_dxgi(hook_type, hook_method);
	}
	// d10?
	if(strcasecmp(hook_type, "d10") == 0) {
		return hook_d10(hook_type, hook_method);
	}
	// d10.1?
	if(strcasecmp(hook_type, "d10.1") == 0) {
		return hook_d10_1(hook_type, hook_method);
	}
	// d11?
	if(strcasecmp(hook_type, "d11") == 0) {
		return hook_d11(hook_type, hook_method);
	}
	//
	ga_error("Unsupported hook type (%s)\n", hook_type);
	return -1;
}
Exemple #2
0
static inline bool attempt_hook(void)
{
	static bool ddraw_hooked = false;
	static bool d3d8_hooked  = false;
	static bool d3d9_hooked  = false;
	static bool dxgi_hooked  = false;
	static bool gl_hooked    = false;

	if (!d3d9_hooked) {
		if (!d3d9_hookable()) {
			d3d9_hooked = true;
		} else {
			d3d9_hooked = hook_d3d9();
			if (d3d9_hooked) {
				return true;
			}
		}
	}

	if (!dxgi_hooked) {
		if (!dxgi_hookable()) {
			dxgi_hooked = true;
		} else {
			dxgi_hooked = hook_dxgi();
			if (dxgi_hooked) {
				return true;
			}
		}
	}

	if (!gl_hooked) {
		gl_hooked = hook_gl();
		if (gl_hooked) {
			return true;
		}
	/*} else {
		rehook_gl();*/
	}

	/*if (!d3d8_hooked) {
		if (!d3d8_hookable()) {
			d3d8_hooked = true;
		} else {
			d3d8_hooked = hook_d3d8();
			if (d3d8_hooked) {
				return true;
			}
		}
	}

	if (!ddraw_hooked) {
		if (!ddraw_hookable()) {
			ddraw_hooked = true;
		} else {
			ddraw_hooked = hook_ddraw();
			if (ddraw_hooked) {
				return true;
			}
		}
	}*/

	return false;
}