Need Help about APPCRASH

Hi friends, i have some problems with my "package unpacker tool" i'm begginer with C++
i hope someone can help me
i m usin Visual Studio 2005

Codes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ExtractPackage.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "BaseTypes.h"
#include "CPkgFile.h"

using namespace sqr;

#define  BUFFER_SIZE  4096


void ExchangeSymbol(char* szBuf, char cSrc, char cDst)
{
	char* ptr = szBuf;
	while ( *ptr != '\0' )
	{
		if ( *ptr == cSrc )
			*ptr = cDst;
		++ptr;
	}
}

const char* GetBaseName(const char* szPath)
{
	const char* ptr = szPath;
	const char* idx = NULL;
	while ( *ptr != '\0' )
	{
		if ( *ptr == '/' )
			idx = ptr;
		++ptr;
	}

	return ++idx;
}


int _tmain(int argc, _TCHAR* argv[])
{
	CPkgFile pkg;
	if ( pkg.Open(L"", argv[1]) != eFE_SUCCESS )
	{
		printf("File not found: %s\n", argv[1]);
		return 1;
	}

	int32 size = pkg.Size();
	char* szBuf = new char[size];
	pkg.Read(szBuf, size);
	pkg.Close();

	char szDir[BUFFER_SIZE];
	GetCurrentDirectory(BUFFER_SIZE, szDir);
	ExchangeSymbol(szDir, '\\', '/');
	strcat(szDir, "/");
	strcat(szDir, GetBaseName(argv[1]));

	FILE* fp = fopen(szDir, "wb");
	fwrite(szBuf, sizeof(char), size, fp);
	fclose(fp);

	delete[] szBuf;

	return 0;
}


etc: when i try to extract any package with .pkg
its "appcrash"
if needs includes i can send
Last edited on
Does that code pack or unpack? I don't see a call that indicates which operation it's doing.
@kbw
http://speedy.sh/6b9en/ExtractPackage.7z this is the source code.. unpack tool
i m still waitin kbw :(
Please use a trusted site like Pastebin if you have to put your code outside of the forums.
pastebin not workin. i cant enter site now :(
Good luck to you then.
Topic archived. No new replies allowed.