GetByte(); - Custom Function

Posts 1–13 of 13 · Page 1 of 1
GetByte(); - Custom Function
Well, because of the antihack that I made, I thought of this function, which is very useless, but I made it for programming convenience.

Just send an address type casted to BYTE*, and will return the first byte of that address.

Code:
BYTE GetByte(BYTE* Address){
return (BYTE)Address[0];}
Made by
-Marneus901/Circadian
oO very usefull xD
but you are returning the last byte

Code:
0x11 22 33 44
   3  2  1  0
Lol, I agree with Gordon`...
LOL, your statement is false due to this source which works >_>
The only part it didnt need was the if statement inside it, dunno why i put it there, because if the byte was NULL, it would return as NULL; lol.
Code:
#include "stdafx.h"
#include "windows.h"
#include <iostream>
using namespace std;

BYTE GetByte(BYTE* Address){return (BYTE)Address[0];}

//Thanks To Fate/////////////////////////////////////////////////////
//------------------------------
//Write To Memory
 
void WriteToMemory(DWORD Offset, DWORD Pointer, DWORD Length){
	DWORD OldProtection;
    VirtualProtect((void *)Offset, Length, PAGE_EXECUTE_READWRITE, &OldProtection);
    RtlMoveMemory((void *)Offset, (const void*)Pointer, Length);
    VirtualProtect((void *)Offset, Length, OldProtection, &OldProtection);
}
 
//------------------------------
//Modify Memory
 
void ModifyMemory( BYTE *Offset, BYTE *ByteArray, DWORD Length){
    for(DWORD i = 0; i < Length; i++)
        WriteToMemory((DWORD)Offset + i, (DWORD)ByteArray + i, 1);
}
/////////////////////////////////////////////////////////////////////
void start_it(){
	DWORD test=0x0040105A;
	BYTE testB=GetByte((BYTE*)test);
	if(testB==0xE9)cout << "The byte is correct" << endl;else cout << "The byte is incorrect" << endl;
	Sleep(100);
	BYTE newbyte[] = {0x90, 0x90, 0x90, 0x90, 0x90};
	ModifyMemory((BYTE*)test, (BYTE*)newbyte, sizeof(newbyte));
	Sleep(100);
	testB=GetByte((BYTE*)test);
	Sleep(100);
	if(testB==0xE9)cout << "The byte is correct" << endl;else cout << "The byte is incorrect" << endl;
}
void main(int argc, char* argv[]){
	DWORD ThreadID;
	CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)&start_it,NULL,NULL,&ThreadID);
	Sleep(400);
	system("pause");
}
I dont think anyone has any better proof than results
Quote Originally Posted by Results
The byte is correct
The byte is incorrect
Press any key to continue
Works just as i said.

Thats why we dont write the binary to an address when modifying the memory backwords...
Like JMP XXXXXXXX is like 0xE9, 0x??, 0x??, 0x??, 0x?? not
0x??, 0x??, 0x??, 0x??, 0xE9
depending on the jump.

Just FYI from another coder
It works for what it was used for, returning the first byte from a byte array.
Quote Originally Posted by radnomguywfq3 View Post
It works for what it was used for, returning the first byte from a byte array.
=)
Yeah, when I was coding my antihack (very cheaply put together, using static addresses rather than hooking API's to detect hooking, because any other addies would just crash the game, or the hack is useless LOL), I was trying to figure out a way to get just the first byte of an address.

So, this function that was used for finding signitures
Code:
bool CompareByteArrays(BYTE* data1, BYTE* data2, int len){
    if (data1==NULL && data2==NULL)
        return true;
    if (data1==NULL || data2==NULL)
        return false;
    for (int i=0; i < len; i++){
        if (data1[i] != data2[i])
            if(data2[i] != 0xEE)
            return false;
        }
    return true;
}
//Called like so
	if((!CompareByteArrays((BYTE*)Addresse, (BYTE*)Byte, 1)))ExitProcess(0);
Compared, but I kinda wanted a shorter, more useful function.
So i made my function LOL, one line.
And returns the byte, rather than just compare. I find my function a little more useful tbh.
Code:
BYTE GetByte(BYTE* Address){return (BYTE)Address[0];}
if(goodByte!=GetByte((BYTE*)Address))ExitProcess(0);
Lot more simpler
Like I said, made for convenience, but it is alot more useful to the CompareByteArray.
Could even use to get dynamic binaries for an address (Kinda confusing, if you got an auto-updater for addresses, and the address it calls/pushes/copies differs from time to time.) But w/e LOL
[img]http://www.**********/img/nooblm8.png[/img]

i win
Quote Originally Posted by Gordon` View Post
[img]http://www.**********/img/nooblm8.png[/img]

i win
OK. Time to teach more noob coders about hacking and programming...
First off, your sending the address incorrectly. Im wanting the first byte of the address im sending, which is - 0040105A
NOT THE ADDRESS OF MY VARIABLE!, which you send by saying - &fail - (address of variable fail).
BTW try sending a valid address LAWL. So, there my freind, you already fail, and have no right to say my code is incorrect.

NOW. Heres a screenshot of my programs' ASM in ollydbg.

Hmmm, lets check address 0040105A
Hmmm, well in my code im sending THAT ADDRESS!
Hence - DWORD test=0x0040105A;
And - BYTE testB=GetByte((BYTE*)test);//Not sending address of variable, im sending the value, which is an address

SO.
Hmmm, check back at my screenie; based on what OllyDBG says, the binary of address 0040105A is
E9 A1 04 00 00
Hmmm, well, lets check the byte that i compared too in my C++ code...
if(testB==0xE9)

Ooooo look! Its the first byte!
Oh yea, also, the program when ran, says its correct... Hmmm, then when i change it to 0x90 (NOP)
It says its incorrect.... Soooo, i was correct?
Hmmm, phail more pl0x?

Code:
#include "stdafx.h"
#include "windows.h"
#include <iostream>
using namespace std;

BYTE GetByte(BYTE* Address){return (BYTE)Address[0];}

//Thanks To Fate/////////////////////////////////////////////////////
//------------------------------
//Write To Memory
 
void WriteToMemory(DWORD Offset, DWORD Pointer, DWORD Length){
	DWORD OldProtection;
    VirtualProtect((void *)Offset, Length, PAGE_EXECUTE_READWRITE, &OldProtection);
    RtlMoveMemory((void *)Offset, (const void*)Pointer, Length);
    VirtualProtect((void *)Offset, Length, OldProtection, &OldProtection);
}
 
//------------------------------
//Modify Memory
 
void ModifyMemory( BYTE *Offset, BYTE *ByteArray, DWORD Length){
    for(DWORD i = 0; i < Length; i++)
        WriteToMemory((DWORD)Offset + i, (DWORD)ByteArray + i, 1);
}
/////////////////////////////////////////////////////////////////////
void start_it(){
	DWORD test=0x0040105A;
	BYTE testB=GetByte((BYTE*)test);
	if(testB==0xE9)cout << "The byte is correct" << endl;else cout << "The byte is incorrect" << endl;
	Sleep(100);
	BYTE newbyte[] = {0x90, 0x90, 0x90, 0x90, 0x90};
	ModifyMemory((BYTE*)test, (BYTE*)newbyte, sizeof(newbyte));
	Sleep(100);
	testB=GetByte((BYTE*)test);
	Sleep(100);
	if(testB==0xE9)cout << "The byte is correct" << endl;else cout << "The byte is incorrect" << endl;
}
void main(int argc, char* argv[]){
	DWORD ThreadID;
	CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)&start_it,NULL,NULL,&ThreadID);
	Sleep(400);
	system("pause");
}
Seriously, you failed. You just showed a novince knowledge of programming and and ASM/OllyDBG.
Please dont try more >_>
[img]http://www.gghax.com/*******/Shut_The_Fuck_Up.jpg[/img]
i think we are talking about different things.

you mean: 0x12345678 E8 0011223344 --> your function returns E8
i mean: myvaraddy 12345678 --> your function returns 12 when the value is 0x78563412

so why are you saying that im not right? also using bad words.. try to become more adult
Quote Originally Posted by Gordon` View Post
i think we are talking about different things.

you mean: 0x12345678 E8 0011223344 --> your function returns E8
i mean: myvaraddy 12345678 --> your function returns 12 when the value is 0x78563412

so why are you saying that im not right? also using bad words.. try to become more adult
More adult? LOL. Im 18... Im old enough to say "stop being an ignorant cuntfaced shitbag" if I want to or not. Its my decision, and does not reflect on my intelligence or age, as it seems not to be here. Considering my coding skills are abit higher than yours it seems.
I made the function to give the first byte of an address that i send; not the first byte of an address of a variable - becacuse technically, it has no visible bytes. Try finding the address of the variable like so.

int newVar=1337;
cout << "The address of the variable is - " << &newVar << endl;
system ("pause");//So we can see the output

Then run it. Write down the address displayed. Then close it, open it in OllyDBG, and try going to it.
Its not a 'real' address ("No memory on the specified address").
And heres how the program sends it as a parameter (when saying &newVar in the cout statement)

00401943 |. 8D4D FC LEA ECX,DWORD PTR SS:[EBP-4]
00401946 |. 51 PUSH ECX

Soooo... Hmmm... Found a pointer pl0x? Guess that means the address of the variable isnt static; nor has a binary value = wtfx be wrong with you sending it to the function. Its useless.
It returns the first byte of the binary, like I had said in the very first post pl0x...

Sooo, what did we learn today kids?
Send parameters correctly and know what your talking about before arguing.
didnt u read my last post?
i think we are talking about different things.
you mean: 0x12345678 E8 0011223344 --> your function returns E8
i mean: myvaraddy 12345678 --> your function returns 12 when the value is 0x78563412
Yea, im saying your using my function for something it wasnt created for. Thats your first fault in coding, and makes you phail.



so why are you saying that im not right?
You used a function incorrectly.

also using bad words.. try to become more adult
More adult? LOL. Im 18... Im old enough to say "stop being an ignorant cuntfaced shitbag" if I want to or not.
didnt u read my last post?
Yes, apparently i did. Anything else little nub?
Yea, im saying your using my function for something it wasnt created for. Thats your first fault in coding, and makes you phail.
no, if you think about it, its the same. yarly

You used a function incorrectly.
i used it correctly, see above

also using bad words.. try to become more adult
More adult? LOL. Im 18... Im old enough to say "stop being an ignorant cuntfaced shitbag" if I want to or not.
Yes, apparently i did. Anything else little nub?
LOL
Posts 1–13 of 13 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us