hola
Estoy tratado de pasar un codigo de VB.NET a C, pero hay unas cosas que no logro enteder, entre ellas una funcion llamada Bitconverter, me podrian ayudar analizando los codigos y decirme si lo estoy haciendo bien?
segun MSDN Bitconverter.ToInt sirve para avanzar a cierto offset y tomar bytes, por ejemplo
bitconverter.ToInt32(buffer, 11)
aqui supuestamente avanzaria al offset 0xB, toma 4 bytes desde el offset 0xB, los cambia a big-endian y lo devuelve en un array de bytes
tampoco se si estoy haciendo bien lo de BitConverter.GetBytes
Esto es lo que hay en la multiplicacion
MFTCluster * SectperCluster * BytesPerSect = 322122547
SetReadFileOffset(NO, MFTCluster * SectperCluster * BytesPerSect)
Private Sub SetReadFileOffset(ByRef NO As System.Threading.NativeOverlapped, ByRef curBig As Int64)
Dim lowoffset() As Byte = BitConverter.GetBytes(curBig)
Dim highoffset As Int32 = BitConverter.ToInt32(lowoffset, 0)
Dim high As Int32
Dim lastbytes(3) As Byte
Array.Copy(lowoffset, 4, lastbytes, 0, 4)
high = BitConverter.ToInt32(lastbytes, 0)
NO.OffsetLow = highoffset
NO.OffsetHigh = high
End Sub
Y este es el codigo que yo hice, endianhextodec lo hice para simular lo que haria Bitconverter.ToInt32
long endianhextodec(BYTE *buffers, int offs){
BYTE tmp[1] = {0};
if(offs == 0){
tmp[0] = buffers[0];
tmp[1] = buffers[1];
tmp[2] = buffers[2];
tmp[3] = buffers[3];
return tmp[3] << 24;
}
}
setreadfileoffset(overlapped, (sectperclusters * (bytespercluster * MFTCluster)));
void setreadfileoffset(OVERLAPPED overlap, INT64 crbig ){
BYTE *lowoffset = (BYTE*)malloc(sizeof(crbig));
INT32 higoffset = endianhextodec(lowoffset, 0);
INT32 high;
BYTE lastbytes[3];
for(int i = 0; i < 4; i++){
for(int n = 4; n > 0; n--){
lastbytes[i] = lowoffset[n];
}
}
high = endianhextodec(lastbytes, 0);
overlap.Offset = higoffset;
overlap.OffsetHigh = high;
}
espero puedan decirme si lo encuentran bien o estoy totalmente equivocado
salu2
Te lo muevo a .Net donde te podrán ayudar mejor