1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-02-21 04:48:42 +01: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:
Will Xyen 2019-12-10 15:23:53 -05:00
parent bf3d543893
commit b1329d10bf
4 changed files with 27 additions and 3 deletions

View File

@ -206,6 +206,7 @@ my_CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags)
char builtString[CAMERA_DATA_STRING_SIZE] = {0};
if (pdnDevInst) {
log_info("seeking: %s", pDeviceID);
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
if (camData[i].setup) {
snprintf(
@ -213,6 +214,7 @@ my_CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags)
CAMERA_DATA_STRING_SIZE,
"USB\\VID_288C&PID_0002&MI_00\\%s",
camData[i].extra_upper);
log_info("built: %s", builtString);
if (strcmp(pDeviceID, builtString) == 0) {
if (!camData[i].fake_located) {
camData[i].fake_located_node = num_located_cams;
@ -280,7 +282,9 @@ HRESULT my_GetAllocatedString(
// should probably check GUID, oh well
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;
@ -308,8 +312,11 @@ HRESULT my_GetAllocatedString(
pwc[29] = L'0';
pwc[30] = L'0';
log_info("Replaced: %ls", *ppwszValue);
wcstombs(pMBBuffer, *ppwszValue, 0x100);
log_info("Replaced: %s", pMBBuffer);
}
free(pMBBuffer);
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)
{
MFStartup(0x20070u, 0);
// fill before applying hooks
for (size_t i = 0; i < config_cam->num_devices; ++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");
}
}
void camhook_fini(void)
{
MFShutdown();
}

View File

@ -5,4 +5,6 @@
void camhook_init(struct camhook_config_cam *config_cam);
void camhook_fini(void);
#endif

View File

@ -75,6 +75,7 @@ iidxhook8_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
}
struct iidxhook8_config_io iidxhook8_config_io;
struct camhook_config_cam config_cam;
static struct bio2emu_port bio2_emu = {
.port = "COM4",
@ -87,7 +88,6 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
struct cconfig *config;
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();
@ -181,6 +181,10 @@ static bool my_dll_entry_main(void)
result = app_hook_invoke_main();
if (!config_cam.disable_emu) {
camhook_fini();
}
if (!iidxhook8_config_io.disable_card_reader_emu) {
log_misc("Shutting down card reader backend");
eam_io_fini();

View File

@ -140,6 +140,10 @@ static bool my_dll_entry_main(void)
result = app_hook_invoke_main();
if (!config_cam.disable_emu) {
camhook_fini();
}
if (!config_io.disable_card_reader_emu) {
log_misc("Shutting down card reader backend");
eam_io_fini();