Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Is thr a simple way to call mscvrt.atan

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Thu Jan 12, 2017 7:56 pm    Post subject: Is thr a simple way to call mscvrt.atan Reply with quote

Basically I am having a hell of time calling mscvrt.dll to do trig functions.
_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Thu Jan 12, 2017 8:09 pm    Post subject: Reply with quote

If you are able to use Lua calls and such in what you are doing, you can use Luas math.atan function.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Thu Jan 12, 2017 8:16 pm    Post subject: Reply with quote

LUA would be very easy. Just figure im this far with this mscvrt.dll I would love to finish it
_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25779
Location: The netherlands

PostPosted: Thu Jan 12, 2017 8:19 pm    Post subject: Reply with quote

in 32-bit or 64-bit ?

it uses cdecl calling convention so:
32-bit:
Code:

push value
call msvcrt.atan
add esp,4 //undo the param push (cdecl thing)

//eax is value


64-bit:
Code:

mov rcx,value
call msvcrt.atan

(with 64-bit do make sure the stack is alligned, and that the function you're in has been setup for function calling, else allocate stackspace first)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Thu Jan 12, 2017 8:37 pm    Post subject: Reply with quote

Thank You DB. At least I know whr to go next.
_________________
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Fri Jan 13, 2017 5:33 am    Post subject: Reply with quote

Well i finally got it to stop crashing. Although I see no trig value being converted anywhere. In 64-bit is stored else where(not returned to a register)?
_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25779
Location: The netherlands

PostPosted: Fri Jan 13, 2017 5:56 am    Post subject: Reply with quote

64 bit takes params in registers rcx, rdx, r8 and r9

(return value is still eax)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Fri Jan 13, 2017 10:02 am    Post subject: Reply with quote

32-bit:
Arguments go on the stack. Integer return values go in eax, fp return values go in st(0).
Code:
globalalloc(example,1024)
createthread(example)

example:
  push [example+104]
  push [example+100]
  call msvcrt.atan
  add esp,8
  fstp qword ptr[example+108]
  ret

example+100:  // input
  dq (double)1.0

example+108:  // result
  dq 0


64-bit:
Integer arguments are passed through rcx, rdx, r8, and r9. fp arguments are passed through xmm0-3. There should be storage on the stack aligned on a 16-byte boundary for the four integer arguments regardless of whether or not there are that many arguments. Excess arguments are passed through the stack above the storage for the four integer arguments. Integer return values go in rax, fp return values go in xmm0.
Code:
globalalloc(example,1024)
createthread(example)

example:
  push rbp
  mov rbp,rsp
  and spl,F0
  sub rsp,20
  movsd xmm0,[example+100]
  call msvcrt.atan
  movsd [example+108],xmm0
  mov rsp,rbp
  pop rbp
  ret

example+100:  // input
  dq (double)1.0

example+108:  // result
  dq 0

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Fri Jan 13, 2017 4:55 pm    Post subject: Reply with quote

Code:



alloc(Trig,1000)
registersymbol(Trig)


alloc(pi,1000)
registersymbol(pi)


alloc(Reg,1000)
registersymbol(Reg)


label(code)
label(return)


label(Over180)
label(Under180)
label(Finish)



/// Pre Load Values

Trig:
dq (double)234

Trig+30:
dq (double)234

// Radian Math

pi:    // Unused
dq (double)3.141592653589793238462643383279

pi+10:    //180/pi
dq (double)57.29577951307854999853275233034

pi+20:
dq (double)180

pi+30:
dq (double)-1
















/// Cosine From Degrees
movsd xmm0,[Trig]
divsd xmm0,[pi+10]
call msvcrt.cos
movsd [Trig+10],xmm0  // Is returned as Cosine
movsd [Trig+20],xmm3  // Is returned as IDK




/// ArcCos from Cosine (Above)
movsd xmm0,[Trig+10]  // Value from Call .cos
call msvcrt.acos
movsd [Trig+70],xmm0            // Is returned as Radians
movsd [Trig+80],xmm3           // Is returned as IDK



   mulsd xmm0,[pi+10]  // Multiply RADIANS by 180 to get Degrees


/// Value Check for Above 180
   movsd xmm3,[Trig]        // Intial Degree Value
   comisd xmm3,[pi+20]   // compare to 180 vale
    jae Over180
    jb Under180


Under180:
  movsd [Trig+90],xmm0   // Is returned as Degrees
   jmp Finish


// FUckery Math
Over180:
  mulsd xmm0,[pi+30]  //mul - 1
  addsd xmm0,[pi+20]  //Add 180 degrees
  addsd xmm0,[pi+20]  //Add 180 degrees
  movsd [Trig+100],xmm0    // Fixed Degrees
   jmp Finish












Well its working as expected Thank You everyone for the help.

I will admit I have seen alot of camera code and I have never seen anything like this. I mention this to ask a question.

Is this is the correct way to code this?

Or is thr a more efficient method?

And what is the relationship to Xmm3?

Also is there some documentation on this somewhere tht is written in ASM? (Searched Google like a mad man nothing turned up)

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites