estas son algnas de las citas del tutorial del hack
Citar
//The list contains the virtual memory address of the functions Add, Sub, GetLastUsedFunc and the constructor.
//Since we obtained the block of memory, we have to call the constructor to initialize the block of memory.
//So, we get the relative virtual address of the constructor in the DLL.
//Since we have the address of the constructor, we have to explicitly call it to initialize the
//block of memory obtained by malloc.
//Yes, but how do we associate an object for the constructor?
//If you remember, when any member function is called, including the constructor,
//the address of the object gets quietly passed to the called function and this address is stored in the stack.
//On an Intel based machine, this address of the object is pushed onto the stack via the ECX register.
//So, if you create a class and call its member function, the ECX register contains the 'this' pointer.
//This screen shot should make things clearer.
//acerca del bloque reservado con malloc..
//since we already have the address of a block of memory (that will in the future be an object),
//we move this address into the ECX register by using the Visual C++ inline assembler syntax:
//__asm { MOV ECX, pCCalc }
//Since we have already obtained the address of the constructor, we just say:
//pCtor ();
//When your function pointer pCtor() returns from the DLL,
//it would have initialized the object of the class contained in the DLL.
//Since we obtained the block of memory, we have to call the constructor to initialize the block of memory.
//So, we get the relative virtual address of the constructor in the DLL.
//Since we have the address of the constructor, we have to explicitly call it to initialize the
//block of memory obtained by malloc.
//Yes, but how do we associate an object for the constructor?
//If you remember, when any member function is called, including the constructor,
//the address of the object gets quietly passed to the called function and this address is stored in the stack.
//On an Intel based machine, this address of the object is pushed onto the stack via the ECX register.
//So, if you create a class and call its member function, the ECX register contains the 'this' pointer.
//This screen shot should make things clearer.
//acerca del bloque reservado con malloc..
//since we already have the address of a block of memory (that will in the future be an object),
//we move this address into the ECX register by using the Visual C++ inline assembler syntax:
//__asm { MOV ECX, pCCalc }
//Since we have already obtained the address of the constructor, we just say:
//pCtor ();
//When your function pointer pCtor() returns from the DLL,
//it would have initialized the object of the class contained in the DLL.
entiendo para que necesita llamar al constructor en este caso, pero en mi caso no entiendo porque deberia llamarlo. si pudieras explicarme la razon de tener que agregar un constructor explicito en mi clase y llamarlo en el EXE por que todavia no entiendo el motivo
en el EXE yo solo quiero crear un objeto en el winmain de esta forma:
winmain()
{
Datos dat;
//y pasarselo a esta funcion importada de la DLL
pFuncionQueUsaUnParametroDeClaseDatos(dat);
}
la funcion exportada de la dll luseria algo asi
Código:
EXPORT void FuncionQueUsaUnParametroDeClaseDatos( Datos &dat )
{
/* modifica el objeto, lo inicializa y le asigna valores a sus miembros (propiedades) */
dat.setValorA(5);//ejemplo
}
y la funcion lo que haria seria modificar el objeto, osea darle valores y eso. entonces para esta caso aunque no sea como el del hack tambien necesitaria hacer lo del bloque de memoria con malloc y llamar al constructor ?