Skip to content

Commit

Permalink
Add host IP resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
esuo1198 committed Mar 28, 2024
1 parent dc2d205 commit 2bdfd6e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/patches/amauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ extern char fullAddress[256];
extern char placeId[16];

namespace patches::AmAuth {

char server_ip[16];

const GUID IID_CAuth{0x045A5150, 0xD2B3, 0x4590, {0xA3, 0x8B, 0xC1, 0x15, 0x86, 0x78, 0xE1, 0xAC}};

const GUID IID_CAuthFactory{0x4603BB03, 0x058D, 0x43D9, {0xB9, 0x6F, 0x63, 0x9B, 0xE9, 0x08, 0xC1, 0xED}};
Expand Down Expand Up @@ -379,7 +382,7 @@ class CAuth : public IUnknown {
strcpy_s (state->mode, "STANDALONE");
strcpy_s (state->pcbid, "ABLN1080001");
strcpy_s (state->dongle_serial, chassisId.c_str ());
strcpy_s (state->auth_server_ip, server.c_str ());
strcpy_s (state->auth_server_ip, server_ip);
strcpy_s (state->local_ip, "127.0.0.1");
strcpy_s (state->shop_router_ip, "127.0.0.1");
strcpy_s (state->subnet_mask, "***.***.***.***");
Expand Down Expand Up @@ -638,5 +641,14 @@ Init () {
MH_Initialize ();
MH_CreateHookApi (L"ole32.dll", "CoCreateInstance", (LPVOID)CoCreateInstanceHook, (void **)&g_origCoCreateInstance); // NOLINT(clang-diagnostic-microsoft-cast)
MH_EnableHook (nullptr);

struct addrinfo *res = 0;
getaddrinfo (server.c_str (), "", 0, &res);
for (struct addrinfo *i = res; i != 0; i = i->ai_next) {
if (res->ai_addr->sa_family != AF_INET) continue;
struct sockaddr_in *p = (struct sockaddr_in *)res->ai_addr;
inet_ntop (AF_INET, &p->sin_addr, server_ip, 0x10);
break;
}
}
} // namespace patches::AmAuth

0 comments on commit 2bdfd6e

Please sign in to comment.