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

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: 1 [2]
11  Programación / Programación C/C++ / Re: [C++] Downloader en: 7 Agosto 2011, 21:28 pm
Ese código contiene algunos errores tipográficos, corrígelos.  :D

Saludos.
12  Programación / Programación C/C++ / Re: ayuda con programa en c y winapi que lista los directorios en un listview en: 7 Agosto 2011, 16:23 pm
Siento responder tarde, estuve de vacaciones...
Te muestro alguna modificación:

Código:
#include <windows.h>

#include  <stdio.h>
#include  <commctrl.h>

#pragma comment(lib, "comctl32.lib")

#define  ID_LISTVIEW    1

char directory[MAX_PATH]="C:\\";


typedef struct
{
   char  szItem[MAX_PATH];
}Item;

int AddIcon(WIN32_FIND_DATA WFData)
{
   SHFILEINFO fi;
   DWORD Flags =  SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES;

   if(WFData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
     SHGetFileInfo("", FILE_ATTRIBUTE_DIRECTORY, &fi, sizeof(SHFILEINFO), Flags);
   else
     SHGetFileInfo(WFData.cFileName, WFData.dwFileAttributes, &fi, sizeof(SHFILEINFO), Flags);

   return fi.iIcon;
}

BOOL WINAPI InitListViewImageLists(HWND hwndLV)
{
   DWORD Flags = SHGFI_SYSICONINDEX | SHGFI_SMALLICON;
   SHFILEINFO fi = {0};
   int SystemSmallIcons = SHGetFileInfo("", 0, &fi, sizeof(SHFILEINFO), Flags);
   ListView_SetImageList(hwndLV, SystemSmallIcons, LVSIL_SMALL);

   return TRUE;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   static   CREATESTRUCT   *cs;
   static   HWND           hWndListView;
   static   HFONT          hFont;
   static   LV_ITEM        lv;
   static   Item           listitemm;
   static   Item*          ListItem;// = (Item* )LocalAlloc(LPTR, sizeof(Item));
   int i;
   HANDLE                  hFile;
   LV_COLUMN               lvC;
   RECT                    rect;
   char path[MAX_PATH];
   char temp[MAX_PATH];
   strcpy(path,directory);
   strcat(path, "*.*");
   WIN32_FIND_DATA data;

   LV_DISPINFO             *lvd;
   NMHDR                   *hdr;

   ListItem = &listitemm;

   switch (iMsg){
     case WM_CREATE :
       cs = (CREATESTRUCT *)lParam;
       hWndListView = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW,
          "", WS_VISIBLE | WS_CHILD | LVS_LIST,
          0, 0, 100, 100, hwnd,(HMENU)ID_LISTVIEW, cs->hInstance, NULL);

//       ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_FULLROWSELECT);
       lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
       lvC.fmt = LVCFMT_LEFT;
       hFile = FindFirstFile(path, &data);
    strcpy(ListItem->szItem, data.cFileName);
     strcpy(temp, directory);
     strcat(temp,data.cFileName);
       lvC.iSubItem = 0;
       lvC.cx = 100;
   i=1;
     InitListViewImageLists(hWndListView);
       while(FindNextFile(hFile,&data)!=0){
         strcpy(temp, directory);
       strcat(temp, data.cFileName);
         strcpy(data.cFileName, temp);
         char *FileName = strrchr(data.cFileName, '\\');
         lv.mask = LVIF_TEXT | LVIF_IMAGE;
         lv.iSubItem = 0;
         lv.pszText = FileName+1;
         lv.iImage = AddIcon(data);
         ListView_InsertItem(hWndListView, &lv);
         i++;
      }
      FindClose(hFile);
  break;

   case WM_SIZE :
      GetClientRect(hwnd, &rect);
      MoveWindow(hWndListView, 3, 3, rect.right - 6, rect.bottom - 6, 1);
      break;

   case WM_NOTIFY :
      switch(((LPNMHDR)lParam)->code)
      {
      case NM_DBLCLK :
         hdr = (NMHDR FAR*)lParam;
         if(hdr->hwndFrom == hWndListView)
         {
//            index = ListView_GetNextItem(hWndListView,-1,LVNI_SELECTED);
           /* if(index != -1)
            {
               MessageBox(hwnd, ListItem[index].szItem, "Doubleclicked on this item", MB_OK);
            }*/
         }
         break;

      case LVN_GETDISPINFO :
         lvd = (LV_DISPINFO FAR*)lParam;
         if((((LPNMHDR)lParam)->hwndFrom == hWndListView))
         {
           
if(lvd->item.iSubItem==0)
            {
               lvd->item.pszText = ListItem[lvd->item.iItem].szItem;
            }
             
            break;
         }
      }
      break;

   case WM_CLOSE :
      DestroyWindow(hwnd);
      break;

   case WM_DESTROY :
      DeleteObject(hFont);
      PostQuitMessage(0);
      break;
   }
   return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
   HWND                    hwnd;
   MSG                     msg;
   WNDCLASS                wndclass;
   char                    szAppName[] = "ListviewApp";
   INITCOMMONCONTROLSEX    icex;

   wndclass.style         = 0;
   wndclass.lpfnWndProc   = WndProc;
   wndclass.cbClsExtra    = 0;
   wndclass.cbWndExtra    = 0;
   wndclass.hInstance     = hInstance;
   wndclass.hIcon         = LoadIcon(hInstance, szAppName);
   wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
   wndclass.lpszMenuName  = szAppName;
   wndclass.lpszClassName = szAppName;
   RegisterClass(&wndclass);

   icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
   icex.dwICC = ICC_LISTVIEW_CLASSES;
   InitCommonControlsEx(&icex);

   hwnd = CreateWindow(szAppName, szAppName,
      WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 600, 250,
      NULL, NULL, hInstance, szCmdLine);

   while (GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   return (int)msg.wParam;
}

Espero que te ayude en algo.

Saludos.
13  Foros Generales / Dudas Generales / Problema con InternetOpenURL en: 1 Junio 2010, 22:41 pm
He observado que tengo un problema con la API InternetOpenURL. Desde hace poco no me funciona en programas que iban bien. Ahora no funciona en absoluto desde mi cuenta de administrador pero si desde otras en la misma máquina.

Devuelve siempre cero y el resultado de  GetLastError es nulo, como si no hubiese error, igual que el test con InternetGetLastResponseInfo.

Como sólo ocurre con la cuenta de administrador en Windows XP, anulé el cortafuegos y el AV, pero sigue igual. He cerrado procesos, por si alguno lo provocase, pero no tengo éxito, así que empiezo a sospechar de alguna infección.

¿Que opináis?

Saludos.
14  Programación / Java / Re: Leyendo imagen de formato .pgm en: 31 Octubre 2009, 00:19 am

Código:
int nivel = 0;
for(int i=0 ; i<alto ; i++)
{
  for(int j=0 ; j<ancho ; j++)
 {
    nivel = ((int)imagen.charAt(i*ancho+j));

    //Esto lo hago por el error para que sea un valor comprendido entre 0-255
    //No debería pasar esto.
    if(nivel>255)
    {
nivel = 255;
    }

    g.setColor(new Color(nivel,nivel,nivel));
    g.drawOval(iniX+j,iniY+i,1,1);
 }
}


El problema lo tienes en la conversión de Byte a int en nivel = ((int)imagen.charAt(i*ancho+j));  define como char la variable nivel.

Saludos.
15  Seguridad Informática / Análisis y Diseño de Malware / Re: Introducción a la programación de drivers en Windows en: 19 Enero 2009, 20:24 pm
He estado siguiendo con mucho interés este hilo y me ha parecido muy bueno. Doy las gracias sinceras a Hendrix por su trabajo y darme la oportunidad de aprender a programas drivers.

He hecho prácticas con el Hook a ZwOpenProcess y me a funcionado bien.
Saludos.

PD:
Quisiera aportar al hilo otra forma de conseguir un Hook, por ejemplo a la misma API mencionada:

Código:
VOID Hook()
{
   _asm cli
   ZwOpenProcessIni =(PZwOpenProcess)(SYSTEMSERVICE(ZwOpenProcess));
   (PZwOpenProcess)(SYSTEMSERVICE(ZwOpenProcess)) = NewZwOpenProcess;
   _asm sti
}

VOID UnHook()
{
   _asm cli
   (PZwOpenProcess)(SYSTEMSERVICE(ZwOpenProcess)) = ZwOpenProcessIni;
   _asm sti
}

// SYSTEMSERVICE es la macro que se describe en este hilo

Saludos.
Páginas: 1 [2]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines