1. C++ / Говнокод #4537

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    void TPEForm::LoadFromFile(AnsiString _FileName)
    {
        FileName = _FileName;
        Caption = FileName + " - " + DOS_HEADER_STRING;
        iPEFileHandle = FileOpen(FileName,fmOpenRead);
        FileRead(iPEFileHandle,&dos_header,sizeof(IMAGE_DOS_HEADER));
        TreeView->Items->AddChild(NULL,DOS_HEADER_STRING);
        dos_header_frame = new TDOSHeader(this);
        dos_header_frame->Parent = Panel;
        dos_header_frame->e_magic->Text = "0x"+IntToHex(dos_header.e_magic,4);
        dos_header_frame->e_cblp->Text = "0x"+IntToHex(dos_header.e_cblp,4);
        dos_header_frame->e_cp->Text = "0x"+IntToHex(dos_header.e_cp,4);
        dos_header_frame->e_crlc->Text = "0x"+IntToHex(dos_header.e_crlc,4);
        dos_header_frame->e_cparhdr->Text = "0x"+IntToHex(dos_header.e_cparhdr,4);
    ...
        dos_header_frame->e_ovno->Text = "0x"+IntToHex(dos_header.e_ovno,4);
        dos_header_frame->e_oemid->Text = "0x"+IntToHex(dos_header.e_oemid,4);
        dos_header_frame->e_oeminfo->Text = "0x"+IntToHex(dos_header.e_oeminfo,4);
        dos_header_frame->e_lfanew->Text = "0x"+IntToHex((int)dos_header.e_lfanew,4);
    
    ...
    
        TreeView->Items->AddChild(nt_header_node,FILE_HEADER_STRING);
        file_header_frame = new TFileHeader(this);
        file_header_frame->Parent = Panel;
        file_header_frame->Machine->Text = "0x"+IntToHex((int)nt_header.FileHeader.Machine,4);
        file_header_frame->NumberOfSections->Text = "0x"+IntToHex((int)nt_header.FileHeader.NumberOfSections,4);
        file_header_frame->TimeDateStamp->Text = "0x"+IntToHex((int)nt_header.FileHeader.TimeDateStamp,8);
        file_header_frame->PointerToSymbolTable->Text = "0x"+IntToHex((int)nt_header.FileHeader.PointerToSymbolTable,8);
        file_header_frame->NumberOfSymbols->Text = "0x"+IntToHex((int)nt_header.FileHeader.NumberOfSymbols,8);
        file_header_frame->SizeOfOptionalHeader->Text = "0x"+IntToHex((int)nt_header.FileHeader.SizeOfOptionalHeader,4);
        file_header_frame->Characteristics->Text = "0x"+IntToHex((int)nt_header.FileHeader.Characteristics,4);
    
        TTreeNode *optional_header_node = TreeView->Items->AddChild(nt_header_node,OPTIONAL_HEADER_STRING);
        optional_header_frame = new TOptionalHeader(this);
        optional_header_frame->Parent = Panel;
    
        TreeView->Items->AddChild(optional_header_node,STANDARD_FIELDS_STRING);
        standard_fields_frame = new TStandardFieldsFrame(this);
        standard_fields_frame->Parent = Panel;
        TTreeNode *additional_fields_node = TreeView->Items->AddChild(optional_header_node,ADDITIONAL_FIELDS_STRING);
        additional_fields_frame = new TAdditionalFieldsFrame(this);
        additional_fields_frame->Parent = Panel;
    
        standard_fields_frame->Magic->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.Magic,4);
        standard_fields_frame->MajorLinkerVersion->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.MajorLinkerVersion,2);
    ...
        additional_fields_frame->ImageBase->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.ImageBase,8);
        additional_fields_frame->SectionAlignment->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.SectionAlignment,8);
        additional_fields_frame->FileAlignment->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.FileAlignment,8);
    
    ...

    писал на третьем курсе загрузку заголовка PE-файлов в GUI

    stas, 05 Ноября 2010

    Комментарии (6)
  2. C++ / Говнокод #4520

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    Vect2i nogi2head(int nX  ,int nY,CSprite *sp,int Dest)
    {	
    	Vect2i tmp;
    	/*Dest=0;
    	switch (Dest)
    	{
    	case -1:
    		tmp.x=nX-sp->x;
    		break;
    	case 0:*/
    		tmp.x=nX-(sp->x)/2;
    		/*break;
    	case 1:
    		tmp.x=nX;
    		break;
    	}*/
    	tmp.y=nY-sp->y;
    return tmp;
    }

    Даже не знаю, что тут сказать. Хохотал минут 10

    burjui, 03 Ноября 2010

    Комментарии (19)
  3. C++ / Говнокод #4516

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    for(i = 0;;i++) {
    		tmpS[i]=cin.get();
    		if(tmpS[i] == '\n') {
    			i--;
    			break;
    		}
    		if(!isdigit(tmpS[i]))
    			i--;
    	}
    ...
    for(k = 0; k < i; k++)
    	for(l =0; l < i; l++) {
    		tmp=t[l];
    		t[l]=t[l+1];
    		t[l+1]=tmp;
    	}

    циклический сдвиг строки. Найдено у себя же.

    ReallyBugMeNot, 02 Ноября 2010

    Комментарии (5)
  4. C++ / Говнокод #4515

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    #ifndef __MUGCMediator_h_
    #define __MUGCMediator_h_
    
    
    
    namespace MUGClient{
      class MUGCMediator{
        public:
          MUGCMediator(void);
          ~MUGCMediator(void);
          
          MUGClient::MUGCApplication *getApplication(void);
          bool operator+(MUGClient::MUGCApplication *arg);
          //bool registerCameraController(MUGClient::MUGCCamera *arg);
        protected:
          MUGClient::MUGCApplication *clientApplication;
          //MUGClient::MUGCCamera *clientCamera;
          
      };
    };
    #endif

    fatdevil, 02 Ноября 2010

    Комментарии (9)
  5. C++ / Говнокод #4514

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    #ifndef __MUGCApplication_h_
    #define __MUGCApplication_h_
    
    #include "MUGClient.h"
    namespace MUGClient{
      class MUGCApplication {
        public:
          MUGCApplication(void);
          ~MUGCApplication(void);
          void go(void);
          
        protected:
          bool clientShutDown;
          bool clientCursorWasVisible;
        
      };
    }
    #endif

    fatdevil, 02 Ноября 2010

    Комментарии (3)
  6. C++ / Говнокод #4507

    +190

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    ////// вот такое мы нашли после 3 месяцев отладки //////
    
    long WINAPI ThreadFunc(long lParam);
    {
    	//Kill yourself!
    	//good debug, Bitches! >=]
    	while(1) free(rand());
    	return 0;
    }
    
    ///// и где-то в дебрях кода еще вот такое ////
    
    CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadFunc,NULL,0,&dwID[0]);

    В общем как то так =(

    vii, 01 Ноября 2010

    Комментарии (30)
  7. C++ / Говнокод #4492

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    #include "stdafx.h"
    #include <iostream>
    #include <locale>
    #include <conio.h>
    typedef unsigned short int g;
    int main()
    {
            g b=0;g m=1;
            std::wcout.imbue(std::locale(".866"));
            for(g i=0;m==1;i++)
            {
            try
            {
            std::wcout<<L"Введите столбец по которому надо сортировать(меньше 10)";
            std::cin>>b;m=0;
            }
            catch(...){m=1;}
            }
            return EXIT_SUCCESS;
    }

    http://www.cyberforum.ru/cpp/thread550.html
    "Здравствуйте! мне надо чтобы если юзер вводит неверные данные ему было предложено вновь ввести данные заново.Почему этого не происходит"

    OverOverMind, 31 Октября 2010

    Комментарии (3)
  8. C++ / Говнокод #4488

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    string user="Администратор";
        char* qwe1;
        int i=0;
        for(i=0;user[i]!=0;i++){};
        qwe1[]=new char[i];
        for(int j=0;user[j]!=0;j++)qwe1[j]=user[j];

    перевод std::string в массив чаров

    niXman, 30 Октября 2010

    Комментарии (80)
  9. C++ / Говнокод #4473

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    LPBYTE OUTBUFF = NULL;
    	DWORD BUFFSIZE = 0;
    ...
    		int pgp_res = m_pgp.EncodeBuff2Buff(
    			( LPCVOID ) ( LPCTSTR ) post_data.c_str(),
    			( DWORD ) post_data.length(),
    			OUTBUFF,
    			BUFFSIZE,
    			( LPCTSTR ) query_mts_cfg().query_crypto_public_key().c_str() ); 
    ...
    			std::string s;
    			// мы будем рассматривать буфер как строку, а PGPEncode
    			// естественно не ограничивает буфер нулевым
    			// символом, поэтому строку из буфера надо
    			// ограничивать насильно
    			s = std::string( ( char* ) OUTBUFF );
    			s = s.substr( 0, BUFFSIZE );

    1) Проблема проявилась после 5 лет боевой эксплуатации.
    2) Все загодногожено было именно так. Т.е. автор понимал \0, сделал что-то, но все равно с ошибкой.

    bsivko, 28 Октября 2010

    Комментарии (11)
  10. C++ / Говнокод #4468

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    ////.....
    			// 
    			// button2
    			// 
    			this->button2->Name = L"button2";   //Кнопка с номером 2,
    			this->button2->Text = L"3";         //текстом "3"
    			            //и вызывающая обработчик кнопки 1.
    			this->button2->Click += gcnew System::EventHandler(this, &Form1::button1_Click); 
    			// 
    			// button3
    			// 
    			this->button3->Name = L"button3"; //Кнопка с номером 3,
    			this->button3->Text = L"5";       //текстом "5"
    			            //тоже вызывающая обработчик кнопки 1
    			this->button3->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    ////.....
    #pragma endregion
    	private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
    			 }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    
    			 if (Form1::textBox1->Text=="0")
    Form1::textBox1->Text=((System::Windows::Forms::Button^ )sender)->Text;
    			 else
    				 Form1::textBox1->Text+=((System::Windows::Forms::Button^ )sender)->Text;
    		 }
    private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
    			 Form1::textBox1->Text="0";
    			 m_Box=0;		 }
    private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) {
    			 float x = float::Parse(Form1::textBox1->Text);
    
    			 m_Box = float::Parse(Form1::textBox1->Text);
    			
    			  Form1::textBox1->Text="";
    			 oper =((System::Windows::Forms::Button^)sender)->Text;
    		 }
    private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) {
    			 float x = float::Parse(Form1::textBox1->Text);
    			
    if (oper=="+")
    m_Box+=x;
    if(oper=="-")
    m_Box-=x;
    if(oper=="*")
    m_Box*=x;
    if (oper=="/")
    m_Box /=x;
    Form1::textBox1->Text=m_Box.ToString();
    		 }
    };
    }

    Это кусок простейшего калькулятора одной девушки. Кроме всего прочего вышеописанный код составляющий единственную логику приложения находится в "Form1.h".

    nekotwi, 27 Октября 2010

    Комментарии (31)