Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[C++] appendoverlay

Featured Replies

Posted
#include <stdio.h>
#include <vector>
#include <string>
#include <windows.h>

bool readFileData(const std::string & fileName, std::vector<unsigned char> & data)
{
    data.clear();
    HANDLE hFile = CreateFileA(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    bool result=false;
    if(hFile != INVALID_HANDLE_VALUE)
    {
        unsigned int fileSize = GetFileSize(hFile, 0);
        unsigned char* dataPtr = new unsigned char[fileSize];
        DWORD read=0;
        if(ReadFile(hFile, dataPtr, fileSize, &read, 0))
            result = true;
        data.assign(dataPtr, dataPtr+fileSize);
        delete[] dataPtr;
        CloseHandle(hFile);
    }
    return result;
}

bool writeFile(const std::string & fileName, const std::vector<unsigned char> & data)
{
    HANDLE hFile = CreateFileA(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
    bool result=false;
    if(hFile != INVALID_HANDLE_VALUE)
    {
        SetEndOfFile(hFile);
        DWORD written=0;
        if(WriteFile(hFile, data.data(), data.size(), &written, 0))
            result=true;
        CloseHandle(hFile);
    }
    return result;
}

int main(int argc, char* argv[])
{
    if(argc < 4)
    {
        puts("usage: appendoverlay file overlay outfile");
        return -1;
    }
    std::vector<unsigned char> fileData;
    if(!readFileData(argv[1], fileData))
    {
        puts("failed to read file!");
        return -1;
    }
    printf("file size: %d\n", fileData.size());
    std::vector<unsigned char> overlayData;
    if(!readFileData(argv[2], overlayData))
    {
        puts("failed to read overlay!");
        return -1;
    }
    printf("overlay size: %d\n", fileData.size());
    fileData.insert(fileData.end(), overlayData.begin(), overlayData.end());
    printf("out size: %d\n", fileData.size());
    if(!writeFile(argv[3], fileData))
    {
        puts("failed to write outfile!");
        return -1;
    }
    puts("all done!");
}

This is a small tool that I wrote, might be useful for some people...

small suggestion - if theres digital signature give the option to exclude it from the appended data dump :)

At cmd prompt... :P

copy /B %SourceFile% + %Ovl% %Target% /B

Ted.

i think one of the /B 's might be redundant ted :)

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.