View Single Post
Author Message
Sam839
Zero Posts
Join Date: Apr 2019
Old 09-23-2020 , 01:06   [T] Small useful codes - Thread
Reply With Quote #1

Insert your little code that you think should be seen by others. I noticed that there are similar threads and decided to do something similar.

For example:
PHP Code:
// C++
int RGetAppID() // Get AppID from steam_appid.txt
{
    
std::ifstream f("steam_appid.txt");
    
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
    
str.erase(std::remove(str.begin(), str.end(), char(0x0A)), str.end());
    
str.erase(std::remove(str.begin(), str.end(), char(0x00)), str.end());
    return 
std::stoi(str);
}

// C++
size_t RSizeOfFunction(voidfunc// Get size of function (opcodes - bytes). For example: RSizeOfFunction(AllocConsole);
{
    if (
func) {
        
size_t size 0;
        
BYTEbytes static_cast<BYTE*>(func);
        while (
bytes[size] != 0xC3 && bytes[size 1] != 0xCC)
        {
            if (
size >= 0x100000) { // 1 mByte = 0x100000
                
return size_t(0);
            }
            
size++;
        }
        return 
size 1;
    }
    else {
        return 
size_t(0);
    }

Sam839 is offline