#include #include #include "debug.h" #include "ConfigApi.h" #include "checkdll.h" #include "appunlock.h" #include "findcert.h" std::string GetApplicationPath() { #ifdef _WIN32 std::tstring appname; appname.resize(1024); if (!GetModuleFileName(NULL, &appname[0], 1024)) return ""; appname.resize(appname.find_last_of(_T('\\'))); return ToString(appname); #else // todo - figure out binary path return "."; #endif } // todo: also try to upload+run 'enablerapi.exe' bool appunlock(int step) { std::string xml; switch(step) { case 0: xml= pd_SetMetabaseKey("RAPI\\windows\\itsutils.dll\\*", 3, 152); break; case 1: xml= pd_SetSecurityPolicy(4097, 1); break; case 2: xml= pd_SetSecurityPolicy(4123, 1); break; case 3: { std::string srcroot= GetApplicationPath(); std::string dstroot= g_devicedllpath; size_t ixslash= dstroot.find_last_of("/\\"); dstroot.resize(ixslash); CeCopyFileToDevice(srcroot+"\\enablerapi.exe", dstroot+"\\enablerapi.exe", true); PROCESS_INFORMATION pi; CeCreateProcess(ToWString(dstroot+"\\enablerapi.exe").c_str(), L"", NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi); CeCloseHandle( pi.hProcess); CeCloseHandle( pi.hThread); } case 4: { // for ppc2003/ppc2002 StringList values; SplitString("Restriction AdminActive AdminInfo NoExternalExes NoRapiRegMod NoAutoRun NoRunDlg", values, " "); xml= pd_DeleteRegistryValues("HKLM\\Security\\Policies\\Shell", values.begin(), values.end()); } break; case 5: { ByteVector cert; if (FindCertificate(GetApplicationPath()+"/itsutils.dll", cert)) xml= pd_LoadCertificate(storenames[CERTSTORE_PRIVILEGED], 0, cert); } break; default: return false; } LoadRapi(); std::string answer; if (!xml.empty()) LoadProvisioningDoc(xml, answer); UnloadRapi(); return true; }