Skip to content

Instantly share code, notes, and snippets.

@elecyb
Created May 9, 2012 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elecyb/2641077 to your computer and use it in GitHub Desktop.
Save elecyb/2641077 to your computer and use it in GitHub Desktop.
Driver Check
char __thiscall HandleDriverCheck(int this, LPCSTR lpDeviceName, char *hash, int seed)
{
int v5; // eax@4
char v6; // cl@5
signed int v7; // eax@6
int v8; // edx@6
char *v9; // ecx@6
int v10; // esi@10
int v11; // eax@11
int v12; // edx@11
int v13; // ecx@11
int v14; // eax@13
int v15; // edx@13
int v16; // ecx@13
int v17; // edx@15
int v18; // ecx@15
signed int v19; // eax@17
int v20; // [sp+8h] [bp-208h]@1
char newHash[20]; // [sp+Ch] [bp-204h]@6
char hmacCtx[224]; // [sp+20h] [bp-1F0h]@4
char TargetPath[260]; // [sp+100h] [bp-110h]@3
unsigned int v24; // [sp+20Ch] [bp-4h]@1
v24 = (unsigned int)&v20 ^ dword_409000;
if ( !*(_BYTE *)(this + 45) || !QueryDosDeviceA(lpDeviceName, TargetPath, 260u) )
return 0;
HMACSHA1__Init((int)hmacCtx, seed);
v5 = (int)TargetPath;
do
v6 = *(_BYTE *)v5++;
while ( v6 );
SHA1__Update((int)TargetPath, (int)hmacCtx, v5 - (_DWORD)&TargetPath[1]);
HMACSHA1__Final((int)hmacCtx, (int)newHash);
v9 = hash;
v7 = 20;
v8 = (int)newHash;
do
{
if ( *(_DWORD *)v8 != *(_DWORD *)v9 )
goto LABEL_10;
v7 -= 4;
v9 += 4;
v8 += 4;
}
while ( (unsigned int)v7 >= 4 );
if ( !v7 )
{
LABEL_19:
v19 = 0;
return v19 == 0;
}
LABEL_10:
v10 = *(_BYTE *)v8 - (unsigned __int8)*v9;
if ( *(_BYTE *)v8 == (unsigned __int8)*v9 )
{
v11 = v7 - 1;
v13 = (int)(v9 + 1);
v12 = v8 + 1;
if ( !v11
|| (v10 = *(_BYTE *)v12 - *(_BYTE *)v13, *(_BYTE *)v12 == *(_BYTE *)v13)
&& ((v14 = v11 - 1, v16 = v13 + 1, v15 = v12 + 1, !v14)
|| (v10 = *(_BYTE *)v15 - *(_BYTE *)v16, *(_BYTE *)v15 == *(_BYTE *)v16)
&& ((v18 = v16 + 1, v17 = v15 + 1, v14 == 1)
|| (v10 = *(_BYTE *)v17 - *(_BYTE *)v18, *(_BYTE *)v17 == *(_BYTE *)v18))) )
goto LABEL_19;
}
v19 = 1;
if ( v10 <= 0 )
v19 = -1;
return v19 == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment