Skip to content

Commit

Permalink
Initial commit!
Browse files Browse the repository at this point in the history
  • Loading branch information
jchv committed Aug 3, 2019
0 parents commit e84418a
Show file tree
Hide file tree
Showing 30 changed files with 2,428 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/
/out/
/.vscode/
28 changes: 28 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# GPLv3 License

The following files, part of an x86 Length Disassembler written by Byron Platt,
are licensed under GPLv3:

* [src/third_party/lend/ld32.c](./src/third_party/lend/ld32.c)
* [src/third_party/lend/ld32.h](./src/third_party/lend/ld32.h)

Please see the respective [COPYING](./src/third_party/lend/COPYING) for the full
license content of the GPLv3.

# ISC License

All other files are licensed under the ISC license:

Pangbox © 2018-2019, John Chadwick <johnwchadwick@gmail.com>

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.
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
WATCOM := $(HOME)/Programs/watcom
WCC := $(WATCOM)/binl/wcc386
WLINK := $(WATCOM)/binl/wlink
MKDIR := mkdir
CP := cp

CFLAGS := \
-i$(WATCOM)/h \
-i$(WATCOM)/h/nt \
-i$(WATCOM)/h/nt/ddk \
-zl \
-s \
-bd \
-os \
-d0 \
-fr= \
-zq

LDFLAGS := \
LIBPATH $(WATCOM)/lib386 \
LIBPATH $(WATCOM)/lib386/nt

OBJS := \
obj/hooks/kernel32/inject.o \
obj/hooks/user32/window.o \
obj/hooks/ws2_32/redir.o \
obj/hooks/wininet/netredir.o \
obj/hooks/hooks.o \
obj/third_party/lend/ld32.o \
obj/common.o \
obj/ijlfwd.o \
obj/inject.o \
obj/main.o \
obj/ntdll.o \
obj/patch.o

OUT := out/ijl15.dll

all: $(OUT)

.PHONY: clean

obj/%.o: src/%.c
@$(MKDIR) -p $(dir $@)
$(WCC) $(CFLAGS) $< -fo=$@

$(OUT): $(OBJS)
@$(MKDIR) -p $(dir $@)
$(WLINK) $(LDFLAGS) NAME $@ @export.def FILE {$(OBJS)}

clean:
$(RM) $(OBJS) $(OUT)

shared: $(OUT)
$(RM) "${HOME}/Shared/ijl15.dll"
$(CP) "$(OUT)" "${HOME}/Shared/ijl15.dll"
$(RM) "${HOME}/Pangya/Clients/PangYa Japan/ijl15.dll"
$(CP) "$(OUT)" "${HOME}/Pangya/Clients/PangYa Japan/ijl15.dll"
$(RM) "${HOME}/Pangya/Clients/PangYa US 852.00/ijl15.dll"
$(CP) "$(OUT)" "${HOME}/Pangya/Clients/PangYa US 852.00/ijl15.dll"
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# rugburn

`rugburn` is an unobtrusive and small shim for `ijl15.dll` that allows you to
run unmodified Pangya without GameGuard.

This also allows you to run PangYa under Wine :)

Features:

* Redirects network traffic to localhost. (You can modify this to redirect
wherever you want; see [src/hooks/ws2_32/redir.c](./src/hooks/ws2_32/redir.c)
and [src/hooks/wininet/netredir.c](./src/hooks/wininet/netredir.c).)

* Patches GameGuard's check routines.

* Prevents PangYa from creating annoying topmost windows.

* Sets PANGYA_ARG when possible to avoid the updater check.

* Implements the IJL15 API and forwards it to `ijl15_real.dll`,
no need for tricky patching.

* **This program is not suitable for cheating. It does not support the only
active region of PangYa and does not offer GameGuard emulation that would
be needed to stay connected to an official server.** This program is
designed for unofficial servers and educational use!

## Compiling

`rugburn` is compiled with OpenWatcom, a simple compiler with few dependencies.
It was chosen because it offered an easy path to cross-compilation while also
allowing for tiny binaries that did not depend on libc.

You can modify the Make variables `WATCOM`, `WCC`, and `WLINK` to match your
environment, then run `make`. An `ijl15.dll` should appear in the `out` folder.

## Installation

1. Move the original ijl15.dll binary in the PangYa folder to ijl15_real.dll.
The exact name is important.

2. Copy the rugburn ijl15.dll into the PangYa folder.

Do not use update.exe anymore. Just run ProjectG directly. The update servers
are still active in US, so if you run the updater you may accidentally patch
over your files.

## Usage

Once installed, you can run ProjectG directly. Enjoy!

## Troubleshooting

If you have any issues, I can **not** guarantee that I can help you. However, please feel free to create a GitHub issue. Please describe your problem and if applicable, attach a copy of the `ijllog.txt` file.

## Contributing

I would be overjoyed if anyone wanted to contribute to this project! However, the project is considered _nearly_ feature complete and therefore new features may not always be accepted. Well-tested, well-written improvements to the patching routines would definitely be welcome.

Please note that I may take a while to get to your pull request. This project is not my fulltime job. Sorry!

## Why the name?
I went through a lot of names during development. I wanted something catchy but not too lame. The initial codename for the project was 'ggtfo', a portmanteau of 'gg' for 'GameGuard' and 'gtfo' for... yeah. This was mostly out of anger, and seemed a bit too edgy.

Another codename it had was 'ijlshim' reflecting the nature of how it works. However, this seemed way too boring. As far as literal names go, it also did not really describe _what_ the software did.

Inspiration came for this name when trying to find anagrams for the word 'GameGuard' and the phrase 'Damage Rug' showed up. 'Damage Rug' was pretty amusing, but it isn't exactly catchy, so I decided to drop the anagram idea and just go with the virtually non-sense name 'rugburn.'

So as is often the case with open source projects, the name is meaningless.

## License
Most of the code of rugburn is licensed under the ISC license. Some portions are licensed differently. See [LICENSE.md](./LICENSE.md) for complete licensing information.
18 changes: 18 additions & 0 deletions export.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FORMAT windows dll
RUNTIME windows = 4.0
ALIAS __DLLstart_ = '_DllMain@12'
LIBRARY {kernel32.lib user32.lib shlwapi.lib}

OPTION START = '_DllMain@12'
OPTION STACK = 8k
OPTION ALIGN = 512
OPTION NODEFAULTLIBS
OPTION ELIMINATE
OPTION QUIET

EXPORT ijlGetLibVersion.1 = '_ijlGetLibVersion@0'
EXPORT ijlInit.2 = '_ijlInit@4'
EXPORT ijlFree.3 = '_ijlFree@4'
EXPORT ijlRead.4 = '_ijlRead@8'
EXPORT ijlWrite.5 = '_ijlWrite@8'
EXPORT ijlErrorStr.6 = '_ijlErrorStr@4'
93 changes: 93 additions & 0 deletions src/common-fnptr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* This file contains many function pointer types and structures for Windows
* APIs. Many of these structures are not actually needed for this patcher,
* but were used in the process of developing it. These types make it easy to
* hook various APIs to manipulate or inspect behavior.
*/

#ifndef COMMON_FNPTR_H
#define COMMON_FNPTR_H

#include <windows.h>

typedef struct _DNS_QUERY_REQUEST {
ULONG Version;
PCWSTR QueryName;
WORD QueryType;
ULONG64 QueryOptions;
PVOID pDnsServerList;
ULONG InterfaceIndex;
PVOID pQueryCompletionCallback;
PVOID pQueryContext;
} DNS_QUERY_REQUEST, *PDNS_QUERY_REQUEST;

typedef struct _DNS_QUERY_RESULT {
ULONG Version;
DNS_STATUS QueryStatus;
ULONG64 QueryOptions;
PDNS_RECORD pQueryRecords;
PVOID Reserved;
} DNS_QUERY_RESULT, *PDNS_QUERY_RESULT;

typedef struct _DNS_QUERY_CANCEL {
CHAR Reserved[32];
} DNS_QUERY_CANCEL, *PDNS_QUERY_CANCEL;

// general
typedef BOOL (WINAPI *PFNDLLMAINPROC)(HMODULE, DWORD, PVOID);

// ws2_32.dll
typedef int (STDCALL *PFNCONNECTPROC)(SOCKET, const struct sockaddr *, int);
typedef BOOL (STDCALL *PFNCONNECTEXPROC)(SOCKET, const struct sockaddr *, int, PVOID, DWORD, LPDWORD, LPOVERLAPPED);
typedef int (STDCALL *PFNWSACONNECTPROC)(SOCKET, const struct sockaddr *, int, LPWSABUF, LPWSABUF, LPQOS, LPQOS);

// dnsapi.dll
typedef DNS_STATUS (STDCALL *PFNDNSQUERYEXPROC)(PDNS_QUERY_REQUEST pQueryRequest, PDNS_QUERY_RESULT pQueryResults, PDNS_QUERY_CANCEL pCancelHandle);

// advapi32.dll
typedef BOOL (STDCALL *PFNCRYPTDECRYPTPROC)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *);
typedef BOOL (STDCALL *PFNCRYPTGETHASHPARAMPROC)(HCRYPTHASH, DWORD, BYTE*, DWORD*, DWORD);
typedef BOOL (STDCALL *PFNCRYPTVERIFYSIGNATUREAPROC)(HCRYPTHASH, CONST BYTE *, DWORD, HCRYPTKEY, LPCSTR, DWORD);
typedef BOOL (STDCALL *PFNCRYPTIMPORTKEYPROC)(HCRYPTPROV, CONST BYTE *, DWORD, HCRYPTKEY, DWORD, HCRYPTKEY *);

// user32.dll
typedef int (STDCALL *PFNMESSAGEBOXAPROC)(HWND, LPCSTR, LPCSTR, UINT);
typedef HWND (STDCALL *PFNCREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
typedef LRESULT (STDCALL *PFNSENDMESSAGEPROC)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
typedef int (STDCALL *PFNMESSAGEBOXAPROC)(HWND, LPCSTR, LPCSTR, UINT);
typedef BOOL (STDCALL *PFNPEEKMESSAGEAPROC)(LPMSG, HWND, UINT, UINT, UINT);
typedef BOOL (STDCALL *PFNGETMESSAGEAPROC)(LPMSG, HWND, UINT, UINT);
typedef UINT_PTR (STDCALL *PFNSETTIMERPROC)(HWND, UINT_PTR, UINT, TIMERPROC);

// kernel32.dll
typedef HMODULE (STDCALL *PFNLOADLIBRARYAPROC)(LPCSTR);
typedef FARPROC (STDCALL *PFNGETPROCADDRESSPROC)(HMODULE, LPCSTR);
typedef DWORD (STDCALL *PFNGETENVIRONMENTVARIABLEAPROC)(LPCSTR, LPSTR, DWORD);
typedef BOOL (STDCALL *PFNCREATEPROCESSAPROC)(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
typedef BOOL (STDCALL *PFNISWOW64PROCESSPROC) (HANDLE, PBOOL);
typedef HANDLE (STDCALL *PFNCREATEFILEAPROC)(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
typedef HANDLE (STDCALL *PFNCREATEFILEMAPPINGAPROC)(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR);
typedef HANDLE (STDCALL *PFNOPENMUTEXAPROC)(DWORD, BOOL, LPCSTR);
typedef VOID (STDCALL *PFNEXITPROCESSPROC)(UINT);
typedef HANDLE (STDCALL *PFNCREATEMUTEXAPROC)(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
typedef DWORD (STDCALL *PFNGETCURRENTTHREADIDPROC)();
typedef VOID (STDCALL *PFNSLEEPPROC)(DWORD);
typedef DWORD (STDCALL *PFNSLEEPEXPROC)(DWORD, BOOL);
typedef DWORD (STDCALL *PFNWAITFORSINGLEOBJECTPROC)(HANDLE, DWORD);
typedef HANDLE (STDCALL *PFNOPENEVENTAPROC)(DWORD, BOOL, LPCSTR);
typedef HANDLE (STDCALL *PFNCREATEEVENTAPROC)(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName);

// ntdll.dll
typedef NTSTATUS (NTAPI *PFNNTQUERYINFORMATIONPROCESSPROC)(HANDLE, DWORD, PVOID, ULONG, PULONG);
typedef NTSTATUS (NTAPI *PFNZWTERMINATEPROCESSPROC)(HANDLE, NTSTATUS);
typedef DWORD (STDCALL *PFNRTLEXITUSERPROCESSPROC)(NTSTATUS ExitStatus);
typedef LONG (NTAPI *PFNNTSUSPENDPROCESSPROC)(IN HANDLE ProcessHandle);

// wininet.dll
typedef void (STDCALL *PFNINTERNETCONNECTAPROC)(HINTERNET, LPCSTR, INTERNET_PORT, LPCSTR, LPCSTR, DWORD, DWORD, DWORD_PTR);
typedef HINTERNET (STDCALL *PFNINTERNETOPENURLAPROC)(HINTERNET, LPCSTR, LPCSTR, DWORD, DWORD, DWORD_PTR);

// winmm.dll
typedef DWORD (STDCALL *PFNTIMEGETTIMEPROC)();

#endif
Loading

0 comments on commit e84418a

Please sign in to comment.