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

Adds URL rewriting in WebBrowser and WinInet GET, POST and POST with file #39

Merged
merged 20 commits into from
Sep 14, 2024

Conversation

Acrisio-Filho
Copy link
Contributor

Adds GG Patch for:
TH S2 312b;
TH S2 321a.

Fixed CreateProccessAHook that was creating false Handle for processes other than GameGuard.des.

Added the option in the rugburn.json config file to ignore invalid certificates in WinInet since PangYa does not handle these errors.
Ex:
....
"BypassSelfSignedCertificate": "TRUE"
....

The WebBrowser is Internet Explorer and it handles these errors so this option is only for WinInet.

In WinInet there is an InternetErrorDlg function to request user permission, but I couldn't make it work even passing the HWND with GetActiveWinow() and with specific flags, it doesn't show the Dlg and returns ERROR_CANCELED, so I decided to put the BypassSelfSignedCertificate option to ignore certificate errors and POST redirection errors that require user confirmation. I didn't make an option, I set it to ignore this error and redirect.

With these implementations, all PangYa URLs will go through ReWriteURL from both WinInet and WebBrowser.

I compiled and tested with MSVC and Cygwin64->MinGW32:
ProjectG.exe S9 TH 826c;
ProjectG.exe S1 BR 216;
ProjectG.exe S2 BR 305a;
update_br.exe S2 BR 305a;
PangFBI.exe BR 305a.

All worked without problems.

"PangFBI.exe" reports logs to the Pangya http server, it is present in old Pangya seasons, in new seasons it is inside ProjectG.exe.

To execute ijl15.dll in "update_br.exe" and "PangFBI.exe" I injected the dll ijl15.dll with the program "CFF_Explorer":
I opened the .exe, clicked on "Import Adder" in the list and clicked on the "Add" button, selected ijl15.dll, clicked ok then selected ijlGetLibVersion, clicked on the "Import By Ordinal" button then clicked on "Rebuild Import Table" after that I clicked on "Rebuilder" in the list, clicked on the "Bind Import Table" checkbox then clicked on the "Rebuild" button then clicked on the save button.

Adiciona GG Patch:
TH S2 312b
TH S2 321a
fix type parameter
Option BypassSelfSignedCertificate

ignora os certificados inválidos
Option BypassSelfSignedCertificate

ignora certificados inválidos
Adiciona os Hooks do WebBrowser.
O básico do MFC(usado no update.exe) e o IWebBrowser(usado no ProjectG.exe)
Add new types to Wininet and WebBrowser
add InitWebBrowserHook
fix CreateProccessAHook
add ole32/web_browser.o
add ole32\web_browser.c
add ole32\web_browser.c
add ole32\web_browser.c
add ole32\web_browser.c
adiciona os hooks para o WinInet.

Versões GET, POST e POST com arquivo.

Já que não consegui fazer o InternetErrorDlg funcionar,
para pedir a permissão do usuário para certificados inválidos e redirecionamento de POST.
(mesmo com HWND e Flags ele não cria o DLG e retorna ERROR_CANCELED).

Então criei uma opção no .json para ignora os erros de certificados:
"BypassSelfSignedCertificate": "TRUE"

POST que precisa de permissão para ele ignora direto e faz o redirecionamento.
adiciona o IWebBrowser type, por que o MinGW do github não tem o arquivo ExDisp.h, mas o cygwin64 -> MinGW tem ele.
definição da struct IWebBrowser
Ajeitei para quando criar uma nova handle do OpenRequest todas as outras funções ganchos usar a nova handle.
fix SysFreeString
Copy link
Collaborator

@jchv jchv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems impressive. That said, I don't have a good way to test it right now. I'll have to accept it for now and work out problems later.

I am going to try to check that this does not cause problems when running under Wine.

@@ -79,7 +79,7 @@ PSTR GetSelfPath() {
return pszSelfPath;
}

BOOL FileExists(LPCTSTR szPath) { return GetFileAttributesA(szPath) != INVALID_FILE_ATTRIBUTES; }
BOOL FileExists(LPCSTR szPath) { return GetFileAttributesA(szPath) != INVALID_FILE_ATTRIBUTES; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch!

@jchv
Copy link
Collaborator

jchv commented Sep 14, 2024

So far I am not noticing any problems so I think this should probably be merged. Some of these hook implementations are pretty complicated, maybe we should start using C++ in our hooks. (Still will need to use COM in the CINTERFACE style though, with manual vtbl... sorry)

@jchv jchv merged commit 027f59d into pangbox:master Sep 14, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants