1
0
mirror of synced 2024-11-27 15:00:49 +01:00

Resolve all compiled warnings

This commit is contained in:
Bottersnike 2023-04-11 11:27:25 +09:00
parent e8cc8e8013
commit 701887940c
No known key found for this signature in database
48 changed files with 306 additions and 503 deletions

View File

@ -19,8 +19,8 @@ mice:
-@subst $(BUILD_DRIVE) .
@cd /D $(BUILD_DRIVE) \
& $(VCVARS) \
& meson setup --cross cross-32.ini $(BUILD_DRIVE)\$(BUILD_DIR) \
& meson compile -C $(BUILD_DRIVE)\$(BUILD_DIR)
& meson.py setup --cross cross-32.ini $(BUILD_DRIVE)\$(BUILD_DIR) \
& meson.py compile -C $(BUILD_DRIVE)\$(BUILD_DIR)
@subst $(BUILD_DRIVE) /D
.PHONY: clean
@ -50,18 +50,10 @@ dist:
@copy /Y "$(BUILD_DIR)/src/micetools/miceboot\miceprestartup.exe" "$(DIST_DIR)/Execute/miceprestartup.exe"
@copy /Y "$(BUILD_DIR)/src/micetools/miceboot\micestartup.exe" "$(DIST_DIR)/Execute/micestartup.exe"
@copy /Y "$(BUILD_DIR)/src/micetools/miceboot\TrueCrypt.exe" "$(DIST_DIR)/Execute/TrueCrypt.exe"
@copy /Y "$(BUILD_DIR)/src/micetools/miceboot\mxmaster.exe" "$(DIST_DIR)/Execute/S/mxmaster.exe"
@copy /Y "$(BUILD_DIR)/src/micetools/util\*.exe" "$(DIST_DIR)/util/"
@copy /Y "$(BUILD_DIR)/src/micetools/util\*.pdb" "$(DIST_DIR)/util/"
@copy /Y "$(BUILD_DIR)/src/micetools/system_dummy\dummymaster\dummymaster.exe" "$(DIST_DIR)/system_dummy/dummymaster.exe"
@copy /Y "$(BUILD_DIR)/src/micetools/system_dummy\dummyinstaller\dummyinstaller.exe" "$(DIST_DIR)/system_dummy/dummyinstaller.exe"
@copy /Y "$(BUILD_DIR)/src/micetools/system_dummy\dummykeychip\dummykeychip.exe" "$(DIST_DIR)/system_dummy/dummykeychip.exe"
@copy /Y "src/micetools/miceboot\TrueCrypt.cmd" "$(DIST_DIR)/Execute/TrueCrypt.cmd"
@xcopy /E /H /C /R /Q /Y src\system "$(DIST_DIR)\system/*"
@xcopy /E /H /C /R /Q /Y src\tools "$(DIST_DIR)\tools/*"
@xcopy /E /H /C /R /Q /Y src\patches "$(DIST_DIR)\patches/*"

View File

@ -2,6 +2,7 @@
c = 'cl'
cpp = 'cl'
strip = 'cl'
ar = ['lib', '/LTCG']
[host_machine]
system = 'windows'

View File

@ -1,6 +1,7 @@
import sys
import os
from mesonbuild import mesonmain
from mesonbuild.linkers.linkers import StaticLinker, VisualStudioLikeLinker, VisualStudioLinker
# https://bugs.python.org/issue36112
os.path.realpath = lambda path: path

View File

@ -16,7 +16,7 @@ __declspec(dllexport) int amvGetConnectedDisplaysEx_Nvidia(LPVOID pGpuHandle, DW
return 0;
}
__declspec(dllexport) int amvGetConnectedDisplays_Nvidia(LPBYTE displayType) {
return amvGetConnectedDisplays_Nvidia(NULL, 4, displayType);
return amvGetConnectedDisplaysEx_Nvidia(NULL, 4, displayType);
}
__declspec(dllexport) int amvGetCurrentPstateEx_Nvidia(LPVOID pGpuHandle, DWORD dwGpuHandleSize,
DWORD* pPstate) {

View File

@ -48,8 +48,7 @@ void set_eeprom_static_config() {
memcpy(&EEPROM_DATA[AM_SYSDATAwH_STATIC_DUP], &Static, sizeof Static);
}
void build_eeprom() {
return;
void build_eeprom() { // return;
log_info(plfEeprom, "Building default EEPROM file");
memset(EEPROM_DATA, 0xff, EEPROM_SIZE);

View File

@ -23,8 +23,9 @@ void build_sram() {
log_info(plfMxSram, "Building default SRAM file");
memset(SRAM_DATA, 0xff, SRAM_SIZE);
return;
// TODO: Do we want to re-enable this with actual values
#if false
AM_SYSDATAwH_BACKUP Backup = { 0 };
fix_crc(Backup);
memcpy(SRAM_DATA + ADDR_BACKUP, (unsigned char*)&Backup, sizeof Backup);
@ -44,6 +45,7 @@ void build_sram() {
fix_crc(ErrorLog);
memcpy(SRAM_DATA + ADDR_ERROR_LOG, (unsigned char*)&ErrorLog, sizeof ErrorLog);
memcpy(SRAM_DATA + ADDR_ERROR_LOG + ADDR_DUP, (unsigned char*)&ErrorLog, sizeof ErrorLog);
#endif
return;
}

View File

@ -345,9 +345,11 @@ HANDLE WINAPI FakeFindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFile
DWORD WINAPI FakeGetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer) {
strcpy_s(lpBuffer, nBufferLength, MiceFSGetCwd());
return strnlen_s(lpBuffer, nBufferLength);
}
DWORD WINAPI FakeGetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) {
MultiByteToWideChar(CP_ACP, 0, MiceFSGetCwd(), -1, lpBuffer, nBufferLength);
return wcsnlen_s(lpBuffer, nBufferLength);
}
void hook_io() {

View File

@ -153,22 +153,22 @@ int __stdcall Fake_socket(int domain, int type, int protocol) {
return sock;
}
static struct sockaddr pingSentTo;
static SOCKADDR pingSentTo;
static unsigned char pingInfo[4];
static struct sockaddr_in toLocalhost = {
.sin_addr = 0x0100007f,
static SOCKADDR_IN toLocalhost = {
.sin_addr.S_un.S_addr = 0x0100007f,
.sin_family = AF_INET,
.sin_port = 24,
.sin_zero = 0,
};
int __stdcall Fake_sendto(SOCKET s, const char* buf, int len, int flags, const struct sockaddr* to,
int __stdcall Fake_sendto(SOCKET s, const char* buf, int len, int flags, const PSOCKADDR to,
int tolen) {
// Hardcoded ICMP4 ping "detection"
// TODO: Only do this if the socket is using the ICMP protocol
if (len == 8 && buf[0] == 0x08 && buf[1] == 0x00) {
uint32_t addr = ((struct sockaddr_in*)to)->sin_addr.S_un.S_addr;
uint32_t addr = ((PSOCKADDR_IN)to)->sin_addr.S_un.S_addr;
memcpy(&pingSentTo, to, sizeof pingSentTo);
@ -178,11 +178,12 @@ int __stdcall Fake_sendto(SOCKET s, const char* buf, int len, int flags, const s
memcpy(&toLocalhost, to, sizeof toLocalhost);
toLocalhost.sin_addr.S_un.S_addr = 0x0100007f; // 127.0.0.1
to = &toLocalhost;
log_warning(plfNetwork, "(probable) Ping to: %d.%d.%d.%d (%d). Redirecting to localhost",
addr & 0xff, (addr >> 8) & 0xff, (addr >> 16) & 0xff, addr >> 24,
((struct sockaddr_in*)to)->sin_port, seq);
((PSOCKADDR_IN)to)->sin_port, seq);
return True_sendto(s, buf, len, flags, (PSOCKADDR)&toLocalhost, tolen);
}
return True_sendto(s, buf, len, flags, to, tolen);

View File

@ -29,7 +29,7 @@ LSTATUS WINAPI FakeRegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD
PFILETIME lpftLastWriteTime) {
log_misc(plfRegistry, "RegEnumKeyExA %08x[%d]", hKey, dwIndex);
if (dwIndex == 0 && !bHALDeleted) {
strcpy(lpName, "Direct3D HAL");
strcpy_s(lpName, RSIZE_MAX, "Direct3D HAL");
return ERROR_SUCCESS;
}
return ERROR_NO_MORE_ITEMS;

View File

@ -71,7 +71,7 @@ HMODULE WINAPI FakeLoadLibraryA(LPCSTR lpLibFileName) {
}
return TrueLoadLibraryA(lpLibFileName);
}
#define WIDEN2(x) L ## x
#define WIDEN2(x) L##x
#define WIDEN(x) WIDEN2(x)
HMODULE WINAPI FakeLoadLibraryW(LPCWSTR lpLibFileName) {
if (wcscmp(lpLibFileName, L"libamv_nvidia.dll") == 0) {
@ -107,10 +107,13 @@ void hook_system() {
"UeI3d2jT+Fw1dgRn7wIDAQAB\r\n"
"-----END PUBLIC KEY-----\r\n");
hook_file_with_buffer(L"C:\\System\\SystemVersion.txt", SystemVersion,
// We're going to violate the non-const data requirements for these files,
// because we're only allowing GENERIC_READ. In the future this may be made
// more generic.
hook_file_with_buffer(L"C:\\System\\SystemVersion.txt", (LPBYTE)SystemVersion,
strlen(SystemVersion) + 1, GENERIC_READ);
hook_file_with_buffer(L"C:\\System\\UpdateVersion.txt", UpdateVersion,
hook_file_with_buffer(L"C:\\System\\UpdateVersion.txt", (LPBYTE)UpdateVersion,
strlen(UpdateVersion) + 1, GENERIC_READ);
hook_file_with_buffer(L"c:\\System\\Execute\\ringmaster_pub.pem", RingmasterPub,
hook_file_with_buffer(L"c:\\System\\Execute\\ringmaster_pub.pem", (LPBYTE)RingmasterPub,
strlen(RingmasterPub) + 1, GENERIC_READ);
}

View File

@ -12,6 +12,10 @@ void SetDataForHandle(HANDLE hObject, DWORD type, PVOID pData, BOOL isHeap);
BOOL RemoveDataForHandle(HANDLE hObject, DWORD type);
HANDLE GetDummyHandle();
void BytesToHex(char* hex_buffer, BYTE* bytes, DWORD nbytes);
/**
* WARNING: This function will not work on XP machines!!
*/
void PrintStack(void);
BOOL PathEqual(LPCSTR path1, LPCSTR path2);

View File

@ -1,3 +1,6 @@
// Windows XP does not have RtlCaptureStackBackTrace. This is an awful workaround.
// TODO: Reimplement this ourselves so we can print stacks on XP
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#include <Windows.h>
#include <dbghelp.h>
@ -22,7 +25,7 @@ void PrintStack(void) {
for (i = 0; i < frames; i++) {
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol);
printf("%i: %s - 0x%0X\n", frames - i - 1, symbol->Name, symbol->Address);
printf("%i: %s - 0x%0X\n", frames - i - 1, symbol->Name, (unsigned int)symbol->Address);
}
free(symbol);
@ -118,7 +121,7 @@ HANDLE GetDummyHandle() {
void BytesToHex(char* hex_buffer, BYTE* bytes, DWORD nbytes) {
for (size_t i = 0; i < nbytes; i++) {
sprintf(hex_buffer + i * 3, "%02x ", bytes[i]);
sprintf_s(hex_buffer + i * 3, RSIZE_MAX, "%02x ", bytes[i]);
}
hex_buffer[nbytes * 3] = '\0';
}
@ -153,13 +156,17 @@ void make_dirs(const char* path) {
free(temp);
}
void* open_mapped_file(LPCWSTR path, DWORD size, HANDLE* file, HANDLE* file_mapping) {
make_dirs(path);
*file = _CreateFileW(path, GENERIC_READ | GENERIC_WRITE,
void* open_mapped_file(LPCWSTR lpFilename, DWORD size, HANDLE* file, HANDLE* file_mapping) {
char szFileName[MAX_PATH] = { 0 };
WideCharToMultiByte(CP_ACP, 0, lpFilename, wcslen(lpFilename), szFileName, sizeof szFileName,
NULL, NULL);
make_dirs(szFileName);
*file = _CreateFileW(lpFilename, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (*file == INVALID_HANDLE_VALUE) {
log_error(plfMisc, "Failed to CreateFileW(%ls): %d", path, GetLastError());
log_error(plfMisc, "Failed to CreateFileW(%ls): %d", lpFilename, GetLastError());
return NULL;
}

View File

@ -44,8 +44,7 @@ AM_DONGLE_STATUS amDongleInit(void) {
}
if (pcpa_err != e_pcpa_ok) {
if (amDongleDebugLevel > 0) {
amiDebugLog("Error: System error happened in pcp stream. ErrorCode = %d.",
pcpa_err);
amiDebugLog("Error: System error happened in pcp stream. ErrorCode = %d.", pcpa_err);
}
return AM_DONGLE_STATUS_ERR_SYS;
}
@ -160,8 +159,7 @@ AM_DONGLE_STATUS amDongleSetupKeychip(void) {
pcpa_err = pcpaOpenClient(&amDongle.pcpa, "127.0.0.1", amDongle.ctrl_port, 90000, 0);
if (pcpa_err != e_pcpa_ok) {
if (pcpa_err != e_pcpa_to) {
if (amDongleDebugLevel > 0)
amiDebugLog("Error : pcpaOpenClient(%d)", pcpa_err);
if (amDongleDebugLevel > 0) amiDebugLog("Error : pcpaOpenClient(%d)", pcpa_err);
amDongle.setupSeq = AM_DONGLE_SETUP_SEQ_ERR;
return AM_DONGLE_STATUS_PENDING;
@ -387,10 +385,12 @@ AM_DONGLE_STATUS amDongleResponseCheck(void) {
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_GET_PLATFORM_ID:
if (strcmp(keyword, "keychip.appboot.platformid") || command == NULL) break;
strcpy_s(amDongle.valueBuffer, 4, command);
strcpy_s((char *)amDongle.valueBuffer, 4, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_GET_NETWORK_ADDRESS:
if (strcmp(keyword, "keychip.appboot.networkaddr") || command == NULL) break;
// We can't use inet_pton because we target XP
#pragma warning(suppress : 4996)
if (amDongle.valueBuffer != NULL) *(uint *)amDongle.valueBuffer = inet_addr(command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_GET_VERSION:
@ -401,27 +401,27 @@ AM_DONGLE_STATUS amDongleResponseCheck(void) {
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_GET_KEYCHIP_ID:
if (strcmp(keyword, "keychip.billing.keyid") || command == NULL) break;
strcpy_s(amDongle.valueBuffer, 0x11, command);
strcpy_s((char *)amDongle.valueBuffer, 17, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_GET_MAIN_ID:
if (strcmp(keyword, "keychip.billing.mainid") || command == NULL) break;
strcpy_s(amDongle.valueBuffer, 0xc, command);
strcpy_s((char *)amDongle.valueBuffer, 12, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_GET_PLAYCOUNT:
if (strcmp(keyword, "keychip.billing.playcount") || command == NULL) break;
hex_to_int(amDongle.valueBuffer, command);
hex_to_int((unsigned int *)amDongle.valueBuffer, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_ADD_PLAYCOUNT:
if (strcmp(keyword, "keychip.billing.playcount") || command == NULL) break;
hex_to_int(amDongle.valueBuffer, command);
hex_to_int((unsigned int *)amDongle.valueBuffer, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_GET_PLAYLIMIT:
if (strcmp(keyword, "keychip.billing.playlimit") || command == NULL) break;
hex_to_int(amDongle.valueBuffer, command);
hex_to_int((unsigned int *)amDongle.valueBuffer, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_GET_NEARFULL:
if (strcmp(keyword, "keychip.billing.nearfull") || command == NULL) break;
hex_to_int(amDongle.valueBuffer, command);
hex_to_int((unsigned int *)amDongle.valueBuffer, command);
return AM_DONGLE_STATUS_OK;
case AM_DONGLE_REQUEST_BILLING_TD_RESTORE:
if (strcmp(keyword, "keychip.tracedata.restore") || command == NULL) break;
@ -1133,8 +1133,7 @@ AM_DONGLE_STATUS amDongleSetIv(AM_DONGLE_BLOCKING blocking) {
if (!amDongle.done_init || !amDongle.available) return AM_DONGLE_STATUS_NG;
if (amDongle.seq != AM_DONGLE_SEQ_NONE) return AM_DONGLE_STATUS_BUSY;
pcp_send_data_t *send_data =
pcpaSetSendPacket(&amDongle.pcpa, "keychip.setiv", "?");
pcp_send_data_t *send_data = pcpaSetSendPacket(&amDongle.pcpa, "keychip.setiv", "?");
if (send_data == NULL && amDongleDebugLevel > 0) {
amiDebugLog("Error: pcpaSetSendPacket return NULL");
}
@ -1146,15 +1145,14 @@ AM_DONGLE_STATUS amDongleSetIv(AM_DONGLE_BLOCKING blocking) {
return amDongleOpen();
}
AM_DONGLE_STATUS amDongleGetSeed(unsigned char* seed, AM_DONGLE_BLOCKING blocking) {
AM_DONGLE_STATUS amDongleGetSeed(unsigned char *seed, AM_DONGLE_BLOCKING blocking) {
if (!amDongle.m_init) return AM_DONGLE_STATUS_ERR_NO_INIT;
if (!amDongle.auth_ready) return AM_DONGLE_STATUS_ERR_AUTH_READY;
if (!amDongle.done_init || !amDongle.available) return AM_DONGLE_STATUS_NG;
if (amDongle.seq != AM_DONGLE_SEQ_NONE) return AM_DONGLE_STATUS_BUSY;
if (seed == NULL) return AM_DONGLE_STATUS_ERR_INVALID_PARAM;
pcp_send_data_t *send_data =
pcpaSetSendPacket(&amDongle.pcpa, "keychip.appboot.seed", "?");
pcp_send_data_t *send_data = pcpaSetSendPacket(&amDongle.pcpa, "keychip.appboot.seed", "?");
if (send_data == NULL && amDongleDebugLevel > 0) {
amiDebugLog("Error: pcpaSetSendPacket return NULL");
}

View File

@ -20,10 +20,11 @@ void amiCrc32RCreateTable(uint32_t *table) {
uint32_t amiCrc32RGet(uint32_t *table, int length, void *data, uint32_t initial) {
uint32_t value = ~initial;
unsigned char* lpcData = (unsigned char*)data;
while (length > 0) {
value = value >> 8 ^ table[(((unsigned char *)data)[0] ^ value) & 0xff];
value = value >> 8 ^ table[(lpcData[0] ^ value) & 0xff];
length += -1;
((unsigned char *)data)++;
lpcData++;
}
return ~value;
}

View File

@ -19,7 +19,7 @@ amtime_t* amiTimerGet(amtime_t* time);
#define _amTimeMs(time) (((time).microseconds / 1000 + (time).seconds * 1000))
#define _amTimeDelta(now, start) \
(((now).microseconds - (start).microseconds) / 1000 + ((now).seconds - (start).seconds) * 1000)
(int)(((now).microseconds - (start).microseconds) / 1000 + ((now).seconds - (start).seconds) * 1000)
int amiTimerDiffSec(amtime_t* start, amtime_t* now);
int amiTimerDiffMsec(amtime_t* start, amtime_t* now);

View File

@ -4,10 +4,10 @@
#define ZERO_BUF(x) memset((x), 0, sizeof(*x))
#include <Winsock2.h>
#include <ws2ipdef.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <ws2ipdef.h>
#include "../ami/ami.h"
@ -29,7 +29,7 @@ typedef unsigned char byte;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned int timeout_t;
typedef int timeout_t;
#define PCP_BUF_MAX 256
#define PCP_CMDS_MAX 64
@ -58,11 +58,6 @@ typedef enum binary_mode {
binary_mode_recv = 2,
} binary_mode_t;
#define PCPT_CONFIG_0 0
#define PCPT_CONFIG_1 1
#define PCPT_SO_LINGER 2
#define PCPT_TCP_NODELAY 3
#define SOCKET_INVAL ((SOCKET)-1)
#define HANDLE_INVAL -1
#define TIMEOUT_NONE ((timeout_t)-1)

View File

@ -137,7 +137,7 @@ e_pcpa_t pcpaOpenClient(pcpa_t *stream, char *ipAddr, ushort port, uint param_4,
}
e_pcpa_t pcpaOpenServerWithBinary(pcpa_t *stream, int open_mode, u_short port, u_short binary_port,
undefined4 param_5) {
timeout_t param_5) {
e_pcpa_t err;
if (stream == NULL) {
@ -524,7 +524,7 @@ LAB_00454d84:
return stream->err;
}
e_pcpa_t pcpaRecvBinary(pcpa_t *stream, uint something) {
e_pcpa_t pcpaRecvBinary(pcpa_t *stream, timeout_t something) {
if (stream == NULL) {
amiDebugLog("error PCPA stream isn't set");
return e_pcpa_stream_unset;
@ -545,7 +545,7 @@ e_pcpa_t pcpaRecvBinary(pcpa_t *stream, uint something) {
return err;
}
e_pcpa_t pcpaSendBinary(pcpa_t *stream, uint param_2) {
e_pcpa_t pcpaSendBinary(pcpa_t *stream, timeout_t param_2) {
if (stream == NULL) {
amiDebugLog("error PCPA stream isn't set");
return e_pcpa_stream_unset;
@ -678,7 +678,7 @@ e_pcpa_t pcpaIsBusy(pcpa_t *pcpa, timeout_t timeout) {
pcpa->state = 12;
if (timeout != TIMEOUT_NONE) {
amiTimerGet(&now);
uint dt = _amTimeDelta(now, start);
timeout_t dt = _amTimeDelta(now, start);
if (dt < timeout) {
timeout -= dt;
} else {
@ -692,7 +692,7 @@ e_pcpa_t pcpaIsBusy(pcpa_t *pcpa, timeout_t timeout) {
pcpa->state = 14;
if (timeout != TIMEOUT_NONE) {
amiTimerGet(&now);
uint dt = _amTimeDelta(now, start);
timeout_t dt = _amTimeDelta(now, start);
if (dt < timeout) {
timeout -= dt;
} else {
@ -764,6 +764,8 @@ e_pcpa_t pcpaOpenBinaryClient(pcpa_t *stream, ushort port, timeout_t timeout) {
SOCKADDR_IN *addr = (SOCKADDR_IN *)pcppGetSockAddr(&stream->pcpp, false);
stream->state = pcpa_state_open_binary;
// We can't use inet_ntop because we target XP
#pragma warning(suppress : 4996)
char *ipAddr = inet_ntoa(addr->sin_addr);
e_pcpa_t pcpa_err =
@ -799,7 +801,7 @@ e_pcpa_t pcpaAccessClient(pcpa_t *stream, timeout_t timeout) {
if (timeout != TIMEOUT_NONE) {
amiTimerGet(&now);
uint delta = amiTimerDiffMsec(&start, &now);
timeout_t delta = amiTimerDiffMsec(&start, &now);
if (delta < timeout) {
timeout -= delta;
} else {

View File

@ -61,7 +61,7 @@ typedef struct pcpa {
uint callback_count;
unsigned char* recv_buffer;
size_t recv_buffer_len;
unsigned char* send_buffer;
const unsigned char* send_buffer;
size_t send_buffer_len;
binary_mode_t binary_mode;
pcpa_callback* binary_mode_before_cb;
@ -81,9 +81,9 @@ void pcpaCloseBinary(pcpa_t* stream);
char* pcpaGetKeyword(pcpa_t* stream, uint keyword_num);
e_pcpa_t pcpaInitStream(pcpa_t* stream);
e_pcpa_t pcpaOpenClient(pcpa_t* stream, char* ipAddr, ushort port, uint param_4, timeout_t timeout);
e_pcpa_t pcpaOpenServerWithBinary(pcpa_t* stream, int open_mode, ushort port, ushort binary_port, undefined4 param_5);
e_pcpa_t pcpaRecvBinary(pcpa_t* stream, undefined4 something);
e_pcpa_t pcpaSendBinary(pcpa_t* stream, undefined4 something);
e_pcpa_t pcpaOpenServerWithBinary(pcpa_t* stream, int open_mode, ushort port, ushort binary_port, timeout_t param_5);
e_pcpa_t pcpaRecvBinary(pcpa_t* stream, timeout_t something);
e_pcpa_t pcpaSendBinary(pcpa_t* stream, timeout_t something);
e_pcpa_t pcpaServer(pcpa_t* stream, timeout_t timeout_ms);
e_pcpa_t pcpaSetAfterBinaryModeCallBackFunc(pcpa_t* stream, pcpa_callback* callback, void* data);
e_pcpa_t pcpaSetBeforeBinaryModeCallBackFunc(pcpa_t* stream, pcpa_callback* callback, void* data);

View File

@ -53,6 +53,14 @@ e_pcpp_t _pcppGetErrorFromPcpt(int err) {
}
}
/**
* @brief Locate a PCP prompt string. The last prompt located in the
* buffer will be used, and all data following it moved to the
* beginning of the buffer.
*
* @return true
* @return false
*/
bool pcppCheckPrompt(pcpp_t* stream) {
if (stream == NULL) {
amiDebugLog("error PCPP stream isn't set");
@ -64,18 +72,19 @@ bool pcppCheckPrompt(pcpp_t* stream) {
for (uint cursor = 0; cursor < max; cursor++) {
char* pos = stream->read_bytes_buf + cursor;
if (stream->read_bytes_buf[cursor] == '>') {
if (cursor < stream->read_bytes_num) {
do {
*pos = pos[1];
pos++;
} while (pos + (-204 - (int)stream) < (char*)stream->read_bytes_num);
// Scan for the prompt character
if (stream->read_bytes_buf[cursor] != PCP_CHAR_PROMPT) continue;
found = true;
// Shift everything one character left (clobber the prompt)
for (uint i = cursor; i < stream->read_bytes_num - 1; i++) {
pos[i] = pos[i + 1];
}
// Adjust counts accordingly
stream->read_bytes_num--;
stream->read_bytes_size++;
found = true;
}
}
return found;
@ -218,7 +227,7 @@ void pcppCloseBinary(pcpp_t* stream) {
}
e_pcpp_t pcppGetBlockingTime(uint param_1, timeout_t timeout, pcpp_t* stream, int param_4,
uint* blocking_time) {
timeout_t* blocking_time) {
byte bVar1;
uint uVar2;
uint uVar3;
@ -348,7 +357,7 @@ e_pcpp_t pcppInitStream(pcpp_t* stream) {
e_pcpp_t pcppOpenClient(pcpp_t* stream, char* ipAddr, ushort port, uint param_4,
timeout_t timeout) {
e_pcpp_t iVar1;
uint uVar3;
timeout_t uVar3;
amtime_t start;
amtime_t now;
@ -739,14 +748,17 @@ e_pcpp_t pcppRecvRequestMain(pcpp_t* stream, bool* bReRecv, undefined4 timeout)
recv_data = stream->read_bytes_buf;
if (pcppCheckRecvMsg(recv_data, stream->read_bytes_num, 1) != e_pcpp_ok) {
pcppResetRead(stream);
return -9;
return e_pcpp_data_format_error;
}
uint local_4 = 0;
pcppChangeRequest(stream, &local_4);
if (local_4 < stream->read_bytes_num)
memcpy(recv_data + local_4, recv_data, stream->read_bytes_num);
if (local_4 < stream->read_bytes_num) {
for (uint i = 0; i < stream->read_bytes_num; i++) {
recv_data[local_4 + i] = recv_data[i];
}
}
stream->read_bytes_num -= local_4;
stream->read_bytes_size += local_4;
@ -795,10 +807,9 @@ LAB_00456133:
e_pcpp_t pcppRecvAllMsg(pcpp_t* stream, uint param_1, bool* bReRecv) {
uint* recv_buf_len;
int iVar1;
e_pcpt_t err;
e_pcpp_t eVar2;
undefined4 uVar3;
uint local_14;
timeout_t local_14;
amtime_t local_10;
amtime_t local_8;
@ -947,11 +958,11 @@ pcp_parse_data_t* pcppChangeRequest(pcpp_t* stream, uint* lenout) {
return stream->recv_data_buffer;
}
int pcppRecvPrompt(pcpp_t* stream, undefined4 param_2, int param_3) {
int pcppRecvPrompt(pcpp_t* stream, undefined4 param_2, timeout_t param_3) {
uint* recv_buf_len;
int iVar1;
uint local_c = param_3;
timeout_t local_c = param_3;
if (stream == NULL) {
amiDebugLog("error PCPP stream isn't set");
return e_pcpp_param_invalid;
@ -1023,19 +1034,20 @@ e_pcpp_t pcppSendRequestMain(pcpp_t* stream, undefined4 param_2, timeout_t timeo
// TODO: MINIMAL CLEANUP DONE HERE
e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len, uint param_4) {
e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len,
timeout_t timeout) {
size_t* psVar1;
int iVar2;
e_pcpt_t eVar3;
e_pcpp_t eVar4;
undefined4 uVar5;
bool bVar6;
uint recvb_local;
timeout_t timeout_local;
amtime_t now;
amtime_t local_10;
amtime_t local_8;
recvb_local = param_4;
timeout_local = timeout;
if (stream == NULL) {
amiDebugLog("error PCPP stream isn't set");
return e_pcpp_param_invalid;
@ -1063,10 +1075,10 @@ e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len,
stream->last_active = _amTimeMs(local_8);
;
}
iVar2 = pcppGetBlockingTime(uVar5, param_4, stream, _amTimeMs(now), &recvb_local);
iVar2 = pcppGetBlockingTime(uVar5, timeout, stream, _amTimeMs(now), &timeout_local);
stream->field_0x214 = 1;
eVar3 = pcptRecv(&stream->data_sock, stream->recv_binary_buf + stream->field_0x1fc, psVar1,
recvb_local);
timeout_local);
eVar4 = _errT2P(eVar3);
stream->err = eVar4;
if ((eVar4 == e_pcpp_to) && (iVar2 != 0)) {
@ -1101,10 +1113,9 @@ e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len,
stream->state = pcpp_state_send_binary_ack;
send_buf[0] = PCP_CHAR_BINACK;
*psVar1 = 1;
iVar2 = pcppGetBlockingTime(stream->field_0x20c, param_4, stream, _amTimeMs(now),
&recvb_local);
eVar3 = pcptSend(&stream->sock, send_buf, psVar1, stream->field_0x208,
recvb_local);
iVar2 = pcppGetBlockingTime(stream->field_0x20c, timeout, stream, _amTimeMs(now),
&timeout_local);
eVar3 = pcptSend(&stream->sock, send_buf, psVar1, stream->field_0x208, timeout_local);
eVar4 = _errT2P(eVar3);
stream->err = eVar4;
if ((eVar4 == e_pcpp_to) && (iVar2 != 0)) {
@ -1120,12 +1131,11 @@ e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len,
amiTimerGet(&local_10);
stream->last_active = _amTimeMs(local_10);
stream->state = pcpp_state_send_binary_ack_wait;
iVar2 = pcppGetBlockingTime(stream->field_0x208, param_4, stream, _amTimeMs(now),
&recvb_local);
iVar2 = pcppGetBlockingTime(stream->field_0x208, timeout, stream, _amTimeMs(now),
&timeout_local);
*psVar1 = PCP_SEND_BUF_MAX;
ZERO(stream->send_buf);
eVar3 =
pcptRecv(&stream->data_sock, send_buf, psVar1, recvb_local);
eVar3 = pcptRecv(&stream->data_sock, send_buf, psVar1, timeout_local);
eVar4 = _errT2P(eVar3);
stream->err = eVar4;
if ((iVar2 != 0) && (eVar4 == e_pcpp_to)) {
@ -1144,7 +1154,7 @@ e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len,
} while (true);
}
e_pcpp_t pcppSendBinary(pcpp_t* stream, unsigned char* send_binary_buffer, size_t param_3,
e_pcpp_t pcppSendBinary(pcpp_t* stream, const unsigned char* send_binary_buffer, size_t param_3,
uint param_4)
{
@ -1154,7 +1164,7 @@ e_pcpp_t pcppSendBinary(pcpp_t* stream, unsigned char* send_binary_buffer, size_
int iVar4;
e_pcpt_t eVar5;
uint uVar6;
uint local_14;
timeout_t local_14;
amtime_t local_10;
amtime_t local_8;
@ -1222,17 +1232,13 @@ e_pcpp_t pcppSendBinary(pcpp_t* stream, unsigned char* send_binary_buffer, size_
uVar6 = 0;
*psVar1 = 8 - stream->field_0x1e8;
stream->state = pcpp_state_none;
stream->err = -9;
if (stream->field_0x1e8 != 0) {
while (*(char*)((int)&stream->send_buf + uVar6) != PCP_CHAR_BINACK) {
uVar6 = uVar6 + 1;
if (stream->field_0x1e8 <= uVar6) {
return stream->err;
for (uint i = 0; i < stream->field_0x1e8; i++) {
if (stream->send_buf[i] == PCP_CHAR_BINACK) {
return (stream->err = e_pcpp_ok);
}
}
stream->err = e_pcpp_ok;
}
eVar3 = stream->err;
return (stream->err = e_pcpp_data_format_error);
}
}
return eVar3;
@ -1245,12 +1251,11 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
int iVar3;
e_pcpt_t eVar4;
int iVar5;
uint uVar6;
timeout_t uVar6;
e_pcpp_t eVar7;
char* pcVar8;
char* pcVar9;
uint uVar10;
uint uVar11;
timeout_t uVar10;
timeout_t uVar11;
bool bVar12;
bool local_24;
int local_20;
@ -1306,7 +1311,10 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
stream->read_bytes_num + stream->read_bytes_size;
stream->read_bytes_size = PCP_BUF_MAX - stream->read_bytes_num;
iVar3 = pcppCheckPrompt(stream);
if (iVar3 != 0) goto LAB_00457676;
if (iVar3 != 0) {
stream->err = e_pcpp_ok;
return e_pcpp_ok;
}
stream->err = ~e_pcpp_no_client;
goto LAB_00457660;
}
@ -1418,10 +1426,7 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
uVar6 = uVar11;
if (uVar11 != TIMEOUT_NONE) {
amiTimerGet(&local_8);
uVar6 =
-(uint)((uint)((local_8.microseconds - local_18.microseconds) / 1000 +
(local_8.seconds - local_18.seconds) * 1000) < uVar11) &
uVar11;
uVar6 = amiTimerDiffMsec(&local_18, &local_8) < uVar11 ? uVar11 : 0;
}
eVar7 = pcppRecvPrompt(stream, stream->field_0xb8, uVar6);
stream->err = eVar7;
@ -1431,11 +1436,7 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
if (uVar11 != TIMEOUT_NONE) {
amiTimerGet(&local_8);
uVar11 =
-(uint)((uint)((local_8.microseconds - local_18.microseconds) /
1000 +
(local_8.seconds - local_18.seconds) * 1000) <
uVar11) &
uVar11;
amiTimerDiffMsec(&local_18, &local_8) < uVar11 ? uVar11 : 0;
}
stream->state = pcpp_state_send_request;
eVar7 = pcppSendRequestMain(stream, stream->field_0xb8, uVar11);
@ -1491,19 +1492,15 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
pcppCheckRecvMsg(pcVar8, stream->read_bytes_num, (uint)(stream->state == 5));
stream->err = eVar7;
if (eVar7 == e_pcpp_ok) {
pcppChangeRequest(stream, &timeout);
uVar11 = timeout;
pcVar9 = pcVar8;
if (timeout < stream->read_bytes_num) {
do {
*pcVar9 = pcVar8[uVar11];
uVar11 = uVar11 + 1;
pcVar9 = pcVar9 + 1;
} while (uVar11 < stream->read_bytes_num);
uint lenout;
pcppChangeRequest(stream, &lenout);
if (lenout < stream->read_bytes_num) {
for (uint i = 0; i < stream->read_bytes_num - lenout; i++) {
pcVar8[i] = pcVar8[i + lenout];
}
LAB_00458226:
stream->read_bytes_num = stream->read_bytes_num - timeout;
stream->read_bytes_size = stream->read_bytes_size + timeout;
}
stream->read_bytes_num = stream->read_bytes_num - lenout;
stream->read_bytes_size = stream->read_bytes_size + lenout;
stream->state = pcpp_state_none;
amiTimerGet(&local_18);
stream->last_active = _amTimeMs(local_18);
@ -1574,18 +1571,16 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
}
if (stream->err == e_pcpp_ok) {
stream->field_0x1e8 = stream->field_0x1e8 + *psVar1;
uVar11 = 0;
*psVar1 = PCP_SEND_BUF_MAX - stream->field_0x1e8;
stream->state = pcpp_state_none;
stream->err = -9;
stream->err = e_pcpp_data_format_error;
if (stream->field_0x1e8 != 0) {
do {
if (*(char*)((int)&stream->send_buf + uVar11) == PCP_CHAR_BINACK) {
for (uint i = 0; i < stream->field_0x1e8; i++) {
if (stream->send_buf[i] == PCP_CHAR_BINACK) {
stream->err = e_pcpp_ok;
break;
}
uVar11 = uVar11 + 1;
} while (uVar11 < stream->field_0x1e8);
}
}
amiTimerGet(&local_10);
stream->last_active = _amTimeMs(local_10);
@ -1614,20 +1609,14 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
;
uVar11 = 0;
stream->send_buf_len = PCP_SEND_BUF_MAX - stream->field_0x1e8;
stream->err = -9;
if (stream->field_0x1e8 != 0) {
while (*(char*)((int)&stream->send_buf + uVar11) != PCP_CHAR_BINACK) {
uVar11 = uVar11 + 1;
if (stream->field_0x1e8 <= uVar11) {
for (uint i = 0; i < stream->field_0x1e8; i++) {
if (stream->send_buf[i] == PCP_CHAR_BINACK) {
return (stream->err = e_pcpp_ok);
}
}
return (stream->err = e_pcpp_data_format_error);
}
return stream->err;
}
}
LAB_00457676:
stream->err = e_pcpp_ok;
return e_pcpp_ok;
}
}
break;
case pcpp_state_recv_binary:
if (stream->field_0x214 != 0) {
bVar12 = (stream->data_sock).open != PCPT_LISTENING;
@ -1827,17 +1816,20 @@ e_pcpp_t pcppIsBusy(pcpp_t* stream, timeout_t timeout) {
amiDebugLog("error Response format error");
return stream->err;
}
pcppChangeRequest(stream, &timeout);
uVar11 = timeout;
pcVar9 = pcVar8;
if (timeout < stream->read_bytes_num) {
do {
*pcVar9 = pcVar8[uVar11];
uVar11 = uVar11 + 1;
pcVar9 = pcVar9 + 1;
} while (uVar11 < stream->read_bytes_num);
uint lenout;
pcppChangeRequest(stream, &lenout);
if (lenout < stream->read_bytes_num) {
for (uint i = 0; i < stream->read_bytes_num - lenout; i++) {
pcVar8[i] = pcVar8[i + lenout];
}
goto LAB_00458226;
}
stream->read_bytes_num = stream->read_bytes_num - lenout;
stream->read_bytes_size = stream->read_bytes_size + lenout;
stream->state = pcpp_state_none;
amiTimerGet(&local_18);
stream->last_active = _amTimeMs(local_18);
return stream->err;
}
if (eVar7 == e_pcpp_to) {
if (local_24 == 0) {
@ -1854,10 +1846,10 @@ switchD_004572ff_caseD_10:
}
int pcpp_something(amtime_t* time, timeout_t timeout, pcpp_t* stream, pcpt_t* sock,
unsigned char* send_buf, size_t* send_len, undefined4 param_7,
const unsigned char* send_buf, size_t* send_len, undefined4 param_7,
undefined4 param_8, int fallback_err) {
uint iVar1;
uint blocking_time;
timeout_t iVar1;
timeout_t blocking_time;
amtime_t now;
e_pcpp_t err;
@ -2020,15 +2012,12 @@ e_pcpp_t pcppRecvResponse(pcpp_t* stream, pcp_parse_data_t* buffer, timeout_t ti
if (iVar1 == 0) {
uint lenout;
pcppChangeRequest(stream, &lenout);
uint ppVar2 = lenout;
char* pcVar3 = pcVar5;
if (lenout < stream->read_bytes_num) {
do {
*pcVar3 = pcVar5[ppVar2];
ppVar2++;
pcVar3++;
} while (ppVar2 < stream->read_bytes_num);
for (uint i = 0; i < stream->read_bytes_num - lenout; i++) {
pcVar5[i] = pcVar5[i + lenout];
}
}
stream->read_bytes_num = stream->read_bytes_num - (int)lenout;
stream->read_bytes_size = (stream->read_bytes_size - 0x46) + lenout;
stream->state = pcpp_state_none;
@ -2045,7 +2034,7 @@ e_pcpp_t pcppRecvResponse(pcpp_t* stream, pcp_parse_data_t* buffer, timeout_t ti
return stream->err;
}
SOCKADDR* pcppGetSockAddr(pcpp_t* stream, bool is_data) {
SOCKADDR_IN* pcppGetSockAddr(pcpp_t* stream, bool is_data) {
if (stream == NULL) {
amiDebugLog("error PCPP stream isn't set");
return NULL;

View File

@ -16,6 +16,7 @@ typedef enum e_pcpp {
e_pcpp_already_open = -3,
e_pcpp_param_invalid = -5,
e_pcpp_timeout_closed = -6,
e_pcpp_data_format_error = -9,
e_pcpp_recv_unset = -10,
e_pcpp_no_server = -11,
e_pcpp_timeout_open = -12,
@ -25,7 +26,6 @@ typedef enum e_pcpp {
e_pcpp_uk1 = -14,
e_pcpp_uk2 = -13,
e_pcpp_uk4 = -9,
e_pcpp_uk5 = -8,
e_pcpp_uk6 = -7,
e_pcpp_uk7 = -4,
@ -76,7 +76,7 @@ typedef struct pcpp {
char send_buf[PCP_SEND_BUF_MAX];
size_t send_buf_len;
uint field_0x1e8;
unsigned char* send_binary_buf;
const unsigned char* send_binary_buf;
uint field_0x1f0;
unsigned char* recv_binary_buf;
size_t field_0x1f8;
@ -86,7 +86,7 @@ typedef struct pcpp {
uint field_0x204;
uint field_0x208;
uint field_0x20c;
uint field_0x210;
timeout_t field_0x210;
int field_0x214;
int open;
} pcpp_t;
@ -99,7 +99,7 @@ uint pcppCheckStr(char* param_1, uint* pcp_len, int* pcp_overflow);
void pcppClose(pcpp_t* stream);
void pcppCloseBinary(pcpp_t* stream);
e_pcpp_t pcppGetBlockingTime(uint param_1, timeout_t param_2, pcpp_t* stream, int param_4,
uint* blocking_time);
timeout_t* blocking_time);
char* pcppGetCommand(pcp_parse_data_t* pcpa, char* command);
char* pcppGetKeyword(pcp_parse_data_t* recvData, uint keyword_num);
SOCKET pcppGetServerSocket(pcpp_t* stream, int which);
@ -109,12 +109,12 @@ e_pcpp_t pcppOpenClient(pcpp_t* stream, char* ipAddr, ushort port, uint param_4,
e_pcpp_t pcppOpenBinaryServer(pcpp_t* stream, int open_mode, ushort port);
e_pcpp_t pcppOpenServer(pcpp_t* stream, int open_mode, ushort port, undefined4 param_4);
e_pcpp_t pcppRecvAllMsg(pcpp_t* stream, uint param_1, bool* bReRecv);
e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len, uint param_4);
e_pcpp_t pcppRecvBinary(pcpp_t* stream, unsigned char* recv_buf, size_t buf_len, timeout_t param_4);
uint pcppRecvCheck(char* buf, int* found_at);
e_pcpp_t pcppRecvPrompt(pcpp_t* stream, undefined4 param_2, int param_3);
e_pcpp_t pcppRecvPrompt(pcpp_t* stream, undefined4 param_2, timeout_t param_3);
e_pcpp_t pcppRecvRequest(pcpp_t* stream, pcp_parse_data_t* recv_data, timeout_t timeout);
e_pcpp_t pcppRecvRequestMain(pcpp_t* stream, bool* bReRecv, undefined4 param_3);
e_pcpp_t pcppSendBinary(pcpp_t* stream, unsigned char* send_binary_buffer, size_t param_3,
e_pcpp_t pcppSendBinary(pcpp_t* stream, const unsigned char* send_binary_buffer, size_t param_3,
uint param_4);
e_pcpp_t pcppSendPrompt(pcpp_t* stream, uint param_2, timeout_t timeout_ms);
e_pcpp_t pcppSendRequestMain(pcpp_t* stream, undefined4 param_2, timeout_t timeout_ms);
@ -123,7 +123,7 @@ e_pcpp_t pcppSendResponse(pcpp_t* stream, pcp_send_data_t* resp_buffer, size_t b
e_pcpp_t pcppSendResponseTable(pcpp_t* stream, pcp_send_data_t* data, timeout_t timeout_ms);
pcp_send_data_t* pcppSetSendPacket(pcp_send_data_t* send_data, char* keyword, char* value);
e_pcpp_t pcpp_something(amtime_t* now, timeout_t timeout, pcpp_t* stream, pcpt_t* sock,
unsigned char* send_buf, size_t* send_len, undefined4 param_7,
const unsigned char* send_buf, size_t* send_len, undefined4 param_7,
undefined4 param_8, e_pcpp_t fallback_err);
void pcppResetRead(pcpp_t* param_1);
e_pcpp_t pcppSendRequestTable(pcpp_t* stream, pcp_send_data_t* request_buffer, timeout_t timeout);
@ -131,4 +131,4 @@ e_pcpp_t pcppSendRequest(pcpp_t* stream, pcp_send_data_t* request_buffer, uint n
timeout_t timeout);
e_pcpp_t pcppRecvResponse(pcpp_t* stream, pcp_parse_data_t* buffer, timeout_t timeout);
e_pcpp_t pcppOpenBinaryClient(pcpp_t* stream, char* ipAddr, ushort port, timeout_t timeout);
SOCKADDR* pcppGetSockAddr(pcpp_t* stream, bool is_data);
SOCKADDR_IN* pcppGetSockAddr(pcpp_t* stream, bool is_data);

View File

@ -125,8 +125,8 @@ e_pcpt_t pcptAcceptServer(pcpt_t *stream, timeout_t timeout_ms) {
e_pcpt_t err = pcptCheckEvent(stream->server_event, timeout_ms, stream->server_sock, FD_ACCEPT);
if (err != e_pcpt_ok) return err;
int addrlen = 16;
SOCKET client = accept(stream->server_sock, &stream->client_addr, &addrlen);
int addrlen = sizeof stream->client_addr;
SOCKET client = accept(stream->server_sock, (PSOCKADDR)&stream->client_addr, &addrlen);
stream->client_sock = client;
if (client == SOCKET_INVAL) return _errW2T(GetLastError());
@ -148,8 +148,8 @@ e_pcpt_t pcptAcceptServer(pcpt_t *stream, timeout_t timeout_ms) {
}
e_pcpt_t pcptCheckConnectAble(pcpt_t *stream, timeout_t timeout_ms) {
DWORD DVar1;
uint uVar3;
timeout_t DVar1;
timeout_t uVar3;
HANDLE event;
bool bVar5;
e_pcpt_t local_44;
@ -224,7 +224,7 @@ e_pcpt_t pcptCheckEvent(HANDLE event, timeout_t timeout_ms, SOCKET socket, uint
amiTimerGet(&start);
now.seconds = start.seconds;
now.microseconds = start.microseconds;
DWORD wait_timeout = timeout_ms;
timeout_t wait_timeout = timeout_ms;
if (timeout_ms == TIMEOUT_NONE) wait_timeout = TIMEOUT_NONE;
if (event == NULL) {
@ -235,7 +235,7 @@ e_pcpt_t pcptCheckEvent(HANDLE event, timeout_t timeout_ms, SOCKET socket, uint
event_mask &= 0xffffffdf;
while (1) {
DWORD err = WaitForSingleObject(event, wait_timeout);
DWORD err = WaitForSingleObject(event, (DWORD)wait_timeout);
if ((err != WAIT_TIMEOUT && err != 0) || FAILED(err)) {
return e_pcpt_wsa2_generic;
}
@ -345,7 +345,7 @@ e_pcpt_t pcptOpenServer(pcpt_t *stream, int open_mode, ushort port) {
e_pcpt_t pcptOpenClient(pcpt_t *stream, char *ipAddr, ushort port, timeout_t timeout) {
pcpt_t *pcpt;
uint uVar6;
timeout_t uVar6;
amtime_t start;
amtime_t now;
@ -366,6 +366,8 @@ e_pcpt_t pcptOpenClient(pcpt_t *stream, char *ipAddr, ushort port, timeout_t tim
SOCKADDR_IN *pAddr = &stream->client_addr;
pAddr->sin_port = ntohs(port);
pAddr->sin_family = AF_INET;
// We can't use inet_pton because we target XP
#pragma warning(suppress : 4996)
pAddr->sin_addr.s_addr = inet_addr(ipAddr);
SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
@ -393,7 +395,8 @@ e_pcpt_t pcptOpenClient(pcpt_t *stream, char *ipAddr, ushort port, timeout_t tim
}
WSAEventSelect(pcpt->client_sock, client_event, 0x30);
if (connect(pcpt->client_sock, &stream->client_addr, 0x10) != -1) {
if (connect(pcpt->client_sock, (PSOCKADDR)&stream->client_addr,
sizeof stream->client_addr) != -1) {
WSAEventSelect(pcpt->client_sock, 0, 0);
WSACloseEvent(pcpt->client_event);
pcpt->client_event = 0;
@ -503,7 +506,7 @@ e_pcpt_t pcptRecv(pcpt_t *sock, unsigned char *recv_buf, size_t *recv_buf_len,
if (timeout_ms != TIMEOUT_NONE) {
amiTimerGet(&now);
uint elapsed = _amTimeDelta(now, start);
timeout_t elapsed = _amTimeDelta(now, start);
if (elapsed < timeout_ms)
timeout_ms = timeout_ms - elapsed;
@ -535,7 +538,7 @@ e_pcpt_t pcptRecv(pcpt_t *sock, unsigned char *recv_buf, size_t *recv_buf_len,
return sock->err;
}
e_pcpt_t pcptSend(pcpt_t *sock, unsigned char *send_buf, size_t *send_len, uint param_4,
e_pcpt_t pcptSend(pcpt_t *sock, const unsigned char *send_buf, size_t *send_len, uint param_4,
timeout_t timeout_ms) {
e_pcpt_t err;
amtime_t now;
@ -569,7 +572,7 @@ e_pcpt_t pcptSend(pcpt_t *sock, unsigned char *send_buf, size_t *send_len, uint
if (err == e_pcpt_ok) {
amiTimerGet(&now);
uint elapsed = _amTimeDelta(now, start_time);
timeout_t elapsed = _amTimeDelta(now, start_time);
if (timeout_ms != TIMEOUT_NONE) {
if (elapsed < timeout_ms)
timeout_ms = timeout_ms - elapsed;
@ -622,10 +625,10 @@ e_pcpt_t pcptSendAllMsg(pcpt_t *sock, timeout_t timeout_ms) {
bVar2 = false;
amiTimerGet(&now);
uint elapsed = _amTimeDelta(now, start);
timeout_t elapsed = _amTimeDelta(now, start);
if (timeout_ms != TIMEOUT_NONE && timeout_ms < elapsed) return e_pcpt_to;
uint wait_time;
timeout_t wait_time;
if (bVar3) {
wait_time = timeout_ms;
if (timeout_ms != TIMEOUT_NONE) wait_time = timeout_ms - elapsed;
@ -662,7 +665,7 @@ e_pcpt_t pcptSendAllMsg(pcpt_t *sock, timeout_t timeout_ms) {
}
}
void pcptSetConfig(pcpt_t *stream, uint config, uint value) {
void pcptSetConfig(pcpt_t *stream, pcpt_config_t config, int value) {
if (stream == NULL) {
amiDebugLog("error don't set stream");
return;
@ -683,6 +686,25 @@ void pcptSetConfig(pcpt_t *stream, uint config, uint value) {
break;
}
}
int pcptGetConfig(pcpt_t *stream, pcpt_config_t config) {
if (stream == NULL) {
amiDebugLog("error don't set stream");
return -1;
}
switch (config) {
case 0:
return stream->config_0;
case 1:
return stream->config_1;
case 2:
return stream->so_linger;
case 3:
return stream->tcp_nodelay;
default:
return 0;
}
}
// TODO: TIDY
@ -772,7 +794,8 @@ e_pcpt_t pcptIsBusy(pcpt_t *sock, timeout_t timeout_ms) {
return sock->err;
}
WSAEventSelect(sock->client_sock, event, FD_CONNECT | FD_CLOSE);
iVar7 = connect(sock->client_sock, &sock->client_addr, 16);
iVar7 = connect(sock->client_sock, (PSOCKADDR)&sock->client_addr,
sizeof sock->client_addr);
if (iVar7 != -1) {
WSAEventSelect(sock->client_sock, 0, 0);
WSACloseEvent(sock->client_event);

View File

@ -26,6 +26,13 @@ typedef enum e_pcpt {
e_pcpt_unknown = -17,
} e_pcpt_t;
typedef enum {
PCPT_CONFIG_0 = 0,
PCPT_CONFIG_1 = 1,
PCPT_SO_LINGER = 2,
PCPT_TCP_NODELAY = 3,
} pcpt_config_t;
e_pcpt_t _pcptGetErrorFromWin(int err);
#define _errW2T(err) _pcptGetErrorFromWin(err)
@ -35,34 +42,40 @@ typedef struct pcpt {
int client_open;
int open;
e_pcpt_t err;
uint field_0x14;
uint config_0;
timeout_t field_0x14;
timeout_t config_0;
uint config_1;
uint so_linger;
uint tcp_nodelay;
WSAEVENT client_event;
WSAEVENT server_event;
unsigned char* send_buf;
const unsigned char* send_buf;
size_t* send_buf_count;
unsigned char* recv_buf;
size_t* recv_buf_count;
uint field_0x40;
SOCKADDR client_addr;
SOCKADDR_IN client_addr;
int field_0x54;
int field_0x58;
} pcpt_t;
e_pcpt_t pcptInitStream(pcpt_t* sock);
// Confirmed with nrs.pdb
void pcptClose(pcpt_t* sock);
void pcptCloseDataSock(pcpt_t* sock);
int pcptGetConfig(pcpt_t* sock, pcpt_config_t config);
e_pcpt_t pcptInitStream(pcpt_t* sock);
e_pcpt_t pcptIsBusy(pcpt_t* sock, timeout_t timeout_ms);
e_pcpt_t pcptOpenClient(pcpt_t* stream, char* ipAddr, ushort port, timeout_t timeout);
e_pcpt_t pcptRecv(pcpt_t* sock, unsigned char* recv_buf, size_t* recv_buf_len,
timeout_t timeout_ms);
e_pcpt_t pcptSend(pcpt_t* sock, const unsigned char* send_buf, size_t* send_len, uint param_4,
timeout_t timeout_ms);
void pcptSetConfig(pcpt_t* sock, pcpt_config_t config, int value);
// Unconfirmed
e_pcpt_t pcptAcceptServer(pcpt_t* stream, timeout_t timeout_ms);
e_pcpt_t pcptCheckConnectAble(pcpt_t* sock, timeout_t timeout_ms);
e_pcpt_t pcptCheckEvent(HANDLE event, timeout_t timeout_ms, SOCKET socket, uint event_mask);
e_pcpt_t pcptIsBusy(pcpt_t* sock, timeout_t timeout_ms);
e_pcpt_t pcptOpenDataSockServer(pcpt_t* sock, timeout_t timeout_ms);
e_pcpt_t pcptOpenServer(pcpt_t* sock, int open_mode, ushort port);
e_pcpt_t pcptOpenClient(pcpt_t *stream, char *ipAddr, ushort port, timeout_t timeout);
e_pcpt_t pcptRecv(pcpt_t* sock, unsigned char* recv_buf, size_t* recv_buf_len, timeout_t timeout_ms);
e_pcpt_t pcptSend(pcpt_t* sock, unsigned char* send_buf, size_t* send_len, uint param_4, timeout_t timeout_ms);
e_pcpt_t pcptSendAllMsg(pcpt_t* sock, timeout_t timeout_ms);
void pcptSetConfig(pcpt_t* sock, uint config, uint value);
e_pcpt_t pcptOpenServer(pcpt_t* sock, int open_mode, ushort port);

View File

@ -14,7 +14,9 @@ config_t MiceConfig = {
#define CFG_bool(s, n, default, comment) .n = default,
#define CFG_int(s, n, default, comment) .n = default,
#define CFG_hex(s, n, precision, default, comment) .n = 0x##default,
#define CFG_ipv4(s, n, a, b, c, d, comment) .n = (a << 24) | (b << 16) | (c << 8) | d,
#define CFG_ipv4(s, n, a, b, c, d, comment) \
.n = (unsigned int)(((unsigned char)a << 24) | ((unsigned char)b << 16) | \
((unsigned char)c << 8) | (unsigned char)d),
#define ENDSECTION(s) \
} \
,
@ -98,7 +100,7 @@ void save_current_config() {
}
keybindBuffer[i] = '\0';
free(MiceConfig.keys.keys);
MiceConfig.keys.keys = strdup(keybindBuffer);
MiceConfig.keys.keys = _strdup(keybindBuffer);
FILE *config_file;
fopen_s(&config_file, CONFIG_PATH, "w");
@ -172,9 +174,10 @@ static int handler(void *user, const char *section, const char *name, const char
cfg->s.n = strtol(value, &end, 16); \
unsigned char ip_a, ip_b, ip_c, ip_d; \
if (sscanf_s(value, "%hhu.%hhu.%hhu.%hhu", &ip_a, &ip_b, &ip_c, &ip_d) == 4) \
cfg->s.n = (ip_a << 24) | (ip_b << 16) | (ip_c << 8) | ip_d; \
cfg->s.n = (unsigned int)((ip_a << 24) | (ip_b << 16) | (ip_c << 8) | ip_d); \
else \
cfg->s.n = (a << 24) | (b << 16) | (c << 8) | d; \
cfg->s.n = (unsigned int)(((unsigned char)a << 24) | ((unsigned char)b << 16) | \
((unsigned char)c << 8) | (unsigned char)d); \
}
#include "config.def"

View File

@ -99,7 +99,7 @@ SECTION(keys, "Raw keybinding data. Edit this using the built in binding tool!")
CFG_int(keys, test, 0, "")
CFG_int(keys, service, 0, "")
CFG_int(keys, board_count, 1, "")
CFG_str(keys, keys, 0, "")
CFG_str(keys, keys, "", "")
ENDSECTION(keys)
SECTION(devices, "Register attached hardware devices. COM4 is reserved for JVS.")

View File

@ -71,7 +71,7 @@ bool load_patches_file(const char* filename) {
printf("Invalid address length: %d\n", rbPtr);
return false;
}
hex_to_int(&(size_t)patch->address, readBuffer);
hex_to_int(&(patch->address), readBuffer);
state = parse_patches_state_colon;
rbPtr = 0;

View File

@ -8,7 +8,7 @@ bool load_patches_file(const char* filename);
bool load_patches(char* indexPath, char* exeName);
typedef struct _patch {
void* address;
size_t address;
size_t count;
unsigned char* match;
unsigned char* replace;

View File

@ -142,7 +142,7 @@ MXK_STATUS mxkAbGameId(MXK_CACHE cache, char* gameId, unsigned char* err) {
memcpy(gameId, AppBoot.m_Cache.m_Header.m_GameId, 4);
return MXK_STATUS_OK;
}
LAB_00401c6a:
// LAB_00401c6a:
KEYCHIP_ERROR = 2;
KEYCHIP_STATUS = 2;
*err = 2;

View File

@ -268,7 +268,7 @@ void mxkSignValue(unsigned int value, unsigned char* signature) {
mxkSign(&hash_data, sizeof hash_data, signature);
}
int mxkCryptCalcHashWithHmacSha1(void* key, unsigned char* md, size_t* nbuffer,
int mxkCryptCalcHashWithHmacSha1(PHmacKey_t key, PHmacSum_t md, size_t* nbuffer,
unsigned char* buffer, size_t nin) {
if (key == NULL || buffer == NULL || md == NULL || nbuffer == NULL) {
amiDebugLog("Error: Invalid param.");
@ -290,17 +290,17 @@ int mxkCryptCalcHashWithHmacSha1(void* key, unsigned char* md, size_t* nbuffer,
HMAC_CTX_init(&hmac_ctx);
HMAC_Init_ex(&hmac_ctx, key, 20, EVP_sha1(), NULL);
HMAC_Update(&hmac_ctx, buffer, nin);
HMAC_Final(&hmac_ctx, md, nbuffer);
HMAC_Final(&hmac_ctx, (unsigned char*)md, nbuffer);
HMAC_CTX_cleanup(&hmac_ctx);
return 0;
}
void mxkCryptCalcHashWithSha1(unsigned char* data, size_t nbytes, unsigned char* sum) {
void mxkCryptCalcHashWithSha1(unsigned char* data, size_t nbytes, PSha1Sum_t sum) {
EVP_MD_CTX* ctx = EVP_MD_CTX_create();
EVP_DigestInit(ctx, EVP_sha1());
EVP_DigestUpdate(ctx, data, nbytes);
unsigned int outlen;
EVP_DigestFinal_ex(ctx, sum, &outlen);
EVP_DigestFinal_ex(ctx, (unsigned char*)sum, &outlen);
EVP_MD_CTX_destroy(ctx);
}

View File

@ -1,7 +1,6 @@
#pragma once
#include <stdint.h>
#include <varargs.h>
#include "mxkCrypt.h"
#include "../../segastructs.h"

View File

@ -46,9 +46,11 @@ unsigned char hex_value(char c) {
return 0xFF;
}
}
int hex_to_bin(char *hex, unsigned char *bin, int hex_len) {
int hex_to_bin(char *hex, void *bin, int hex_len) {
if (hex_len == 0) return 1;
unsigned char *lpucBin = (unsigned char *)bin;
int work_len = 0;
for (int hex_ptr = 0; hex_ptr < hex_len; hex_ptr += 2, work_len++) {
char msn = hex[hex_ptr];
@ -73,21 +75,23 @@ int hex_to_bin(char *hex, unsigned char *bin, int hex_len) {
else
return 0;
bin[work_len] = msn << 4 | lsn;
lpucBin[work_len] = msn << 4 | lsn;
}
return 1;
}
void bin_to_hex(char *hex, unsigned char *bin, int nbytes) {
for (int i = 0; i < nbytes; i++) {
if ((bin[i] & 0xf0) > 0x90)
hex[i * 2] = ((bin[i] & 0xf0) >> 4) - 0x0a + 'a';
else
hex[i * 2] = ((bin[i] & 0xf0) >> 4) + '0';
void bin_to_hex(char *hex, void *bin, int nbytes) {
unsigned char *lpucBin = (unsigned char *)bin;
if ((bin[i] & 0x0f) > 0x09)
hex[i * 2 + 1] = (bin[i] & 0x0f) - 0x0a + 'a';
for (int i = 0; i < nbytes; i++) {
if ((lpucBin[i] & 0xf0) > 0x90)
hex[i * 2] = ((lpucBin[i] & 0xf0) >> 4) - 0x0a + 'a';
else
hex[i * 2 + 1] = (bin[i] & 0x0f) + '0';
hex[i * 2] = ((lpucBin[i] & 0xf0) >> 4) + '0';
if ((lpucBin[i] & 0x0f) > 0x09)
hex[i * 2 + 1] = (lpucBin[i] & 0x0f) - 0x0a + 'a';
else
hex[i * 2 + 1] = (lpucBin[i] & 0x0f) + '0';
}
hex[nbytes * 2] = '\0';
}

View File

@ -1,5 +1,5 @@
int hex_to_byte(char *hex, unsigned char *val);
unsigned char hex_value(char c);
int hex_to_bin(char *hex, unsigned char *bin, int hex_len);
int hex_to_bin(char *hex, void *bin, int hex_len);
int hex_to_int(unsigned int *value, char *hex);
void bin_to_hex(char *hex, unsigned char *bin, int nbytes);
void bin_to_hex(char *hex, void *bin, int nbytes);

View File

@ -1,4 +0,0 @@
@echo off
@REM "C:\Program Files (x86)\TrueCrypt\TrueCrypt.exe" %*
echo %*
pause

View File

@ -14,14 +14,6 @@ executable(
],
)
executable(
'truecrypt',
win_subsystem: subsystem,
sources: [
'truecrypt.c',
],
)
executable(
'mxmaster',
win_subsystem: subsystem,

View File

@ -1,5 +0,0 @@
#include <stdio.h>
int main(int argc, char** argv) {
puts("TrueCrypt.exe dummy hit");
}

View File

@ -81,8 +81,6 @@ static void make_default_config() {
static int handler(void *user, const char *section, const char *name, const char *value) {
config_t *cfg = (config_t *)user;
char *end;
if (false)
;
#define CFG_str(s, n, default, comment) \
@ -92,16 +90,19 @@ static int handler(void *user, const char *section, const char *name, const char
strcmp(value, "true") == 0;
#define CFG_int(s, n, default, comment) \
else if (_stricmp(section, #s) == 0 && _stricmp(name, #n) == 0) { \
char *end; \
cfg->s.n = strtol(value, &end, 10); \
if (end == value || *end != '\0' || errno == ERANGE) cfg->s.n = default; \
}
#define CFG_hex(s, n, precision, default, comment) \
else if (_stricmp(section, #s) == 0 && _stricmp(name, #n) == 0) { \
char *end; \
cfg->s.n = strtol(value, &end, 16); \
if (end == value || *end != '\0' || errno == ERANGE) cfg->s.n = 0x##default; \
}
#define CFG_ipv4(s, n, a, b, c, d, comment) \
else if (_stricmp(section, #s) == 0 && _stricmp(name, #n) == 0) { \
char *end; \
cfg->s.n = strtol(value, &end, 16); \
unsigned char ip_a, ip_b, ip_c, ip_d; \
if (sscanf_s(value, "%hhu.%hhu.%hhu.%hhu", &ip_a, &ip_b, &ip_c, &ip_d) == 4) \

View File

@ -266,6 +266,8 @@ void mxMasterFdcProcessesStart(MX_MASTER* mxMaster) {
if (mxMaster->m_kcReady) {
char* format;
// We can't use inet_ntop because we target XP
#pragma warning(suppress : 4996)
char* networkAddr = inet_ntoa(mxMaster->m_networkAddr);
if (mxMaster->m_develop == 0) {

View File

@ -1,18 +1,7 @@
dependencies = []
link_with = [libpcp, amiDebug]
sources = [
'dummyinstaller.c',
]
dummyinstaller = static_library(
'dummyinstaller',
sources: sources,
link_with: link_with,
)
executable(
'dummyinstaller',
win_subsystem: subsystem,
sources: ['main.c'] + sources,
link_with: link_with,
dependencies: dependencies,
sources: [
'dummyinstaller.c',
],
link_with: [libpcp, amiDebug],
)

View File

@ -1,22 +1,11 @@
link_with = [libpcp, amiDebug, util_lib]
sources = [
dummykeychip = static_library(
'dummykeychip',
sources: [
'callbacks-stub.c',
'callbacks-crypto.c',
'dummykeychip.c',
]
dummykeychip = static_library(
'dummykeychip',
sources: sources,
link_with: link_with,
include_directories: [openssl_inc],
dependencies: [openssl_lib],
)
executable(
'dummykeychip',
win_subsystem: subsystem,
sources: ['main.c'] + sources,
link_with: link_with,
],
link_with: [libpcp, amiDebug, util_lib],
include_directories: [openssl_inc],
dependencies: [openssl_lib],
)

View File

@ -1,18 +1,7 @@
dependencies = []
link_with = [libpcp, amiDebug]
sources = [
'dummymaster.c',
]
dummymaster = static_library(
'dummymaster',
sources: sources,
link_with: link_with,
)
executable(
'dummymaster',
win_subsystem: subsystem,
sources: ['main.c'] + sources,
link_with: link_with,
dependencies: dependencies,
sources: [
'dummymaster.c',
],
link_with: [libpcp, amiDebug],
)

View File

@ -303,7 +303,7 @@ int exio_mac_test(byte* buffer) {
int keychip_ds_eeprom_dump(void) {
byte pageData[32];
for (int page = 0; page < 4; page++) {
for (byte page = 0; page < 4; page++) {
printf("Page %d\n", page);
if (mxkDsKeychipReadEeprom(pageData, page)) {
puts("Read failed");

View File

@ -36,14 +36,6 @@ executable(
],
)
executable(
'micemonitor',
win_subsystem: subsystem,
sources: [
'micemonitor.c',
],
)
executable(
'exio_test',
win_subsystem: subsystem,
@ -64,13 +56,6 @@ executable(
],
)
executable(
'testBin',
win_subsystem: subsystem,
sources: [
'test.c',
],
)
executable(
'micegbdisk',
win_subsystem: subsystem,
@ -81,14 +66,3 @@ executable(
amiDebug,
],
)
executable(
'micefs_test',
win_subsystem: subsystem,
sources: [
'micefs_test.c',
],
link_with: [
mice_lib,
],
)

View File

@ -1,32 +0,0 @@
#include <stdio.h>
#include "../lib/mice/mice.h"
// TODO: Ewww
BOOL(WINAPI* TruePathFileExistsA)(LPCSTR pszPath) = PathFileExistsA;
int main() {
MiceFSInit();
// MiceFSAddDevLayers();
// MiceFSAddRingedgeLayers(FALSE);
CHAR path[MAX_PATH + 1];
strcpy_s(path, sizeof path, "X:\\Systemconfig.txt");
MICE_FS_PATH_TOK pathTok;
LPSTR pathComponent = MiceFSPathTokA(path, _countof(path), &pathTok);
while (pathComponent) {
printf("Component : '%s'\n", pathComponent);
pathComponent = MiceFSPathTokNextA(&pathTok);
}
// CHAR tail[MAX_PATH + 1];
// printf("Test 1: %d\n", MiceFSMatchPathA("C:\\windows\\system32\\etc\\help.exe", "C:\\WINDOWS", tail, sizeof(tail)));
// printf("Tail: %s\n", tail);
// LPSTR redirected = NULL;
// MiceFSRedirectPathA("X:\\game.bat", &redirected);
// printf("Redirected path: %s\n", redirected);
}

View File

@ -1,14 +0,0 @@
#include <Windows.h>
#include <stdio.h>
#define P2A_PATH "C:\\ProgramData\\boost_interprocess\\ALLNetComP2A"
#define A2P_PATH "C:\\ProgramData\\boost_interprocess\\ALLNetComA2P"
int main(int argc, char* argv) {
FILE* f;
fopen_s(&f, "./test.txt", "w");
fprintf(f, "count: %d", argc);
fclose(f);
return 0;
}

View File

@ -1,80 +0,0 @@
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
char path[MAX_PATH * 1000];
int oldmain(int argc, char** argv) {
// printf("%d", QueryDosDeviceA(NULL, path, sizeof path));
// printf(" %03x\n", GetLastError());
// char* pPath = path;
// while (1) {
// size_t len = strlen(pPath);
// if (!len) break;
// puts(pPath);
// pPath += len + 1;
// }
DWORD volumeSerialNumber;
// Crackproof-style call
BOOL ret = GetVolumeInformationA("C:\\", NULL, 0, &volumeSerialNumber, NULL, NULL, NULL, 0);
printf("volumeSerialNumber: %08x\n", volumeSerialNumber);
// Exhaustive call
CHAR volumeNameBuffer[MAX_PATH];
DWORD maximumComponentLength;
DWORD fileSystemFlags;
CHAR fileSystemName[MAX_PATH];
ret = GetVolumeInformationA("C:\\", volumeNameBuffer, sizeof volumeNameBuffer,
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
fileSystemName, sizeof fileSystemName);
printf("volumeNameBuffer: %s\n", volumeNameBuffer);
printf("volumeSerialNumber: %08x\n", volumeSerialNumber);
printf("maximumComponentLength: %08x\n", maximumComponentLength);
printf("fileSystemFlags: %08x\n", fileSystemFlags);
printf("fileSystemName: %s\n", fileSystemName);
return 0;
}
#define RING
#ifdef RING
#define A2P \
"C:\\Documents and Settings\\All Users\\Application Data/boost_interprocess/ALLNetComA2P"
#else
#define A2P "G:\\MegaSync\\SDEY_1.99\\maimai\\dev\\c\\ProgramData/boost_interprocess/ALLNetComA2P"
#endif
int main(int argc, char** argv) {
unsigned char buf[1];
char buf2[4];
DWORD temp;
HANDLE hFile = CreateFileA(A2P, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
printf("Failed to open A2P %03x\n", GetLastError());
return -1;
}
SetFilePointer(hFile, 4, NULL, 0);
buf[0] = '\1';
WriteFile(hFile, buf, sizeof buf, &temp, NULL);
// buf[0] = '\2'; // game start
buf[0] = '\3'; // game test
SetFilePointer(hFile, 0, NULL, 0);
WriteFile(hFile, buf, sizeof buf, &temp, NULL);
SetFilePointer(hFile, 8, NULL, 0);
buf2[0] = '1';
buf2[0] = '.';
buf2[0] = '9';
buf2[0] = '9';
WriteFile(hFile, buf2, sizeof buf2, &temp, NULL);
CloseHandle(hFile);
}

View File

@ -1,40 +0,0 @@
import json
patches = []
patchset = {
"name": "Rebind keys",
"description": "Automatically generated",
"apply": True,
"patches": patches
}
original = ['W', 'E', 'D', 'C', 'X', 'Z', 'A', 'Q']
base = 1517787
for i in range(8):
key = input(f"Key for {i+1}: ")
if len(key) != 1:
print("That's not one key!")
quit()
key = f"{ord(key.upper()):02x}"
orig = f"{ord(original[i].upper()):02x}"
if i == 0:
patches.append({
"at": base,
"from": f"c70424{orig}000000",
"to": f"c70424{key}000000",
})
else:
instr = f"c74424{4 * i:02x}"
patches.append({
"at": base + 7 + 8 * (i - 1),
"from": instr + orig + "000000",
"to": instr + key + "000000",
})
with open("keybinds.json", "w") as f:
json.dump([patchset], f)
print("Wrote patches to keybinds.json")

View File

@ -14,6 +14,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define GLUT_DISABLE_ATEXIT_HACK
#include "freeglut_std.h"
#include "freeglut_ext.h"

View File

@ -80,6 +80,7 @@
# if FREEGLUT_LIB_PRAGMAS
// Disabled! We're going to to load freeglut in at runtime!
// # pragma comment (lib, "freeglut.lib")
#undef FGAPI
# define FGAPI extern
# endif

View File

@ -14,6 +14,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define GLUT_DISABLE_ATEXIT_HACK
#include "freeglut_std.h"
/*** END OF FILE ***/