The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: David BS on July 21, 2014, 09:46:17 AM

Title: CPUID x64 DLL
Post by: David BS on July 21, 2014, 09:46:17 AM
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

Title: Re: CPUID x64 DLL
Post by: qWord on July 21, 2014, 11:10:42 AM
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)
Title: Re: CPUID x64 DLL
Post by: David BS on July 22, 2014, 10:11:43 AM
 :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: