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

Function Hk_CreateFileW

HijackMethod_arm64/dllmain.cpp:202–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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