Jump to content

  • Log In with Google      Sign In   
  • Create Account


.3lite

Member Since 15 Oct 2011
Offline Last Active May 17 2012 11:11 PM
-----

Topics I've Started

ASM and Ollydbg - code injection

16 May 2012 - 02:00 AM

Hi folks,


so I was recently editing executable to load my own dll library and all I typed in Ollydbg to load library was "CALL LoadLibraryA".

In ollydbg it is translated to kernel32.LoadLibraryA and everything works great BUT! It's somehow a temporary solution - when OS is rebooted executable won't run anymore, it will just crash.

I'm pretty sure typing CALL LoadLibraryA is just making it somehow temporal address made by ollydbg and as far as it goes without restarting OS it works like charm.

Posted Image

I had to do "SUB ESP, 4" to make stack "uncorrupted" for later calls where I've added JMP to my part of code (located in codecave somewhere) but it doesn't matter since everything works fine, dll is loaded and everything seems to be cool until next system reboot - executable won't load anymore (wrong LoadLibraryA addr to call).

Any ideas guys?

Direct3D matrix scalling problem

16 October 2011 - 02:52 PM

Hey guys,

I'm having some kind of issue with scaling my sprites, if they are scaled by for example value of 1.5f there are some spaces between them in rendered game image, first of all let me show you my drawing engine functions:


void D3D9_engine::BeginScene(){
	g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
	g_pd3dDevice->BeginScene();
	gSprite->Begin(D3DXSPRITE_ALPHABLEND);
}

void D3D9_engine::SetScaleLevel(float scale){
	scaleLevel = scale;

	D3DXMatrixScaling(&matrix, scale, scale, 0.0f);
	gSprite->SetTransform(&matrix);
}

float D3D9_engine::GetScaleLevel(){
	return scaleLevel;
}

void D3D9_engine::PresentScene(){
	gSprite->End();
	g_pd3dDevice->EndScene();
	g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}

void D3D9_engine::DrawSprite(uint16_t sprite, uint16_t x, uint16_t y){
 	uint16_t vectPos = sprite / spr_limits; // TODO for bitshift operator.
	uint16_t spritePos = sprite & (spr_limits - 1);
	
	RECT srcRect;
	srcRect.top    = spritePos << 5;
	srcRect.left   = 0;
	srcRect.bottom = srcRect.top + 32;
	srcRect.right  = 32;
	
	static D3DXVECTOR3 vCenter(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 vPosition(x, y, 0.0f);
	
	
    gSprite->Draw(spritesVector[vectPos],
                          &srcRect,
                          &vCenter,
                          &vPosition,
                          D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f));
}




Sprites are basically images of size 32x32 loaded into several textures, it works like charm and the memory usage as well as rendering speed is well above expected value.


I'm creating a Tibia game ( http://tibia.com ) client (old one, over 7 years old) just out of fun and the problem appears when I want to scale sprites using that SetScaleLevel function, sprites are not draw exactly as expected and there are some blank pixel lines between them:

Posted Image




Back to the blank pixel lines problem, CLAMP won't help at this point:

g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);

g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);




I'm stuck right now with this scaling problem (and I really need it but I think it might be problem with single precision numbers - hope not), hopefully you can help me.

PARTNERS