INT64 (or double)

Just starting out? Need help? Post your questions and find answers here.
tonnelier
User
User
Posts: 45
Joined: Mon May 03, 2004 10:34 pm
Location: France

INT64 (or double)

Post by tonnelier »

Problem : the opentrace API function return a tracehandle which is an INT64 (not its adress). How can I do to get the value returned with PB?

Thanks in advance.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

perhaps someone with more knowledge will answer your question, but if you can
post a snipped that will show your problem, then i may be able to help.
i think an int64 would be returned in the registers eax:edx, so if that's the case
you may be able to save the registers to a PB variable right after the API call. :)
tonnelier
User
User
Posts: 45
Joined: Mon May 03, 2004 10:34 pm
Location: France

Post by tonnelier »

Example : very simple. in a program, i do h=callfunction(0,"OpenTraceA",@log) (the library is advapi32.dll).
No error (doesn't return -1), but h becomes 1, which is an invalid tracehandle.
Register : perhaps. Who knows?
Moonshine
Enthusiast
Enthusiast
Posts: 263
Joined: Tue May 25, 2004 12:13 am
Location: UK

Post by Moonshine »

Not really sure but heres a snippet that will convert a double to a float, if it's of any use:

Code: Select all

Structure dblout
  p1.l
  p2.l
EndStructure

Procedure.f Float(p1.l,p2.l)
  Global _output.f
  Global _dblin.dblout
  _dblin\p1=p1
  _dblin\p2=p2
  !FLD qword[v__dblin]
  !FST dword[v__output]
  ProcedureReturn _output
EndProcedure
Mark my words, when you least expect it, your uppance will come...
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

I'm not sur if this helps.. But with my iSED Lib.. It returns double an such,
have a look:

Code: Select all

Structure iSQPDouble
  Hi.l
  Lo.l
EndStructure

Procedure MakeiSQPDouble(LONG.f, ADDRESS.l)
  !FLD dword [ Esp ]
  !MOV dword Eax, [ Esp + 4 ]
  !FSTP qword [ Eax ]
EndProcedure

; here is an example return

Procedure.l iSEDDrawImage(Left.f, Top.f, Width.f, Height.f)
  dLeft.iSQPDouble
  dTop.iSQPDouble
  dWidth.iSQPDouble
  dHeight.iSQPDouble
  MakeiSQPDouble(Left.f, @dLeft)
  MakeiSQPDouble(Top.f, @dTop)
  MakeiSQPDouble(Width.f, @dWidth)
  MakeiSQPDouble(Height.f, @dHeight)
  ProcedureReturn CallFunctionFast(FPDrawImage, dLeft\Hi, dLeft\Lo, dTop\Hi, dTop\Lo, dWidth\Hi, dWidth\Lo, dHeight\Hi, dHeight\Lo)
EndProcedure
- np
tonnelier
User
User
Posts: 45
Joined: Mon May 03, 2004 10:34 pm
Location: France

Post by tonnelier »

eventually, this type of thing work :

a.large_integer
a\lowpart=callfunction(...)

I think PB gives to the DLL the adress of the variable to fill in.

And for a DLL that requires only one variable a, which is a large_integer, it appears that callfunction(0,"function",a\lowpart,a\highpart) works.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

tonnelier wrote:eventually, this type of thing work :

a.large_integer
a\lowpart=callfunction(...)

I think PB gives to the DLL the adress of the variable to fill in.

And for a DLL that requires only one variable a, which is a large_integer, it appears that callfunction(0,"function",a\lowpart,a\highpart) works.
Yeah, I have no idea.. ;) I'm pretty clueless with the doubles thing..

Someday though, I might learn it.
Post Reply