elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 49
11  Sistemas Operativos / Mac OS X / Exsite alguna version de MAC antigua para AMD o VritualBox? en: 16 Julio 2014, 00:38 am
existe alguna versión de MAC que pueda funcionar con una laptop AMD series G, de preferencia para VirtualBox ya que trae por defecto Intel?, aunque sea una versión vieja, solo la quiero para método de estudio, no para diseño gráfico o cosas demasiado pesadas
12  Programación / Programación C/C++ / como hacer la conversión de hexadecimales a UTF? en: 6 Marzo 2014, 21:06 pm
hola

bueno, por fin tendré un tiempo para seguir con un programa que estoy haciendo, quise pedir ayuda a algún maestro pero aunque me entendían, no tienen idea de como hacer algo que pedía... así que me tendré que apoyar nuevamente en la ayuda de este foro para continuar, espero no ser una molestia

bueno, anteriormente me quede con un código donde podía empezar a leer los datos de MFT que es la tabla donde se guarda la información de los archivos que se encuentran en una unidad

pero están codificados y necesito decodificarlos a UTF-8 o UTF-16, hace tiempo me hicieron entender que convertir código de VB a C no es muy recomendable (y es cierto), y la mayoría de ejemplos que encuentro son para VB.net o C#, y utilizan mucho una función llamada Encoding utf8 que ya lo hace automáticamente

y la mayoría de información que encontré fue en Wikipedia, la otra fue de ejemplos como mencione anteriormente, pero no se si no estoy buscando bien o casi no hay información

me podrían ayudar diciéndome de que manera debería buscar en google sobre conversion de hexadecimales a UTF? porque no creo que haya tan poca documentación sobre eso en C o alguien conoce ejemplos o si alguien sabe como hacerlo, me podrían explicar como es la conversión de hexadecimales a UTF-8 o 16

porque aquí esta la tabla con la información del primer archivo, en este caso, seria el nombre, fecha de creación, etc, etc...

$FileName

Código:
0x30 0x00 0x00 0x00 0x68 0x00 0x00 0x00
0x00 0x00 0x18 0x00 0x00 0x00 0x03 0x00 0x4A 0x00 0x00 0x00 0x18 0x00 0x01 0x00
0x05 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0xC7 0xE6 0xC2 0x91 0x93 0x7B 0xCE 0x01
0xC7 0xE6 0xC2 0x91 0x93 0x7B 0xCE 0x01 0xC7 0xE6 0xC2 0x91 0x93 0x7B 0xCE 0x01
0xC7 0xE6 0xC2 0x91 0x93 0x7B 0xCE 0x01 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x04 0x03 0x24 0x00 0x4D 0x00 0x46 0x00 0x54 0x00 0x00 0x00 0x00 0x00 0x00 0x00

según wikipedia hay que modificar algunos bits pero no comprendí muy bien

encontré un programa forense para decodificar la fecha, pero no tiene código libre así que no logre saber como lo hace pero puedo asegurar que aquí esta la información necesaria

espero alguien sepa sobre esto y me pueda pasar algo de información

salu2
13  Programación / Programación C/C++ / Re: no funciona ReadFile y overlapped en: 6 Febrero 2014, 23:43 pm
hola, perdon por contestar hasta ahora pero se me acabo el tiempo, tengo que regresar a la escuela y con el trabajo ya no creo tener tanto tiempo

pero tienes razon, yo estaba utilizando otra estructura que era NTFS_VOLUME_DATA_BUFFER

typedef struct {
  LARGE_INTEGER VolumeSerialNumber;
  LARGE_INTEGER NumberSectors;
  LARGE_INTEGER TotalClusters;
  LARGE_INTEGER FreeClusters;
  LARGE_INTEGER TotalReserved;
  DWORD         BytesPerSector;
  DWORD         BytesPerCluster;
  DWORD         BytesPerFileRecordSegment;
  DWORD         ClustersPerFileRecordSegment;
  LARGE_INTEGER MftValidDataLength;
  LARGE_INTEGER MftStartLcn;
  LARGE_INTEGER Mft2StartLcn;
  LARGE_INTEGER MftZoneStart;
  LARGE_INTEGER MftZoneEnd;
} NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;

pero tuve dos problemas, la primera fue un error mio que no me habia dado cuenta que no estaba leyendo $BOOT sino otro que era Disk_Geometry, fue cuando me di cuenta que debia hacerlo funcionar con C: y no PhysicalDrive0

y la segunda fue que no encontraba SectorsPerCluster

hice un intento de multiplicarlo directamente por 8 con el anterior codigo y me salio el mismo resultado que en el codigo de arriba en este momento

Código
  1.   MFTcl.QuadPart =  ntfsData.MftStartLcn.QuadPart * ntfsData.BytesPerSector * 8;
  2.  

pero ya no me dio tiempo de arreglar SetFilePointer y Readfile, asi que ejecute el programa pero enseguida salto a CloseHandle(hDevice); con el if INVALID_SET_FILE_POINTER

pero bueno, supuestamente con esto ya deberia haber llegado a $MFT, de aqui deberia empezar a leer las entradas MFT, donde ya podria encontrar los archivos junto con sus atributos y se encuentran en cada 1024 bytes

Gracias x64Core, logre avanzar bastante gracias a tu ayuda, seguire un poco lento pero quiero terminar de aprender esto

salu2
14  Programación / Programación C/C++ / Re: no funciona ReadFile y overlapped en: 4 Febrero 2014, 05:17 am
coincido contigo sobre WaitForSingleObject, pero no quiero empezar a hacer preguntas de algo que no me funciono y darme cuenta que fue por no colocar algo que en el otro codigo si habia, pero terminando hare lo que me mencionas sobre SetFilePointer y quitare y optimizare otras cosas que las estoy dejando pasar por ahora, solo que no me habia tocado el momento de trabajar con varias funciones y API's de ahorita, por eso se me esta dificultando entender

y el codigo que me pusiste, no se si estoy haciendo algo mal, porque el prinft me sigue mostrando los mismo bytes, como que no avanza, y necesito avanzar dependiendo el valor de overlapped, porque en el codigo de VB.net me sale un offset de 56 + 1

Código
  1. Dim offset As Long = LittleEndianHEXToDecimal(Buffer, 20, 2) + 1

al principio creia que no encontraba ese offset, pero lo busque y ninguno del offset 20 me sale 56 en decimal, es la suma de 2 bytes segun bitconverter, entonces es donde me di cuenta que readfile no avanza y parece que lee los mismo bytes

acabo de compilar el codigo y avanza igual de bien, pero me sigue mostrando los mismos bytes del inicio, en el tercer offset empieza NTFS, asi que sigue siendo el inicio y eso es lo que no entiendo, porque no avanza

Código:
0xEB 0x52 0x90 0x4E 0x54 0x46 0x53 0x20 0x20 0x20 0x20 0x00 0x02 0x08 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0xF8 0x00 0x00 0x3F 0x00 0xFF 0x00 0x00 0x28 0x03 0x00
0x00 0x00 0x00 0x00 0x80 0x00 0x80 0x00 0xFF 0xAF 0xEE 0x0C 0x00 0x00 0x00 0x00
0x00 0x00 0x0C 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0xF6 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x87 0xFF 0x92 0x82 0x24 0x93 0x82 0x1E
0x00 0x00 0x00 0x00 0xFA 0x33 0xC0 0x8E 0xD0 0xBC 0x00 0x7C 0xFB 0x68 0xC0 0x07
0x1F 0x1E 0x68 0x66 0x00 0xCB 0x88 0x16 0x0E 0x00 0x66 0x81 0x3E 0x03 0x00 0x4E
0x54 0x46 0x53 0x75 0x15 0xB4 0x41 0xBB 0xAA 0x55 0xCD 0x13 0x72 0x0C 0x81 0xFB
0x55 0xAA 0x75 0x06 0xF7 0xC1 0x01 0x00 0x75 0x03 0xE9 0xDD 0x00 0x1E 0x83 0xEC
0x18 0x68 0x1A 0x00 0xB4 0x48 0x8A 0x16 0x0E 0x00 0x8B 0xF4 0x16 0x1F 0xCD 0x13
0x9F 0x83 0xC4 0x18 0x9E 0x58 0x1F 0x72 0xE1 0x3B 0x06 0x0B 0x00 0x75 0xDB 0xA3
0x0F 0x00 0xC1 0x2E 0x0F 0x00 0x04 0x1E 0x5A 0x33 0xDB 0xB9 0x00 0x20 0x2B 0xC8
0x66 0xFF 0x06 0x11 0x00 0x03 0x16 0x0F 0x00 0x8E 0xC2 0xFF 0x06 0x16 0x00 0xE8
0x4B 0x00 0x2B 0xC8 0x77 0xEF 0xB8 0x00 0xBB 0xCD 0x1A 0x66 0x23 0xC0 0x75 0x2D
0x66 0x81 0xFB 0x54 0x43 0x50 0x41 0x75 0x24 0x81 0xF9 0x02 0x01 0x72 0x1E 0x16
0x68 0x07 0xBB 0x16 0x68 0x70 0x0E 0x16 0x68 0x09 0x00 0x66 0x53 0x66 0x53 0x66
0x55 0x16 0x16 0x16 0x68 0xB8 0x01 0x66 0x61 0x0E 0x07 0xCD 0x1A 0x33 0xC0 0xBF
0x28 0x10 0xB9 0xD8 0x0F 0xFC 0xF3 0xAA 0xE9 0x5F 0x01 0x90 0x90 0x66 0x60 0x1E
0x06 0x66 0xA1 0x11 0x00 0x66 0x03 0x06 0x1C 0x00 0x1E 0x66 0x68 0x00 0x00 0x00
0x00 0x66 0x50 0x06 0x53 0x68 0x01 0x00 0x68 0x10 0x00 0xB4 0x42 0x8A 0x16 0x0E
0x00 0x16 0x1F 0x8B 0xF4 0xCD 0x13 0x66 0x59 0x5B 0x5A 0x66 0x59 0x66 0x59 0x1F
0x0F 0x82 0x16 0x00 0x66 0xFF 0x06 0x11 0x00 0x03 0x16 0x0F 0x00 0x8E 0xC2 0xFF
0x0E 0x16 0x00 0x75 0xBC 0x07 0x1F 0x66 0x61 0xC3 0xA0 0xF8 0x01 0xE8 0x09 0x00
0xA0 0xFB 0x01 0xE8 0x03 0x00 0xF4 0xEB 0xFD 0xB4 0x01 0x8B 0xF0 0xAC 0x3C 0x00
0x74 0x09 0xB4 0x0E 0xBB 0x07 0x00 0xCD 0x10 0xEB 0xF2 0xC3 0x0D 0x0A 0x45 0x72
0x72 0x6F 0x72 0x20 0x64 0x65 0x20 0x64 0x69 0x73 0x63 0x6F 0x00 0x0D 0x0A 0x46
0x61 0x6C 0x74 0x61 0x20 0x62 0x6F 0x6F 0x74 0x6D 0x67 0x72 0x00 0x0D 0x0A 0x42
0x6F 0x6F 0x74 0x6D 0x67 0x72 0x20 0x63 0x6F 0x6D 0x70 0x72 0x69 0x6D 0x69 0x64
0x6F 0x00 0x0D 0x0A 0x50 0x72 0x65 0x73 0x2E 0x20 0x43 0x74 0x72 0x6C 0x2B 0x41
0x6C 0x74 0x2B 0x53 0x75 0x70 0x72 0x20 0x70 0x61 0x72 0x61 0x20 0x72 0x65 0x69
0x6E 0x69 0x63 0x69 0x61 0x72 0x0D 0x0A 0x00 0x6C 0x20 0x74 0x6F 0x20 0x72 0x65
0x73 0x74 0x61 0x72 0x74 0x0D 0x0A 0x00 0x8C 0x9D 0xAD 0xC2 0x00 0x00 0x55 0xAA
0x07 0x00 0x42 0x00 0x4F 0x00 0x4F 0x00 0x54 0x00 0x4D 0x00 0x47 0x00 0x52 0x00
0x04 0x00 0x24 0x00 0x49 0x00 0x33 0x00 0x30 0x00 0x00 0xD4 0x00 0x00 0x00 0x24
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0xEB 0x22 0x90 0x90 0x05 0x00 0x4E 0x00 0x54 0x00
0x4C 0x00 0x44 0x00 0x52 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x66 0x0F 0xB7 0x06 0x0B 0x00
0x66 0x0F 0xB6 0x1E 0x0D 0x00 0x66 0xF7 0xE3 0x66 0xA3 0x52 0x02 0x66 0x8B 0x0E
0x40 0x00 0x80 0xF9 0x00 0x0F 0x8F 0x0E 0x00 0xF6 0xD9 0x66 0xB8 0x01 0x00 0x00
0x00 0x66 0xD3 0xE0 0xEB 0x08 0x90 0x66 0xA1 0x52 0x02 0x66 0xF7 0xE1 0x66 0xA3
0x66 0x02 0x66 0x0F 0xB7 0x1E 0x0B 0x00 0x66 0x33 0xD2 0x66 0xF7 0xF3 0x66 0xA3
0x56 0x02 0xE8 0x95 0x04 0x66 0x8B 0x0E 0x4E 0x02 0x66 0x89 0x0E 0x26 0x02 0x66
0x03 0x0E 0x66 0x02 0x66 0x89 0x0E 0x2A 0x02 0x66 0x03 0x0E 0x66 0x02 0x66 0x89
0x0E 0x2E 0x02 0x66 0x03 0x0E 0x66 0x02 0x66 0x89 0x0E 0x3E 0x02 0x66 0x03 0x0E
0x66 0x02 0x66 0x89 0x0E 0x46 0x02 0x66 0xB8 0x90 0x00 0x00 0x00 0x66 0x8B 0x0E
0x26 0x02 0xE8 0x83 0x09 0x66 0x0B 0xC0 0x0F 0x84 0x5E 0xFE 0x66 0xA3 0x32 0x02
0x66 0xB8 0xA0 0x00 0x00 0x00 0x66 0x8B 0x0E 0x2A 0x02 0xE8 0x6A 0x09 0x66 0xA3
0x36 0x02 0x66 0xB8 0xB0 0x00 0x00 0x00 0x66 0x8B 0x0E 0x2E 0x02 0xE8 0x58 0x09
0x66 0xA3 0x3A 0x02 0x66 0xA1 0x32 0x02 0x66 0x0B 0xC0 0x0F 0x84 0x2B 0xFE 0x67
0x80 0x78 0x08 0x00 0x0F 0x85 0x22 0xFE 0x67 0x66 0x8D 0x50 0x10 0x67 0x03 0x42
0x04 0x67 0x66 0x0F 0xB6 0x48 0x0C 0x66 0x89 0x0E 0x72 0x02 0x67 0x66 0x8B 0x48
0x08 0x66 0x89 0x0E 0x6E 0x02 0x66 0xA1 0x6E 0x02 0x66 0x0F 0xB7 0x0E 0x0B 0x00
0x66 0x33 0xD2 0x66 0xF7 0xF1 0x66 0xA3 0x76 0x02 0x66 0xA1 0x46 0x02 0x66 0x03
0x06 0x6E 0x02 0x66 0xA3 0x4A 0x02 0x66 0x83 0x3E 0x36 0x02 0x00 0x0F 0x84 0x1D
0x00 0x66 0x83 0x3E 0x3A 0x02 0x00 0x0F 0x84 0xCF 0xFD 0x66 0x8B 0x1E 0x3A 0x02
0x1E 0x07 0x66 0x8B 0x3E 0x4A 0x02 0x66 0xA1 0x2E 0x02 0xE8 0xE0 0x01 0x66 0x0F
0xB7 0x0E 0x00 0x02 0x66 0xB8 0x02 0x02 0x00 0x00 0xE8 0x22 0x08 0x66 0x0B 0xC0
0x0F 0x85 0x16 0x00 0x66 0x0F 0xB7 0x0E 0x5A 0x02 0x66 0xB8 0x5C 0x02 0x00 0x00
0xE8 0x0C 0x08 0x66 0x0B 0xC0 0x0F 0x84 0x42 0x0C 0x67 0x66 0x8B 0x00 0x1E 0x07
0x66 0x8B 0x3E 0x3E 0x02 0xE8 0x3F 0x06 0x66 0xA1 0x3E 0x02 0x66 0xBB 0x20 0x00
0x00 0x00 0x66 0xB9 0x00 0x00 0x00 0x00 0x66 0xBA 0x00 0x00 0x00 0x00 0xE8 0xE4




15  Programación / Programación C/C++ / Re: no funciona ReadFile y overlapped en: 4 Febrero 2014, 03:51 am
Este es el codigo que llevo hecho, por el momento todo me ha funcionado bien, hasta ahorita con overlapped

Código
  1.  
  2. #include <Windows.h>
  3. #include <winioctl.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. #define zwpath L"\\\\.\\C:"
  8.  
  9.  
  10. long endianhextodec(BYTE *buffers, int offs){
  11.  
  12. BYTE tmp[2] = {0};
  13. BYTE tmp2[1] = {0};
  14. BYTE tmp3[3] = {0};
  15. BYTE tmp4[1] = {0};
  16.  
  17. if(offs == 11){
  18. tmp[0] = buffers[11];
  19. tmp[1] = buffers[12];
  20.  
  21. return tmp[1] << 8;
  22.  
  23. }
  24.  
  25. if(offs == 13){
  26.  
  27. tmp2[0] = buffers[13];
  28.  
  29. return tmp2[0];
  30.  
  31. }
  32.  
  33. if(offs == 30){
  34.  
  35. tmp3[0] = buffers[48];
  36. tmp3[1] = buffers[49];
  37. tmp3[2] = buffers[50];
  38.  
  39. return tmp3[2] << 16;
  40. }else{return 0;}
  41. }
  42.  
  43.  
  44. int main(int argc, char *argv[]){
  45.  
  46. HANDLE hDevice;
  47. OVERLAPPED overlapped;
  48. DWORD crbig;
  49. BYTE buff[1024] = {0};
  50. DWORD numerobyte = 0, nbytes = 0;
  51. UINT32 ret;
  52. DWORD *d1;
  53. int offset1 = 11, offset2 = 13, offset3 = 30;
  54. long MFTCluster = 0, bytespercluster = 0, sectperclusters = 0, offet = 0;
  55. unsigned long mult = 0;
  56.  
  57. ZeroMemory(&overlapped ,sizeof(OVERLAPPED));
  58.  
  59. hDevice = CreateFileW(zwpath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
  60.  
  61. if(hDevice != INVALID_HANDLE_VALUE){
  62.  
  63. ret = ReadFile(hDevice, buff, 1024, &numerobyte, &overlapped);
  64.  
  65. }else
  66. {
  67. return NULL;
  68. }
  69.  
  70. if(ret == 0){
  71.  
  72.  
  73. ret = WaitForSingleObject(hDevice,INFINITE );
  74.  
  75. switch (ret)
  76. {
  77. case WAIT_OBJECT_0:break;
  78. case WAIT_TIMEOUT:break;
  79. default:
  80. break;
  81. }
  82. }
  83. else
  84. {
  85. return NULL;
  86. }
  87.  
  88.  
  89. if((int)buff[3] == 'N' && (int)buff[4] == 'T' && (int)buff[5] == 'F' && (int)buff[6] == 'S' ){
  90. printf("Volumen es formato NTFS\n\n\n");
  91. }
  92.  
  93. bytespercluster = endianhextodec(buff, offset1);
  94. sectperclusters = endianhextodec(buff, offset2);
  95. MFTCluster = endianhextodec(buff, offset3);
  96.  
  97. printf("Bytes por clusters = %d\nsectores por clusters = %d\nMFTClusters = %ld\n\n", bytespercluster, sectperclusters, MFTCluster);
  98.  
  99. crbig = (sectperclusters * (bytespercluster * MFTCluster));
  100.  
  101. d1 = (DWORD*)&crbig;
  102. overlapped.Offset = d1[1];
  103. overlapped.OffsetHigh = d1[0];
  104.  
  105. ret = ReadFile(hDevice, buff, 1024, &numerobyte, &overlapped);
  106.  
  107. if(ret == 0){
  108.  
  109.  
  110. ret = WaitForSingleObject(hDevice,INFINITE );
  111.  
  112. switch (ret)
  113. {
  114. case WAIT_OBJECT_0:break;
  115. default:
  116. break;
  117. }
  118. }
  119. else
  120. {
  121. return NULL;
  122. }
  123.  
  124. for (int n=0; n<sizeof(buff); n++)  
  125.    {  
  126.        printf("0x%02X ", buff[n]);  
  127.    }
  128.  
  129. CloseHandle(hDevice);
  130.  
  131. }

Y este es la parte del codigo de VB.NET que he hecho en C

Código
  1. Public Function IsNFTSDrive(ByVal strDrive As String) As Boolean
  2.        Dim Hnd As Integer, nRead As Integer
  3.        Dim ret As UInt32
  4.        Dim Buffer(1024) As Byte
  5.        Hnd = CreateFile("\\.\" & Mid(strDrive, 1, 2), GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, _
  6.        Nothing, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_OVERLAPPED, IntPtr.Zero)
  7.        If (Hnd <> INVALID_HANDLE_VALUE) Then
  8.            ret = ReadFile(Hnd, Buffer, 1024, nRead, New System.Threading.NativeOverlapped)
  9.            Console.WriteLine(Buffer(200))
  10.        Else
  11.            Return False
  12.        End If
  13.        If ret = 0 Then
  14.            ret = WaitForSingleObject(Hnd, INFINITE)
  15.            Select Case ret
  16.                Case WAIT_OBJECT_0
  17.                Case WAIT_TIMEOUT
  18.            End Select
  19.        Else
  20.            Return False
  21.        End If
  22.        CloseHandle(Hnd)
  23.        Return Buffer(3) = 78 And Buffer(4) = 84 And Buffer(5) = 70 And Buffer(6) = 83
  24.    End Function
  25.  
  26.    Public Function GetFiles(ByVal strDrive As String, ByVal bnAllFiles As Boolean) As DataTable
  27.        Dim Hnd As Integer, nRead As Integer
  28.        Dim ret As UInt32
  29.        Dim Buffer(1024) As Byte
  30.  
  31.        Dim BytesPerSect As Long
  32.        Dim SectperCluster As Long
  33.        Dim MFTCluster As Long
  34.        Dim intIgnoredFiles As Integer = 0
  35.  
  36.        Dim NO As System.Threading.NativeOverlapped
  37.        'Read Partition Info
  38.        Hnd = CreateFile("\\.\" & Mid(strDrive, 1, 2), GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, _
  39.        Nothing, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_OVERLAPPED, IntPtr.Zero)
  40.        If (Hnd <> INVALID_HANDLE_VALUE) Then
  41.            ret = ReadFile(Hnd, Buffer, 1024, nRead, NO)
  42.        Else
  43.            Return Nothing
  44.        End If
  45.        If ret = 0 Then
  46.            ret = WaitForSingleObject(Hnd, INFINITE)
  47.            Select Case ret
  48.                Case WAIT_OBJECT_0
  49.                Case WAIT_TIMEOUT
  50.            End Select
  51.        Else
  52.            Return Nothing
  53.        End If
  54.        BytesPerSect = LittleEndianHEXToDecimal(Buffer, &HB, 2)
  55.        SectperCluster = LittleEndianHEXToDecimal(Buffer, &HD, 1)
  56.        MFTCluster = LittleEndianHEXToDecimal(Buffer, &H30, 8)
  57.        'Read MFT
  58.        SetReadFileOffset(NO, MFTCluster * SectperCluster * BytesPerSect)
  59.        ret = ReadFile(Hnd, Buffer, 1024, nRead, NO)
  60.        If ret = 0 Then
  61.            ret = WaitForSingleObject(Hnd, INFINITE)
  62.            Select Case ret
  63.                Case WAIT_OBJECT_0
  64.                Case Else
  65.            End Select
  66.        Else
  67.            Return Nothing
  68.        End If


Código
  1. Private Function LittleEndianHEXToDecimal(ByRef Buffer As Byte(), ByVal offset As Long, ByVal Length As Long) As Long
  2.        If Length = 1 Then
  3.            Return BitConverter.ToInt16(Buffer, offset)
  4.        End If
  5.        If Length = 2 Then
  6.            Return BitConverter.ToInt16(Buffer, offset)
  7.        End If
  8.        If Length = 4 Then
  9.            Return BitConverter.ToInt32(Buffer, offset)
  10.        End If
  11.        If Length = 8 Then
  12.            Return BitConverter.ToInt64(Buffer, offset)
  13.        End If
  14.  
  15.    End Function

Código
  1. Private Sub SetReadFileOffset(ByRef NO As System.Threading.NativeOverlapped, ByRef curBig As Int64)
  2.  
  3.        Dim lowoffset() As Byte = BitConverter.GetBytes(curBig)
  4.        Dim highoffset As Int32 = BitConverter.ToInt32(lowoffset, 0)
  5.        Dim high As Int32
  6.        Dim lastbytes(3) As Byte
  7.        Array.Copy(lowoffset, 4, lastbytes, 0, 4)
  8.        high = BitConverter.ToInt32(lastbytes, 0)
  9.        NO.OffsetLow = highoffset
  10.        NO.OffsetHigh = high
  11.    End Sub

Donde empieza mi problema es en la ultima parte donde dice 'Read MFT del codigo VB
16  Programación / Programación C/C++ / Re: no funciona ReadFile y overlapped en: 4 Febrero 2014, 02:50 am
pues como le mencione en varios post, estoy siguiendo ejemplos de VB.net sobre MFT, ahorita trato de convertir un codigo de VB a C para ir aprendiendo que hace el programa, ya entendi la mitad junto con varios post teoricos sobre MFT, en este momento con overlapped estoy por llegar a MFT para empezar a tomar los atributos, donde se encuentran los nombres de archivos que estan en la computadora o fueron eliminados pero no puedo avanzar con readfile y overlapped

en VB usan overlapped para moverse por bytes, por ejemplo

Código
  1. Private Sub SetReadFileOffset(ByRef NO As System.Threading.NativeOverlapped, ByRef curBig As Int64)
  2.  
  3.        Dim lowoffset() As Byte = BitConverter.GetBytes(curBig)
  4.        Dim highoffset As Int32 = BitConverter.ToInt32(lowoffset, 0)
  5.        Dim high As Int32
  6.        Dim lastbytes(3) As Byte
  7.        Array.Copy(lowoffset, 4, lastbytes, 0, 4)
  8.        high = BitConverter.ToInt32(lastbytes, 0)
  9.        NO.OffsetLow = highoffset
  10.        NO.OffsetHigh = high
  11.    End Sub

Esto es hacer lo mismo que esto

Código
  1. crbig = (sectperclusters * (bytespercluster * MFTCluster));
  2.  
  3. d1 = (DWORD*)&crbig;
  4. overlapped.Offset = d1[1];
  5. overlapped.OffsetHigh = d1[0];

pero usandolo en Readfile parece que no funciona
17  Programación / Programación C/C++ / no funciona ReadFile y overlapped en: 4 Febrero 2014, 00:48 am
hola

tengo un problema con Readfile

Código
  1. d1 = (DWORD*)&crbig;
  2. overlapped.Offset = d1[1];
  3. overlapped.OffsetHigh = d1[0];
  4.  
  5. ret = ReadFile(hDevice, buff, 1024, &numerobyte, &overlapped);
  6.  

tengo a crbig que es igual a 322122547

los coloco en overlapped low y high

offsethigh = 00000003
offset = 22122547;

supuestamente ReadFile deberia leer los datos de la unidad hDevice, en este caso 1024 bytes y deberia empezar a leer desde donde le digo a overlapped que lo haga

al inicio lo hago de esta manera ya que quiero leer el inicio de la unidad

Código
  1. ZeroMemory(&overlapped ,sizeof(OVERLAPPED));
  2.  
  3. hDevice = CreateFileW(zwpath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
  4.  
  5. if(hDevice != INVALID_HANDLE_VALUE){
  6.  
  7. ret = ReadFile(hDevice, buff, 1024, &numerobyte, &overlapped);
  8.  
  9. }
  10.  
si coloco un for de esta manera para saber que aparecio, me salen los bytes sin probemas en un printf

Código
  1. for (int n=0; n<sizeof(buff); n++)  
  2.    {  
  3.        printf("0x%02X ", buff[n]);  
  4.    }

pero despues es cuando modifico overlapped y uso por segunda vez ReadFile

Código
  1. d1 = (DWORD*)&crbig;
  2. overlapped.Offset = d1[1];
  3. overlapped.OffsetHigh = d1[0];
  4.  
  5. ret = ReadFile(hDevice, buff, 1024, &numerobyte, &overlapped);
  6.  

pero me siguen apareciendo los mismo bytes en el for(), ya intente antes de usar por segunda vez ReadFile, borrar el buffer usando memset e incluso usando un buffer diferente, pero me sigue mostrando lo mismo

y supuestamente como les mencione, deberia avanzar hacia donde overlapped dice, deberia leer los 1024 bytes de esa zona, y lo que deberia pasar es que el for me deberia mostrar otros bytes, pero no parece funcionar

alguien sabe o tiene alguna idea de porque no funciona?

salu2
18  Programación / Programación C/C++ / Re: Error al imprimir caracteres en: 4 Febrero 2014, 00:31 am
trata cambiando el scanf de nombres, usa el string %s
19  Programación / Programación C/C++ / Re: Enciclopedia del Lenguaje C, graph.h ??? en: 2 Febrero 2014, 19:39 pm
me paso lo mismo hace años con los programas de Visual studio 2005, lo que hice fue buscar la libreria faltante en google, ya sea en alguna pagina que muestre el codigo abierto o descarga algun programa para compilar que use graph.h, por lo general vienen los headers incluidos, si lo encuentras ya solo sera que lo coloques en la carpeta de tu compilador
20  Programación / .NET (C#, VB.NET, ASP) / podrian decirme si la conversion de VB.net a C lo hice bien? en: 1 Febrero 2014, 05:41 am
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

Código
  1. SetReadFileOffset(NO, MFTCluster * SectperCluster * BytesPerSect)
  2.  
  3. Private Sub SetReadFileOffset(ByRef NO As System.Threading.NativeOverlapped, ByRef curBig As Int64)
  4.        Dim lowoffset() As Byte = BitConverter.GetBytes(curBig)
  5.        Dim highoffset As Int32 = BitConverter.ToInt32(lowoffset, 0)
  6.        Dim high As Int32
  7.        Dim lastbytes(3) As Byte
  8.        Array.Copy(lowoffset, 4, lastbytes, 0, 4)
  9.        high = BitConverter.ToInt32(lastbytes, 0)
  10.        NO.OffsetLow = highoffset
  11.        NO.OffsetHigh = high
  12.    End Sub

Y este es el codigo que yo hice, endianhextodec lo hice para simular lo que haria Bitconverter.ToInt32


Código
  1. long endianhextodec(BYTE *buffers, int offs){
  2.  
  3.    BYTE tmp[1] = {0};
  4.  
  5.       if(offs == 0){
  6.  
  7.        tmp[0] = buffers[0];
  8.        tmp[1] = buffers[1];
  9.        tmp[2] = buffers[2];
  10.        tmp[3] = buffers[3];
  11.  
  12.        return tmp[3] << 24;
  13.    }
  14. }
  15.  
  16.  
  17. setreadfileoffset(overlapped, (sectperclusters * (bytespercluster * MFTCluster)));
  18.  
  19.  
  20. void setreadfileoffset(OVERLAPPED overlap, INT64 crbig ){
  21.  
  22. BYTE *lowoffset = (BYTE*)malloc(sizeof(crbig));
  23. INT32 higoffset = endianhextodec(lowoffset, 0);
  24. INT32 high;
  25. BYTE lastbytes[3];
  26.  
  27. for(int i = 0; i < 4; i++){
  28. for(int n = 4; n > 0; n--){
  29.  
  30. lastbytes[i] = lowoffset[n];
  31. }
  32. }
  33.  
  34. high = endianhextodec(lastbytes, 0);
  35. overlap.Offset = higoffset;
  36. overlap.OffsetHigh = high;
  37. }

espero puedan decirme si lo encuentran bien o estoy totalmente equivocado

salu2
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 49
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines