Author Topic: CPUID x64 DLL  (Read 4827 times)

David BS

  • Regular Member
  • *
  • Posts: 30
CPUID x64 DLL
« 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


qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: CPUID x64 DLL
« Reply #1 on: July 21, 2014, 11:10:42 AM »
See the attachment.
Code: [Select]
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

  • Regular Member
  • *
  • Posts: 30
Re: CPUID x64 DLL
« Reply #2 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: