Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <Windows.h>
- #include "base64.h"
- #include <iostream>
- #include <wchar.h>
- #include <stdio.h>
- using namespace std;
- char buffer[100]; // Yes i know i should'nt use globals! *hug*
- char filename[256] = "stub"; // Yes i know i should'nt use globals! *hug*
- DWORD patchedBytes = 0;
- char newFilename[256] = "";
- int _tmain(int argc, _TCHAR* argv[])
- {
- {
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, (FOREGROUND_GREEN));
- }
- cout << "##########################################" << endl;
- cout << "" << endl;
- cout << "" << endl;
- ZeroMemory(&buffer, 200);
- cout << "Enter connection URL: ";
- cin >> buffer;
- if (strlen(buffer) > 100)
- {
- MessageBoxA(NULL, LPCSTR("File has not been patched. URL is too long!"), LPCSTR("Error!"), MB_ICONERROR);
- cin.get();
- exit(0);
- }
- {
- string s = buffer;
- string encoded = base64_encode(reinterpret_cast<const unsigned char*>(s.c_str()), s.length());
- string decoded = base64_decode(encoded);
- cout << "encoded: " << encoded << std::endl;
- cout << "decoded: " << decoded << std::endl;
- }
- HANDLE resultCreateFile = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
- //cout << resultCreateFile << " GetLastError :" << GetLastError << endl;
- DWORD resultFilePointer = SetFilePointer(resultCreateFile, (LONG)0x9BD0, nullptr, FILE_BEGIN);
- //cout << resultFilePointer << " GetLastError :" << GetLastError << endl;
- BOOL resultWriteFile = WriteFile(resultCreateFile, buffer, 200, &patchedBytes, NULL);
- //cout << resultWriteFile << " GetLastError: " << GetLastError << endl;
- if (resultWriteFile > 0)
- {
- cout << "Save file as(don't forget file extension):";
- cin >> newFilename;
- BOOL copyFileresult = CopyFile(filename, newFilename, false);
- MessageBoxA(NULL, LPCSTR("File has been successfully patched!"), LPCSTR("Success!"), MB_OK);
- }
- else if (resultWriteFile == 0)
- {
- MessageBoxA(NULL, LPCSTR("File has not been patched, make sure Stub is available and not in use!"), LPCSTR("Error!"), MB_ICONERROR);
- return (0);
- }
- BOOL resultCloseHandle = CloseHandle(nullptr);
- int f;
- cin >> f;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement