I am Not Sure What Your Intentnot sure what your intent is.
ifIf you mean you have to add a function and call it before main after the source is compiled
, then yes it is definitely possible
all. All you have to do is run through some hoops like finding a code cave , assembling the new code in code cave , and detouring the first instruction of main to call your new function and return back to mainsmain's next instruction.
ifIf you mean iI want the function to be sequential then it might be possible if you can destroy and recreate the assembly in-place (kinda tough ).
andAnd no there is no label you need to calculate relative address / absolute address of the newly added function and use one form of e8 or ff25 call
havingHaving source can help you in understanding the assembly but you have to play in assembly only if you have to patch a compiled executable.
aA program prior to addition of encrypt proc will look like this (a simple msgbox in windows notice both caption and text are pointing to a string which is unintelligible)
youYou may need to implement the commented out source code inline for decrypting
afterAfter you implement your decrypt proc some where in existing free space (called code cave) it may look like this
nowNow you have to destroy the first call jmp here decrypt add the code that you destroyed and jump back to the next correct sequential instruction post the destroyed code