Jump to content

Recommended Posts

Posted (edited)

IniWrite uses CreatePreferences. This is wrong, as CreatePreferences creates an empty file and will destroy all preferences, leaving only one.
MsgBox - you are using WinAPI, but you can use the original MessageRequester() function, then you get cross-platform code.
StringIsDigit uses PCRE for you, but I gave you a function without using PCRE. Using PCRE adds 150 KB to the size of the executable. In this case, your file size will be almost the same as that of AutoIt3.
FindPartialWindow() - why are you creating the t$=Space(999) variable inside the loop. This can be done 1 time outside the loop.

 

Run()

EnableExplicit

Structure ComLine
    key.s
    exec.s
EndStructure

; modified function by reference to extract parameters and executable
; https://www.cyberforum.ru/pure-basic/thread3028721.html#post16492165
Procedure.s SplitComLine(*s.ComLine)
    Protected pos, Char.s

    pos = FindString(*s\exec, Chr(34), 1)
    If pos = 1 ; if you find a quote in the first character, then Char=quote, it means the path with spaces
        Char = Chr(34)
    Else
        Char = " "
    EndIf
    pos = FindString(*s\exec, Char, 2) ; looking for separator Char from the second character
    If pos > 0
        pos + 1
        If Mid(*s\exec, pos, 1) = " "
            pos + 1
        EndIf
        ; found "pos" - the real position of the beginning of the com line
        *s\key = Right(*s\exec, Len(*s\exec) - pos + 1) ; options
        *s\exec = Left(*s\exec, pos - 1) ; executable
    EndIf
EndProcedure


Procedure Run(program.s, workdir.s = "", show_flag = 0, opt_flag = 0)
    Protected s.ComLine
    s\exec = program
    s\key = ""
    SplitComLine(@s)
    show_flag & opt_flag ; I didn't check the flags
    RunProgram(s\exec, s\key, workdir, show_flag)
EndProcedure 

; Run(~"Explorer.exe /Select,\"C:\\Windows\\INF\"")
Run("notepad.exe C:\Windows\system.ini")
; Run("cmd.exe /c (@Echo off & @Echo. & Color 1e & chkdsk.exe Z: /F /X& set /p Ok=^>^>)")
; Run("cmd.exe /c (@Echo off & @Echo. & Color 1e & fsutil fsinfo ntfsinfo C: & set /p Ok=^>^>)") ; admin required

 

Edited by AZJIO
  • 2 weeks later...
Posted (edited)

thank you next code update i will integrate this

I program a new function and I optimize the code to save space having a small executable and fast

 
 
Edited by ghost911
  • 1 month later...
  • 4 months later...
  • 1 month later...
  • 1 year later...
  • 1 month later...
Posted
On 3/6/2019 at 9:33 PM, ghost911 said:

 

Your source code is secure )

 

My idea of a source being "secure" isn't just plain asm compiled. I fail to comprehend both the security merits, and the purpose of this. If your autoit code is going to be converted to another language, wouldn't it be easier to learn that language instead? Then you can VMP easily, end of story. Unless your only intent is to prevent kids who only know how to drag drop to get your 1337 source, this will not provide you the slightest help.
 

  • 4 months later...
Posted

StringIsDigit, StringIsFloat, StringIsXDigit (link)

the behavior of the StringIsFloat function is slightly different

EnableExplicit

Procedure StringIsDigit(*text)
    Protected flag = #True, *c.Character = *text
    
    If *c = 0 Or *c\c = 0
        ProcedureReturn 0
    EndIf
    
    Repeat
        If *c\c < '0' Or *c\c > '9'
            flag = #False
            Break
        EndIf
        *c + SizeOf(Character)  
    Until Not *c\c
    
    ProcedureReturn flag
EndProcedure

Debug StringIsDigit(@"123")
Debug StringIsDigit(@"12 3")
Debug StringIsDigit(@"")
Debug "==="


Procedure StringIsFloat(*text)
    Protected flag = #True, *c.Character = *text, sep = 0, increment = 1
    
    If *c = 0 Or *c\c = 0
        ProcedureReturn 0
    EndIf
    
    Repeat
        If *c\c >= '0' And *c\c <= '9'
;           Debug "-> 0-9"
            sep = increment
        ElseIf sep And *c\c = '.'
;           Debug "-> ."
            If sep <= 0
;               Debug "-> Out2"
                flag = #False
                Break
            EndIf
            sep = 0
            increment = -1
        Else
;           Debug "-> Out"
            flag = #False
            Break
        EndIf
        *c + SizeOf(Character)  
    Until Not *c\c
    
    If sep <> -1
;       Debug "-> Out3"
        flag = #False
    EndIf
    
    ProcedureReturn flag
EndProcedure

Debug StringIsFloat(@"1.2")
Debug StringIsFloat(@"1..2")
Debug StringIsFloat(@"1.2.3")
Debug StringIsFloat(@"1")
Debug StringIsFloat(@"1.")
Debug StringIsFloat(@".1")
Debug StringIsFloat(@"qwerty")
Debug StringIsFloat(@".")
Debug StringIsFloat(@"")
Debug "==="



Procedure StringIsXDigit(*text)
    Protected flag = #True, *c.Character = *text
    
    If *c = 0 Or *c\c = 0
        ProcedureReturn 0
    EndIf
    
    Repeat
        If Not ((*c\c >= '0' And *c\c <= '9') Or (*c\c >= 'a' And *c\c <= 'f') Or (*c\c >= 'A' And *c\c <= 'F'))
            flag = #False
            Break
        EndIf
        *c + SizeOf(Character)  
    Until Not *c\c
    
    ProcedureReturn flag
EndProcedure

Debug StringIsXDigit(@"123")
Debug StringIsXDigit(@"FF34FF")
Debug StringIsXDigit(@"")
Debug StringIsXDigit(@"  ")

 

  • 4 months later...
Posted

thank you for your help I will resume the project when I have time I found a solution for the windows and the buttons I had some setbacks

Posted

Hello, to secure a source code until proven otherwise, only compilation works quite well, even if it is not perfect, the goal is simple Bring together the strength of the two languages i propose a solution

Posted (edited)

thank you for your help I will see that I will include it in the project

 

if you want to add functions you can send me the source code I will look at it

Edited by ghost911
  • 4 weeks later...
  • 2 months later...
Posted (edited)

@AZJIO thank you for your support to the project i will update the code

help is not refused hahaha ! 😄

@Belini I will add your research in the source code thank you to you I have not forgotten

I take any improvement proposes unity is strength

if you can give me some ready to use code with the same logic it helps to speed up the project

@Belini I have the impression that your code is not complete see picture

Capture.PNG

Edited by ghost911
Posted (edited)

Other big update is coming I'm still testing the code

I hope that my work will make your life easier and save you time and that you will gain security and development time

Update 01/12/2022 to adapt to the new version of purebasic with function additions 😇

Edited by ghost911
  • 2 months later...
Posted (edited)

 

IniWrite uses CreatePreferences. This is wrong, as CreatePreferences creates an empty file and will destroy all preferences, leaving only one.
MsgBox - you are using WinAPI, but you can use the original MessageRequester() function, then you get cross-platform code.
StringIsDigit uses PCRE for you, but I gave you a function without using PCRE. Using PCRE adds 150 KB to the size of the executable. In this case, your file size will be almost the same as that of AutoIt3.
FindPartialWindow() - why are you creating the t$=Space(999) variable inside the loop. This can be done 1 time outside the loop.

Run()

EnableExplicit

Structure String2
    key.s
    exec.s
EndStructure

; modified function by reference to extract parameters and executable
; https://www.cyberforum.ru/pure-basic/thread3028721.html#post16492165
Procedure.s CmdLineRaw(*res.String2)
    Protected pos, Char.s

    pos = FindString(*res\exec, Chr(34), 1)
    If pos = 1 ; if you find a quote in the first character, then Char=quote, it means the path with spaces
        Char = Chr(34)
    Else
        Char = " "
    EndIf
    pos = FindString(*res\exec, Char, 2) ; looking for separator Char from the second character
    If pos > 0
        pos + 1
        If Mid(*res\exec, pos, 1) = " "
            pos + 1
        EndIf
        ; found "pos" - the real position of the beginning of the com line
        *res\key = Right(*res\exec, Len(*res\exec) - pos + 1) ; options
        *res\exec = Left(*res\exec, pos - 1) ; executable
    EndIf
EndProcedure

Procedure Run(program.s, workdir.s = "", show_flag = 0, opt_flag = 0)
    Protected res.String2
    res\exec = program
    res\key = ""
    CmdLineRaw(@res)
    show_flag & opt_flag ; I didn't check the flags
    ProcedureReturn RunProgram(res\exec, res\key, workdir, show_flag)
EndProcedure 

; Run(~"Explorer.exe /Select,\"C:\\Windows\\INF\"")
Run("notepad.exe C:\Windows\system.ini")
; Run("cmd.exe /c (@Echo off & @Echo. & Color 1e & chkdsk.exe Z: /F /X& set /p Ok=^>^>)")

 

Edited by AZJIO

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...