mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-04-25 23:37:54 -05:00
camhook: Fix cameras not being auto-detected sometimes on older machines
MFStartup needs to be called before any MF functions are used (such as for auto detect)
This commit is contained in:
parent
bf3d543893
commit
b1329d10bf
|
|
@ -206,6 +206,7 @@ my_CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags)
|
||||||
|
|
||||||
char builtString[CAMERA_DATA_STRING_SIZE] = {0};
|
char builtString[CAMERA_DATA_STRING_SIZE] = {0};
|
||||||
if (pdnDevInst) {
|
if (pdnDevInst) {
|
||||||
|
log_info("seeking: %s", pDeviceID);
|
||||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||||
if (camData[i].setup) {
|
if (camData[i].setup) {
|
||||||
snprintf(
|
snprintf(
|
||||||
|
|
@ -213,6 +214,7 @@ my_CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags)
|
||||||
CAMERA_DATA_STRING_SIZE,
|
CAMERA_DATA_STRING_SIZE,
|
||||||
"USB\\VID_288C&PID_0002&MI_00\\%s",
|
"USB\\VID_288C&PID_0002&MI_00\\%s",
|
||||||
camData[i].extra_upper);
|
camData[i].extra_upper);
|
||||||
|
log_info("built: %s", builtString);
|
||||||
if (strcmp(pDeviceID, builtString) == 0) {
|
if (strcmp(pDeviceID, builtString) == 0) {
|
||||||
if (!camData[i].fake_located) {
|
if (!camData[i].fake_located) {
|
||||||
camData[i].fake_located_node = num_located_cams;
|
camData[i].fake_located_node = num_located_cams;
|
||||||
|
|
@ -280,7 +282,9 @@ HRESULT my_GetAllocatedString(
|
||||||
|
|
||||||
// should probably check GUID, oh well
|
// should probably check GUID, oh well
|
||||||
ret = real_GetAllocatedString(self, guidKey, ppwszValue, pcchLength);
|
ret = real_GetAllocatedString(self, guidKey, ppwszValue, pcchLength);
|
||||||
log_info("Obtained: %ls", *ppwszValue);
|
char *pMBBuffer = (char *)malloc(0x100);
|
||||||
|
wcstombs(pMBBuffer, *ppwszValue, 0x100);
|
||||||
|
log_info("Obtained: %s", pMBBuffer);
|
||||||
|
|
||||||
wchar_t *pwc = NULL;
|
wchar_t *pwc = NULL;
|
||||||
|
|
||||||
|
|
@ -308,8 +312,11 @@ HRESULT my_GetAllocatedString(
|
||||||
|
|
||||||
pwc[29] = L'0';
|
pwc[29] = L'0';
|
||||||
pwc[30] = L'0';
|
pwc[30] = L'0';
|
||||||
log_info("Replaced: %ls", *ppwszValue);
|
|
||||||
|
wcstombs(pMBBuffer, *ppwszValue, 0x100);
|
||||||
|
log_info("Replaced: %s", pMBBuffer);
|
||||||
}
|
}
|
||||||
|
free(pMBBuffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -787,6 +794,8 @@ void fill_cam_struct(struct CameraData *data, const char *devid)
|
||||||
|
|
||||||
void camhook_init(struct camhook_config_cam *config_cam)
|
void camhook_init(struct camhook_config_cam *config_cam)
|
||||||
{
|
{
|
||||||
|
MFStartup(0x20070u, 0);
|
||||||
|
|
||||||
// fill before applying hooks
|
// fill before applying hooks
|
||||||
for (size_t i = 0; i < config_cam->num_devices; ++i) {
|
for (size_t i = 0; i < config_cam->num_devices; ++i) {
|
||||||
fill_cam_struct(&camData[i], config_cam->device_id[i]);
|
fill_cam_struct(&camData[i], config_cam->device_id[i]);
|
||||||
|
|
@ -814,3 +823,8 @@ void camhook_init(struct camhook_config_cam *config_cam)
|
||||||
log_info("No cams detected, not hooking");
|
log_info("No cams detected, not hooking");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void camhook_fini(void)
|
||||||
|
{
|
||||||
|
MFShutdown();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,6 @@
|
||||||
|
|
||||||
void camhook_init(struct camhook_config_cam *config_cam);
|
void camhook_init(struct camhook_config_cam *config_cam);
|
||||||
|
|
||||||
|
void camhook_fini(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ iidxhook8_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct iidxhook8_config_io iidxhook8_config_io;
|
struct iidxhook8_config_io iidxhook8_config_io;
|
||||||
|
struct camhook_config_cam config_cam;
|
||||||
|
|
||||||
static struct bio2emu_port bio2_emu = {
|
static struct bio2emu_port bio2_emu = {
|
||||||
.port = "COM4",
|
.port = "COM4",
|
||||||
|
|
@ -87,7 +88,6 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||||
struct cconfig *config;
|
struct cconfig *config;
|
||||||
|
|
||||||
struct iidxhook_config_gfx config_gfx;
|
struct iidxhook_config_gfx config_gfx;
|
||||||
struct camhook_config_cam config_cam;
|
|
||||||
|
|
||||||
// log_server_init is required due to IO occuring in a non avs_thread
|
// log_server_init is required due to IO occuring in a non avs_thread
|
||||||
log_server_init();
|
log_server_init();
|
||||||
|
|
@ -181,6 +181,10 @@ static bool my_dll_entry_main(void)
|
||||||
|
|
||||||
result = app_hook_invoke_main();
|
result = app_hook_invoke_main();
|
||||||
|
|
||||||
|
if (!config_cam.disable_emu) {
|
||||||
|
camhook_fini();
|
||||||
|
}
|
||||||
|
|
||||||
if (!iidxhook8_config_io.disable_card_reader_emu) {
|
if (!iidxhook8_config_io.disable_card_reader_emu) {
|
||||||
log_misc("Shutting down card reader backend");
|
log_misc("Shutting down card reader backend");
|
||||||
eam_io_fini();
|
eam_io_fini();
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,10 @@ static bool my_dll_entry_main(void)
|
||||||
|
|
||||||
result = app_hook_invoke_main();
|
result = app_hook_invoke_main();
|
||||||
|
|
||||||
|
if (!config_cam.disable_emu) {
|
||||||
|
camhook_fini();
|
||||||
|
}
|
||||||
|
|
||||||
if (!config_io.disable_card_reader_emu) {
|
if (!config_io.disable_card_reader_emu) {
|
||||||
log_misc("Shutting down card reader backend");
|
log_misc("Shutting down card reader backend");
|
||||||
eam_io_fini();
|
eam_io_fini();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user