Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and style improvements #37

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@v11
- uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Check formatting
run: nix develop --command clang-format --dry-run -Werror src/**/*.c src/**/*.h
run: |
shopt -s globstar
nix develop --command clang-format --dry-run -Werror src/**/*.c src/**/*.h
5 changes: 1 addition & 4 deletions src/common-fnptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
* hook various APIs to manipulate or inspect behavior.
*/

#ifndef COMMON_FNPTR_H
#define COMMON_FNPTR_H
#pragma once

#include <windows.h>
#include <ws2tcpip.h>
Expand Down Expand Up @@ -157,5 +156,3 @@ typedef int(STDCALL *PFNIJLFREEPROC)(int);
typedef int(STDCALL *PFNIJLREADPROC)(int, int);
typedef int(STDCALL *PFNIJLWRITEPROC)(int, int);
typedef int(STDCALL *PFNIJLERRORSTRPROC)(int);

#endif
5 changes: 1 addition & 4 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* THIS SOFTWARE.
*/

#ifndef COMMON_H
#define COMMON_H
#pragma once

#define STDCALL __stdcall
#define EXPORT __export
Expand Down Expand Up @@ -76,5 +75,3 @@ VOID Exit(DWORD dwExitCode);
PANGYAVER DetectPangyaVersion();
PSTR GetPangyaArg(PANGYAVER pangyaVersion);
PSTR GetSelfPath();

#endif
5 changes: 1 addition & 4 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* THIS SOFTWARE.
*/

#ifndef CONFIG_H
#define CONFIG_H
#pragma once

#include "common.h"
#include "regex.h"
Expand Down Expand Up @@ -58,5 +57,3 @@ void LoadJsonRugburnConfig();
LPCSTR RewriteURL(LPCSTR url);
BOOL RewriteAddr(LPSOCKADDR_IN addr);
void PatchAddress();

#endif
5 changes: 1 addition & 4 deletions src/hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* THIS SOFTWARE.
*/

#ifndef HEX_H
#define HEX_H
#pragma once

#include "common.h"

Expand All @@ -24,5 +23,3 @@ DWORD FromHex(LPCSTR pHex, PVOID pData);

DWORD ParseAddress(LPCSTR lpszText);
void ParsePatch(LPCSTR lpszText, LPSTR *pDataOut, DWORD *pSizeOut);

#endif
5 changes: 1 addition & 4 deletions src/hooks/comctl32/dynamic_patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_COMCTL32_DYNAMIC_PATH
#define HOOKS_COMCTL32_DYNAMIC_PATH
#pragma once

#include "../../common.h"

VOID InitComCtl32Hook();

#endif // !HOOKS_COMCTL32_DYNAMIC_PATH
5 changes: 1 addition & 4 deletions src/hooks/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_HOOKS_H
#define HOOKS_HOOKS_H
#pragma once

#include "../common.h"

VOID InitHooks();

#endif
5 changes: 1 addition & 4 deletions src/hooks/kernel32/inject.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_KERNEL32_INJECT_H
#define HOOKS_KERNEL32_INJECT_H
#pragma once

#include "../../common.h"

VOID InitInjectHook();

#endif
5 changes: 1 addition & 4 deletions src/hooks/msvcr100/msvcr100.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_MSVCR100_MSVCR100_H
#define HOOKS_MSVCR100_MSVCR100_H
#pragma once

#include "../../common.h"

VOID InitMsvcrHook();

#endif
5 changes: 1 addition & 4 deletions src/hooks/projectg/us852/ranking.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_PROJECTG_US852_RANKING_H
#define HOOKS_PROJECTG_US852_RANKING_H
#pragma once

#include "../../../common.h"

VOID InitUS852RankingHook();

#endif
5 changes: 1 addition & 4 deletions src/hooks/user32/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_USER32_WINDOW_H
#define HOOKS_USER32_WINDOW_H
#pragma once

#include "../../common.h"

VOID InitWindowHook();

#endif
5 changes: 1 addition & 4 deletions src/hooks/wininet/netredir.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_WININET_NETREDIR_H
#define HOOKS_WININET_NETREDIR_H
#pragma once

#include "../../common.h"

VOID InitNetRedirHook();

#endif
5 changes: 1 addition & 4 deletions src/hooks/ws2_32/redir.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef HOOKS_WS2_32_REDIR_H
#define HOOKS_WS2_32_REDIR_H
#pragma once

#include "../../common.h"

VOID InitRedirHook();

#endif
33 changes: 21 additions & 12 deletions src/ijl15.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
/**
* Copyright 2018-2024 John Chadwick <john@jchw.io>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose
* with or without fee is hereby granted, provided that the above copyright notice
* and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/

#include <windows.h>

#include "../third_party/ijl/ijl.h"

const IJLibVersion *__stdcall ijlGetLibVersionWrapper() {
return ijlGetLibVersion();
}
const IJLibVersion *__stdcall ijlGetLibVersionWrapper() { return ijlGetLibVersion(); }

IJLERR __stdcall ijlInitWrapper(JPEG_CORE_PROPERTIES *jcprops) {
return ijlInit(jcprops);
}
IJLERR __stdcall ijlInitWrapper(JPEG_CORE_PROPERTIES *jcprops) { return ijlInit(jcprops); }

IJLERR __stdcall ijlFreeWrapper(JPEG_CORE_PROPERTIES *jcprops) {
return ijlFree(jcprops);
}
IJLERR __stdcall ijlFreeWrapper(JPEG_CORE_PROPERTIES *jcprops) { return ijlFree(jcprops); }

IJLERR __stdcall ijlReadWrapper(JPEG_CORE_PROPERTIES *jcprops, IJLIOTYPE iotype) {
return ijlRead(jcprops, iotype);
Expand All @@ -21,6 +32,4 @@ IJLERR __stdcall ijlWriteWrapper(JPEG_CORE_PROPERTIES *jcprops, IJLIOTYPE iotype
return ijlWrite(jcprops, iotype);
}

const char *__stdcall ijlErrorStrWrapper(IJLERR code) {
return ijlErrorStr(code);
}
const char *__stdcall ijlErrorStrWrapper(IJLERR code) { return ijlErrorStr(code); }
5 changes: 1 addition & 4 deletions src/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* THIS SOFTWARE.
*/

#ifndef JSON_H
#define JSON_H
#pragma once

#include "common.h"

Expand Down Expand Up @@ -50,5 +49,3 @@ int JsonReadInteger(LPSTR *json);
BOOL JsonReadBool(LPSTR *json);
void JsonReadMap(LPSTR *json, LFNREADMAPVALUECB valuefn);
void JsonReadArray(LPSTR *json, LFNREADARRAYVALUECB valuefn);

#endif
5 changes: 1 addition & 4 deletions src/ld.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* THIS SOFTWARE.
*/

#ifndef LD_H
#define LD_H
#pragma once

#include "common.h"

unsigned int LenDisasm(LPVOID address);

#endif
5 changes: 1 addition & 4 deletions src/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* THIS SOFTWARE.
*/

#ifndef PATCH_H
#define PATCH_H
#pragma once

#include "common.h"

Expand All @@ -28,5 +27,3 @@ PVOID HookProc(HMODULE hModule, LPCSTR szName, PVOID pfnTargetProc);
PVOID BuildThiscallToStdcallThunk(PVOID pfnProc);
PVOID BuildStdcallToThiscallThunk(PVOID pfnProc);
PVOID BuildStdcallToVirtualThiscallThunk(DWORD dwVtblOffset);

#endif
5 changes: 1 addition & 4 deletions src/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* THIS SOFTWARE.
*/

#ifndef RE_H
#define RE_H
#pragma once

#include "common.h"

Expand All @@ -28,5 +27,3 @@ LPSTR ReReplace(REGEX *find, LPCSTR replace, LPCSTR text);
int ReGetNumCaptures(REGEX *pattern);
int ReGetCaptureLen(REGEX *pattern, int i);
void ReGetCaptureData(REGEX *pattern, int i, LPSTR buffer);

#endif
Loading