mirror of
https://github.com/brain-hackers/version-txt-dumper.git
synced 2024-12-22 12:10:12 +09:00
commit
d569fb1b5c
70
.github/workflows/build.yml
vendored
Normal file
70
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: 'ci*'
|
||||
tags: '*'
|
||||
|
||||
jobs:
|
||||
create_release:
|
||||
name: Create release
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: false
|
||||
- name: Generate release name
|
||||
id: release_name
|
||||
# https://github.community/t/how-to-get-just-the-tag-name/16241/4
|
||||
run: echo ::set-output name=name::${GITHUB_REF/refs\/*s\//}
|
||||
- name: Create release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.release_name.outputs.name }}
|
||||
release_name: ${{ steps.release_name.outputs.name }}
|
||||
body: ''
|
||||
draft: false
|
||||
prerelease: true
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [create_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- name: Make /opt writable
|
||||
run: sudo chown "$(whoami):$(whoami)" /opt
|
||||
- name: Install cegcc
|
||||
run: |
|
||||
wget -O cegcc.zip https://github.com/brain-hackers/cegcc-build/releases/download/2022-04-11-133546/cegcc-2022-04-11-133546.zip
|
||||
unzip -q cegcc.zip
|
||||
cp -r cegcc /opt/
|
||||
- name: Build dumper
|
||||
run: make
|
||||
- name: Setup releases
|
||||
id: release_name
|
||||
run: |
|
||||
mkdir 'Version.txt Dumper'
|
||||
touch 'Version.txt Dumper/index.din'
|
||||
cp AppMain.exe 'Version.txt Dumper/AppMain.exe'
|
||||
zip -r version-txt-dumper.zip 'Version.txt Dumper'
|
||||
- name: Generate archive name
|
||||
id: archive_name
|
||||
run: echo ::set-output name=name::version-txt-dumper-${GITHUB_REF/refs\/*s\//}
|
||||
- name: Upload version-txt-dumper.zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
asset_path: version-txt-dumper.zip
|
||||
asset_name: ${{ steps.archive_name.outputs.name }}.zip
|
||||
asset_content_type: application/zip
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.exe
|
31
Makefile
Normal file
31
Makefile
Normal file
@ -0,0 +1,31 @@
|
||||
VERSION_MAJOR=1
|
||||
VERSION_MINOR=0
|
||||
VERSION_PATCH=0
|
||||
|
||||
PREFIX?=/opt/cegcc
|
||||
|
||||
CC=$(PREFIX)/bin/arm-mingw32ce-gcc
|
||||
CXX=$(PREFIX)/bin/arm-mingw32ce-g++
|
||||
LD=$(PREFIX)/bin/arm-mingw32ce-g++
|
||||
STRIP=$(PREFIX)/bin/arm-mingw32ce-strip
|
||||
DLLTOOL=$(PREFIX)/bin/arm-mingw32ce-dlltool
|
||||
AS=$(PREFIX)/bin/arm-mingw32ce-as
|
||||
NM=$(PREFIX)/bin/arm-mingw32ce-nm
|
||||
WINDRES=$(PREFIX)/bin/arm-mingw32ce-windres
|
||||
|
||||
OUTPUT=AppMain.exe
|
||||
|
||||
CXXFLAGS= -DEV_PLATFORM_WIN32 -DUNICODE -D_UNICODE -DEV_UNSAFE_SWPRINTF -mwin32 \
|
||||
-O0 -mcpu=arm926ej-s -D_WIN32_WCE=0x600 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
|
||||
-D_FILE_OFFSET_BITS=64 -static
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUTPUT)
|
||||
|
||||
clean:
|
||||
rm -f $(OUTPUT)
|
||||
|
||||
AppMain.exe: main.cpp
|
||||
$(CXX) main.cpp -o AppMain.exe $(CXXFLAGS)
|
||||
$(STRIP) AppMain.exe
|
14
README.md
14
README.md
@ -1,2 +1,12 @@
|
||||
# version-txt-dumper
|
||||
Shows the body of version.txt in SHARP Brain and copies it to the external SD card
|
||||
Version.txt Dumper
|
||||
==================
|
||||
|
||||
*Shows the body of version.txt in SHARP Brain and copies it to the external SD card*
|
||||
|
||||
|
||||
Install (using the pre-built binary)
|
||||
------------------------------------
|
||||
|
||||
1. Download the ZIP in [the latest release](https://github.com/brain-hackers/version-txt-dumper/releases) and unzip it
|
||||
2. Create `アプリ` directory in the SD card's root directory and copy `Version.txt Dumper` into it
|
||||
|
||||
|
72
main.cpp
Normal file
72
main.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include <windows.h>
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow)
|
||||
{
|
||||
wchar_t msg[1024];
|
||||
HANDLE file;
|
||||
DWORD fileSize;
|
||||
DWORD readSize;
|
||||
DWORD err;
|
||||
TCHAR errStr[32];
|
||||
void* buf;
|
||||
|
||||
file = CreateFile(L"\\NAND\\version.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
err = GetLastError();
|
||||
switch (err)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
swprintf(errStr, L"File not found");
|
||||
break;
|
||||
default:
|
||||
swprintf(errStr, L"Yabai error sorry");
|
||||
break;
|
||||
}
|
||||
|
||||
swprintf(msg, L"Failed to open version.txt\n%#010x: %s", err, errStr);
|
||||
MessageBox(NULL, msg, L"(X_X) < OMG", MB_ICONWARNING);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fileSize = GetFileSize(file, NULL);
|
||||
buf = LocalAlloc(LPTR, fileSize+1);
|
||||
if (buf == NULL)
|
||||
{
|
||||
MessageBox(NULL, L"Failed to allocate memory", L"(X_X) < OMG", MB_ICONWARNING);
|
||||
goto disaster;
|
||||
}
|
||||
|
||||
if (!ReadFile(file, buf, fileSize, &readSize, NULL))
|
||||
{
|
||||
MessageBox(NULL, L"Failed to read version.txt", L"(X_X) < OMG", MB_ICONWARNING);
|
||||
goto disaster;
|
||||
}
|
||||
|
||||
CloseHandle(file);
|
||||
|
||||
((char *)buf)[fileSize] = '\0';
|
||||
mbstowcs(msg, (char *)buf, fileSize);
|
||||
MessageBox(NULL, msg, L"(>_O)b < My version.txt is...", MB_ICONINFORMATION);
|
||||
|
||||
file = CreateFile(L"\\Storage Card\\version.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
MessageBox(NULL, L"Failed to create \\Storage Card\\version.txt", L"(X_X) < OMG", MB_ICONWARNING);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!WriteFile(file, buf, fileSize, NULL, NULL))
|
||||
{
|
||||
MessageBox(NULL, L"Failed to write \\Storage Card\\version.txt", L"(X_X) < OMG", MB_ICONWARNING);
|
||||
goto disaster;
|
||||
}
|
||||
|
||||
CloseHandle(file);
|
||||
return 0;
|
||||
|
||||
disaster:
|
||||
CloseHandle(file);
|
||||
return 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user