forked from Hay1tsme/segatools
MSVC and 32-bit fixes
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "imageutil.h"
|
#include "imageutil.h"
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ int ConvertDataToBitmap(
|
|||||||
|
|
||||||
if (cbInput < (dwWidth * dwHeight * dwBitCount / 8)) return -3;
|
if (cbInput < (dwWidth * dwHeight * dwBitCount / 8)) return -3;
|
||||||
|
|
||||||
PBYTE pBuffer = (PBYTE)malloc(cbInput);
|
PBYTE pBuffer = malloc(cbInput);
|
||||||
if (!pBuffer) return -2;
|
if (!pBuffer) return -2;
|
||||||
|
|
||||||
BYTE dwColors = (BYTE)(dwBitCount / 8);
|
BYTE dwColors = (BYTE)(dwBitCount / 8);
|
||||||
@ -148,7 +149,7 @@ int WriteDataToBitmapFile(
|
|||||||
|
|
||||||
DWORD cbResult;
|
DWORD cbResult;
|
||||||
DWORD cbBuffer = dwImageSize + 0x500;
|
DWORD cbBuffer = dwImageSize + 0x500;
|
||||||
PBYTE pbBuffer = (PBYTE)calloc(cbBuffer, 1);
|
PBYTE pbBuffer = calloc(cbBuffer, 1);
|
||||||
if (!pbBuffer) return -2;
|
if (!pbBuffer) return -2;
|
||||||
|
|
||||||
if (ConvertDataToBitmap(dwBitCount, dwWidth, dwHeight, pbInput, dwImageSize, pbBuffer, cbBuffer, &cbResult, pFlip) < 0) {
|
if (ConvertDataToBitmap(dwBitCount, dwWidth, dwHeight, pbInput, dwImageSize, pbBuffer, cbBuffer, &cbResult, pFlip) < 0) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wtypes.h>
|
#include <wtypes.h>
|
||||||
@ -519,7 +520,7 @@ static int __stdcall hook_CXCMD_Print(int slotId, int id, int color, int bufferI
|
|||||||
|
|
||||||
// convert image from seperate CMY arrays to one RGB array
|
// convert image from seperate CMY arrays to one RGB array
|
||||||
int size = IMAGE_BUFFER_SIZE * 3;
|
int size = IMAGE_BUFFER_SIZE * 3;
|
||||||
uint8_t* raw_image = malloc(size);
|
uint8_t* raw_image = (uint8_t*)malloc(size);
|
||||||
for (int i = 0; i < IMAGE_BUFFER_SIZE; i++) {
|
for (int i = 0; i < IMAGE_BUFFER_SIZE; i++) {
|
||||||
// 0 is "white" and we don't really care about that
|
// 0 is "white" and we don't really care about that
|
||||||
raw_image[i * 3] = 0xFF - (bufferIndex == 0 ? back_buffer : front_buffer)[1][i];
|
raw_image[i * 3] = 0xFF - (bufferIndex == 0 ? back_buffer : front_buffer)[1][i];
|
||||||
|
@ -15,32 +15,53 @@
|
|||||||
|
|
||||||
#include "util/dprintf.h"
|
#include "util/dprintf.h"
|
||||||
|
|
||||||
#define CALL __cdecl
|
#if _WIN32 || _WIN64
|
||||||
|
#if _WIN64
|
||||||
|
#define ENV64BIT
|
||||||
|
#else
|
||||||
|
#define ENV32BIT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
CALL float API_DLLVersion();
|
// Check GCC
|
||||||
CALL uint32_t API_GetLastError(int* hDevice);
|
#if __GNUC__
|
||||||
CALL uint32_t API_GetErrorMessage(uint32_t errNo, char* szMessage, int numBytes);
|
#if __x86_64__ || __ppc64__
|
||||||
CALL int* API_Connect(char* szPortName);
|
#define ENV64BIT
|
||||||
CALL int API_Close(int* hDevice);
|
#else
|
||||||
CALL int API_Start(int* hDevice);
|
#define ENV32BIT
|
||||||
CALL int API_Stop(int* hDevice);
|
#endif
|
||||||
CALL float API_GetFirmVersion(int* hDevice);
|
#endif
|
||||||
CALL uint32_t API_GetFirmName(int* hDevice);
|
|
||||||
CALL uint32_t API_GetTargetCode(int* hDevice);
|
#ifdef ENV64BIT
|
||||||
CALL uint32_t API_GetStatus(int* hDevice);
|
#define CALL
|
||||||
CALL uint32_t API_GetCounter(int* hDevice);
|
#else
|
||||||
CALL int API_ClearError(int* hDevice);
|
#define CALL __cdecl
|
||||||
CALL int API_Reset(int* hDevice, bool isHardReset);
|
#endif
|
||||||
CALL int API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo);
|
|
||||||
CALL int API_GetCardInfoCharSize();
|
float CALL API_DLLVersion();
|
||||||
CALL int API_FirmwareUpdate(int* hDevice, uint32_t address, uint32_t size, uint8_t* buffer);
|
uint32_t CALL API_GetLastError(int* hDevice);
|
||||||
CALL int API_Calibration(int* hDevice, int calib);
|
uint32_t CALL API_GetErrorMessage(uint32_t errNo, char* szMessage, int numBytes);
|
||||||
CALL int API_GetCalibrationResult(int* hDevice, int calib, uint32_t* result);
|
int* CALL API_Connect(char* szPortName);
|
||||||
CALL uint32_t API_GetProcTime(int* hDevice);
|
int CALL API_Close(int* hDevice);
|
||||||
CALL uint32_t API_GetMemStatus(int* hDevice);
|
int CALL API_Start(int* hDevice);
|
||||||
CALL uint32_t API_GetMemCounter(int* hDevice);
|
int CALL API_Stop(int* hDevice);
|
||||||
CALL int API_SetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam);
|
float CALL API_GetFirmVersion(int* hDevice);
|
||||||
CALL int API_GetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam);
|
uint32_t CALL API_GetFirmName(int* hDevice);
|
||||||
|
uint32_t CALL API_GetTargetCode(int* hDevice);
|
||||||
|
uint32_t CALL API_GetStatus(int* hDevice);
|
||||||
|
uint32_t CALL API_GetCounter(int* hDevice);
|
||||||
|
int CALL API_ClearError(int* hDevice);
|
||||||
|
int CALL API_Reset(int* hDevice, bool isHardReset);
|
||||||
|
int CALL API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo);
|
||||||
|
int CALL API_GetCardInfoCharSize();
|
||||||
|
int CALL API_FirmwareUpdate(int* hDevice, uint32_t address, uint32_t size, uint8_t* buffer);
|
||||||
|
int CALL API_Calibration(int* hDevice, int calib);
|
||||||
|
int CALL API_GetCalibrationResult(int* hDevice, int calib, uint32_t* result);
|
||||||
|
uint32_t CALL API_GetProcTime(int* hDevice);
|
||||||
|
uint32_t CALL API_GetMemStatus(int* hDevice);
|
||||||
|
uint32_t CALL API_GetMemCounter(int* hDevice);
|
||||||
|
int CALL API_SetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam);
|
||||||
|
int CALL API_GetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam);
|
||||||
|
|
||||||
signed int CALL API_SetDevice(int a1, int a2);
|
signed int CALL API_SetDevice(int a1, int a2);
|
||||||
signed int CALL API_SetCommand(int a1, int a2, int a3, int* a4);
|
signed int CALL API_SetCommand(int a1, int a2, int a3, int* a4);
|
||||||
@ -310,12 +331,12 @@ void y3_insert_hooks(HMODULE target) {
|
|||||||
_countof(Y3_hooks));
|
_countof(Y3_hooks));
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL float API_DLLVersion() {
|
float CALL API_DLLVersion() {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetLastError(int* hDevice) {
|
uint32_t CALL API_GetLastError(int* hDevice) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
if (!y3_config.enable) {
|
if (!y3_config.enable) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -323,7 +344,7 @@ CALL uint32_t API_GetLastError(int* hDevice) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetErrorMessage(uint32_t errNo, char* szMessage,
|
uint32_t CALL API_GetErrorMessage(uint32_t errNo, char* szMessage,
|
||||||
int numBytes) {
|
int numBytes) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
if (!y3_config.enable) {
|
if (!y3_config.enable) {
|
||||||
@ -335,7 +356,7 @@ CALL uint32_t API_GetErrorMessage(uint32_t errNo, char* szMessage,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int* API_Connect(char* szPortName) {
|
int* CALL API_Connect(char* szPortName) {
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
dprintf("Y3: %s(%s)\n", __func__, szPortName);
|
dprintf("Y3: %s(%s)\n", __func__, szPortName);
|
||||||
@ -355,7 +376,7 @@ CALL int* API_Connect(char* szPortName) {
|
|||||||
return (int*)(uintptr_t)atoi(number);
|
return (int*)(uintptr_t)atoi(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_Close(int* hDevice) {
|
int CALL API_Close(int* hDevice) {
|
||||||
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
||||||
|
|
||||||
y3_dll.close();
|
y3_dll.close();
|
||||||
@ -363,22 +384,22 @@ CALL int API_Close(int* hDevice) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_Start(int* hDevice) {
|
int CALL API_Start(int* hDevice) {
|
||||||
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_Stop(int* hDevice) {
|
int CALL API_Stop(int* hDevice) {
|
||||||
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL float API_GetFirmVersion(int* hDevice) {
|
float CALL API_GetFirmVersion(int* hDevice) {
|
||||||
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetFirmName(int* hDevice) {
|
uint32_t CALL API_GetFirmName(int* hDevice) {
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
||||||
|
|
||||||
@ -395,7 +416,7 @@ CALL uint32_t API_GetFirmName(int* hDevice) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetTargetCode(int* hDevice) {
|
uint32_t CALL API_GetTargetCode(int* hDevice) {
|
||||||
uint32_t result = 1162760014;
|
uint32_t result = 1162760014;
|
||||||
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
dprintf("Y3: %s(%p)\n", __func__, hDevice);
|
||||||
|
|
||||||
@ -412,27 +433,27 @@ CALL uint32_t API_GetTargetCode(int* hDevice) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetStatus(int* hDevice) {
|
uint32_t CALL API_GetStatus(int* hDevice) {
|
||||||
// dprintf("Y3: %s\n", __func__);
|
// dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetCounter(int* hDevice) {
|
uint32_t CALL API_GetCounter(int* hDevice) {
|
||||||
// dprintf("Y3: %s\n", __func__);
|
// dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_ClearError(int* hDevice) {
|
int CALL API_ClearError(int* hDevice) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_Reset(int* hDevice, bool isHardReset) {
|
int CALL API_Reset(int* hDevice, bool isHardReset) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo) {
|
int CALL API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo) {
|
||||||
// dprintf("Y3: %s(%p), %d\n", __func__, hDevice, numCards);
|
// dprintf("Y3: %s(%p), %d\n", __func__, hDevice, numCards);
|
||||||
// ret = num cards
|
// ret = num cards
|
||||||
// numCards = max cards
|
// numCards = max cards
|
||||||
@ -467,47 +488,47 @@ CALL int API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_GetCardInfoCharSize() {
|
int CALL API_GetCardInfoCharSize() {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_FirmwareUpdate(int* hDevice, uint32_t address, uint32_t size,
|
int CALL API_FirmwareUpdate(int* hDevice, uint32_t address, uint32_t size,
|
||||||
uint8_t* buffer) {
|
uint8_t* buffer) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 1; // not supported
|
return 1; // not supported
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_Calibration(int* hDevice, int calib) {
|
int CALL API_Calibration(int* hDevice, int calib) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_GetCalibrationResult(int* hDevice, int calib, uint32_t* result) {
|
int CALL API_GetCalibrationResult(int* hDevice, int calib, uint32_t* result) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetProcTime(int* hDevice) {
|
uint32_t CALL API_GetProcTime(int* hDevice) {
|
||||||
// dprintf("Y3: %s\n", __func__);
|
// dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL uint32_t API_GetMemStatus(int* hDevice) {
|
uint32_t CALL API_GetMemStatus(int* hDevice) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
CALL uint32_t API_GetMemCounter(int* hDevice) {
|
uint32_t CALL API_GetMemCounter(int* hDevice) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_SetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam) {
|
int CALL API_SetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL int API_GetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam) {
|
int CALL API_GetParameter(int* hDevice, uint32_t uParam, uint32_t* pParam) {
|
||||||
dprintf("Y3: %s\n", __func__);
|
dprintf("Y3: %s\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
@ -160,7 +161,7 @@ static void y3ws_read_cards(char* output_data, size_t* output_size) {
|
|||||||
// ReSharper disable once CppRedundantCastExpression
|
// ReSharper disable once CppRedundantCastExpression
|
||||||
cJSON* path_str = cJSON_CreateString(fpatha);
|
cJSON* path_str = cJSON_CreateString(fpatha);
|
||||||
cJSON_AddItemToObject(card, "path", path_str);
|
cJSON_AddItemToObject(card, "path", path_str);
|
||||||
cJSON* card_id = cJSON_CreateNumber((double)((uint64_t)buf[0] >> 32 | buf[1] >> 24 | buf[2] >> 16 | buf[3] >> 8 | buf[4]));
|
cJSON* card_id = cJSON_CreateNumber((double)((uint64_t)buf[0] >> 32 | (uint64_t)buf[1] >> 24 | (uint64_t)buf[2] >> 16 | (uint64_t)buf[3] >> 8 | buf[4]));
|
||||||
cJSON_AddItemToObject(card, "card_id", card_id);
|
cJSON_AddItemToObject(card, "card_id", card_id);
|
||||||
|
|
||||||
} while (FindNextFileW(hFind, &ffd) != 0 && count++ < MAX_CARDS);
|
} while (FindNextFileW(hFind, &ffd) != 0 && count++ < MAX_CARDS);
|
||||||
@ -176,7 +177,7 @@ static void y3ws_read_cards(char* output_data, size_t* output_size) {
|
|||||||
|
|
||||||
static void y3ws_read_card_image(char* file_name, char* output_data, size_t* output_size) {
|
static void y3ws_read_card_image(char* file_name, char* output_data, size_t* output_size) {
|
||||||
wchar_t path[MAX_PATH];
|
wchar_t path[MAX_PATH];
|
||||||
swprintf(path, MAX_PATH, L"%ls\\%s", cfg.card_path, file_name);
|
swprintf(path, MAX_PATH, L"%ls\\%S", cfg.card_path, file_name);
|
||||||
|
|
||||||
HANDLE hImage = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
HANDLE hImage = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (hImage == INVALID_HANDLE_VALUE) {
|
if (hImage == INVALID_HANDLE_VALUE) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LIBRARY taisenhook
|
LIBRARY ekthook
|
||||||
|
|
||||||
EXPORTS
|
EXPORTS
|
||||||
aime_io_get_api_version
|
aime_io_get_api_version
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LIBRARY taisenhook
|
LIBRARY sekitohook
|
||||||
|
|
||||||
EXPORTS
|
EXPORTS
|
||||||
aime_io_get_api_version
|
aime_io_get_api_version
|
||||||
|
Reference in New Issue
Block a user