Output REG_BINARY

Posts 1–9 of 9 · Page 1 of 1
Output REG_BINARY
So basically, I go through a few keys in a game, so decided I'd make my own hex cd key changer as a way of learning. Just having an issue I cant get my head around >.<

I set the hex key to A1 B2 C3



But I can't output a1 b2 c3 to the screen, it displays as this:



Anyone able to help me out or point me in the right direction?

Code:
#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{


	SetConsoleTitle("OA Key Change");

	
    HKEY hKey;
	char data[255] = {0};
	char key[255] = {0};
	DWORD dwTypeSZ = REG_SZ;
	DWORD dwTypeBIN = REG_BINARY;
	DWORD dwBufSizeSZ = sizeof(data);
	DWORD dwBufSizeBIN = sizeof(key);


	RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Bohemia Interactive Studio\\ArmA 2 OA",0, KEY_QUERY_VALUE, &hKey);
	RegQueryValueEx(hKey, "data", 0, &dwTypeSZ, (BYTE*)data, &dwBufSizeSZ);
	cout << "data is : " << data << endl;
	RegQueryValueEx(hKey, "KEY", 0, &dwTypeBIN, (BYTE*)key, &dwBufSizeBIN);
	cout << "\nkey is : " << key << endl;
	RegCloseKey;


    system("pause");
}
(I know, I haven't checked for errors, just trying to get past this first)
Code:
std::cout.setf(std::ios::hex, std::ios::basefield);

std::cout.fill('0');
std::cout.width(2);

for (char x : key)
  std::cout << static_cast<int>(x) << ' ';
Quote Originally Posted by Fovea View Post
Code:
std::cout.setf(std::ios::hex, std::ios::basefield);

std::cout.fill('0');
std::cout.width(2);

for (char x : key)
  std::cout << static_cast<int>(x) << ' ';
Not sure how this works. But have tried something similar and it didn't work.

Just to be clear, I want to output the hex of a REG_BINARY value.

E.g I want to output 86 9D F0... etc, not the text on the right hand side.


I believe I need to convert it somehow.
It works...
How?

I get a syntax error on "for (char x : key)" when trying.
You are probably compiling it with the older standard that doesn't support that (that looks a lot like Java btw. :>).

You can replace it with a regular loop, for example
Code:
for (int i=0; i<255; ++i)
  std::cout << static_cast<int>(key[i]) << ' ';
try this:

Code:
using namespace std;

int main()
{


	SetConsoleTitle("OA Key Change");

	
    HKEY hKey;
	char data[255] = {0};
	BYTE key[255] = {0};
	DWORD dwTypeSZ = REG_SZ;
	DWORD dwTypeBIN = REG_BINARY;
	DWORD dwBufSizeSZ = sizeof(data);
	DWORD dwBufSizeBIN = sizeof(key);


	RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Bohemia Interactive Studio\\ArmA 2 OA",0, KEY_QUERY_VALUE, &hKey);
	RegQueryValueEx(hKey, "data", 0, &dwTypeSZ, (BYTE*)data, &dwBufSizeSZ);
	cout << "data is : " << data << endl;
	RegQueryValueEx(hKey, "KEY", 0, &dwTypeBIN, (BYTE*)key, &dwBufSizeBIN);
	cout << "\nkey is : ";
        for (int i=0; i<dwBufSizeBin; ++i)
                << key[i] << "  ";
        cout << endl;
	RegCloseKey(hKey);


    system("pause");
}
changes are in green
Code:
typedef unsigned char BYTE;
That won't work, nice try.

Anyways, CALauncher is right. If your compiler does not support the ranged based for extension, just use a normal for loop.
so decided I'd make my own hex cd key changer as a way of learning. Just having an issue I cant get my head around >.<
Sounds more like a DayZ/ARMA II Key Stealer to me.
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us