News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

CPUID x64 DLL

Started by David BS, July 21, 2014, 09:46:17 AM

Previous topic - Next topic

David BS

Hello All!

I would like to convert the MASM code below for YASM x64 or JWASM x64.  My goal is make a DLL to be called from x64 code (Visual Basic). The code below functions 100% in x86 format, but I don't know exactly the changes I must conduct to get x64 valid code. 

Thanks for any help.



get_cpu_vendor_information Proc Public Entrada_Index:UINT, bufferpointer:LPVOID

; Assume que rcx = pointer to the buffer to store the data into

   PushA

   Mov Eax, Entrada_Index      ; value 1

   CPUID

   Mov Esi, [bufferpointer]

   Mov [Esi], Eax
   Mov [Esi + 4], Ebx
   Mov [Esi + 08H], Ecx
   Mov [Esi + 0CH], Edx

   xor    eax, eax
   Mov [Esi + 10H], Eax

   PopA

   Ret

get_cpu_vendor_information EndP


qWord

See the attachment.
Declare Function get_cpuid Lib "cpuid.dll" (ByVal eax As UInteger, ByVal ecx As UInteger, <MarshalAs(UnmanagedType.SafeArray, SafeArraySubType:=VarEnum.VT_UI4)> ByRef result() As UInteger) As Boolean
...
Dim regs(3) As UInteger ' regs[0]=eax, regs[1]=ebx, regs[2]=ecx, regs[3]=edx
Dim success As Boolean = get_cpuid(1, 0, regs)
MREAL macros - when you need floating point arithmetic while assembling!

David BS

 :biggrin:

Thank you VERY much qWORD!
As Gunther had mentioned, you ARE really BAD.

I really appreciated your attention to me. Thanks a lot.
:eusa_clap: