Browse Source

clean restrict.cpp

pull/25/head
Andrew Dunstan 8 years ago committed by Anders Jenbo
parent
commit
d8da11f0dc
  1. 103
      Source/restrict.cpp
  2. 6
      Source/restrict.h

103
Source/restrict.cpp

@ -2,72 +2,59 @@
#include "../types.h" #include "../types.h"
bool __cdecl SystemSupported() BOOL __cdecl SystemSupported()
{ {
bool v0; // di OSVERSIONINFO VersionInformation;
struct _OSVERSIONINFOA VersionInformation; // [esp+4h] [ebp-94h] BOOL ret = FALSE;
v0 = 0; memset(&VersionInformation, 0, sizeof(VersionInformation));
memset(&VersionInformation, 0, 0x94u); VersionInformation.dwOSVersionInfoSize = sizeof(VersionInformation);
VersionInformation.dwOSVersionInfoSize = 148; if (GetVersionEx(&VersionInformation)
if ( GetVersionEx(&VersionInformation) && VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT
&& VersionInformation.dwPlatformId == 2 && VersionInformation.dwMajorVersion >= 5) {
&& VersionInformation.dwMajorVersion >= 5 ) ret = TRUE;
{ }
v0 = 1; return ret;
}
return v0;
} }
bool __cdecl RestrictedTest() BOOL __cdecl RestrictedTest()
{ {
bool v0; // si FILE *f;
FILE *v2; // eax char Buffer[MAX_PATH];
char Buffer[260]; // [esp+4h] [ebp-104h] BOOL ret = FALSE;
v0 = 0; if (SystemSupported() && GetWindowsDirectory(Buffer, sizeof(Buffer))) {
if ( SystemSupported() && GetWindowsDirectory(Buffer, 0x104u) ) strcat(Buffer, "\\Diablo1RestrictedTest.foo");
{ f = fopen(Buffer, "wt");
strcat(Buffer, "\\Diablo1RestrictedTest.foo"); if (f) {
v2 = fopen(Buffer, "wt"); fclose(f);
if ( v2 ) remove(Buffer);
{ } else {
fclose(v2); ret = TRUE;
remove(Buffer); }
} }
else return ret;
{
v0 = 1;
}
}
return v0;
} }
bool __cdecl ReadOnlyTest() BOOL __cdecl ReadOnlyTest()
{ {
bool v0; // si char *c;
char *v1; // eax FILE *f;
FILE *v2; // eax char Filename[MAX_PATH];
char Filename[260]; // [esp+4h] [ebp-104h] BOOL ret = FALSE;
v0 = 0; if (GetModuleFileName(ghInst, Filename, sizeof(Filename))) {
if ( GetModuleFileName(ghInst, Filename, 0x104u) ) c = strrchr(Filename, '\\');
{ if (c) {
v1 = strrchr(Filename, '\\'); strcpy(c + 1, "Diablo1ReadOnlyTest.foo");
if ( v1 ) f = fopen(Filename, "wt");
{ if (f) {
strcpy(v1 + 1, "Diablo1ReadOnlyTest.foo"); fclose(f);
v2 = fopen(Filename, "wt"); remove(Filename);
if ( v2 ) } else {
{ ret = TRUE;
fclose(v2); }
remove(Filename); }
} }
else return ret;
{
v0 = 1;
}
}
}
return v0;
} }

6
Source/restrict.h

@ -2,8 +2,8 @@
#ifndef __RESTRICT_H__ #ifndef __RESTRICT_H__
#define __RESTRICT_H__ #define __RESTRICT_H__
bool __cdecl SystemSupported(); BOOL __cdecl SystemSupported();
bool __cdecl RestrictedTest(); BOOL __cdecl RestrictedTest();
bool __cdecl ReadOnlyTest(); BOOL __cdecl ReadOnlyTest();
#endif /* __RESTRICT_H__ */ #endif /* __RESTRICT_H__ */

Loading…
Cancel
Save