Osiris icon indicating copy to clipboard operation
Osiris copied to clipboard

flashlight

Open bruteforcehacker opened this issue 7 years ago • 1 comments

I saw in the source of a cheat call dead-cell eternityX.

I think we need to change the third line

void c_misc::flashlight( ) { auto destroy_flashlight = [ ]( c_flashlight_effect* flashlight_ptr ) { static auto destroy_fn = pattern::find< void( __thiscall* )( c_flashlight_effect*, c_flashlight_effect* ) >( g_csgo.m_client_dll, "56 8B F1 E8 ?? ?? ?? ?? 8B 4E 28" );

	// the flash light destructor handles the memory management, so we dont need to free the allocated memory
	// call the destructor of the flashlight
	destroy_fn( flashlight_ptr, flashlight_ptr );
};
auto update_flashlight = [ ]( c_flashlight_effect* flashlight_ptr, const vec3_t &pos, const vec3_t &forward, const vec3_t &right, const vec3_t &up ) {
	// here we tell to the compiler wich calling convention we will use to call the function and the paramaters needed (note the __thiscall*)
	typedef void( __thiscall* update_light_t )( void*, int, const vec3_t&, const vec3_t&, const vec3_t&, const vec3_t&, float, float, float, bool, const char* );

	static update_light_t update_light = NULL;

	if ( !update_light ) {
		// here we have to deal with a call instruction (E8 rel32)
		auto call_instruction = pattern::find( g_csgo.m_client_dll, "E8 ?? ?? ?? ?? 8B 06 F3 0F 10 46" ); // get the instruction address
		uintptr_t rel_address = *reinterpret_cast< uintptr_t* >( call_instruction + 1 ); // read the rel32
		uintptr_t next_instruction = call_instruction + 5; // get the address of next instruction
		update_light = reinterpret_cast< update_light_t >( next_instruction + rel_address ); // our function address will be nextInstruction + relativeAddress
	}

	update_light( flashlight_ptr, flashlight_ptr->m_idx, pos, forward, right, up, flashlight_ptr->m_fov, flashlight_ptr->m_far_z, flashlight_ptr->m_linear_atten, flashlight_ptr->m_casts_shadow, flashlight_ptr->m_texture_name );
};

auto local = c_csplayer::get_local( );
if ( !local || !local->alive( ) )
	return;

static c_flashlight_effect *flashlight = NULL;
static float last_tick = 0;

if ( g_input.key_pressed( g_vars.misc.flashlight_key ) && GetTickCount( ) > last_tick + 250 ) {
	if ( !flashlight ) {
		flashlight = create_flashlight( local->get_index( ), "effects/flashlight001", 35, 5000, 1000 );
	}
	else {
		destroy_flashlight( flashlight );
		flashlight = NULL;
	}

	last_tick = GetTickCount( );
}

if ( flashlight ) {
	vec3_t f, r, u;
	vec3_t viewAngles;

	g_csgo.m_engine->get_viewangles( viewAngles );
	math::angle_to_vectors( viewAngles, &f, &r, &u );

	flashlight->m_is_on = true;
	flashlight->m_casts_shadow = false;
	flashlight->m_fov = 35;
	update_flashlight( flashlight, local->eye_pos( ), f, r, u );
}

}

bruteforcehacker avatar Jul 07 '19 08:07 bruteforcehacker

Cool and good

HECCYE avatar Jul 07 '19 14:07 HECCYE