Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Simple Hexdump In C/c++ Win32 Api - By #m0Rph ;p

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    C / C++ Simple Hexdump In C/c++ Win32 Api - By #m0Rph ;p

    Iae galera.... Tudo de boas?

    Fiz um simples HexDump em C/C++, espero que gostem.

    Print!






    Source:

    Código PHP:
    #define WINVER 0x0501
    #define _WIN32_WINNT 0x0501
    #include <stdio.h>
    #include <windows.h>
    #include <richedit.h>
    #include <winuser.h>

    HWND hwnd;               /* This is the handle for our window */
    DWORD dwThreadId;
    DWORD ThreadProc  (LPVOID lpdwThreadParam );

    HWND button1,button2,button3richedit1;
    #define bt1   1001
    #define bt2   1003
    #define bt3   1004
    #define rich1 1002
    int dump(char *arqui){
    const 
    int conta=16;
        
    FILE *arquivo;
        
    FILE *gravar;
        
    char a[16];
        
    char str_a[9];
        
    int jk;
        
    arquivo fopen(arqui,"r+b");
        
    gravar  fopen("dumpede.txt","w");
        while(!
    feof(arquivo)){
            
    fgets(a,16,arquivo);
            for(
    int i=0;i<conta;i++){
                
    jk a[i];
                
    sprintf(str_a"%X"jk);
                if (
    jk == || jk == || jk == || jk == 3|| jk == || jk == || jk == || jk == || jk == || jk == || jk == 10 || jk == 11 || jk == 12 || jk == 13 || jk == 14 || jk == 15){
                    
    fprintf(gravar"0%X",jk);
                }
                else if(
    strlen(str_a) == 8){
                    
    fprintf(gravar,str_a+6);
                }else{
                    
    fprintf(gravar"%X",jk);
                }
                
    fprintf(gravar" ");
            }
            
    fprintf(gravar"  ");
            for(
    int u=0;u<conta;u++){
                
    jk a[u];
                if (
    jk >= 32 && jk <= 126){
                    
    putc((char)jk,gravar);
                }
                else{
                    
    fprintf(gravar"_");
                }
            }
            
    fprintf(gravar"\n");
        }
      
        
    MessageBox(0,"Dump complete!","Dump",MB_ICONINFORMATION);
        
    //cout << "A analise terminou!"<< endl;
        //getche();
        
    fclose(arquivo);
        
    fclose(gravar);  
      
    }

    /*  Declare Windows procedure  */
    LRESULT CALLBACK WindowProcedure (HWNDUINTWPARAMLPARAM);
    /*  Make the class name into a global variable  */
    char szClassName[ ] = "WindowsApp";
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        
    HINSTANCE hPrevInstance,
                        
    LPSTR lpszArgument,
                        
    int nFunsterStil)
    {
        
    MSG messages;            /* Here messages to the application are saved */
        
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
        /* The Window structure */
        
    wincl.hInstance hThisInstance;
        
    wincl.lpszClassName szClassName;
        
    wincl.lpfnWndProc WindowProcedure;      /* This function is called by windows */
        
    wincl.style CS_DBLCLKS;                 /* Catch double-clicks */
        
    wincl.cbSize sizeof (WNDCLASSEX);
        
    /* Use default icon and mouse-pointer */
        
    wincl.hIcon LoadIcon (NULLIDI_APPLICATION);
        
    wincl.hIconSm LoadIcon (NULLIDI_APPLICATION);
        
    wincl.hCursor LoadCursor (NULLIDC_ARROW);
        
    wincl.lpszMenuName NULL;                 /* No menu */
        
    wincl.cbClsExtra 0;                      /* No extra bytes after the window class */
        
    wincl.cbWndExtra 0;                      /* structure or the window instance */
        /* Use Windows's default color as the background of the window */
        
    wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW 2);//(HBRUSH) COLOR_BACKGROUND;
        /* Register the window class, and if it fails quit the program */
        
    if (!RegisterClassEx (&wincl))
            return 
    0;
        
    /* The class is registered, let's create the program*/
        
    hwnd CreateWindowEx (
               
    0,                   /* Extended possibilites for variation */
               
    szClassName,         /* Classname */
               
    "Simple HexDump in C/C++ WIN32 API - By #M0rph",       /* Title Text */
               
    WS_SYSMENU/* default window */
               
    CW_USEDEFAULT,       /* Windows decides the position */
               
    CW_USEDEFAULT,       /* where the window ends up on the screen */
               
    815,                 /* The programs width */
               
    550,                 /* and height in pixels */
               
    HWND_DESKTOP,        /* The window is a child-window to desktop */
               
    NULL,                /* No menu */
               
    hThisInstance,       /* Program Instance handler */
               
    NULL                 /* No Window Creation data */
               
    );
        
    /* Make the window visible on the screen */
        //ShowWindow (hwnd, nFunsterStil);
        
    AnimateWindow(hwnd2000AW_BLEND|AW_HOR_POSITIVE);
        
    /* Run the message loop. It will run until GetMessage() returns 0 */
        
    while (GetMessage (&messagesNULL00))
        {
            
    /* Translate virtual-key messages into character messages */
            
    TranslateMessage(&messages);
            
    /* Send message to WindowProcedure */
            
    DispatchMessage(&messages);
        }
        
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
        
    return messages.wParam;
    }
    HFONT hFont;
    /*  This function is called by the Windows function DispatchMessage()  */
    LRESULT CALLBACK WindowProcedure (HWND hwndUINT messageWPARAM wParamLPARAM lParam)
    {
        switch (
    message)                  /* handle the messages */
        
    {  
            case 
    WM_CREATE:
                 
    LoadLibrary("riched20.dll");
                
                 
    button1 CreateWindow(TEXT("button"),TEXT("Dump"),
                 
    WS_CHILD WS_VISIBLE WS_BORDER,
                 
    10,10,80,25,
                 
    hwnd,(HMENU)bt1,NULL,NULL);
                
                 
    richedit1 CreateWindow(RICHEDIT_CLASS,TEXT(""),
                 
    WS_CHILD WS_VISIBLE WS_HSCROLL |
                 
    WS_VSCROLL ES_LEFT ES_MULTILINE |
                 
    ES_AUTOHSCROLL ES_AUTOVSCROLL|WS_BORDER,
                 
    10,40,780,465,
                 
    hwnd,(HMENU)rich1,NULL,NULL);
                
                   
    HFONT font;
                   
    font=CreateFont(18,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                        
    CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITYVARIABLE_PITCH,TEXT("Lucida Console"));
            
             
    SendMessage(richedit1,WM_SETFONT,(WPARAMfont,MAKELPARAM(TRUE0));
             
    SendMessage(button1,WM_SETFONT,(WPARAMfont,MAKELPARAM(TRUE0));
                
                 break;
            case 
    WM_COMMAND:
                
                 if(
    LOWORD(wParam) == bt1){
                    
                      if (
    CreateThread(NULL,0, (LPTHREAD_START_ROUTINE)&ThreadProc,(LPVOID1,0,&dwThreadId) == NULL){
                           
    MessageBox(NULL,"Erro Creating Thread!","Hello",MB_ICONINFORMATION);
                       }
                                  
                 }
      
                 break;
            case 
    WM_SETFOCUS:
                 
    SetFocus(richedit1);
                 return 
    0;
            case 
    WM_CLOSE:
                 
    AnimateWindow(hwnd9000AW_BLEND);
                 
    ExitProcess(0);
                 break;
            case 
    WM_DESTROY:
                 
    //AnimateWindow(hwnd, 2000, AW_BLEND);
                
    PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                
    break;
            default:                      
    /* for messages that we don't deal with */
                
    return DefWindowProc (hwndmessagewParamlParam);
        }
        return 
    0;
    }

    //Thread Routine
    DWORD ThreadProc (LPVOID lpdwThreadParam )
    {  
         
    OPENFILENAME ofn;
         
    char szFileName[MAX_PATH] = "";
         
    ZeroMemory(&ofnsizeof(ofn));
         
    ofn.lStructSize sizeof(ofn);
         
    ofn.hwndOwner hwnd;
         
    ofn.lpstrFilter "EXE Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0";
         
    ofn.lpstrFile szFileName;
         
    ofn.nMaxFile MAX_PATH;
         
    ofn.Flags OFN_EXPLORER OFN_FILEMUSTEXIST OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT;
         
    ofn.lpstrDefExt "exe";
         if(
    GetOpenFileName(&ofn))
         {                      
             
    //MessageBox(NULL,szFileName,"",MB_ICONINFORMATION);
         
    }
        
         
    dump(szFileName);
      
        
    char buffer[MAX_PATH];
        
    FILE *ui;
        
    ui fopen("dumpede.txt","r");
        
    char str[1000000];
        while(!
    feof(ui)){
           
    fgets(str,1000000,ui);
           
    SendMessage((HWND)richedit1,(UINTEM_REPLACESEL, (WPARAM)1,(LPARAM)str);
        }
      
        return 
    0;

    Last edited by SunGlaSS; 02-06-2012, 12:31.
    "Nunca desista de seus sonhos. Desisti de seus sonhos é abrir mão da felicidade."
    (Augusto Cury)



    Meu Blog... http://www.lab-infor.blogspot.com
    Meu canal do Youtube... http://www.youtube.com/user/rodrigo32323232
X
Working...
X