Skip to content

Commit

Permalink
Fix missing static declarations (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchv committed Sep 14, 2024
1 parent aa84807 commit 1e29f4b
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 97 deletions.
12 changes: 6 additions & 6 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const char ExampleRugburnConfig[] =
" ]\r\n"
"}\r\n";

void ReadJsonUrlRewriteRuleMap(LPSTR *json, LPCSTR key) {
static void ReadJsonUrlRewriteRuleMap(LPSTR *json, LPCSTR key) {
LPCSTR value = JsonReadString(json);

if (Config.NumUrlRewriteRules == MAXURLREWRITES) {
Expand All @@ -49,7 +49,7 @@ void ReadJsonUrlRewriteRuleMap(LPSTR *json, LPCSTR key) {
Config.NumUrlRewriteRules++;
}

void ReadJsonPortRewriteRuleMap(LPSTR *json, LPCSTR key) {
static void ReadJsonPortRewriteRuleMap(LPSTR *json, LPCSTR key) {
if (!strcmp(key, "FromPort")) {
Config.PortRewriteRules[Config.NumPortRewriteRules].fromport = JsonReadInteger(json);
} else if (!strcmp(key, "ToPort")) {
Expand All @@ -61,7 +61,7 @@ void ReadJsonPortRewriteRuleMap(LPSTR *json, LPCSTR key) {
}
}

void ReadJsonPortRewriteRuleArray(LPSTR *json) {
static void ReadJsonPortRewriteRuleArray(LPSTR *json) {
if (Config.NumPortRewriteRules == MAXURLREWRITES) {
FatalError("Reached maximum number of URL rewrite rules!");
}
Expand All @@ -70,7 +70,7 @@ void ReadJsonPortRewriteRuleArray(LPSTR *json) {
Config.NumPortRewriteRules++;
}

void ReadJsonPatchAddressMap(LPSTR *json, LPCSTR key) {
static void ReadJsonPatchAddressMap(LPSTR *json, LPCSTR key) {
LPCSTR value = JsonReadString(json);

if (Config.NumPatchAddress == MAXPATCHADDRESS) {
Expand All @@ -83,7 +83,7 @@ void ReadJsonPatchAddressMap(LPSTR *json, LPCSTR key) {
Config.NumPatchAddress++;
}

void ReadJsonBypassSelfSignedCertificate(LPSTR *json, LPCSTR key) {
static void ReadJsonBypassSelfSignedCertificate(LPSTR *json, LPCSTR key) {
LPCSTR value = JsonReadString(json);

Config.bBypassSelfSignedCertificate = FALSE;
Expand All @@ -95,7 +95,7 @@ void ReadJsonBypassSelfSignedCertificate(LPSTR *json, LPCSTR key) {
Config.bBypassSelfSignedCertificate = TRUE;
}

void ReadJsonConfigMap(LPSTR *json, LPCSTR key) {
static void ReadJsonConfigMap(LPSTR *json, LPCSTR key) {
if (!strcmp(key, "UrlRewrites")) {
JsonReadMap(json, ReadJsonUrlRewriteRuleMap);
} else if (!strcmp(key, "PortRewrites")) {
Expand Down
6 changes: 3 additions & 3 deletions src/exe/test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ typedef struct _DISPATCH_TESTCASE {
PFNDISPATCHTESTPROC proc;
} DISPATCH_TESTCASE;

void STDCALL DispatchTest(const DISPATCH_TESTCASE *_this, DWORD testnum) {
static void STDCALL DispatchTest(const DISPATCH_TESTCASE *_this, DWORD testnum) {
ConsoleLog("ok %d - %s\r\n", testnum, _this->name);
}

void STDCALL DispatchThroughThiscallTest(const DISPATCH_TESTCASE *_this, DWORD testnum) {
static void STDCALL DispatchThroughThiscallTest(const DISPATCH_TESTCASE *_this, DWORD testnum) {
PFNDISPATCHTESTPROC pfnDispatchProc =
(PFNDISPATCHTESTPROC)BuildStdcallToThiscallThunk(BuildThiscallToStdcallThunk(DispatchTest));
pfnDispatchProc(_this, testnum);
Expand All @@ -101,7 +101,7 @@ const LPCSTR ld_tests[] = {
"ff259017f476",
};

BOOL ijl15_crash_test() {
static BOOL ijl15_crash_test() {
JPEG_CORE_PROPERTIES jcp;
DWORD dwWholeImageSize, dwJPGSizeBytes;
PVOID pJPGBytes;
Expand Down
30 changes: 15 additions & 15 deletions src/hooks/comctl32/dynamic_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static PFNGETSTARTUPINFOWPROC pGetStartupInfoW = NULL;

#define GETRETURNADDRESS(_FirstParameter) *(((DWORD *)&(_FirstParameter)) - 1)

BOOL compare_virtual_memory(DWORD _dwAddress, DWORD _value) {
static BOOL compare_virtual_memory(DWORD _dwAddress, DWORD _value) {
MEMORY_BASIC_INFORMATION mbi;

if (VirtualQuery((void *)_dwAddress, &mbi, sizeof(mbi)) == 0) {
Expand All @@ -50,7 +50,7 @@ BOOL compare_virtual_memory(DWORD _dwAddress, DWORD _value) {
return TRUE;
}

BOOL isModuleAllocationBase(DWORD _dwAddress) {
static BOOL isModuleAllocationBase(DWORD _dwAddress) {
MEMORY_BASIC_INFORMATION mbi;

if (VirtualQuery((void *)_dwAddress, &mbi, sizeof(mbi)) == 0) {
Expand All @@ -74,7 +74,7 @@ BOOL isModuleAllocationBase(DWORD _dwAddress) {
/**
* Implements the GameGuard patches for Pangya US.
*/
void PatchGG_US() {
static void PatchGG_US() {
if (compare_virtual_memory(0x00A495E0, 0x8F143D83)) {
Patch((LPVOID)0x00A495E0, "\xC3\x90\x90\x90\x90\x90\x90", 7);
Patch((LPVOID)0x00A49670, "\xC3\x90\x90\x90\x90\x90\x90", 7);
Expand Down Expand Up @@ -150,7 +150,7 @@ void PatchGG_US() {
/**
* Implements the GameGuard patches for Pangya JP.
*/
void PatchGG_JP() {
static void PatchGG_JP() {
if (compare_virtual_memory(0x00A5CD10, 0x1BA43D83)) {
Patch((LPVOID)0x00A5CD10, "\xC3\x90\x90\x90\x90\x90\x90", 7);
Patch((LPVOID)0x00A5CDA0, "\xC3\x90\x90\x90\x90\x90\x90", 7);
Expand Down Expand Up @@ -194,7 +194,7 @@ void PatchGG_JP() {
}
}

void PatchGG_TW() {
static void PatchGG_TW() {
if (compare_virtual_memory(0x00643743, 0xFF6B98E8)) {
Patch((LPVOID)0x00643743, "\xE9\x00\x00\x00\x00", 5);
Log("Patched GG check routines (TW S2 3.00a)\r\n");
Expand All @@ -204,14 +204,14 @@ void PatchGG_TW() {
}
}

void PatchHS_ID() {
static void PatchHS_ID() {
if (compare_virtual_memory(0x005FC66D, 0xFF071EE8)) {
Patch((LPVOID)0x005FC66D, "\xE9\x00\x00\x00\x00", 5);
Log("Patched HSHIELD check routines (INA S1 2.12a)\r\n");
}
}

void PatchHS_BR() {
static void PatchHS_BR() {
if (compare_virtual_memory(0x005FE093, 0xFF8858E8)) {
Patch((LPVOID)0x005FE093, "\xE9\x00\x00\x00\x00", 5);
Log("Patched HSHIELD check routines (BR S1 2.14a)\r\n");
Expand Down Expand Up @@ -239,7 +239,7 @@ void PatchHS_BR() {
}
}

void PatchGG_KR() {
static void PatchGG_KR() {
if (compare_virtual_memory(0x00634EAD, 0xFF178EE8)) {
Patch((LPVOID)0x00634EAD, "\xE9\x00\x00\x00\x00", 5);
Log("Patched GG check routines (KR S2 3.26a)\r\n");
Expand All @@ -252,7 +252,7 @@ void PatchGG_KR() {
}
}

void PatchGG_TH() {
static void PatchGG_TH() {
if (compare_virtual_memory(0x005F678A, 0xFF5B21E8)) {
Patch((LPVOID)0x005F678A, "\xB8\x01\x00\x00\x00", 5);
Log("Patched GG check routines (TH S1 217)\r\n");
Expand Down Expand Up @@ -280,7 +280,7 @@ void PatchGG_TH() {
}
}

void PatchGG_SEA() {
static void PatchGG_SEA() {
if (compare_virtual_memory(0x00611CF8, 0xFF86D3E8)) {
Patch((LPVOID)0x00611CF8, "\xE9\x00\x00\x00\x00", 5);
Log("Patched GG check routines (SEA S1 2.16a)\r\n");
Expand All @@ -290,7 +290,7 @@ void PatchGG_SEA() {
}
}

void PatchGG_EU() {
static void PatchGG_EU() {
if (compare_virtual_memory(0x006160D1, 0xFF161AE8)) {
Patch((LPVOID)0x006160D1, "\xE9\x00\x00\x00\x00", 5);
Log("Patched GG check routines (EU S2 3.01a)\r\n");
Expand All @@ -303,7 +303,7 @@ void PatchGG_EU() {
}
}

void oneExec_PatchDynamicAndGG() {
static void oneExec_PatchDynamicAndGG() {
static int one = 0;
PANGYAVER pangyaVersion;

Expand Down Expand Up @@ -353,22 +353,22 @@ void oneExec_PatchDynamicAndGG() {
PatchAddress();
}

BOOL STDCALL InitCommonControlsExHook(const INITCOMMONCONTROLSEX *picce) {
static BOOL STDCALL InitCommonControlsExHook(const INITCOMMONCONTROLSEX *picce) {
BOOL ret = pInitCommonControlsEx(picce);

oneExec_PatchDynamicAndGG();

return ret;
}

VOID STDCALL GetStartupInfoAHook(LPSTARTUPINFOA lpStartupInfo) {
static VOID STDCALL GetStartupInfoAHook(LPSTARTUPINFOA lpStartupInfo) {
pGetStartupInfoA(lpStartupInfo);

if (isModuleAllocationBase(GETRETURNADDRESS(lpStartupInfo)))
oneExec_PatchDynamicAndGG();
}

VOID STDCALL GetStartupInfoWHook(LPSTARTUPINFOW lpStartupInfo) {
static VOID STDCALL GetStartupInfoWHook(LPSTARTUPINFOW lpStartupInfo) {
pGetStartupInfoW(lpStartupInfo);

if (isModuleAllocationBase(GETRETURNADDRESS(lpStartupInfo)))
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/msvcr100/msvcr100.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ static HMODULE hMsvcrModule = NULL;
static STRICMPFNPTR pStricmp = NULL;
static SETLOCALEFNPTR pSetLocale = NULL;

int lower(int c) { return (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c; }
static int lower(int c) { return (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c; }

int __cdecl StricmpHook(const char *s1, const char *s2) {
static int __cdecl StricmpHook(const char *s1, const char *s2) {
int result = 0;
if (!s1 || !s2)
return 0x7fffffff;
Expand All @@ -39,7 +39,7 @@ int __cdecl StricmpHook(const char *s1, const char *s2) {
return result;
}

VOID InitMsvcr100Hook() {
static VOID InitMsvcr100Hook() {
const char *oldlocale;
int result;

Expand Down Expand Up @@ -72,7 +72,7 @@ VOID InitMsvcr100Hook() {
}
}

VOID InitMsvcr71Hook() {
static VOID InitMsvcr71Hook() {
const char *oldlocale;
int result;

Expand Down
20 changes: 10 additions & 10 deletions src/hooks/ole32/web_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const IID kIID_MicrosoftWebBrowser = {
const IID kIID_IWebBrowser2 = {
0xD30C1661, 0xCDAF, 0x11D0, {0x8A, 0x3E, 0, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}};

BSTR RewriteURLW(BSTR urlw) {
static BSTR RewriteURLW(BSTR urlw) {

int len_urlw = lstrlenW(urlw);
int len = WideCharToMultiByte(CP_ACP, 0, urlw, len_urlw, NULL, 0, NULL, NULL);
Expand Down Expand Up @@ -57,9 +57,9 @@ BSTR RewriteURLW(BSTR urlw) {
return NULL;
}

HRESULT InvokeHook(IDispatch *This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
UINT *puArgErr) {
static HRESULT InvokeHook(IDispatch *This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
UINT *puArgErr) {

BSTR newURL = NULL;

Expand All @@ -83,8 +83,8 @@ HRESULT InvokeHook(IDispatch *This, DISPID dispIdMember, REFIID riid, LCID lcid,
puArgErr);
}

HRESULT STDCALL NavigateHook(IWebBrowser2 *This, BSTR URL, VARIANT *Flags, VARIANT *TargetFrameName,
VARIANT *PostData, VARIANT *Headers) {
static HRESULT STDCALL NavigateHook(IWebBrowser2 *This, BSTR URL, VARIANT *Flags,
VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers) {

BSTR newURL = NULL;

Expand All @@ -104,8 +104,8 @@ HRESULT STDCALL NavigateHook(IWebBrowser2 *This, BSTR URL, VARIANT *Flags, VARIA
return hResult;
}

HRESULT STDCALL CoGetClassObjectHook(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved,
REFIID riid, LPVOID *ppv) {
static HRESULT STDCALL CoGetClassObjectHook(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved,
REFIID riid, LPVOID *ppv) {

static void *g_pInvoke = NULL;

Expand Down Expand Up @@ -148,8 +148,8 @@ HRESULT STDCALL CoGetClassObjectHook(REFCLSID rclsid, DWORD dwClsContext, LPVOID
return ret;
}

HRESULT STDCALL CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext,
REFIID riid, LPVOID *ppv) {
static HRESULT STDCALL CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
DWORD dwClsContext, REFIID riid, LPVOID *ppv) {

static void *g_pNavigate = NULL;

Expand Down
8 changes: 4 additions & 4 deletions src/hooks/user32/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ static PFNCREATEWINDOWEXAPROC pCreateWindowExA = NULL;
* CreateWindowExAHook is a convenience patch that prevents PangYa from
* creating topmost windows.
*/
HWND STDCALL CreateWindowExAHook(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName,
DWORD dwStyle, int X, int Y, int nWidth, int nHeight,
HWND hWndParent, HMENU hMenu, HINSTANCE hInstance,
LPVOID lpParam) {
static HWND STDCALL CreateWindowExAHook(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName,
DWORD dwStyle, int X, int Y, int nWidth, int nHeight,
HWND hWndParent, HMENU hMenu, HINSTANCE hInstance,
LPVOID lpParam) {
dwExStyle &= (~WS_EX_TOPMOST);
return pCreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight,
hWndParent, hMenu, hInstance, lpParam);
Expand Down
Loading

0 comments on commit 1e29f4b

Please sign in to comment.