Closed GavinRay97 closed 3 years ago
Oh, I also missed that when reviewing the last PR. How did you get access to the REAPER source code? ;)
From the Source-code Fairy ;^)
Here's the full thing if you're curious:
// 2 #STR: "_reaper_python", "reaper_perl", "reaper_php", "reaper_"
// #API: FindClose(), MultiByteToWideChar(), FindFirstFileW(), WideCharToMultiByte(), FindNextFileW(), FindNextFileA(), FindFirstFileA()
void __fastcall sub_1405B8878(__int64 a1)
{
void *v1; // rsp
LPARAM *v3; // rbx
int v4; // eax
const CHAR *v5; // r8
int v6; // eax
const CHAR *v7; // r8
HANDLE v8; // rsi
const char *v9; // rbx
__int64 v10; // rax
int v11; // edx
int v12; // edx
int v13; // er15
unsigned int v14; // edi
int v15; // esi
char *v16; // r8
int v17; // eax
int v18; // eax
int v19; // eax
void *v20; // rdx
void *v21; // rdx
const CHAR *v22; // rsi
unsigned int v23; // edx
int v24; // esi
unsigned int v25; // er15
int v26; // edi
char *v27; // r8
int v28; // eax
int v29; // eax
_BYTE *v30; // rbx
__int64 v31; // rsi
_BYTE *v32; // rdi
unsigned __int8 *v33; // rdx
__int64 v34; // r15
const CHAR *v35; // rcx
const CHAR *v36; // r8
WCHAR *lpWideCharStr; // rax
const WCHAR *v38; // rcx
WCHAR WideCharStr[1024]; // [rsp+12AF0h] [rbp+0h] BYREF
char v40[4]; // [rsp+132F0h] [rbp+800h] BYREF
struct _WIN32_FIND_DATAW FindFileData; // [rsp+132F4h] [rbp+804h] BYREF
CHAR MultiByteStr[1300]; // [rsp+13544h] [rbp+A54h] BYREF
HANDLE hFindFile; // [rsp+13A58h] [rbp+F68h]
void *v44; // [rsp+13A60h] [rbp+F70h] BYREF
int v45; // [rsp+13A68h] [rbp+F78h]
int v46; // [rsp+13A6Ch] [rbp+F7Ch]
int v47; // [rsp+13A70h] [rbp+F80h]
__int64 v48; // [rsp+13A78h] [rbp+F88h]
LPWSTR v49; // [rsp+13A80h] [rbp+F90h] BYREF
int v50; // [rsp+13A88h] [rbp+F98h]
unsigned int v51; // [rsp+13A8Ch] [rbp+F9Ch]
int v52; // [rsp+13A90h] [rbp+FA0h]
char *v53; // [rsp+13A98h] [rbp+FA8h]
const char *v54; // [rsp+13AA0h] [rbp+FB0h] BYREF
void *v55; // [rsp+13AA8h] [rbp+FB8h] BYREF
int v56; // [rsp+13AB0h] [rbp+FC0h]
int v57; // [rsp+13AB4h] [rbp+FC4h]
int v58; // [rsp+13AB8h] [rbp+FC8h]
void *Block; // [rsp+13AC0h] [rbp+FD0h] BYREF
int v60; // [rsp+13AC8h] [rbp+FD8h]
int v61; // [rsp+13ACCh] [rbp+FDCh]
int v62; // [rsp+13AD0h] [rbp+FE0h]
char *v63; // [rsp+13AD8h] [rbp+FE8h]
void *v64; // [rsp+13AE0h] [rbp+FF0h]
void *v65; // [rsp+13AE8h] [rbp+FF8h]
void *v66; // [rsp+13AF0h] [rbp+1000h]
int v67; // [rsp+13B18h] [rbp+1028h]
int v68; // [rsp+13B1Ch] [rbp+102Ch]
int v69; // [rsp+13B20h] [rbp+1030h]
__int64 v70[3]; // [rsp+13B28h] [rbp+1038h] BYREF
v1 = alloca(4240i64);
v48 = -2i64;
v70[1] = StackCookie;
if ( (byte_140BA4424 & 1) == 0 )
{
dword_140BA4E40 = 4096;
byte_140BA4424 |= 1u;
qword_140BA4E30 = 0i64;
qword_140BA4E48 = (__int64 (__fastcall *)(_QWORD, _QWORD))sub_1401CDF48;
qword_140BA4E60 = 0i64;
dword_140BA4E38 = 0;
dword_140BA4E3C = 0;
qword_140BA4E50 = (__int64 (__fastcall *)(_QWORD))sub_1402C38F8;
qword_140BA4E58 = (__int64)sub_14056BBE8;
atexit(sub_1405B870C);
}
v55 = 0i64;
v66 = &v55;
v58 = 128;
v56 = 0;
v57 = 0;
if ( a1 )
sub_1408793EC(&v55, a1, 0i64);
v67 = 1;
hFindFile = (HANDLE)-1i64;
v40[0] = 0;
v44 = 0i64;
v65 = &v44;
v47 = 128;
v45 = 0;
v46 = 0;
v68 = 1;
if ( v57 )
{
v3 = (LPARAM *)v55;
}
else
{
LOBYTE(CommandLine) = 0;
v3 = &CommandLine;
}
Block = 0i64;
v64 = &Block;
v62 = 128;
v60 = 0;
v61 = 0;
if ( v3 )
sub_1408793EC(&Block, v3, 0i64);
v69 = 1;
if ( v61 <= 0 || v61 - 1 <= 0 )
{
v69 = 0;
free(Block);
LABEL_87:
v68 = 0;
v53 = v40;
if ( hFindFile != (HANDLE)-1i64 )
FindClose(hFindFile);
hFindFile = (HANDLE)-1i64;
free(v44);
v67 = 0;
free(v55);
return;
}
v4 = *((char *)v3 + v61 - 2);
if ( v4 == 92 || v4 == 47 )
sub_14088607C(&Block, (unsigned int)(v61 - 2), 0i64, 32i64);
sub_14087961C(&v44, &Block, 0i64);
sub_140886118(&Block, "\\*", 0i64);
hFindFile = (HANDLE)-1i64;
v40[0] = 1;
if ( v61 )
v5 = (const CHAR *)Block;
else
v5 = &cp;
v6 = MultiByteToWideChar(0xFDE9u, 8u, v5, -1, 0i64, 0);
if ( v6 > 1000 )
{
v49 = 0i64;
v50 = 0;
v52 = 4096;
v51 = 0;
sub_140888FC8(&v49, 2i64 * v6 + 20, 1i64);
if ( v61 )
v36 = (const CHAR *)Block;
else
v36 = &cp;
lpWideCharStr = 0i64;
if ( v51 )
lpWideCharStr = v49;
if ( MultiByteToWideChar(0xFDE9u, 8u, v36, -1, lpWideCharStr, v51 >> 1) )
{
v38 = 0i64;
if ( v51 )
v38 = v49;
v8 = FindFirstFileW(v38, &FindFileData);
hFindFile = v8;
}
else
{
v8 = hFindFile;
}
free(v49);
}
else
{
if ( v61 )
v7 = (const CHAR *)Block;
else
v7 = &cp;
if ( MultiByteToWideChar(0xFDE9u, 8u, v7, -1, WideCharStr, 1024) )
{
v8 = FindFirstFileW(WideCharStr, &FindFileData);
hFindFile = v8;
}
else
{
v8 = hFindFile;
}
}
if ( v8 == (HANDLE)-1i64 )
{
v40[0] = 0;
if ( v61 )
v35 = (const CHAR *)Block;
else
v35 = &cp;
v8 = FindFirstFileA(v35, (LPWIN32_FIND_DATAA)&FindFileData);
hFindFile = v8;
}
free(Block);
if ( v8 == (HANDLE)-1i64 )
goto LABEL_87;
while ( 2 )
{
if ( v40[0] )
{
if ( !WideCharToMultiByte(0xFDE9u, 0, FindFileData.cFileName, -1, MultiByteStr, 1300, 0i64, 0i64) )
MultiByteStr[0] = 0;
v9 = MultiByteStr;
}
else
{
v9 = (const char *)FindFileData.cFileName;
}
if ( strnicmp("reaper_", v9, 7ui64) )
goto LABEL_78;
v10 = 0i64;
while ( v9[v10] )
{
v11 = (unsigned __int8)v9[v10 + 1];
v10 += 2i64;
if ( !v11 )
{
--v10;
break;
}
}
if ( stricmp(&v9[v10 - 4], ".dll")
|| !strnicmp(v9, "_reaper_python", 0xEui64)
|| !strnicmp(v9, "reaper_perl", 0xBui64)
|| !strnicmp(v9, "reaper_php", 0xAui64) )
{
goto LABEL_78;
}
v12 = dword_140BA4E3C;
v70[0] = (__int64)v9;
v13 = 0;
v14 = (unsigned int)dword_140BA4E3C >> 4;
if ( !((unsigned int)dword_140BA4E3C >> 4) )
{
LABEL_44:
v18 = 0;
goto LABEL_45;
}
while ( 1 )
{
v15 = (int)(v13 + v14) / 2;
v16 = 0i64;
if ( v12 )
v16 = (char *)qword_140BA4E30;
v17 = qword_140BA4E48(v70, &v16[16 * v15]);
if ( v17 > 0 )
{
v13 = v15 + 1;
goto LABEL_42;
}
if ( v17 >= 0 )
break;
v14 = (int)(v13 + v14) / 2;
LABEL_42:
if ( v13 == v14 )
goto LABEL_44;
v12 = dword_140BA4E3C;
}
v18 = 1;
v13 = (int)(v13 + v14) / 2;
LABEL_45:
if ( !v18 )
goto LABEL_46;
v33 = 0i64;
if ( dword_140BA4E3C )
v33 = (unsigned __int8 *)qword_140BA4E30;
v34 = 16i64 * v13;
if ( &v33[v34] == (unsigned __int8 *)-8i64 )
LABEL_46:
v19 = 0;
else
v19 = v33[v34 + 8];
if ( !v19 )
{
v20 = v46 ? v44 : &cp;
sub_1408793EC(&v55, v20, 0i64);
sub_140884200(&v55, "\\", 0i64);
if ( v40[0] )
{
if ( !WideCharToMultiByte(0xFDE9u, 0, FindFileData.cFileName, -1, MultiByteStr, 1300, 0i64, 0i64) )
MultiByteStr[0] = 0;
v21 = MultiByteStr;
}
else
{
v21 = FindFileData.cFileName;
}
sub_140884200(&v55, v21, 0i64);
if ( v57 )
{
v22 = (const CHAR *)v55;
}
else
{
LOBYTE(CommandLine) = 0;
v22 = (const CHAR *)&CommandLine;
}
if ( v40[0] && !WideCharToMultiByte(0xFDE9u, 0, FindFileData.cFileName, -1, MultiByteStr, 1300, 0i64, 0i64) )
MultiByteStr[0] = 0;
if ( (unsigned __int8)sub_1405B95A4(v22) )
{
v23 = dword_140BA4E3C;
v54 = v9;
v24 = 0;
v25 = (unsigned int)dword_140BA4E3C >> 4;
if ( (unsigned int)dword_140BA4E3C >> 4 )
{
while ( 1 )
{
v26 = (int)(v24 + v25) / 2;
v27 = 0i64;
if ( v23 )
v27 = (char *)qword_140BA4E30;
v28 = qword_140BA4E48(&v54, &v27[16 * v26]);
if ( v28 <= 0 )
{
if ( v28 >= 0 )
{
v23 = dword_140BA4E3C;
v29 = 1;
v24 = (int)(v24 + v25) / 2;
goto LABEL_69;
}
v25 = (int)(v24 + v25) / 2;
}
else
{
v24 = v26 + 1;
}
if ( v24 == v25 )
{
v23 = dword_140BA4E3C;
break;
}
v23 = dword_140BA4E3C;
}
}
v29 = 0;
LABEL_69:
if ( v29 )
{
v30 = qword_140BA4E30;
if ( !v23 )
v30 = 0i64;
v31 = 16i64 * v24;
if ( qword_140BA4E60 )
qword_140BA4E60((unsigned __int8)v30[v31 + 8]);
v30[v31 + 8] = 1;
}
else
{
v32 = (_BYTE *)(sub_140888FC8(&qword_140BA4E30, 16 * ((v23 >> 4) + 1i64), 1i64) + 16i64 * v24);
memmove(v32 + 16, v32, 16 * (((unsigned int)dword_140BA4E3C >> 4) - v24 - 1));
if ( qword_140BA4E50 )
v9 = (const char *)qword_140BA4E50(v9);
v32[8] = 1;
*(_QWORD *)v32 = v9;
}
}
}
LABEL_78:
if ( hFindFile != (HANDLE)-1i64 )
{
if ( v40[0] )
{
if ( FindNextFileW(hFindFile, &FindFileData) )
continue;
}
else if ( FindNextFileA(hFindFile, (LPWIN32_FIND_DATAA)&FindFileData) )
{
continue;
}
}
break;
}
v63 = v40;
if ( hFindFile != (HANDLE)-1i64 )
FindClose(hFindFile);
hFindFile = (HANDLE)-1i64;
free(v44);
free(v55);
}
Plugin name needs to start with
reaper_
not justreaper
, my mistake. From REAPER source: