Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8e3d90c

Browse files
Added --limit-file-checks command line option.
1 parenteb89b4d commit8e3d90c

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

‎analyze.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ var wscript_proxy = new Proxy({
911911
quit:function(){
912912
lib.logIOC("WScript","Quit()","The sample explicitly called WScript.Quit().");
913913
//console.trace()
914-
if(!argv["ignore-wscript-quit"]){
914+
if((!argv["ignore-wscript-quit"])||lib.doWscriptQuit()){
915915
process.exit(0);
916916
}
917917
},

‎emulator/FileSystemObject.js‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,38 @@ function FileSystemObject() {
174174
returntrue;
175175
};
176176
this.fileexists=(path)=>{
177-
constvalue=!argv["no-file-exists"];
177+
varvalue=!argv["no-file-exists"];
178178
if(value){
179179
lib.info(`Returning true for FileSystemObject.FileExists(${path}); use --no-file-exists if nothing happens`);
180180
}
181+
if(typeof(this._fileCheckCount)=="undefined")this._fileCheckCount=0;
182+
this._fileCheckCount++;
183+
if(argv["limit-file-checks"]&&(this._fileCheckCount>10)){
184+
// Flip whether the file exists or not to see if that
185+
// breaks a loop.
186+
value=!value;
187+
// Might break emulation based on WScript.quit(). Stop
188+
// ignoring WScript.quit().
189+
lib.doWscriptQuit(true);
190+
}
181191
lib.logIOC("FileExists",path,"The script checked to see if a file exists.");
182192
returnvalue;
183193
};
184194
this.folderexists=(path)=>{
185-
constvalue=!argv["no-folder-exists"];
195+
varvalue=!argv["no-folder-exists"];
186196
if(value){
187197
lib.info(`Returning true for FileSystemObject.FolderExists(${path}); use --no-folder-exists if nothing happens`);
188198
}
199+
if(typeof(this._fileCheckCount)=="undefined")this._fileCheckCount=0;
200+
this._fileCheckCount++;
201+
if(argv["limit-file-checks"]&&(this._fileCheckCount>500)){
202+
// Flip whether the file exists or not to see if that
203+
// breaks a loop.
204+
value=!value;
205+
// Might break emulation based on WScript.quit(). Stop
206+
// ignoring WScript.quit().
207+
lib.doWscriptQuit(true);
208+
}
189209
lib.logIOC("FolderExists",path,"The script checked to see if a folder exists.");
190210
returnvalue;
191211
};

‎flags.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
"type":"Boolean",
123123
"description":"Return `false` for Scripting.FileSystemObject.FileExists(x)"
124124
},
125+
{
126+
"name":"limit-file-checks",
127+
"type":"Boolean",
128+
"description":"Switch default value for folder/file exists checks if many checks are performed (try to break infinite file check loops)."
129+
},
125130
{
126131
"name":"no-folder-exists",
127132
"type":"Boolean",

‎lib.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,20 @@ function noCasePropObj(obj)
184184
returnnewObj;// object with upper cased keys
185185
};
186186

187+
_doWscriptQuit=false;
188+
functiondoWscriptQuit(flag){
189+
if(typeof(flag)!="undefined")_doWscriptQuit=flag;
190+
return_doWscriptQuit;
191+
}
192+
187193
module.exports={
188194
argv,
189195
kill,
190196
getUUID,
191197
throttleFileWrites,
192198
throttleCommands,
193199
noCasePropObj,
200+
doWscriptQuit,
194201

195202
debug:log.bind(null,"debug"),
196203
verbose:log.bind(null,"verb"),

‎patch.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ let __PATCH_CODE_ADDED__ = true;
33
window=this;
44

55
_globalTimeOffset=0;
6+
_sleepCount=0;
67
WScript.sleep=function(delay){
78
_globalTimeOffset+=delay;
9+
_sleepCount++;
810
}
911

1012
letfullYearGetter=Date.prototype.getFullYear;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp