-
Dec 30th, 2014, 07:28 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Build Console
Can someone build me this console , because for me not working right vs 2010
and share me project source thanks
Code:
// MuError Decoder.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#pragma comment(lib, "th32.lib")
//And make sure you have your headers at the top of any .cpp files:
#define _WIN32_WINNT 0x0501 // WinXP only.
#define VC_EXTRALEAN
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <shlwapi.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
HANDLE hEvent;
HANDLE hInput;
HANDLE hOutput;
#define BUF_SIZE (16)
BYTE bKey[BUF_SIZE] = { 0x7C, 0xBD, 0x81, 0x9F, 0x3D, 0x93, 0xE2, 0x56, 0x2A, 0x73, 0xD2, 0x3E, 0xF2, 0x83, 0x95, 0xBF };
int AsyncFileRead()
{
CHAR szBuffer[BUF_SIZE];
DWORD dwBytesToRead = BUF_SIZE;
DWORD dwBytesRead = 0;
DWORD dwBytesWritten = 0;
INT iKeyOffset = 0;
OVERLAPPED stOverlapped = {0};
BOOL bResult = FALSE;
BOOL bContinue = TRUE;
stOverlapped.hEvent = hEvent;
while (bContinue)
{
bContinue = FALSE;
memset(szBuffer, 0x00, sizeof(szBuffer));
bResult = ReadFile(hInput, szBuffer, dwBytesToRead, &dwBytesRead, &stOverlapped);
if (!bResult)
{
BOOL bPending = TRUE;
while (bPending)
{
bPending = FALSE;
bResult = GetOverlappedResult(hInput, &stOverlapped, &dwBytesRead, FALSE);
if (!bResult)
{
bPending = TRUE;
bContinue = TRUE;
}
else
{
ResetEvent(stOverlapped.hEvent);
}
}
}
for (INT i=0; i<(INT)dwBytesToRead; i++)
{
if (i >= (INT)dwBytesRead)
{
break;
}
szBuffer[i] = szBuffer[i] ^ bKey[iKeyOffset];
iKeyOffset++;
if (iKeyOffset >= (INT)dwBytesToRead)
{
iKeyOffset = 0;
}
}
WriteFile(hOutput, szBuffer, dwBytesRead, &dwBytesWritten, NULL);
stOverlapped.Offset += dwBytesRead;
if (stOverlapped.Offset < GetFileSize(hInput, NULL))
{
bContinue = TRUE;
}
else
{
return 1;
}
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
char szXorFile[MAX_PATH];
SetConsoleTitle("XOR Decoder (by Young)");
printf("|----------------------------------------------------------|\r\n| XOR Decoder for WebZen MuError Log 0.1 |\r\n| by Young (http://forum.ragezone.com/members/147136.html) |\r\n|----------------------------------------------------------|\r\n\r\n");
printf("Reading xordec.ini... ");
GetPrivateProfileString("DEFAULT", "XorFile", "MuError.log", szXorFile, MAX_PATH, ".//xordec.ini");
if (GetLastError() != ERROR_SUCCESS)
{
printf("ERROR! Using default configuration.\r\n");
}
else
{
printf("DONE!\r\n");
}
printf("Reading %s... ", szXorFile);
hInput = (HANDLE)CreateFile(szXorFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (hInput == INVALID_HANDLE_VALUE)
{
printf("File not found or access denied.\r\n", szXorFile);
system("PAUSE");
return 0;
}
printf("DONE!\r\n");
printf("Creating Output.txt... ", szXorFile);
hOutput = (HANDLE)CreateFile("Output.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hOutput == INVALID_HANDLE_VALUE)
{
printf("Access denied or full disk.\r\n");
system("PAUSE");
return 0;
}
printf("DONE!\r\n");
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent == NULL)
{
printf("WOW! Unable to create the event for the async file read.\r\n");
system("PAUSE");
return 0;
}
UINT iTickCount = GetTickCount();
printf("Decoding %s... ", szXorFile);
if (AsyncFileRead() == 0)
{
printf("Unknow error reading/writing the file.\r\n");
system("PAUSE");
return 0;
}
printf("DONE!\r\n\r\nBytes read: %d\r\nElapsed time: %ds\r\n", GetFileSize(hInput, NULL), (GetTickCount() - iTickCount) / 1000);
CloseHandle(hInput);
CloseHandle(hOutput);
ShellExecute(NULL, "open", "notepad.exe", ".//Output.txt", NULL, SW_SHOWNORMAL);
system("PAUSE");
return 0;
}
-
Dec 30th, 2014, 07:45 AM
#2
Re: Build Console
You have 2 functions called _tmain(). I suspect you need to remove this one
Code:
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Dec 30th, 2014, 08:24 AM
#3
Thread Starter
Fanatic Member
Re: Build Console
still the same, can you build an console project with this code?
-
Dec 30th, 2014, 08:36 AM
#4
Re: Build Console
Still same what? Presumably you're getting an error of some kind, yes? Well since none of us are clairvoyant and none of us (as far as I know at any rate) are sitting in your lap, we cannot see what you're seeing. Given the lack of details, all I can assume is that your fingers have fallen off (some would consider that a problem). Remove the eels from your hover craft and re-compile.
-tg
-
Dec 30th, 2014, 10:56 AM
#5
Thread Starter
Fanatic Member
Re: Build Console
Edit: one moment
Error 1 error C2061: syntax error : identifier '_TCHAR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 93 1 MuError Decoder
Error 2 error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [23]' to 'LPCWSTR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 97 1 MuError Decoder
Error 3 error C2664: 'GetPrivateProfileStringW' : cannot convert parameter 1 from 'const char [8]' to 'LPCWSTR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 102 1 MuError Decoder
Error 4 error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char [260]' to 'LPCWSTR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 113 1 MuError Decoder
Error 5 error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 123 1 MuError Decoder
Error 6 error C2664: 'ShellExecuteW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 153 1 MuError Decoder
7 IntelliSense: identifier "_TCHAR" is undefined c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 93 22 MuError Decoder
8 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 97 18 MuError Decoder
9 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 102 26 MuError Decoder
10 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 102 37 MuError Decoder
11 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 102 48 MuError Decoder
12 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 102 63 MuError Decoder
13 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 102 84 MuError Decoder
14 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 113 30 MuError Decoder
15 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 123 31 MuError Decoder
16 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 153 21 MuError Decoder
17 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 153 29 MuError Decoder
18 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 153 44 MuError Decoder
Last edited by diablo21; Dec 30th, 2014 at 11:02 AM.
-
Dec 30th, 2014, 11:02 AM
#6
Re: Build Console
This compiles for me as c code
Code:
// MuError Decoder.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#pragma comment(lib, "th32.lib")
//And make sure you have your headers at the top of any .cpp files:
#define _WIN32_WINNT 0x0501 // WinXP only.
#define VC_EXTRALEAN
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <shlwapi.h>
HANDLE hEvent;
HANDLE hInput;
HANDLE hOutput;
#define BUF_SIZE (16)
BYTE bKey[BUF_SIZE] = { 0x7C, 0xBD, 0x81, 0x9F, 0x3D, 0x93, 0xE2, 0x56, 0x2A, 0x73, 0xD2, 0x3E, 0xF2, 0x83, 0x95, 0xBF };
int AsyncFileRead()
{
CHAR szBuffer[BUF_SIZE];
DWORD dwBytesToRead = BUF_SIZE;
DWORD dwBytesRead = 0;
DWORD dwBytesWritten = 0;
INT iKeyOffset = 0;
OVERLAPPED stOverlapped = { 0 };
BOOL bResult = FALSE;
BOOL bContinue = TRUE;
stOverlapped.hEvent = hEvent;
while (bContinue)
{
bContinue = FALSE;
memset(szBuffer, 0x00, sizeof(szBuffer));
bResult = ReadFile(hInput, szBuffer, dwBytesToRead, &dwBytesRead, &stOverlapped);
if (!bResult)
{
BOOL bPending = TRUE;
while (bPending)
{
bPending = FALSE;
bResult = GetOverlappedResult(hInput, &stOverlapped, &dwBytesRead, FALSE);
if (!bResult)
{
bPending = TRUE;
bContinue = TRUE;
}
else
{
ResetEvent(stOverlapped.hEvent);
}
}
}
for (INT i = 0; i<(INT)dwBytesToRead; i++)
{
if (i >= (INT)dwBytesRead)
{
break;
}
szBuffer[i] = szBuffer[i] ^ bKey[iKeyOffset];
iKeyOffset++;
if (iKeyOffset >= (INT)dwBytesToRead)
{
iKeyOffset = 0;
}
}
WriteFile(hOutput, szBuffer, dwBytesRead, &dwBytesWritten, NULL);
stOverlapped.Offset += dwBytesRead;
if (stOverlapped.Offset < GetFileSize(hInput, NULL))
{
bContinue = TRUE;
}
else
{
return 1;
}
}
return 0;
}
int _tmain(int argc, TCHAR* argv[])
{
char szXorFile[MAX_PATH];
SetConsoleTitle("XOR Decoder (by Young)");
printf("|----------------------------------------------------------|\r\n| XOR Decoder for WebZen MuError Log 0.1 |\r\n| by Young (http://forum.ragezone.com/members/147136.html) |\r\n|----------------------------------------------------------|\r\n\r\n");
printf("Reading xordec.ini... ");
GetPrivateProfileString("DEFAULT", "XorFile", "MuError.log", szXorFile, MAX_PATH, ".//xordec.ini");
if (GetLastError() != ERROR_SUCCESS)
{
printf("ERROR! Using default configuration.\r\n");
}
else
{
printf("DONE!\r\n");
}
printf("Reading %s... ", szXorFile);
hInput = (HANDLE)CreateFile(szXorFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (hInput == INVALID_HANDLE_VALUE)
{
printf("File not found or access denied.\r\n", szXorFile);
system("PAUSE");
return 0;
}
printf("DONE!\r\n");
printf("Creating Output.txt... ", szXorFile);
hOutput = (HANDLE)CreateFile("Output.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hOutput == INVALID_HANDLE_VALUE)
{
printf("Access denied or full disk.\r\n");
system("PAUSE");
return 0;
}
printf("DONE!\r\n");
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent == NULL)
{
printf("WOW! Unable to create the event for the async file read.\r\n");
system("PAUSE");
return 0;
}
UINT iTickCount = GetTickCount();
printf("Decoding %s... ", szXorFile);
if (AsyncFileRead() == 0)
{
printf("Unknow error reading/writing the file.\r\n");
system("PAUSE");
return 0;
}
printf("DONE!\r\n\r\nBytes read: %d\r\nElapsed time: %ds\r\n", GetFileSize(hInput, NULL), (GetTickCount() - iTickCount) / 1000);
CloseHandle(hInput);
CloseHandle(hOutput);
ShellExecute(NULL, "open", "notepad.exe", ".//Output.txt", NULL, SW_SHOWNORMAL);
system("PAUSE");
return 0;
}
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Dec 30th, 2014, 11:04 AM
#7
Thread Starter
Fanatic Member
Re: Build Console
can you share source of project cause for me get only errors like i showed uppon
i create Console 32 application>clean project>
and i cant build it
-
Dec 30th, 2014, 11:27 AM
#8
Re: Build Console
Start here:
http://stackoverflow.com/questions/2...f-type-lpcwstr
A simple search of the most common error turned that up as the first result. When I changed "DEFAULT" to L"DEFAULT" the error went away. There's also another option, changing the project properties.
-tg
edit: Indeed. Changing the character set to Multi-Byte cleared out all exceptions but two:
Cannot open source file "stdafx.h"
IntelliSense: identifier "_TCHAR" is undefined
Odds are that second one is a result of the first. Since you don't have those errors (at least you didn't report that you did), then changing the project property is probably all you need.
-tgx2
-
Dec 30th, 2014, 12:03 PM
#9
Thread Starter
Fanatic Member
Re: Build Console
Error 1 error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [23]' to 'LPCWSTR' c:\users\user\documents\visual studio 2010\projects\muerror decoder\muerror decoder\main.cpp 97 1 MuError Decoder
-
Dec 30th, 2014, 01:22 PM
#10
Re: Build Console
_TCHAR should be TCHAR as in the code I posted in post #6.
Use SetConsoleTitleA() as you are compiling as unicode but passing an ANSI string. Or use SetConsoleTitle(L"XOR Decoder (by Young)");
Why are you compiling as unicode when your program is ANSI? As techgnome indicated in post #8, change the compiler setting for character set to multi-byte from unicode.
This code below compiles on my VS 2013 system whether you are using unicode or multi-byte
Code:
// MuError Decoder.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#pragma comment(lib, "th32.lib")
//And make sure you have your headers at the top of any .cpp files:
#define _WIN32_WINNT 0x0501 // WinXP only.
#define VC_EXTRALEAN
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <shlwapi.h>
HANDLE hEvent;
HANDLE hInput;
HANDLE hOutput;
#define BUF_SIZE (16)
BYTE bKey[BUF_SIZE] = { 0x7C, 0xBD, 0x81, 0x9F, 0x3D, 0x93, 0xE2, 0x56, 0x2A, 0x73, 0xD2, 0x3E, 0xF2, 0x83, 0x95, 0xBF };
int AsyncFileRead()
{
CHAR szBuffer[BUF_SIZE];
DWORD dwBytesToRead = BUF_SIZE;
DWORD dwBytesRead = 0;
DWORD dwBytesWritten = 0;
INT iKeyOffset = 0;
OVERLAPPED stOverlapped = { 0 };
BOOL bResult = FALSE;
BOOL bContinue = TRUE;
stOverlapped.hEvent = hEvent;
while (bContinue)
{
bContinue = FALSE;
memset(szBuffer, 0x00, sizeof(szBuffer));
bResult = ReadFile(hInput, szBuffer, dwBytesToRead, &dwBytesRead, &stOverlapped);
if (!bResult)
{
BOOL bPending = TRUE;
while (bPending)
{
bPending = FALSE;
bResult = GetOverlappedResult(hInput, &stOverlapped, &dwBytesRead, FALSE);
if (!bResult)
{
bPending = TRUE;
bContinue = TRUE;
}
else
{
ResetEvent(stOverlapped.hEvent);
}
}
}
for (INT i = 0; i<(INT)dwBytesToRead; i++)
{
if (i >= (INT)dwBytesRead)
{
break;
}
szBuffer[i] = szBuffer[i] ^ bKey[iKeyOffset];
iKeyOffset++;
if (iKeyOffset >= (INT)dwBytesToRead)
{
iKeyOffset = 0;
}
}
WriteFile(hOutput, szBuffer, dwBytesRead, &dwBytesWritten, NULL);
stOverlapped.Offset += dwBytesRead;
if (stOverlapped.Offset < GetFileSize(hInput, NULL))
{
bContinue = TRUE;
}
else
{
return 1;
}
}
return 0;
}
int _tmain(int argc, TCHAR* argv[])
{
char szXorFile[MAX_PATH];
SetConsoleTitleA("XOR Decoder (by Young)");
printf("|----------------------------------------------------------|\r\n| XOR Decoder for WebZen MuError Log 0.1 |\r\n| by Young (http://forum.ragezone.com/members/147136.html) |\r\n|----------------------------------------------------------|\r\n\r\n");
printf("Reading xordec.ini... ");
GetPrivateProfileStringA("DEFAULT", "XorFile", "MuError.log", szXorFile, MAX_PATH, ".//xordec.ini");
if (GetLastError() != ERROR_SUCCESS)
{
printf("ERROR! Using default configuration.\r\n");
}
else
{
printf("DONE!\r\n");
}
printf("Reading %s... ", szXorFile);
hInput = (HANDLE)CreateFileA(szXorFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (hInput == INVALID_HANDLE_VALUE)
{
printf("File not found or access denied.\r\n", szXorFile);
system("PAUSE");
return 0;
}
printf("DONE!\r\n");
printf("Creating Output.txt... ", szXorFile);
hOutput = (HANDLE)CreateFileA("Output.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hOutput == INVALID_HANDLE_VALUE)
{
printf("Access denied or full disk.\r\n");
system("PAUSE");
return 0;
}
printf("DONE!\r\n");
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent == NULL)
{
printf("WOW! Unable to create the event for the async file read.\r\n");
system("PAUSE");
return 0;
}
UINT iTickCount = GetTickCount();
printf("Decoding %s... ", szXorFile);
if (AsyncFileRead() == 0)
{
printf("Unknow error reading/writing the file.\r\n");
system("PAUSE");
return 0;
}
printf("DONE!\r\n\r\nBytes read: %d\r\nElapsed time: %ds\r\n", GetFileSize(hInput, NULL), (GetTickCount() - iTickCount) / 1000);
CloseHandle(hInput);
CloseHandle(hOutput);
ShellExecuteA(NULL, "open", "notepad.exe", ".//Output.txt", NULL, SW_SHOWNORMAL);
system("PAUSE");
return 0;
}
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|