Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-06-2024
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
mxProtector x32 y x64

Estimados colegas

Yo utilizo el componente mxProtector en algunas aplicaciones para realizar el control de registro de seriales, etc...

El problema al que me vi enfrentado era que al intentar compilar algunas de estas aplicaciones en x64, este componente no lo permitia ya que tenia una restricción que esta en el archivo MAX.INC.

Código Delphi [-]
{$IFNDEF WIN32}
  Sorry, only 32bit versions of Delphi/C++ Builder are supported by this component!
{$ENDIF}

Nota: Luego de realizar las modificaciones esta línea hay que comentarla...

La razón de esto son las funciones en Asembler que forman parte del componente:
  • IsCPUIDAvailable
  • GetCPUID
  • GetCPUVendor

Y como dicen la necesidad tiene cara de hereje, me di a la labor de buscar opciones para estas funciones y afortunadamente encontre soluciones.

Ahora puedo compilar este componente en aplicaciones x32 y x64 y mis aplicaciones siguen operando como si nada hubiera pasado.

Les comparto el código que utilice para superar este pequeño problema, no si antes indicar las fuentes de donde obtuve las soluciones, que son:

David Heffernan
https://stackoverflow.com/questions/...-code-to-amd64

JBontes
https://github.com/JBontes/FastCode/...tcodeCPUID.pas

Aquí va los segmentos de códigos que hay que tocar en archivo mxProtector.Pas:
Código Delphi [-]
....

/ *************************************************************************************
// ** IsCPUIDAvailable, 10/12/01 2:04:15 PM
// *************************************************************************************

Const
     ID_BIT = $200000;

Type
     TCPUID = Array[ 1..4 ] Of Longint;
     TVendor = Array[ 0..11 ] Of Ansichar;

{Function IsCPUIDAvailable: Boolean; Register;
Asm
  PUSHFD
  POP     EAX
  MOV     EDX,EAX
  XOR     EAX,ID_BIT
  PUSH    EAX
  POPFD
  PUSHFD
  POP     EAX
  XOR     EAX,EDX
  JZ      @exit
  MOV     AL,True
@exit:
End;}

//Nueva código que sustituye IsCPUIDAvailable
Function IsCPUIDAvailable: Boolean; Register;
Asm
{$IF Defined(CPUX86)}
  PUSHFD
  POP     EAX
  MOV     EDX,EAX
  XOR     EAX,ID_BIT
  PUSH    EAX
  POPFD
  PUSHFD
  POP     EAX
  XOR     EAX,EDX
  JZ      @exit
  MOV     AL,True
@exit:
{$ELSE}
  MOV     EAX, True      {x64 always has CPUID}
{$ENDIF}
End;

// *************************************************************************************
// ** GetCPUID, 10/12/01 2:04:09 PM
// *************************************************************************************

{Function GetCPUID: TCPUID; Assembler; Register;
Asm
  PUSH    EBX
  PUSH    EDI
  MOV     EDI,EAX
  MOV     EAX,1
  DW      $A20F
  STOSD
  MOV     EAX,EBX
  STOSD
  MOV     EAX,ECX
  STOSD
  MOV     EAX,EDX
  STOSD
  POP     EDI
  POP     EBX
End;}

{
Autor : David Heffernan
Url   :https://stackoverflow.com/questions/...-code-to-amd64
}
function GetCPUID: TCPUID; Assembler; Register;
asm
{$IF Defined(CPUX86)}
  push  ebx
  push  edi
  mov   edi, eax
  mov   eax, 1
  xor   ecx,ecx
  cpuid
  mov   [edi+$0], eax
  mov   [edi+$4], ebx
  mov   [edi+$8], ecx
  mov   [edi+$c], edx
  pop   edi
  pop   ebx
{$ELSEIF Defined(CPUX64)}
  mov   r8, rbx
  mov   r9, rcx
  mov   eax, 1
  cpuid
  mov   [r9+$0], eax
  mov   [r9+$4], ebx
  mov   [r9+$8], ecx
  mov   [r9+$c], edx
  mov   rbx, r8
{$IFEND}
end;

// *************************************************************************************
// ** GetCPUVendor, 10/12/01 2:04:06 PM
// *************************************************************************************

{Function GetCPUVendor: TVendor; Assembler; Register;
Asm
  PUSH    EBX
  PUSH    EDI
  MOV     EDI,EAX
  MOV     EAX,0
  DW      $A20F
  MOV     EAX,EBX
  XCHG    EBX,ECX
  MOV    ECX,4
@1:
  STOSB
  SHR     EAX,8
  LOOP    @1
  MOV     EAX,EDX
  MOV    ECX,4
@2:
  STOSB
  SHR     EAX,8
  LOOP    @2
  MOV     EAX,EBX
  MOV    ECX,4
@3:
  STOSB
  SHR     EAX,8
  LOOP    @3
  POP     EDI
  POP     EBX
End;}

{
Autor: JBontes
Url  : https://github.com/JBontes/FastCode/...tcodeCPUID.pas
}
function GetCPUVendor:TVendor; Assembler; Register;
type
  TRegisters = record
      EAX,
      EBX,
      ECX,
      EDX: Cardinal;
  end;

var
  Registers: TRegisters;

  procedure GetCPUID_Internal({Param: Cardinal; }var Registers: TRegisters);
  {https://github.com/JBontes/FastCode/blob/master/FastcodeCPUID.pas}
  asm
  {$ifdef cpux86}
    PUSH    EBX                         {save affected registers}
    PUSH    EDI
    MOV     EDI, Registers
    XOR     EBX, EBX                    {clear EBX register}
    XOR     ECX, ECX                    {clear ECX register}
    XOR     EDX, EDX                    {clear EDX register}
    DB $0F, $A2                         {CPUID opcode}
    MOV     TRegisters(EDI).&EAX, EAX   {save EAX register}
    MOV     TRegisters(EDI).&EBX, EBX   {save EBX register}
    MOV     TRegisters(EDI).&ECX, ECX   {save ECX register}
    MOV     TRegisters(EDI).&EDX, EDX   {save EDX register}
    POP     EDI                         {restore registers}
    POP     EBX
  {$else X64}
    PUSH    RBX
    PUSH    RDI
    MOV     RDI, Registers
    MOV     EAX, ECX
    XOR     EBX, EBX
    XOR     ECX, ECX
    XOR     EDX, EDX
    CPUID
    MOV     TRegisters(RDI).&EAX, EAX
    MOV     TRegisters(RDI).&EBX, EBX
    MOV     TRegisters(RDI).&ECX, ECX
    MOV     TRegisters(RDI).&EDX, EDX
    POP     RDI
    POP     RBX
  {$endif}
  end;

begin
  GetCPUID_Internal({0,} Registers);

  {get vendor string}
  Move(Registers.EBX, Result[0], 4);
  Move(Registers.EDX, Result[4], 4);
  Move(Registers.ECX, Result[8], 4);
end;

// *************************************************************************************
// ** TmxProtector.InternalGetHardwareID, 10/12/01 2:04:03 PM
// *************************************************************************************

Function TmxProtector.InternalGetHardwareID: String;
...

Espero les sirva...Saludos cordiales
Responder Con Cita
  #2  
Antiguo 05-06-2024
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Responder Con Cita
  #3  
Antiguo 06-06-2024
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.141
Poder: 36
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola a todos,

¡Gracias por compartirlo con todos nosotros, cloayza!
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #4  
Antiguo 06-06-2024
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.435
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Gracias...
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #5  
Antiguo 29-04-2025
Neeruu Neeruu is offline
Miembro
 
Registrado: oct 2007
Posts: 512
Poder: 19
Neeruu Va por buen camino
Hola cloayza, muchas gracias...

Podrias compartir todos los componentes mxprotector? ( pido que los comparta porque entiendo que son de libre distribucion), si estoy equivocado, perdon. Avisen y borro el post.)

Gracias.
__________________
Saluda Atte Neeruu!!! :)
Responder Con Cita
  #6  
Antiguo 30-04-2025
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.435
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Creo recordar que estaban en el FTP del club.
https://terawiki.clubdelphi.com/Delp...xComponents__/
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #7  
Antiguo 12-05-2025
genyus00 genyus00 is offline
Miembro
 
Registrado: jun 2010
Posts: 31
Poder: 0
genyus00 Va por buen camino
Hola, de modo que compilara sin colocar problemas con las versiones delphi a la fecha aplique esta modificacion, espero les sirva.

Código Delphi [-]
procedure ShowAboutBox(const ComponentName: String);
begin
  with Tfrm_AboutBox.Create(Application) do
  try
    Lbl_ComponentName.Caption := ComponentName;

    Lbl_Delphi.Caption := 'Compiled in ' +

{$IFDEF VER80} 'Delphi 1.0' {$ENDIF}
{$IFDEF VER90} 'Delphi 2.0' {$ENDIF}
{$IFDEF VER100} 'Delphi 3.0' {$ENDIF}
{$IFDEF VER120} 'Delphi 4.0' {$ENDIF}
{$IFDEF VER130} 'Delphi 5.0' {$ENDIF}
{$IFDEF VER140} 'Delphi 6.0' {$ENDIF}

{$IF CompilerVersion = 15.0} 'Delphi 7.0' {$IFEND}
{$IF CompilerVersion = 16.0} 'Delphi 8.0' {$IFEND}
{$IF CompilerVersion = 17.0} 'Delphi 2005' {$IFEND}
{$IF CompilerVersion = 18.0} 'Delphi 2006' {$IFEND}
{$IF CompilerVersion = 18.5} 'Delphi 2007' {$IFEND}
{$IF CompilerVersion = 20.0} 'Delphi 2009' {$IFEND}
{$IF CompilerVersion = 21.0} 'Delphi 2010' {$IFEND}
{$IF CompilerVersion = 22.0} 'Delphi XE' {$IFEND}
{$IF CompilerVersion = 23.0} 'Delphi XE2' {$IFEND}
{$IF CompilerVersion = 24.0} 'Delphi XE3' {$IFEND}
{$IF CompilerVersion = 25.0} 'Delphi XE4' {$IFEND}
{$IF CompilerVersion = 26.0} 'Delphi XE5' {$IFEND}
{$IF CompilerVersion = 27.0} 'Delphi XE6' {$IFEND}
{$IF CompilerVersion = 28.0} 'Delphi XE7' {$IFEND}
{$IF CompilerVersion = 29.0} 'Delphi XE8' {$IFEND}
{$IF CompilerVersion = 30.0} 'Delphi 10 Seattle' {$IFEND}
{$IF CompilerVersion = 31.0} 'Delphi 10.1 Berlin' {$IFEND}
{$IF CompilerVersion = 32.0} 'Delphi 10.2 Tokyo' {$IFEND}
{$IF CompilerVersion = 33.0} 'Delphi 10.3 Rio' {$IFEND}
{$IF CompilerVersion = 34.0} 'Delphi 10.4 Sydney' {$IFEND}
{$IF CompilerVersion = 35.0} 'Delphi 11 Alexandria' {$IFEND}
{$IF CompilerVersion = 36.0} 'Delphi 12 Athens' {$IFEND}

    ;

    ShowModal;
  finally
    Free;
  end;
end;
Responder Con Cita
  #8  
Antiguo 13-05-2025
genyus00 genyus00 is offline
Miembro
 
Registrado: jun 2010
Posts: 31
Poder: 0
genyus00 Va por buen camino
Hola, en la unidad msProtector.pas antes de la linea Function TmxProtector.InternalGetHardwareID: String; agregar funcion:

Código Delphi [-]
function GetCPUVendorStr: string;//
var
  Vendor: TVendor;
begin
  Vendor := GetCPUVendor;
  SetString(Result, PAnsiChar(@Vendor[0]), Length(Vendor));
end;
// *************************************************************************************
// ** TmxProtector.InternalGetHardwareID, 10/12/01 2:04:03 PM
// *************************************************************************************

Function TmxProtector.InternalGetHardwareID: String;

y dentro de Function TmxProtector.InternalGetHardwareID: String; modificar:

Código Delphi [-]
//Quitar: W1057 Implicit string cast from 'AnsiChar' to 'string' por cambio en TVendor = array[0..11] de Char por AnsiChar;
ID_5 := GetCPUVendor;   =>  ID_5 := GetCPUVendorStr;

espero les sirva.
Responder Con Cita
  #9  
Antiguo 13-05-2025
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.435
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #10  
Antiguo 02-06-2025
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.503
Poder: 23
MAXIUM Va camino a la fama
Hola, muchas gracias.

Lo he implementado en Delphi 10.4.2 pero sigue diciendo que el número de serie no funciona
https://delphiallimite.blogspot.com/...otector-2.html

Cita:
Empezado por genyus00 Ver Mensaje
Hola, en la unidad msProtector.pas antes de la linea Function TmxProtector.InternalGetHardwareID: String; agregar funcio:

Código Delphi [-]
function GetCPUVendorStr: string;//
var
  Vendor: TVendor;
begin
  Vendor := GetCPUVendor;
  SetString(Result, PAnsiChar(@Vendor[0]), Length(Vendor));
end;
// *************************************************************************************
// ** TmxProtector.InternalGetHardwareID, 10/12/01 2:04:03 PM
// *************************************************************************************

Function TmxProtector.InternalGetHardwareID: String;

y dentro de Function TmxProtector.InternalGetHardwareID: String; modificar:

Código Delphi [-]
//Quitar: W1057 Implicit string cast from 'AnsiChar' to 'string' por cambio en TVendor = array[0..11] de Char por AnsiChar;
ID_5 := GetCPUVendor;   =>  ID_5 := GetCPUVendorStr;

espero les sirva.
Responder Con Cita
  #11  
Antiguo 03-06-2025
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.503
Poder: 23
MAXIUM Va camino a la fama
Cita:
Empezado por MAXIUM Ver Mensaje
Lo he implementado en Delphi 10.4.2 pero sigue diciendo que el número de serie no funciona
https://delphiallimite.blogspot.com/...otector-2.html
OK, el componente viene con código de ejemplo como mxProtector\Demo\KeyGenerator\Application pero no funciona porque siempre arroja el mensaje This serial number is invalid! cuando se quiere proteger por número de serie.

La solución sería agregar este código al igual como aparece la app encargada de generar el número de serie

Código Delphi [-]
procedure Tfrm_MainWindow.mxProtectorGetHardwareID(Sender: TObject; var HardwareID: string);
begin
     HardwareID := Edit_HWID.Text;
end;
Responder Con Cita
  #12  
Antiguo 12-09-2025
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.503
Poder: 23
MAXIUM Va camino a la fama
Hola,

Quiero probar la opción de Trial y tengo la siguiente inquietud.

¿Qué ocurre si dejo corriendo el programa hasta más allá de la fecha límite? ¿Alguien sabe si se activa el trial o solo funciona al arrancar la app?
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Alternativa a mxProtector Jose Roman OOP 1 01-03-2020 22:40:36
ayuda con el componente Mxprotector jose.ignacio.ve Varios 0 03-09-2015 01:26:19
MXProtector Delphi XE2 y superiores sonjeux Varios 1 24-07-2014 14:55:55
Componente MXProtector cmfab Varios 5 03-07-2013 16:50:41
utilizando componente mxProtector DM2005 Varios 2 11-08-2007 23:13:52


La franja horaria es GMT +2. Ahora son las 06:16:27.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi