Cesar C. Salazar Gonzalez Master


Registrado: 01 Oct 2002Mensajes: 2155Ubicación: San Cristóbal de Las Casas, Chiapas
|
Publicado: Vie 20 Jun, 2003 9:28 am Asunto: codigo en _asm, que no esta funcionando bien |
|
|
Miren muchachos, llevo unos buenos dias, tratando de componer, una funcion que encontre, para leer el FIRMWARE del disco duro, (el serial y nombre del disco, etc), y el unico problema que tengo, es que esta funcion que forma parte del codigo, no quiere,
| Código: |
bool CallRing0(PVOID pvRing0FuncAddr, WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize)
{
struct GDT_DESCRIPTOR *pGDTDescriptor;
struct GDTR gdtr;
// WORD CallgateAddr[3]; //original
WORD CallgateAddr[3];
WORD wGDTIndex = 1;
_asm Sgdt [gdtr]
// Skip the null descriptor
pGDTDescriptor = (struct GDT_DESCRIPTOR *)(gdtr.dwGDTBase + 8);
// Search for a free GDT descriptor
for (wGDTIndex = 1; wGDTIndex < (gdtr.wGDTLimit / 8); wGDTIndex++)
{
if (pGDTDescriptor->Type == 0 &&
pGDTDescriptor->System == 0 &&
pGDTDescriptor->DPL == 0 &&
pGDTDescriptor->Present == 0)
{
// Found one !
// Now we need to transform this descriptor into a callgate.
// Note that we're using selector 0x28 since it corresponds
// to a ring 0 segment which spans the entire linear address
// space of the processor (0-4GB).
struct CALLGATE_DESCRIPTOR *pCallgate;
pCallgate = (struct CALLGATE_DESCRIPTOR *) pGDTDescriptor;
pCallgate->Offset_0_15 = LOWORD(pvRing0FuncAddr);
pCallgate->Selector = 0x28;
pCallgate->ParamCount = 0;
pCallgate->Unused = 0;
pCallgate->Type = 0xc;
pCallgate->System = 0;
pCallgate->DPL = 3;
pCallgate->Present = 1;
pCallgate->Offset_16_31 = HIWORD(pvRing0FuncAddr);
// Prepare the far call parameters
CallgateAddr[0] = 0x0;
CallgateAddr[1] = 0x0;
CallgateAddr[2] = (wGDTIndex << 3) | 3;
// Please fasten your seat belts!
// We're about to make a hyperspace jump into RING 0.
/* // codigo original del proceso
_asm Mov DX, [wPortAddr]
_asm Mov EBX, [pdwPortVal]
_asm Mov CL, [bSize]
_asm Call FWORD PTR [CallgateAddr] //original donde esta el fallo
*/
_asm {
Mov DX, [wPortAddr]
Mov EBX, [pdwPortVal]
Mov CL, [bSize]
Call FWORD PTR [CallgateAddr] // el mismo fallo
}
// We have made it !
// Now free the GDT descriptor
memset(pGDTDescriptor, 0, 8);
// Our journey was successful. Seeya.
return true;
}
// Advance to the next GDT descriptor
pGDTDescriptor++;
}
// Whoops, the GDT is full
return false;
}
|
bueno el problema concreto es en la siguiente linea
donde se encuentra la palabra FWORD PTR
| Código: |
// WORD CallgateAddr[3]; //original
WORD CallgateAddr[3];
{...}
CallgateAddr[0] = 0x0;
CallgateAddr[1] = 0x0;
CallgateAddr[2] = (wGDTIndex << 3) | 3;
/* // codigo original del proceso
_asm Mov DX, [wPortAddr]
_asm Mov EBX, [pdwPortVal]
_asm Mov CL, [bSize]
_asm Call FWORD PTR [CallgateAddr] //original donde esta el fallo
*/
_asm {
Mov DX, [wPortAddr]
Mov EBX, [pdwPortVal]
Mov CL, [bSize]
Call FWORD PTR [CallgateAddr] // el mismo fallo
}
|
la ayuda del visual c, indica que la FWORD, es un identificador para manejar, datos de 6 bits, (eso dice la ayuda), bueno el problema es que al compilarlo, me marca que los parametros estan erroneos, intente cambiar la sentica por WORD PTR, se compila, pero al ejectuar marca un error de lectura de memoria, tambien lo intente con DWORD PTR, pero marca error de lectura de memoria, claro en otra direccion., alguien que pudiera decirme como cambiar el FWORD PTR, y remplazarlo, para ejecutar, el programa, Esto, es para leer, un far word, pero en builder no existe o no se como convertirlo
gracias por tomarte el tiempo de leerlo. _________________
 |
|