void DecodeSelf( void ) { CTEXTSTR progname = GetProgramName(); FILE *self; if( decode.first_section ) { self = fopen( progname, "rb" ); if( self ) { POINTER out; uint32_t section_length; struct section section; char *filename; fseek( self, decode.first_section, SEEK_SET ); while( fread( §ion_length, 1, sizeof( section_length ), self ) ) { fread( §ion, 1, section_length, self ); filename = (char*)Allocate( section.length ); fread( filename, 1, section.length, self ); out = OpenSpace( filename, NULL, 0 ); fread( out, 1, section.library_length, self ); if( section.flags & SECTION_FLAG_STARTUP ) { decode.startup_library = filename; filename = NULL; } Release( out ); if( filename ) Release( filename ); } fclose( self ); } } }
int main( int argc, TEXTCHAR **argv ) { int saveas = 0; if( argc < 2 ) { printf( WIDE("Usage: %s <config filename> [optional - set as config filename]\n" ), argv[0] ); return 1; } if( argc > 2 ) saveas = 1; { TEXTSTR tmp = (TEXTSTR)StrDup( argv[1] ); TEXTSTR filename = (TEXTSTR)pathrchr( tmp ); if( !filename ) filename = tmp; { uint32_t size = 0; POINTER mem = OpenSpace( NULL, argv[1], &size ); if( mem && size ) { #ifndef __NO_SQL__ SACK_WriteProfileBlob( WIDE("intershell/configuration" ), saveas?argv[2]:filename, (TEXTCHAR*)mem, size ); #endif CloseSpace( mem ); } } } return 1; }
int main( int argc, char **argv ) { POINTER mem_lock; uintptr_t size = 0; TEXTCHAR *myname = StrDup( pathrchr( DupCharToText( argv[0] ) ) ); TEXTCHAR *endname; TEXTCHAR lockname[256]; if( myname ) myname++; else myname = DupCharToText( argv[0] ); // go to the .exe extension endname = (TEXTCHAR*)StrRChr( myname, '.' ); if( endname ) { // remove .exe extension endname[0] = 0; // go to the .stop extension endname = (TEXTCHAR*)StrRChr( myname, '.' ); } if( endname ) { // remove .stop extension endname[0] = 0; } else { // this would be an invalid name. return 0; } snprintf( lockname, sizeof( lockname ), WIDE( "%s.instance.lock" ), myname ); lprintf( WIDE( "Checking lock %s" ), lockname ); mem_lock = OpenSpace( lockname , NULL //, WIDE("memory.delete") , &size ); if( mem_lock ) { #ifdef WIN32 PRENDER_INTERFACE pri = GetDisplayInterface(); PVIDEO video = (PVIDEO)mem_lock; if( video->hWndOutput ) { ForceDisplayFocus( video ); RestoreDisplay( video ); } else { // region found, but no content... } #endif } else lprintf( WIDE("lock region not found.") ); return 0; }
POINTER OpenAFile( const char *file, uintptr_t *size ) { POINTER result = OpenSpace( NULL, file, size ); return result; }
int main( int argc, char **argv ) { POINTER mem_lock; uintptr_t size = 0; TEXTCHAR *myname = StrDup( pathrchr( DupCharToText( argv[0] ) ) ); TEXTCHAR *endname; TEXTCHAR lockname[256]; if( myname ) myname++; else myname = DupCharToText( argv[0] ); // go to the .exe extension endname = (TEXTCHAR*)StrRChr( myname, '.' ); if( endname ) { // remove .exe extension endname[0] = 0; // go to the .stop extension endname = (TEXTCHAR*)StrRChr( myname, '.' ); } if( endname ) { // remove .stop extension endname[0] = 0; } else { // this would be an invalid name. return 0; } snprintf( lockname, sizeof( lockname ), WIDE( "%s.instance.lock" ), myname ); lprintf( WIDE( "Checking lock %s" ), lockname ); mem_lock = OpenSpace( lockname , NULL //, WIDE("memory.delete") , &size ); if( mem_lock ) { #ifdef WIN32 PRENDER_INTERFACE pri = GetDisplayInterface(); PVIDEO video = (PVIDEO)mem_lock; if( video->hWndOutput ) { ForceDisplayFocus( video ); keybd_event( VK_MENU, 56, 0, 0 ); keybd_event( VK_F4, 62, 0, 0 ); keybd_event( VK_F4, 62, KEYEVENTF_KEYUP, 0 ); keybd_event( VK_MENU, 56, KEYEVENTF_KEYUP, 0 ); #if 0 { int tick = timeGetTime(); while( ( tick + 15000 > timeGetTime() ) && IsWindow( video->hWndOutput ) ) WakeableSleep( 100 ); if( IsWindow( video->hWndOutput ) ) #define WM_EXIT_PLEASE 0xd1e if( !SendMessage( video->hWndOutput, WM_QUERYENDSESSION, 0, 0 ) ) printf( "Failed to post queyendsession." ); } #endif } else { // region found, but no content... } #endif } else lprintf( WIDE("lock region not found.") ); return 0; }
int HandleArgs( int argc, TEXTCHAR **argv ) { PVARTEXT pvt = NULL; int arg = 1; if( argc == 1 ) { MessageBox( NULL, WIDE( "Available Arguments\n" ) WIDE( " -back $aarrggbb : set background color in hex, alpha, red, green, blue [default black]\n" ) WIDE( " -text $aarrggbb : set text color in hex, alpha, red, green, blue [default white]\n" ) WIDE( " -lines N : Set the target number of lines (font height, bigger number is smaller) [default 20]\n" ) WIDE( " -cols N : Set the target number of columns (font width, bigger number is smaller) [default 30]\n" ) WIDE( " -file <filename> : Use contents fo the file specified for text\n" ) WIDE( " -alpha : enable alpha transparency display\n" ) WIDE( " -dead : disable click and keyboard bypass\n" ) WIDE( " -display N : specify which display to show on\n" ) WIDE( " -timeout N : default time delay for no action (milliseconds)\n" ) WIDE( "\n" ) WIDE( " -notop : shows the banner as not topmost (default is top).\n" ) WIDE( " -yesno : shows the Yes/No buttons, and returns error level 0 for yes and 1 for no.\n" ) WIDE( " -okcancel : shows the Okay/Cancel buttons, and returns error level 0 for yes and 1 for no.\n" ) WIDE( " -yesno and -okaycancel : returns error level 0 for yes and 1 for no, 2 for cancel, 3 for ok.\n" ) WIDE( " \n" ) WIDE( " any other unknown argument or other word will show as text.\n" ) WIDE( " banner_command -back $20800010 -text $FF70A080 Show \"This Text On\" Banner\n" ) WIDE( " - the prior command will show 3 lines 'show', 'this text on', 'banner'" ) WIDE( " banner_command Show \"\\\"This Text On\\\"\" Banner\n" ) WIDE( " - the prior command shows how to include showing quotes" ) , WIDE( "Usage" ) , MB_OK ); return 0; } // default to topmost. l.flags.bTop = 1; while( arg < argc ) { if( argv[arg][0]=='-' ) { if( StrCaseCmp( argv[arg]+1, WIDE( "back" ) ) == 0 ) { // blah arg++; if( arg < argc ) { PTEXT tmp2; PTEXT tmp = SegCreateFromText( argv[arg] ); tmp2 = tmp; GetColorVar( &tmp, &l.back_color ); LineRelease( tmp2 ); } } else if( StrCaseCmp( argv[arg]+1, WIDE( "text" ) ) == 0 ) { arg++; if( arg < argc ) { PTEXT tmp2; PTEXT tmp = SegCreateFromText( argv[arg] ); tmp2 = tmp; GetColorVar( &tmp, &l.text_color ); LineRelease( tmp2 ); } } else if( StrCaseCmp( argv[arg]+1, WIDE( "lines" ) ) == 0 ) { arg++; if( arg < argc ) { #ifdef UNICODE l.lines = _wtoi( argv[arg] ); #else l.lines = atoi( argv[arg] ); #endif } } else if( StrCaseCmp( argv[arg]+1, WIDE( "cols" ) ) == 0 ) { arg++; if( arg < argc ) { #ifdef UNICODE l.columns = _wtoi( argv[arg] ); #else l.columns = atoi( argv[arg] ); #endif } } else if( StrCaseCmp( argv[arg]+1, WIDE( "display" ) ) == 0 ) { arg++; if( arg < argc ) { #ifdef UNICODE l.display = _wtoi( argv[arg] ); #else l.display = atoi( argv[arg] ); #endif } } else if( StrCaseCmp( argv[arg]+1, WIDE( "timeout" ) ) == 0 ) { arg++; if( arg < argc ) { #ifdef UNICODE l.timeout = _wtoi( argv[arg] ); #else l.timeout = atoi( argv[arg] ); #endif } } else if( StrCaseCmp( argv[arg]+1, WIDE( "dead" ) ) == 0 ) { l.flags.bDead = 1; } else if( StrCaseCmp( argv[arg]+1, WIDE( "alpha" ) ) == 0 ) { l.flags.bAlpha = 1; } else if( StrCaseCmp( argv[arg]+1, WIDE( "file" ) ) == 0 ) { // blah arg++; if( arg < argc ) { POINTER p; l.file = argv[arg]; p = OpenSpace( NULL, l.file, &l.text_size ); if( p ) { l.text = NewArray( TEXTCHAR, l.text_size + 1 ); MemCpy( l.text, p, l.text_size ); l.text[l.text_size] = 0; Release( p ); } } } else if( StrCaseCmp( argv[arg]+1, WIDE( "notop" ) ) == 0 ) { l.flags.bTop = 0; } else if( StrCaseCmp( argv[arg]+1, WIDE( "yesno" ) ) == 0 ) { l.flags.bYesNo = 1; } else if( StrCaseCmp( argv[arg]+1, WIDE( "okcancel" ) ) == 0 ) { l.flags.bOkayCancel = 1; } else { if( !pvt ) { pvt = VarTextCreate(); vtprintf( pvt, WIDE( "%s" ), argv[arg] ); } else vtprintf( pvt, WIDE( "\n%s" ), argv[arg] ); } } else { if( !pvt ) { pvt = VarTextCreate(); vtprintf( pvt, WIDE( "%s" ), argv[arg] ); } else vtprintf( pvt, WIDE( "\n%s" ), argv[arg] ); } arg++; } if( pvt ) { l.text = StrDup( GetText( VarTextPeek( pvt ) ) ); } if( !l.text ) { l.text = WIDE( "INVALID COMMAND LINE\nARGUMENTS" ) ; } else { int n = 0; int o = 0; for( n = 0; l.text[n]; n++ ) { if( l.text[n] < 32 ) { if( l.text[n] == '\n' ) { l.text[o++] = l.text[n]; } } else l.text[o++] = l.text[n]; } l.text[o++] = l.text[n]; } return 1; }