CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2009
    Posts
    219

    Problem with function

    hello

    First a piece of code

    Code:
    #include <windows.h>
    #include "Resource.h"
    #include <WinBase.h>
    #include <time.h>
    #include <math.h>
    #include <commctrl.h>
    #include "Winuser.h"
    #include <cstdio>
    #include "mspackets.h"
    
    DWORD Channel1 = 0x9B9700;
    DWORD ChannelOffset1 = 0x2058;
    
    DWORD People1 = 0x9BDB60;
    DWORD PeopleOffset1 = 0x18;//
    
    DWORD AttkReadBase1 = 0x9BDB4C;
    DWORD AttkReadOffsetCharBase1 = 0x25F0;//
    
    __inline ULONG_PTR ReadPointer(ULONG_PTR* ulBase, INT nOffset)
    {
       if ( !IsBadReadPtr((VOID*)ulBase, sizeof(ULONG_PTR)) )
            if ( !IsBadReadPtr((VOID*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(ULONG_PTR)) )
                return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
        return 0;
    }
    		
    extern BOOL CCTimeCheck;
    extern BOOL CCAttCheck;
    extern BOOL CCPplCheck;
    extern BOOL CCExit;
    
    extern BOOL CH1; 
    extern BOOL CH2; 
    extern BOOL CH3; 
    extern BOOL CH4; 
    extern BOOL CH5; 
    extern BOOL CH6; 
    extern BOOL CH7; 
    extern BOOL CH8; 
    extern BOOL CH9; 
    extern BOOL CH10;
    extern BOOL CH11; 
    extern BOOL CH12;
    extern BOOL CH13;
    extern BOOL CH14;
    
    unsigned int CCtime;
    DWORD CCAtt;
    unsigned int CCPpl;
    
    int ChangeChannel (int Functionx);
    
    
    void CC (HWND hWnd)
    {
    	
    	if (CCTimeCheck == TRUE)
    		CCtime = GetDlgItemInt(hWnd, IDC_EDITCSTIME, 0, FALSE); 
    	if (CCAttCheck == TRUE)
    		CCAtt = GetDlgItemInt(hWnd, IDC_EDITCSATT, 0, FALSE); 
    	if (CCPplCheck == TRUE)
    		CCPpl = GetDlgItemInt(hWnd, IDC_EDITCSPPL, 0, FALSE);
    	
    	while (!CCExit)
    	{
    		int RealChannel = ReadPointer((ULONG_PTR*)Channel1, ChannelOffset1 + 1);
    
    		if (CCPplCheck == TRUE && CCPpl <= ReadPointer((ULONG_PTR*)People1, PeopleOffset1 + 1))
    			ChangeChannel (RealChannel);
    
    		if (CCAttCheck == TRUE && CCAtt <= ReadPointer((ULONG_PTR*)AttkReadBase1, AttkReadOffsetCharBase1))
    			ChangeChannel (RealChannel);
    
    		Sleep(400);
    	}
    
    }		
    
    	int ChangeChannel (int Functionx)
    	{		
    		int NextChannel = Functionx + 1;
    		if (NextChannel == 15)
    			NextChannel = 1;
    
    		while ( 6 > 2){
    
    			if (CH1 == FALSE && NextChannel == 1){
                    NextChannel++;}
       
                else if ( CH1 == TRUE && NextChannel == 1){	
    			    msSendPacketA("1D0000349E7F00");
    				NextChannel++;
                    return 0;}
    		
    			if (CH2 == FALSE && NextChannel == 2){
                    NextChannel++;}
       
                else if ( CH2 == TRUE && NextChannel == 2){	
    			    msSendPacketA("1D0001349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH3 == FALSE && NextChannel == 3){
                    NextChannel++;}
       
                else if ( CH3 == TRUE && NextChannel == 3){	
    			    msSendPacketA("1D0002349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH4 == FALSE && NextChannel == 4){
                    NextChannel++;}
       
                else if ( CH4 == TRUE && NextChannel == 4){	
    			    msSendPacketA("1D0003349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH5 == FALSE && NextChannel == 5){
                    NextChannel++;}
       
                else if ( CH5 == TRUE && NextChannel == 5){	
    			    msSendPacketA("1D0004349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH6 == FALSE && NextChannel == 6){
                    NextChannel++;}
       
                else if ( CH6 == TRUE && NextChannel == 6){	
    			    msSendPacketA("1D0005349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH7 == FALSE && NextChannel == 7){
                    NextChannel++;}			
       
                else if ( CH7 == TRUE && NextChannel == 7){	
    			    msSendPacketA("1D0006349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH8 == FALSE && NextChannel == 8){
                    NextChannel++;}
       
                else if ( CH8 == TRUE && NextChannel == 8){	
    			    msSendPacketA("1D0007349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH9 == FALSE && NextChannel == 9){
                    NextChannel++;}
       
                else if ( CH9 == TRUE && NextChannel == 9){	
    			    msSendPacketA("1D0008349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH10 == FALSE && NextChannel == 10){
                    NextChannel++;}
       
                else if ( CH10 == TRUE && NextChannel == 10){	
    			    msSendPacketA("1D0009349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH11 == FALSE && NextChannel == 11){
                    NextChannel++;}
       
                else if ( CH11 == TRUE && NextChannel == 11){	
    			    msSendPacketA("1D000A349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH12 == FALSE && NextChannel == 12){
                    NextChannel++;}
       
                else if ( CH12 == TRUE && NextChannel == 12){	
    			    msSendPacketA("1D000B349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH13 == FALSE && NextChannel == 13){
                    NextChannel++;}
       
                else if ( CH13 == TRUE && NextChannel == 13){	
    			    msSendPacketA("1D000C349E7F00");
    				NextChannel++;
                    return 0;}
    
    			if (CH14 == FALSE && NextChannel == 14){
                    NextChannel = 1;}
       
                else if ( CH14 == TRUE && NextChannel == 14){	
    			    msSendPacketA("1D000D349E7F00");
    				NextChannel++;
                    return 0;}			
    		}		
    	}
    it doesnt work and idk why, it doesnt getdlgitemint, but still the function chane channel works O_o

    could it be because 1 is from DialogBox and from that dialogbox() i did CreateDialog(), and so i create another BOOL CALLBACK, idk maybe some1 can help me

    thanks at least

    EDIT: make the function shorter, its so long , is it possible? The If and Else if loops i mean in ChangeChannel()

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Problem with function

    Could you rewrite your post in English?
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2009
    Posts
    219

    Re: Problem with function

    sorry, well the problem is, the code doesnt work, and i dont know why it doesnt work

    void CC (HWND hWnd)
    {

    if (CCTimeCheck == TRUE)
    CCtime = GetDlgItemInt(hWnd, IDC_EDITCSTIME, 0, FALSE);
    if (CCAttCheck == TRUE)
    CCAtt = GetDlgItemInt(hWnd, IDC_EDITCSATT, 0, FALSE);
    if (CCPplCheck == TRUE)
    CCPpl = GetDlgItemInt(hWnd, IDC_EDITCSPPL, 0, FALSE);


    those lines, im not sure, but i believe they dont give any value,
    i tried it
    i filled myself 2 in the edit box

    if ( CCAtt == 2)
    messagbebox()

    nothing appeared

    and the last lines could those be easier written, al thsoe else and if else etc

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Problem with function

    What's a messagebebox?

    Have you tried the debugger?

  5. #5
    Join Date
    Aug 2009
    Posts
    219

    Re: Problem with function

    i ment

    MessageBox()

    how does the debgger works? O_o

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Problem with function

    Quote Originally Posted by NLscotty View Post
    i ment

    MessageBox()

    how does the debgger works? O_o
    MSDN will explain it better than I could. It's an essential tool for a programmer. Not optional at all. More than likely it would point out your problem in seconds.

  7. #7
    Join Date
    Aug 2009
    Posts
    219

    Re: Problem with function

    oki i tried, but the problem is i try to attach it at maplestory, packed with themida, or if i run the process, a debugger tries to ..... into process

    So its not an option

  8. #8
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Problem with function

    Quote Originally Posted by NLscotty View Post
    oki i tried, but the problem is i try to attach it at maplestory, packed with themida, or if i run the process, a debugger tries to ..... into process

    So its not an option
    What is "maplestory"?

    You should plan ahead next time -- you can't write a program and expect never to debug it. Remove the calls to "maplestory" and debug that program instead.

    Regards,

    Paul McKenzie

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Problem with function

    Quote Originally Posted by NLscotty View Post
    oki i tried, but the problem is i try to attach it at maplestory, packed with themida, or if i run the process, a debugger tries to ..... into process

    So its not an option
    That makes no sense at all. maplestory, themida and ..... are meaningless to pretty much anybody reading your post.

    Compile your project using debug settings and run it in the debugger.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured