MCPcopy Create free account
hub / github.com/LiteLoaderQQNT/QQNTFileVerifyPatch / Hk_CreateFileW

Function Hk_CreateFileW

HijackMethod/dllmain.cpp:210–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210HANDLE WINAPI Hk_CreateFileW(
211 _In_ LPCWSTR lpFileName,
212 _In_ DWORD dwDesiredAccess,
213 _In_ DWORD dwShareMode,
214 _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
215 _In_ DWORD dwCreationDisposition,
216 _In_ DWORD dwFlagsAndAttributes,
217 _In_opt_ HANDLE hTemplateFile
218) {
219
220 if (wcsstr(lpFileName, L"\\resources\\app\\app_launcher\\index.js") != NULL&& mulock1 !=true&&mulock2!=true&&OldQQ==true)
221 {
222
223 if (_taccess(L"PatchConfig.json", 0) != 0) {
224 if (!IsRunAsAdmin()) {
225 RestartAsAdmin();
226 exit(0);
227 }
228
229 nlohmann::json data;
230 data["LLPath"] = "NULL";
231 std::ofstream file("PatchConfig.json");
232 file << std::setw(4) << data << std::endl;
233 file.close();
234 SetFileALLAccessPrems(L"PatchConfig.json");
235
236 }
237 else
238 {
239 std::ifstream file("PatchConfig.json");
240 nlohmann::json j;
241 file >> j;
242 file.close();
243 std::string value = "";
244 if (j.find("LLPath") != j.end()) {
245 value = j["LLPath"];
246 }
247 else
248 {
249 MessageBoxA(nullptr, "Cant find jsonkey \"LLPath\"", "ERROR", MB_ICONERROR | MB_OK);
250 exit(1);
251 }
252 if (value != "NULL"&&value!="") {
253 mulock1 = true;
254 FILE* indexfile = _wfopen(lpFileName, L"r");
255 if (indexfile == NULL) {
256 MessageBoxA(nullptr, "failed to open index.js", "ERROR", MB_ICONERROR | MB_OK);
257 exit(1);
258 }
259 char OrgConte[1024] = "";
260 if (fgets(OrgConte, sizeof(OrgConte), indexfile) == NULL) {
261 OrgConte[0] = '\0';
262 }
263 size_t OrgSize = strlen(OrgConte);
264 fclose(indexfile);
265 if (strstr(OrgConte, "require(String.raw`") == NULL) {
266 indexfile = _wfopen(lpFileName, L"w+");
267 if (indexfile == NULL) {

Callers

nothing calls this directly

Calls 4

IsRunAsAdminFunction · 0.70
RestartAsAdminFunction · 0.70
SetFileALLAccessPremsFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected