ChangePitch

Posts 1–14 of 14 · Page 1 of 1
ChangePitch
Don't Have CA installed atm so cant test it, pretty sure it works. Just bored, opened olly saw, and made it..Thanks
Code:
void ChangePitch(float* Pitch)
{
	_asm
	{
	MOV EAX,3778CF58 //Moving pointer to EAX Register
	MOV ECX,EAX         //Moving EAX to ECX (We have this because you cant write the pointer directly to the register ECX, With an offset)
	MOV EDX,ECX+18    //Moving ECX+0x18 to EDX
	ADD ESP,8             //Adding 0x8 to ESP
	PUSH Pitch             //Pushing Our pitch
	PUSH EAX              //Pushing our Pointer
	CALL EDX               //Calling our shit
	}
}
ehhh Don't have much time to look at this, but why is pitch a char? Shouldn't it be a float?
oops my bad, supposed to be a float...
Quote Originally Posted by DeadLinez View Post
oops my bad, supposed to be a float...
Okay. That's what I thought. Now, if this was voice recognition pitch control, voice char would be fine
Is this like better version of Pushtoconsole
Quote Originally Posted by Stewie_Griffin View Post
Is this like better version of Pushtoconsole
Not at all
Quote Originally Posted by Stewie_Griffin View Post
Is this like better version of Pushtoconsole
This is ASM code to chnage pitch of ur palyer to aim on things.
Commented for the curious.
Quote Originally Posted by DeadLinez View Post
Don't Have CA installed atm so cant test it, pretty sure it works. Just bored, opened olly saw, and made it..Thanks
Code:
void ChangePitch(float* Pitch)
{
	_asm
	{
	MOV EAX,3778CF58 //Moving pointer to EAX Register
	MOV ECX,EAX         //Moving EAX to ECX (We have this because you cant write the pointer directly to the register ECX, With an offset)
	MOV EDX,ECX+18    //Moving ECX+0x18 to EDX
	ADD ESP,8             //Adding 0x8 to ESP
	PUSH Pitch             //Pushing Our pitch
	PUSH EAX              //Pushing our Pointer
	CALL EDX               //Calling our shit
	}
}
Unless you're working on a 16 bit machine or a very old compiler there's no reason why you can't use ANY register (even the stack registers) to write offsets and pointers. Also ADD ESP,8 before you're pushing your data can have bad effects, for all you know you're overwriting the return address or other important data.

Code:
 MOV EDX,ECX+18
No compiler and/or assembler worth it's name is going to allow this statement. I assume it means mov edx, [ecx+18h]

Having said that, here's an improved version:

Code:
void ChangePitch(float* Pitch)
{
	_asm
	{
	MOV EAX,3778CF58  //Moving pointer to EAX Register
	MOV EDX, eax          //mov pointer to edx
	PUSH Pitch              //Pushing Our pitch
	PUSH EAX               //Pushing our Pointer
	CALL [EDX+18h]      //Calling our shit
	ADD ESP,8              //Adding 0x8 to ESP
	}
}
if mov ebx, ecx+18 instead assembles to mov edx, ecx add edx, 18h, the code would look like this:

Code:
void ChangePitch(float* Pitch)
{
	_asm
	{
	MOV EAX,3778CF58  //Moving pointer to EAX Register
	MOV EDX, eax          //mov pointer to edx
        ADD EDX, 18h           // adding 18 h to our pointer to get the function name
	PUSH Pitch              //Pushing Our pitch
	PUSH EAX               //Pushing our Pointer
	CALL EDX               //Calling our shit
	ADD ESP,8              //Adding 0x8 to ESP
	}
}
Don't take this the wrong way, but I just like to improve everything I see It's great to see that people realize ASM is far better then cpp
why are we using assembly can we not write directly to the pointer?
also, some asm questions:
why do we add 8 to esp register?
why is there a function at edx? isnt it the pitch value?
Quote Originally Posted by kibbles18 View Post
why do we add 8 to esp register?
why is there a function at edx? isnt it the pitch value?
calling convention is cdecl, that means you need to fix the stack after calling the function. functionparameters * 4 = 8

Code:
PUSH Pitch              //push second parameter
PUSH EAX               //push first parameter
CALL [EDX+18h]      //call
ADD ESP,8              //fix stack, parameters*4 = 8
edx holds the pointer.
do all functions use the cdcel calling convention?
and esp is the stack pointer, rite? so your making sure the next pop or w/e dosent accidently get what we pushed?
Quote Originally Posted by stshock View Post
what does this do
Read the title ./fp
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us