I have a simple program that allocates memory, and copy a file from resource to that memory space, but the problem is the program exit after calling malloc function without any exception or errors. I use VS2010 express, I put a breakpoint, and when I hit F10 (step over) the program exits. here's the code :
int main(void){
    HRSRC rInfo;
    HGLOBAL rPointer;
    PVOID filePointer;
    int fileSize;
    unsigned char *buffer;
    rInfo = FindResourceA(0, MAKEINTRESOURCE(101), RT_RCDATA);
    if(rInfo == NULL){
        return 0;
    }
    rPointer = LoadResource(NULL, rInfo);
    if(rPointer == NULL){
        return 0;
    }
    filePointer = LockResource(rPointer);
    if(filePointer == NULL){
        return 0;
    }
    fileSize = SizeofResource(0, rInfo);
    if(fileSize == 0){
        return 0;
    }
    buffer = (unsigned char *)malloc(fileSize); // <-- breakpoint here
    if(buffer == NULL){
        MessageBoxA(0, "Error allocating memory.", "My App", 0);
    }else{
        MessageBoxA(0, "Allocating memory done without errors.", "My App", 0);
    }
    memcpy(buffer, stubPointer, stubSize);
}
I've verified the size returned by SizeofResource(0, rInfo); (1024 bytes, using debugger)
I don't know if you want more infos. let me know if.
