Log in

View Full Version : SysInfo plugin v0.1.2.9


Pages : [1] 2 3 4 5 6

Groucho2004
24th February 2019, 12:26
This plugin returns info about OS/CPU*/Memory/Screen/Avisynth

System related functions:

string SI_OSVersionString()
Returns Operating System info

float SI_OSVersionNumber()
int SI_OSBuildNumber
float SI_OSServicePack
bool SI_IsOS64Bit
bool SI_IsWin10
bool SI_IsWin7
bool SI_IsWin8
bool SI_IsWin81
bool SI_IsWinServer2003
bool SI_IsWinServer2008
bool SI_IsWinServer2008R2
bool SI_IsWinServer2012
bool SI_IsWinServer2012R2
bool SI_IsWinVista
bool SI_IsWinXP
Convenience functions for the running OS

string SI_CPUName()
Returns the CPU brand string + code name

int SI_NumberOfCPUs()
Returns the number of physical CPUs in the system

int SI_PhysicalCores()
Returns the total number of physical cores in the system. If multiple CPUs
are in the system, the sum of physical cores of all CPUs is returned.

int SI_LogicalCores()
Returns the total number of logical cores in the system. If multiple CPUs
are in the system, the sum of logical cores of all CPUs is returned.

string SI_CPUExtensions()
Returns supported CPU extensions/Instruction sets.

bool SI_HasAVX
bool SI_HasAVX2
bool SI_HasAVX512
bool SI_HasFMA3
bool SI_HasFMA4
bool SI_HasMMX
bool SI_HasSSE
bool SI_HasSSE2
bool SI_HasSSE3
bool SI_HasSSE41
bool SI_HasSSE42
bool SI_HasSSSE3
Convenience functions for supported CPU extensions

int SI_TotalSystemMemory()
Returns the total system memory in MiB

int SI_AvailableSystemMemory()
Returns the available system memory in MiB

string SI_ProcessName()
Returns the name of the current process

int SI_ProcessBitness()
Returns the bitness of the current process

int SI_ModulePath()
Returns the path of the SysInfo plugin.

int SI_ScreenResX()
Returns the horizontal screen resolution

int SI_ScreenResY()
Returns the vertical screen resolution

int SI_ScreenBitsPerPixel()
Returns the screen BPP

int SI_ScreenVRefresh()
Returns the vertical refresh rate of the screen

string SI_GetEnvVar(string "env_var")
Returns the value of the environment variable "env_var"
Example:
Path = SI_GetEnvVar("PATH")
The argument "env_var" is not case-sensitive

string SI_UserName()
Returns the name of the currently logged in user

string SI_GetLogicalDrives()
Returns logical drives with labels

int SI_GetLogicalDriveTotalSize("drive_letter")
Returns the total size (in MiB) for a given drive letter

int SI_GetLogicalDriveFreeSpace("drive_letter")
Returns the free space (in MiB) for a given drive letter

int SI_GetLogicalDriveUsedSpace("drive_letter")
Returns the used space (in MiB) for a given drive letter



Avisynth related functions:

string AI_AvsFileVersion
Returns the value of the FileVersion resource property

string AI_AvsProductVersion
Returns the value of the ProductVersion resource property

int AI_AvsPlusBuildNumber
Returns the AVS+ build number

bool AI_IsAvs26
Returns true if the Avisynth VersionNumber is >= 2.6

bool AI_IsAvsPlus
Returns true for Avisynth+

string AI_AvsDLLPath()
Returns the path of the loaded avisynth.dll

string AI_AvsDLLTimeStamp()
Returns the time stamp (last write time) of the loaded avisynth.dll

bool AI_InternalFunctionExists(string "name")
Returns true if an internal function ("name") is available in the current environment
The argument 'name' is not case-sensitive

bool AI_ExternalFunctionExists(string "name")
Returns true if an external (plugin) function ("name") is available in the current environment
The argument 'name' is not case-sensitive

bool AI_FunctionExists(string "name")
Returns true if an internal or external (plugin) function ("name") is available in the current environment
The argument 'name' is not case-sensitive

string AI_AutoLoadPath(string "registry_location")
Returns the Avisynth auto-load directory/directories. Valid arguments for "registry_location" are (case sensitive!):
(See http://avisynth.nl/index.php/AviSynth%2B#New_Functions for info on the origin of these arguments)
USER_PLUS_PLUGINS
MACHINE_PLUS_PLUGINS
USER_CLASSIC_PLUGINS
MACHINE_CLASSIC_PLUGINS


Other functions:

float SysInfoVersion()
Returns SysInfo.dll version number




Download (32 & 64 bit) (http://www.mediafire.com/folder/x6f7yqjufdg7c/Groucho's_Avisynth_Stuff) (SysInfo_*.7z on the download page)


Recent changes (full history in 'ChangeLog.txt'):

v0.1.2.9
- Updated libcpuid (Intel Rocket Lake, AMD Ryzen Milan)


*CPU feature detection uses Veselin Georgiev's libcpuid C-library (https://github.com/anrieff/libcpuid).

wonkey_monkey
24th February 2019, 12:49
Another fine Groucho2004 production.

Groucho2004
24th February 2019, 12:54
Another fine Groucho2004 production.Thanks. This is my first plugin, I hope I didn't screw up.

StainlessS
24th February 2019, 15:12
Hi G2K4,

Just pointing out something that you may like to query with your provider, below from FlagFox, FireFox extension.

https://i.postimg.cc/QVQvZXRC/G2K4.jpg (https://postimg.cc/QVQvZXRC)

Maybe just means that it is not an HTTPS, dont know.

Groucho2004
24th February 2019, 15:23
Maybe just means that it is not an HTTPS, dont know.It probably isn't. I signed up for this account 20+ years ago when I was still living in Ireland and have been using it for (free) data storage since.

If it is of concern to you I might change the hosting although this host is quite convenient for me...

StainlessS
24th February 2019, 15:45
It is of no concern to me, but as I noticed it, thought I would point it out.

However, took a little look at source, and think you need to use env->SaveString() when returning strings to avs.
Avisynth has its own free store, as have you, you need hand over control and responsibility to free mem to avs.

See Here:- https://forum.doom9.org/showthread.php?p=1633936#post1633936

EDIT: http://avisynth.nl/index.php/Filter_SDK/Env_SaveString

EDIT: eg here

AVSValue SI_OSVersion(AVSValue args, void* user_data, IScriptEnvironment* env)
{
if (!bOSVersionInitialized)
GetOSVersion();

char * os;
os = new char[4096];
sprintf(os, "%s", OSVersion.c_str());

// return os;
AVSValue ret = env->SaveString(os);
delete [] os;
return ret;
}


EDITED

Groucho2004
24th February 2019, 16:00
However, took a little look at source, and think you need to use env->SaveString() when returning strings to avs.
Avisynth has its own free store, as have you, you need hand over control and responsibility to free mem to avs.

See Here:- https://forum.doom9.org/showthread.php?p=1633936#post1633936

EDIT: http://avisynth.nl/index.php/Filter_SDK/Env_SaveString

EDIT: eg here

AVSValue SI_OSVersion(AVSValue args, void* user_data, IScriptEnvironment* env)
{
if (!bOSVersionInitialized)
GetOSVersion();

char * os;
os = new char[4096];
sprintf(os, "%s", OSVersion.c_str());

// return os;
AVSValue ret = env->SaveString(os);
delete [] os;
return ret;
}


EDITED
Thanks! That stray char array was bothering me anyway.
Will change it in the next version.

silverwing
24th February 2019, 21:39
This filter returns info about OS/CPU.

Nice work! I will test. Thank you! :thanks:

Groucho2004
24th February 2019, 21:44
v0.1.0.1
- Better error handling
- Fixed some minor bugs
- Added SI_NumberOfCPUs

Groucho2004
25th February 2019, 00:20
v0.1.0.2
- Added SI_CPUClock
- Added gpl/copyright stuff

BTW, I'm open to suggestions as to what other functions to add (fitting within the scope/context of this plugin).

StainlessS
25th February 2019, 00:58
Added SI_CPUClock
...
SI_CPUClock [int]
Returns the (measured) CPU clock


So would that be whatever it is running at when measured ?
[Ie, would that be, nominal rated clock, current clock incl throttling, max burst clock (as on some ATOM chips, my Win10 ATOM Z3735F is quad @ 1.33GHz, burst to 1.8GHz).]
Guessin' current.

Groucho2004
25th February 2019, 02:35
So would that be whatever it is running at when measured ?
[Ie, would that be, nominal rated clock, current clock incl throttling, max burst clock (as on some ATOM chips, my Win10 ATOM Z3735F is quad @ 1.33GHz, burst to 1.8GHz).]
Guessin' current.It won't be the idle clock since the measuring routine will bring the CPU out of idle state. So yes, I guess it'll be current.

Anyway, I'll probably remove it since it's not terribly useful and, after reading the documentation, results can be unreliable in some cases.

Sparktank
25th February 2019, 07:41
Wow, this cool. Thanks a lot! This is bound to help plenty out in the future.

Groucho2004
25th February 2019, 14:18
v0.1.0.3
- Added SI_AvailableSystemMemory
- Removed SI_CPUClock

Groucho2004
2nd March 2019, 13:56
v0.1.0.4
- Added SI_ModulePath
- Updated some error messages

'SI_ModulePath' returns the directory in which SysInfo.dll resides and can be used for example to load DLL dependencies such as libfftw3f-3.dll via tsp's LoadDLL() (https://forum.doom9.org/showthread.php?t=173259). Example:
LoadDLL(SI_ModulePath + "\libfftw3f-3.dll")
AVISource("Test.avi")
FFT3DFilter()

ChaosKing
2nd March 2019, 14:37
Perfect! Lazy People can use a autoLoadDLLs.avsi script like this now

\plugins
\fft

LoadDLL(SI_ModulePath + "\..\fft\libfftw3-3.dll")
LoadDLL(SI_ModulePath + "\..\fft\libfftw3f-3.dll")

Groucho2004
2nd March 2019, 15:10
Perfect! Lazy People can use a autoLoadDLLs.avsi script like this now

\plugins
\fft

LoadDLL(SI_ModulePath + "\..\fft\libfftw3-3.dll")
LoadDLL(SI_ModulePath + "\..\fft\libfftw3f-3.dll")
Neat. Have not even considered that. :cool:

StainlessS
2nd March 2019, 22:09
Me does this rel Plugins (same script works both x86 & x64 & Std) [Assuming x86/x64 dlls all have same name, or could eg switch on CPU]

InitExternalPlugins.avsi

RT_DebugF("Init_ExternalPlugins")

# ...

fn6= ".\LSMASH_CPP\LSMASHSource.dll" # L-Smash CPP
Exist(fn6) ? RT_DebugF("Loading %s",fn6) : RT_DebugF("NOT FOUND %s",fn6)
Exist(fn6) ? LoadPlugin(fn6) : NOP

Groucho2004
6th March 2019, 19:33
v0.1.0.5
- Added SI_TotalSystemMemory
- Refactor/Reorganize

StainlessS
7th March 2019, 06:34
Ooh lovely, Thank you Grouchy 200.4% https://www.cosgan.de/images/smilie/froehlich/a065.gif

StainlessS
25th March 2019, 15:47
Yo Dude,
Just had a daft idea, hows bout info on current screen display size, depth, could introduce a number of other functions in same vein.
No probs if not implemented, havva guddun :)

EDIT: Was thinkin' to let user know likely frame size ahead of time, of frame returned from new ClipBoard_GetDIB() thingy.

Groucho2004
25th March 2019, 16:27
Just had a daft idea, hows bout info on current screen display size, depth, could introduce a number of other functions in same vein.
Good idea.

EDIT: Was thinkin' to let user know likely frame size ahead of time, of frame returned from new ClipBoard_GetDIB() thingy.Don't know what that means. Can you elaborate a bit?

StainlessS
25th March 2019, 16:30
elaborate a bit?
https://forum.doom9.org/showthread.php?p=1869895#post1869895

Post in thread before your post,


ClipBoard_GetDIB() : Get DIB/BitMap from ClipBoard (RGB24 and RGB32[as RGB24] Only).
Returns:-
Int,
0 : DIB Bitmap not available on ClipBoard
-1: Cannot Open Clipboard
-2: Cannot get ClipBoard data
-3: Lock ClipBoard memory failed
-?: Other errors (See DebugView output, Google)
Clip,
DIB/Bitmap from ClipBoard. (Single Frame RGB24 @ 24FPS).

Groucho2004
25th March 2019, 16:37
So far I have this:

https://i.postimg.cc/GmZjbmbz/Image2.png

Is that what you had in mind?

StainlessS
25th March 2019, 16:42
Perfecto :)

EDIT: But, how come you got two screen x dimensions, dual displays perhaps :)

EDIT: Dual dispay stuff did not even occur to me, function returning number of displays [eg Disps=SI_NumberDisplays()], and then SI_Display_XDim(Display=Disps-1) for Last display x dim.
(above is zero relative display number).

Groucho2004
25th March 2019, 16:47
But, how come you got two screen x dimensions, dual displays perhaps :)Typo in the script. :o

Groucho2004
25th March 2019, 17:08
v0.1.0.6
- Added Device caps for the screen (SI_ScreenXRes, SI_ScreenYRes and SI_ScreenBitsPerPixel)

StainlessS
25th March 2019, 17:14
Oooooo Lovely Jubbly. https://www.cosgan.de/images/smilie/froehlich/c030.gif

StainlessS
25th March 2019, 17:52
Its come in handy already

ShowAndWriteClipBoard_DIB.AVS

# ShowAndWriteClipBoard_DIB.AVS
# Show & Write to Image file, last Bitmap copied to ClipBoard (eg "CTRL/ALT/Print_Screen" or "CTRL/Fn/Print_Screen" or whatever your key combo is)
# VDub2 does NOT need be TOP Window to CAP & Write Screen Using eg CTRL/ALT/Print_Screen
####### CONFIG ################
W=640 # If W > 0 then resize clipBoard Bitmap to W : Else use Original Screen X Dimension
H=480 # If Y > 0 then resize clipBoard Bitmap to H : Else use Original Screen Y Dimension
CHECKEVERY=24 # Check for ClipBoard BitMap every CHECKEVERY frames (24 = once per second for 24FPS Blankclip)
# MPC-HC seems a little unresponsive to this script, VDub2 plays fine, x86 and x64.
WRITE=True # Write BitMap to eg D:\CB_000000.BMP, Requires RT_Stats v1.43 if WRITEFILE NOT FullPathName (Incl COLON eg 'D:\')
WRITEFILE="D:\ClipBoard\CB_" # Path MUST Exist
######## End Of CONFIG ###############
WRITEFILE = (WRITE && FindStr(WRITEFILE,":")==0) ? RT_GetFullPathName(WRITEFILE) : WRITEFILE
XRES=SI_ScreenResX YRES=SI_ScreenResY # Req Groucho2004 SysInfo plugin v0.1.0.7
W = (W<=0) ? XRES : W H = (H<=0) ? YRES : H RESIZE = (W!=XRES || H!=YRES)
BlankClip(Width=W,Height=H,Length=24*60*60,Pixel_Type="RGB24").KillAudio
CLP=Trim(0,-1) WrClp=CLP.BlankClip(Length=0) IMGN=0 # Dummy Prep
SSS="""
n = current_frame
CB=(n % CHECKEVERY == 0) ? ClipBoard_GetDIB() : 0
GotDIB=(CB.IsClip)
(GotDIB) ? ClipBoard_Clear() : NOP
CB = (GotDIB&&RESIZE) ? CB.BiCubicResize(W,H) : CB
WrClp= (GotDIB&&WRITE) ? WrClp++CB : WrClp
current_frame = (GotDIB&&WRITE) ? IMGN : n # Force ImageWriter to use our ClipBoard CAP frame number
CLP = (GotDIB&&WRITE) ? WrClp.ImageWriter(WRITEFILE,type="bmp") : CLP
IMGN = (GotDIB&&WRITE) ? IMGN + 1 : IMGN
return CLP
"""
Scriptclip(SSS)

EDIT: Script Update and now requires current version as per below post.

Groucho2004
25th March 2019, 22:36
v0.1.0.7
- Added proper error handling for DevCaps
- Renamed SI_ScreenXRes/SI_ScreenYRes to SI_ScreenResX/SI_ScreenResY
- Added SI_CPUExtensions

As usual, see first post in this thread for details.

StainlessS
21st April 2019, 12:42
No idea if at all of use, but just found this code in Wsus Offline update : Client/Bin/IfAdmin.cpp


// Code is a Microsoft sample found at http://msdn2.microsoft.com/en-us/library/aa376389.aspx

#include "windows.h"
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
/*++
Routine Description: This routine returns TRUE if the caller's
process is a member of the Administrators local group. Caller is NOT
expected to be impersonating anyone and is expected to be able to
open its own process and process token.
Arguments: None.
Return Value:
TRUE - Caller has Administrators local group.
FALSE - Caller does not have Administrators local group. --
*/
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(b)
{
if (!CheckTokenMembership( NULL, AdministratorsGroup, &b))
{
b = FALSE;
}
FreeSid(AdministratorsGroup);
}
return(b);
}


Guess that you may already have such code (but just incase you dont have not got none) :)

.

Groucho2004
21st April 2019, 13:34
No idea if at all of use, but just found this code in Wsus Offline update : Client/Bin/IfAdmin.cpp


// Code is a Microsoft sample found at http://msdn2.microsoft.com/en-us/library/aa376389.aspx

#include "windows.h"
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
/*++
Routine Description: This routine returns TRUE if the caller's
process is a member of the Administrators local group. Caller is NOT
expected to be impersonating anyone and is expected to be able to
open its own process and process token.
Arguments: None.
Return Value:
TRUE - Caller has Administrators local group.
FALSE - Caller does not have Administrators local group. --
*/
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(b)
{
if (!CheckTokenMembership( NULL, AdministratorsGroup, &b))
{
b = FALSE;
}
FreeSid(AdministratorsGroup);
}
return(b);
}


Guess that you may already have such code (but just incase you dont have not got none) :)

.Certainly useful, thank you.

Groucho2004
23rd April 2019, 11:10
v0.1.0.8
- Added 'SI_ProcessBitness'

StainlessS
6th May 2019, 17:26
Any chance of Windows NT version number, for use to eg decide which MvTools.dll to load, XP (<6.0) or Vista+ (>=6.0).
Much easier than having multiple Plugins setups for different hardware (better if avsi plugin loader based on NT version number).
SI_OSVersion could be persuaded to assist but would be a bit of a tedious task and a bit convoluted.
Thanks.
Suggest maybe SI_NtVersionNumber().

Windows NT on WikiPedia:- https://en.wikipedia.org/wiki/Windows_NT
And:- https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions

Groucho2004
6th May 2019, 19:13
Any chance of Windows NT version number, for use to eg decide which MvTools.dll to load, XP (<6.0) or Vista+ (>=6.0).
Much easier than having multiple Plugins setups for different hardware (better if avsi plugin loader based on NT version number).
SI_OSVersion could be persuaded to assist but would be a bit of a tedious task and a bit convoluted.
Thanks.
Suggest maybe SI_NtVersionNumber().

Windows NT on WikiPedia:- https://en.wikipedia.org/wiki/Windows_NT
And:- https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
Sure, no problem. I suggest SI_OSVersionString() (instead of SI_OSVersion()) and SI_OSVersionNumber(), similar to Avisynth.

Edit - SI_OSVersionNumber(): return string or float?

StainlessS
6th May 2019, 20:44
SI_OSVersionNumber(): return string or float?

Float preferable, easier for direct compare greater/equal/lesser style.

Groucho2004
7th May 2019, 00:40
v0.1.0.9
- Added 'SI_OSVersionNumber'
- Changed 'SI_OSVersion' to 'SI_OSVersionString'

StainlessS
7th May 2019, 00:53
Magical, thank you sir.

Emulgator
17th May 2019, 00:28
#25:EDIT: Dual dispay stuff did not even occur to me,
I'd like to be dispayed too ! Dual ! Or better not...
Well, late to the party I am a bit indeed now, isn't it ;-)
(In a "retiring home from a muscateller" mood...)
And many thanks for your continued work, you both !

StainlessS
20th June 2019, 21:27
Hi Grouchy, can you tell, is there any contradiction in these two outputs regarding CPU extensions.
https://i.postimg.cc/pdWTwzDC/CB-Info.jpg (https://postimages.org/)

and


InitExternalPlugins:
InitExternalPlugins: Auto load plugins script ENTRY
InitExternalPlugins:
InitExternalPlugins:ShowAvsInfo:
InitExternalPlugins:ShowAvsInfo: VersionString = 'AviSynth+ 0.1 (r2772, MT, i386)'
InitExternalPlugins:ShowAvsInfo: OSVersionString = 'Windows 7 (x64) Service Pack 1.0 (Build 7601)'
InitExternalPlugins:ShowAvsInfo: OSVersionNumber = 6.100000
InitExternalPlugins:ShowAvsInfo: CPUName = 'Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz / Yorkfield (Core 2 Quad) 6M'
InitExternalPlugins:ShowAvsInfo: Cores = 04:04 (Phy:Log)
InitExternalPlugins:ShowAvsInfo: CPU Extensions = 'MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1'
InitExternalPlugins:ShowAvsInfo: Total Memory = 12221MB
InitExternalPlugins:ShowAvsInfo: Avail Memory = 9824MB'
InitExternalPlugins:ShowAvsInfo: Sys Bitness = 32 # EDIT: Actually 32 bit AVS bitness
InitExternalPlugins:ShowAvsInfo: Screen Res = 1920x1080
InitExternalPlugins:ShowAvsInfo: Screen BitPerPixel = 32
InitExternalPlugins:ShowAvsInfo:


Produced by this INCOMPLETE script in plugins


RT_debugF("DBGVIEWCLEAR\n\nAuto load plugins script ENTRY\n",name="InitExternalPlugins: ") # 'DBGVIEWCLEAR' sent to Debugview window clears the window. (thanx Wonkey)

# For whatever usage within this script
Global G_InitPlugs_IsAvs26 = ( VersionNumber>=2.6 )
Global G_InitPlugs_IsAvsPlus = ( FindStr(VersionString, "AviSynth+")!= 0 || FindStr(VersionString, " Neo")!= 0 )
Global G_InitPlugs_Bitness = ( SI_ProcessBitness() )

Function ShowAvsInfo() {
myName="InitExternalPlugins:ShowAvsInfo: "
S=RT_String("\nVersionString = '%s'\n", VersionString)
S=RT_String("%sOSVersionString = '%s'\n", S,SI_OSVersionString)
S=RT_String("%sOSVersionNumber = %f\n", S,SI_OSVersionNumber)
S=RT_String("%sCPUName = '%s'\n", S,SI_CPUName)
S=RT_String("%sCores = %02d:%02d (Phy:Log)\n", S,SI_PhysicalCores,SI_LogicalCores)
S=RT_String("%sCPU Extensions = '%s'\n", S,SI_CPUExtensions)
S=RT_String("%sTotal Memory = %dMB\n", S,SI_TotalSystemMemory)
S=RT_String("%sAvail Memory = %dMB'\n", S,SI_AvailableSystemMemory)
S=RT_String("%sSys Bitness = %d\n", S,SI_ProcessBitness)
S=RT_String("%sScreen Res = %dx%d\n", S,SI_ScreenResX,SI_ScreenResY)
S=RT_String("%sScreen BitPerPixel = %d\n", S,SI_ScreenBitsPerPixel)
RT_DebugF("%s",S,name=myName)
}

Function Load_CPP_Plugin(String fn) {
myName = "InitExternalPlugins:Load_CPP_Plugin: "
FN = RT_GetFullPathName(fn)
EX = Exist(FN)
Try {
EX ? LoadPlugin(FN) : NOP
EX ? RT_DebugF("%s LOADED OK",FN,name=my_Name) : RT_DebugF("%s NOT FOUND",FN,name=myName)
} catch(msg) { RT_DebugF("ERROR on '%s'\nSysErr='%s'",FN,msg,name=myName) }
}

Function Load_C_Plugin(String fn) {
myName = "InitExternalPlugins:Load_C_Plugin: "
FN = RT_GetFullPathName(fn)
EX = Exist(FN)
Try {
EX ? Load_Stdcall_Plugin(FN) : NOP
EX ? RT_DebugF("%s LOADED OK",FN,name=my_Name) : RT_DebugF("%s NOT FOUND",FN,name=myName)
} catch(msg) { RT_DebugF("ERROR on '%s'\nSysErr='%s'",FN,msg,name=myName) }
}

Function Import_Avsi(String fn) { # EDIT: This may not work at all
myName = "InitExternalPlugins:Import_Avsi: "
FN = RT_GetFullPathName(fn)
EX = Exist(FN)
Try {
EX ? Import(FN) : NOP
EX ? RT_DebugF("%s IMPORTED OK",FN,name=my_Name) : RT_DebugF("%s NOT FOUND",FN,name=myName)
} catch(msg) { RT_DebugF("ERROR on '%s'\nSysErr='%s'",FN,msg,name=myName) }
}

##################

ShowAvsInfo()

#Load_C_Plugin(".\FFMS_C\ffms2.dll") # FFMpegSource C Plugin
#Import_Avsi(".\FFMS_C\ffms2.avsi") # FFMpegSource C Avsi file with LoadCPlugin line commented OUT.
#Load_CPP_Plugin(".\FFMS2000_CPP\ffms2.dll") # FFMpegSource CPP Plugin
#Import_Avsi(".\FFMS2000_CPP\ffms2.avsi") # FFMpegSource CPP Avsi file with LoadCPlugin line commented OUT.
#Load_CPP_Plugin(".\LSMASH_CPP\LSMASHSource.dll") # L-Smash CPP

#Load_CPP_Plugin(".\DGDecode\DGDecode_x86.DLL") # DGDecode CPP
#Load_C_Plugin("C:\NON-INSTALL\DGAVCDec\DGAVCDecode.dll") # DGAVCDec C


EDIT: Ie, does SSE, SSE2, SSE3 == ISSE

EDIT: Not sure if the avsi Import function actually works when import into local function, might have to use Eval on contents of file, even then might not work, dont know yet. we may need to somehow import into main level script, but dont know how from local function [maybe return contents of file to caller, and they need to eval on it at main level].

Groucho2004
20th June 2019, 21:43
Ie, does SSE, SSE2, SSE3 == ISSEI don't think so. I'll look into it.

Edit: From this (https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions) page:

SSE was originally called Katmai New Instructions (KNI), Katmai being the code name for the first Pentium III core revision. During the Katmai project Intel sought to distinguish it from their earlier product line, particularly their flagship Pentium II. It was later renamed Internet Streaming SIMD Extensions (ISSE[1]), then SSE. AMD eventually added support for SSE instructions, starting with its Athlon XP and Duron (Morgan core) processors. So, ISSE = SSE (I guess?).

Groucho2004
20th June 2019, 22:03
Function ShowAvsInfo() {
myName="InitExternalPlugins:ShowAvsInfo: "
S=RT_String("\nVersionString = '%s'\n", VersionString)
S=RT_String("%sOSVersionString = '%s'\n", S,SI_OSVersionString)
S=RT_String("%sOSVersionNumber = %f\n", S,SI_OSVersionNumber)
S=RT_String("%sCPUName = '%s'\n", S,SI_CPUName)
S=RT_String("%sCores = %02d:%02d (Phy:Log)\n", S,SI_PhysicalCores,SI_LogicalCores)
S=RT_String("%sCPU Extensions = '%s'\n", S,SI_CPUExtensions)
S=RT_String("%sTotal Memory = %dMB\n", S,SI_TotalSystemMemory)
S=RT_String("%sAvail Memory = %dMB'\n", S,SI_AvailableSystemMemory)
S=RT_String("%sSys Bitness = %d\n", S,SI_ProcessBitness)
S=RT_String("%sScreen Res = %dx%d\n", S,SI_ScreenResX,SI_ScreenResY)
S=RT_String("%sScreen BitPerPixel = %d\n", S,SI_ScreenBitsPerPixel)
RT_DebugF("%s",S,name=myName)
}Just curious - Why do you call the function "ShowAvsInfo()" even though it doesn't gather anything related to Avisynth?

StainlessS
20th June 2019, 22:08
Thanks G2K4,

I take it that all three SSE, SSE2 and SSE3 are integer SSE, and so maybe in AVS ISSE is just shorthand for the lot.

Just thought that additional nicety might be the current or Parent process name, in RT_stats we have RT_GetProcessName(), might be handy in your plug too.
I have used to make small changes when using eg MPC-HC (where eg enable output of float audio),
and some other reason connected with Vdub current process, cant offhand remember what that was.


RT_GetProcessName(bool "parent"=false,bool "debug"=false)
Returns string, name of current process eg "VirtualDubMod.exe" or "AvsPMod.exe" or name of parent process
(the one that started our process eg "Explorer.exe"). Debug outputs some info to DebugView.


From RT_


/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "RT_Stats.h"


#define DPRINTFNAME "RT_GetProcessName: "


AVSValue __cdecl RT_GetProcessName(AVSValue args, void*, IScriptEnvironment* env) {

bool parent= args[0].AsBool(false);
bool debug = args[1].AsBool(false);


// DWORD WINAPI GetCurrentProcessId(void);
// Return value: The return value is the process identifier of the calling process.
// Minimum supported client:- Windows XP WinBase.h (Processthreadsapi.h W8 Server 2012)
// ssS, Rubbish, also works fine on W2K

DWORD PID = GetCurrentProcessId(); // Cannot fail (I think) as current process is obviously running.





// HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags,DWORD th32ProcessID);
//
//
// The th32ProcessID argument is only used if TH32CS_SNAPHEAPLIST or
// TH32CS_SNAPMODULE is specified. th32ProcessID == 0 means the current
// process.
//
// NOTE that all of the snapshots are global except for the heap and module
// lists which are process specific. To enumerate the heap or module
// state for all WIN32 processes call with TH32CS_SNAPALL and the
// current process. Then for each process in the TH32CS_SNAPPROCESS
// list that isn't the current process, do a call with just
// TH32CS_SNAPHEAPLIST and/or TH32CS_SNAPMODULE.
//
// dwFlags
//
// #define TH32CS_SNAPHEAPLIST 0x00000001
// #define TH32CS_SNAPPROCESS 0x00000002
// #define TH32CS_SNAPTHREAD 0x00000004
// #define TH32CS_SNAPMODULE 0x00000008
// #define TH32CS_SNAPMODULE32 0x00000010
// #define TH32CS_SNAPALL (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE)
// #define TH32CS_INHERIT 0x80000000
//
HANDLE hProcessSnap = NULL;

// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
// Returns an open handle to the specified snapshot if successful or INVALID_HANDLE_VALUE otherwise.
// The snapshot taken by this function is examined by the other tool help functions to provide their results.
// Access to the snapshot is read only. The snapshot handle acts like an object handle and is subject to the same
// rules regarding which processes and threads it is valid in.
// To retrieve an extended error status code generated by this function, use the GetLastError function.
// To destroy the snapshot, use the CloseHandle function.


if (hProcessSnap == INVALID_HANDLE_VALUE)
return -1;


// Describes an entry from a list that enumerates the processes residing in the system address space when a snapshot was taken.
//
// typedef struct tagPROCESSENTRY32 {
// DWORD dwSize;
// DWORD cntUsage;
// DWORD th32ProcessID;
// ULONG_PTR th32DefaultHeapID;
// DWORD th32ModuleID;
// DWORD cntThreads;
// DWORD th32ParentProcessID;
// LONG pcPriClassBase;
// DWORD dwFlags;
// TCHAR szExeFile[MAX_PATH];
// } PROCESSENTRY32;
// typedef PROCESSENTRY32 *PPROCESSENTRY32;
//
// Members
//
// dwSize
// Specifies the length, in bytes, of the structure. Before calling the Process32First function, set this member to
// sizeof(PROCESSENTRY32). If you do not initialize dwSize, Process32First will fail.
// cntUsage
// Number of references to the process. A process exists as long as its usage count is nonzero. As soon as its usage
// count becomes zero, a process terminates.
// th32ProcessID
// Identifier of the process.
// th32DefaultHeapID
// Identifier of the default heap for the process. The contents of this member has meaning only to the tool help
// functions. It is not a handle, nor is it usable by functions other than the ToolHelp functions.
// th32ModuleID
// Module identifier of the process. The contents of this member has meaning only to the tool help functions
// It is not a handle, nor is it usable by functions other than the ToolHelp functions.
// cntThreads
// Number of execution threads started by the process.
// th32ParentProcessID
// Identifier of the process that created the process being examined.
// pcPriClassBase
// Base priority of any threads created by this process.
// dwFlags
// Reserved; do not use.
// szExeFile
// Path and filename of the executable file for the process.
//
// Requirements:- Windows NT/2000/XP: Included in Windows 2000 and later. ::: Tlhelp32.h.

PROCESSENTRY32 pe32 = {0};
// Fill in the size of the structure before using it.
pe32.dwSize = sizeof(PROCESSENTRY32);



// Walk the snapshot of the processes, and for each process,
// BOOL WINAPI Process32First(HANDLE hSnapshot,LPPROCESSENTRY32 lppe);
if (!Process32First(hProcessSnap, &pe32)) {
CloseHandle (hProcessSnap);
return -2; // Cant find first process
}

AVSValue ret = -3; // Init to cant find my own PID

do {
if(pe32.th32ProcessID == PID) {
if(debug) {
dprintf(DPRINTFNAME"ExeFile = %s\n",pe32.szExeFile);
dprintf(DPRINTFNAME"ProcessID = 0x%08X\n",pe32.th32ProcessID);
dprintf(DPRINTFNAME"Threads = %d\n",pe32.cntThreads);
dprintf(DPRINTFNAME"ParentProc = 0x%08X\n",pe32.th32ParentProcessID);
}
if(parent==false) {
ret = env->SaveString(pe32.szExeFile);
} else {
ret = -4; // Init Cant find parent
DWORD PARPID = pe32.th32ParentProcessID;
if (Process32First(hProcessSnap, &pe32)) {
do {
if(pe32.th32ProcessID == PARPID) {
if(debug) {
dprintf(DPRINTFNAME"ExeFile = %s\n",pe32.szExeFile);
dprintf(DPRINTFNAME"ProcessID = 0x%08X\n",pe32.th32ProcessID);
dprintf(DPRINTFNAME"Threads = %d\n",pe32.cntThreads);
dprintf(DPRINTFNAME"ParentProc = 0x%08X\n",pe32.th32ParentProcessID);
}
ret = env->SaveString(pe32.szExeFile);
break;
}
} while (Process32Next(hProcessSnap, &pe32));
}
}
break; // DONE
}
} while (Process32Next(hProcessSnap, &pe32));

CloseHandle (hProcessSnap); // Cleanup process snapshot

return (ret);
}

EDIT: Above there seems to be quite a few '32' snippits in code, perhaps it dont work in 64 bit proc.


EDIT:
Just curious - Why do you call the function "ShowAvsInfo()" even though it doesn't gather anything related to Avisynth?
Just be thankfull that it aint called Test() or Fred(), two popular names I use a lot. [and it does show Avs version String, 1st line).

Groucho2004
20th June 2019, 22:12
Just thought that additional nicety might be the Parent process name, in RT_stats we have RT_GetProcessName(), might be handy in your plug too.
Yep, sounds like a good idea, thanks for the code snippet.

Groucho2004
20th June 2019, 22:14
EDIT:

Just be thankfull that it aint called Test() or Fred(), two popular names I use a lot. [and it does show Avs version String, 1st line).Ok, never mind. :D

I do like "Fred()".

StainlessS
20th June 2019, 22:23
On Qwerty Keyboard, all 4 keys are adjacent, so easy to type for us lazy coders [Fred].
Note also the comment below code on lots of '32' snippits in code block, maybe not work on x64.

EDIT: Off to pub for last orders.

Groucho2004
20th June 2019, 22:24
EDIT: Above there seems to be quite a few '32' snippits in code, perhaps it dont work in 64 bit proc.I wrote a ProcessInfo() class for AVSMeter so there should not be any problems with 64 bit.

Groucho2004
21st June 2019, 11:36
Just thought that additional nicety might be the Parent process name, in RT_stats we have RT_GetProcessName(), might be handy in your plug too.
Yep, sounds like a good idea, thanks for the code snippet.

Edit: It's actually as simple as this:
char szBuffer[MAX_PATH];
GetModuleFileName(NULL, (LPTSTR)szBuffer, sizeof(szBuffer));
:D

StainlessS
21st June 2019, 12:15
Will you be implementing both Current Process Name, & Parent Process Name ? [I intially wrote parent, but meant current process, RT_ returns either].

Groucho2004
21st June 2019, 12:18
Will you be implementing both Current Process Name, & Parent Process Name ?I don't understand the difference. There is always just one process that loads avisynth.dll.

Edit: Ok, I see what you mean. Can you give me an example where it's useful to know the parent process?