Hey all,

Im almost finished hacking out a voice recongnition engine for MASM (using COMponents). But i hit a wall with how the params are indicated in regard to one of the calls:

It asks for a parameter requiring an "ULONGLONG" type (which i defined as a 'QWORD' in asm, and thought nothing more of it, until i needed to use it.)

My question is simple, how does one 'push' 64 bits on the stack properly such that the COM will see the number correctly??

I could play around all night testing out ideas how this could be done, but if someone knows from experience, or thinks they know how to do this, then you have my fullest attention :)

PS: I did try the search cause i remembered some 64 bit talk a while ago, but unfortunately the search feature wants three chars min, and '64 bit' doesnt fit.... :rolleyes: , found some stuff with '64-bit' but nothing substancial.

Thanxs again for any help you can provide.
:stupid:
NaN
Posted on 2002-12-01 19:46:44 by NaN
Well, if it followed the processor it'd be:

; EDX:EAX = 64-bit
push edx
push eax

...or...

sub esp, 8
movq , mm0

...or...

sub esp, 8
fist QWORD PTR

...all put the least significant byte at
Posted on 2002-12-01 19:57:10 by bitRAKE
Thanx, i will give it a try...

The problem here is two unknowns... one, if the ULONGLONG pushing on the stack is done correctly or not, and two, if the softare in general is correct... which is why im asking for advice to rule out point one... ;)

Thanx again!
:alright:
NaN
Posted on 2002-12-01 20:02:53 by NaN
This is the Odd hack macro i wipped up, based on the C++ version:
;?  #define SPFEI_FLAGCHECK ( (1ui64 << SPEI_RESERVED1) | (1ui64 << SPEI_RESERVED2) )

;? #define SPFEI_ALL_TTS_EVENTS (0x000000000000FFFEui64 | SPFEI_FLAGCHECK)
;? #define SPFEI_ALL_SR_EVENTS (0x001FFFFC00000000ui64 | SPFEI_FLAGCHECK)
;? #define SPFEI_ALL_EVENTS 0xEFFFFFFFFFFFFFFFui64
;? #define SPFEI(SPEI_ord) ((1ui64 << SPEI_ord) | SPFEI_FLAGCHECK)

; 00000000 40000000 or 00000002 00000000 =>> 00000002 40000000
SPFEI_FLAGCHECK equ ( (1 SHL SPEI_RESERVED1) or (1 SHL SPEI_RESERVED2) )
; 00000000 0000FFFE or 00000002 40000000 =>> 00000002 4000FFFE
SPFEI_ALL_TTS_EVENTS equ (000000000000FFFEh or SPFEI_FLAGCHECK)
; 001FFFFC 00000000 or 00000002 40000000 =>> 001FFFFE 40000000
SPFEI_ALL_SR_EVENTS equ (001FFFFC00000000h or SPFEI_FLAGCHECK)
; EFFFFFFF FFFFFFFF
SPFEI_ALL_EVENTS equ 0EFFFFFFFFFFFFFFFh

SPFEI MACRO SPEI_ord
LOCAL aa
aa = SPEI_ord
mov eax, 1
mov edx, eax
if aa GT 31
aa = aa - 32
if aa GT 0
% shl edx, aa
endif
or edx, 00000002h
mov eax, 40000000h
else
% shl eax, aa
or eax, 40000000h
mov edx, 00000002h
endif
endm

Q64 MACRO eedx, eeax
exitm < eedx, eeax >
ENDM


There is a list of equates that go as high as 63 that can be placed into the SPFEI macro...

I use it in source as:
     SPFEI (SPEI_RECOGNITION)

ole32 pISpContext, ISpRecoContext_SetInterest, Q64(eax,edx), Q64(eax,edx)


SPEI_RECOGNITION is equated to be 38. Anyways, if you have a better solution, let me know, I dont get compile errors with this, but im still not far enought to know it is *correct* with the COM's....

Thanx again.
:alright:
nAn
Posted on 2002-12-01 21:12:55 by NaN
I checked MSVC to see how it behaves with ULONGLONGs.

push high_dword

push low_dword
call function


For functions that return type ULONGLONG, edx:eax is return value.
Posted on 2002-12-01 21:39:03 by iblis
Thanx iblis,

I dont use MS VC++ at all (i have it, but i dont understand it ~ if you can believe that ^lol^ ). However, i can read C and C++ with no problems.

The thing about VC++ is all the extra crap. The SDK im working with has a zillion header files and 'helper' files and cpp files. The funny part is, after i transcribe a section to MASM, its about 60% less "fluff" and to the point. I spent the last hour chasing down some spegetti code, and straightenned out about 4 pages of C++ subroutines into one half page asm code (with no nestings).

To me it just doesnt make sence ;)

Anywho, back to the point, your help is greatly appreciated. And confirmed at this point, since i got the MASM version of the Speach Recognition engine working. I still have to wip up a front end, and display the text in an edit window... but these are just details... and i have to go to work tomorrow, so im calling it quits at this point ;)

Thanx again BitRAKE and Iblis for your help..
:alright:
NaN
Posted on 2002-12-01 23:37:03 by NaN
Invoke accepts qwords and pushes them correctly.

eg.

myproc proto q1:qword

.data
q qword

.code
invoke myproc, q
Posted on 2002-12-02 03:41:20 by gfalen
hi all, i had a little slighly related int64 question. i want to do int64 calculation from a wdm driver. i had tried _atoi64() and use the stdlib.h as include. but, the problem is , it is error . anyone know how msvc redirect this call into ntoskernel.lib? or how to solve this problem?

thanks
Posted on 2002-12-02 05:38:51 by dion
Link with MSVCRT.LIB.. VC++ isn't capable of doing some 64 bit operations (e.g. div or mod) without LIBC or equivalent.
Posted on 2002-12-02 05:49:21 by Maverick
dion atoi64 is in ntdll. Can you call it by its function address? Unfortunately the address is different in every os. In XP service pack 1 it is 2012897507.

And NaN you can search less than 3 characters this way: stack 64* bit
Posted on 2002-12-02 09:56:47 by roaknog
roaknog,

Doh! It looks so obvious when you see it :) . Thanx.

gfalen,

Thanx as well, i realize this, but im not using invoke for COM calls. Simply cause im tired of all the crap you have to do to get prototypes working with them. So im useing an Invoke-like macro that pushes all the params, and unfortunalely you cant go PUSH QWORD... (I tried it before i posted this thread ;) ).

Thanx again for the tips!
:alright:
NaN
Posted on 2002-12-02 16:26:44 by NaN

dion atoi64 is in ntdll. Can you call it by its function address? Unfortunately the address is different in every os. In XP service pack 1 it is 2012897507.


hmm... yeah, i know that after seeing ntdll.lib. but, the problem is, how i dont know to call it. even i dont know from where msvc know that when i insert sprintf() then it link to ntkern.lib directly.

thanks
Posted on 2002-12-02 20:42:22 by dion
oh, i am forgot that i want to it from wdm, which is run on ring 0. and the ntdll.dll is not . could someone suggest me another source for string handling and int64 calculation, so that i can statically link it to my wdm?

thanks
Posted on 2002-12-03 06:04:20 by dion
Did you try MSVCRT.LIB I suggested you some posts above?
Posted on 2002-12-03 06:17:25 by Maverick
hi Maverick, actually i dont know how to call it, do you? and if u said that, i assume that you told me to statically linked, coz i need to run it on ring0, and meanwhile msvcrt doesnt.

thx
Posted on 2002-12-03 06:20:59 by dion
This is how I make the call in ring 0 in XP and 2000. On my 300 megahertz computer it takes about 30 seconds so don?t be impatient.

I call _atoi64 by function address two times. One time I use the string '987654321', 0 and another time I use the string 'crap', 0. You can see the results with a debugger output through DbgPrint. A return of 0 is an error. You need cojones to do it this way. I am sure there are other ways to do it. The address is different by the service pack. I don?t do much with 98 because XP is holding 98 down, and 2000 has a pillow over 98?s head.

h*ttp://freehafer.tripod.com/zip/zatoi64.zip minus *
Posted on 2002-12-03 11:52:34 by roaknog
Hi dion,
My worry is that VisualC++ is calling some function of MSVCRT.LIB without your will. For example, it does so if you use division or modulo on __int64. Clearly it shouldn't, but it does. Such routines of course work also in ring0. Since what is happening is beyond your control, I had the suspect it may be such case (i.e. that VisualC++ links with some "secret" function in LIBC/MSVCRT).
A question: do you do __int64 divisions/modulo/etc.. in your code?

In any case, to fix this eventual problem, try to add MSVCRT.LIB in the Link.EXE options.
Posted on 2002-12-03 15:30:05 by Maverick
thx all ;) i'll take a look at your sample, roaknog ;)
Posted on 2002-12-03 20:42:49 by dion
BTW: I found "atoi64" in MSVCRT.LIB.
Posted on 2002-12-04 03:48:49 by Maverick
first, i'm very sorry to Nan and other if i got too bother and out of topic here :(

Maverick: hmm... u know my mind! yup! actually i want to do some crypto stuff from ring 0, so now i think i need bignum lib instead stick'n with I64. why ring 0? mmm... i dont want to tell u ;p uh! i made lot mistake those days coz i cant got connected too long to read posts carefully, and all is about $,$ & $ :(

roaknog: wow! your sample was superb ;) but... thx anyway :D

is there any good or best bignum src/reference that have own string handling ?

thx all ;)
Posted on 2002-12-04 05:41:25 by dion