Autor Tema: Funcion ver serial del cpu  (Leído 1003 veces)

0 Usuarios y 1 Visitante están viendo este tema.

obethermy

  • Megabyte
  • ***
  • Mensajes: 116
  • Reputación: +6/-7
    • Ver Perfil
Funcion ver serial del cpu
« en: Febrero 19, 2017, 10:07:07 pm »
Código: (VB) [Seleccionar]
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As String, ByRef hWnd As Long, ByRef Msg As Long, ByRef wParam As Long, ByRef lParam As Long) As Long

Private m_CPUAsm As String

Public Function GetCPUSerialAPI() As String
   Dim sOut As String
   Dim eax As Long, ebx As Long, ecx As Long, edx As Long
   
   Call CallWindowProc(CPUAsm, eax, ebx, ecx, edx)
   If eax > 0 Then
      eax = 1
      CallWindowProc CPUAsm, eax, ebx, ecx, edx
      If eax <> 0 Then sOut = Right("00000000" & Hex(eax), 8 )
      If edx <> 0 Then sOut = Right("00000000" & Hex(edx), 8 ) & sOut
      GetCPUSerialAPI = sOut
   End If
End Function

Private Function CPUAsm() As String
   If m_CPUAsm = "" Then
      Dim Asm As String
      Asm = Asm & Chr(&H56)                            '56        push   esi
      Asm = Asm & Chr(&H55)                            '55        push   ebp
      Asm = Asm & Chr(&H8B) & Chr(&HEC)                '8B EC     mov  ebp,esp
      Asm = Asm & Chr(&H8B) & Chr(&H75) & Chr(&HC)     '8B 75 0C  mov  esi,dword ptr[ebp+0Ch]
      Asm = Asm & Chr(&H8B) & Chr(&H6)                 '8B 06     mov  eax,dword ptr[esi]
      Asm = Asm & Chr(&HF) & Chr(&HA2)                 '0F A2     cpuid
      Asm = Asm & Chr(&H8B) & Chr(&H75) & Chr(&HC)     '8B 75 0C  mov  esi,dword ptr[ebp+0Ch]
      Asm = Asm & Chr(&H89) & Chr(&H6)                 '89 06     mov  dword ptr [esi],eax
      Asm = Asm & Chr(&H8B) & Chr(&H75) & Chr(&H10)    '8B 75 10  mov  esi,dword ptr[ebp+10h]
      Asm = Asm & Chr(&H89) & Chr(&H1E)                '89 1E     mov  dword ptr [esi],ebx
      Asm = Asm & Chr(&H8B) & Chr(&H75) & Chr(&H14)    '8B 75 14  mov  esi,dword ptr[ebp+14h]
      Asm = Asm & Chr(&H89) & Chr(&HE)                 '89 0E     mov  dword ptr [esi],ecx
      Asm = Asm & Chr(&H8B) & Chr(&H75) & Chr(&H18)    '8B 75 18  mov  esi,dword ptr[ebp+18h]
      Asm = Asm & Chr(&H89) & Chr(&H16)                '89 16     mov  dword ptr [esi],edx
      Asm = Asm & Chr(&H5D)                            '5D        pop  ebp
      Asm = Asm & Chr(&H5E)                            '5E        pop  esi
      Asm = Asm & Chr(&HC2) & Chr(&H10) & Chr(&H0)     'C2 10 00  ret  10h
      m_CPUAsm = Asm
   End If
   CPUAsm = m_CPUAsm
End Function

Private Sub Command1_Click()
Debug.Print GetCPUSerialAPI
End Sub


el serial del cpu en 16 caracteres hexadecimales.


PatriciaBB

  • Kilobyte
  • **
  • Mensajes: 51
  • Reputación: +5/-0
    • Ver Perfil
Re:Funcion ver serial del cpu
« Respuesta #1 en: Febrero 28, 2017, 12:53:12 pm »
Wow..... que padre este código.

Obethermy, tendrá  un código similar en ASM pero para el ID de la placa madre o del la BIOS

Gracias...  :)

TOLO68

  • Kilobyte
  • **
  • Mensajes: 60
  • Reputación: +2/-0
    • Ver Perfil
Re:Funcion ver serial del cpu
« Respuesta #2 en: Febrero 28, 2017, 06:04:19 pm »
Hola PatriciaBB, este codigo lo puse yo tambien primero a ver si me podian traducirlo para .net, porque a mi me da un error de memoria

Yo he buscado bastante informacion por google sobre esto del ASM en VB, y siempre es el mismo ejemplo, el de CPUID

Todo esto y mucha mas informacion tambien lo puedes leer con WMI

lo unico malo es que tarda 3-4 segundos en leer el numero, si este retraso de tiempo no te molesta, te podria servir.

Aparte segun que datos los lee en XP pero no en Vista u otros sistemas operativos

Si buscas en google

Read Serial CPU WMI VB6, te saldran varios ejemplos

:)

Espero que te sirva

Saludos