IDA reset function name - rename

I'd like to set the name of my renamed functions back to their actual ones. I've been able to generate the name sub_123456, but setting it with MakeName(addr, name) aswell as with MakeNameEx(addr, name, flags) always fail due to the reserved prefix.
Has somebody been able to achieve this already or do I have to use a custom prefix?
Thank you

If you pass an empty name, IDA will restore the automatically generated name. This usually works with functions and data.

Related

i am playing with processes etc. but I dont know how to add "client.dll" to hex value

In cheat engine you can do "client.dll"+00D3AC5C and in reclass <client.dll>+00D3AC5C
how to do the same in python I am using ReadWriteMemory but I will soon change it for something more complex. Can you tell me please how to do it with RWM or with something other ?
According to the source code of that library, there's seemingly no way to get the base address of a process.
However you can get the base address by bypassing the library and doing it yourself via this method. Then, once you have the hex value of the base address, you can then simply add an offset to it, then use RWM's read() or get_pointer().

Free-format prototype with variables already defined?

I have an RPGLE program that I'm trying to convert from fixed-format to free-format. In general, I know that defining entry variables is done using prototypes like so:
dcl-pr myprogram;
I#Entry1 char(5);
end-pr;
dcl-pi myprogram;
InEntry1 char(5);
end-pi;
But what I don't know is how to do this when the field is already defined. We have a standard definitions file that we copy into programs such as the one I am writing, which has the field I'm using as the enter variable already defined and copied in. In fixed-format, this is just
C *Entry PList
C Parm InEntry1
I have already tried just doing the copy before the prototype entry and leaving the specification blank, but that caused errors. I know I could just use the 'LIKE' keyword and change the variable names, but for readability's sake I would prefer to avoid doing that, and I don't know what problems that may cause down the road.
Just in case it's necessary, there are two variables I'm trying to get in: a data structure and a zoned decimal.
How can I use a variable that is already defined as an entry variable in free-format RPGLE, whether using prototypes or some other way that I do not know of?
The "right" way to handle this would be to create a new version of your standard definitions file (StdDefs==>StdDefs2) to declare the variables under a new name (perhaps with a _t suffix) and the TEMPLATE keyword.
Then in your refactored PR/PI, you use LIKE or LIKEDS.
so your original program looks somthing like
/copy StdDefs
C *Entry PList
C Parm InEntry1
Your refactored one with PR/PI looks like
/copy StdDefs2
/copy Mypr
dcl-pi myprogram;
InEntry1 like(inEntry_t);
end-pi;
Note that best practice is to have the PR in a separate member that's /COPY'd into both caller and callee.
Could not find a solution without declaring another variable with like. And assign the new variable to the old at the begenning of the program, and vice versa at the end.

Rename/backup file to a random name in Inno Setup

I know that I can rename any file with:
function RenameFile(const OldName, NewName: string): Boolean;
I already have this:
RenameFile(ExpandConstant('{app}\myfile.dll'), ExpandConstant('{app}\Myfile.dll.old'));
Which I can rename my file to any desired name, but in this case I need to rename it with a random generated name, I tried to use: ExpandConstant('{app}\Myfile.dll.{tmp}')); to get the random name generated by {tmp} but that did not work.
Is there any idea how to make it work?
You can use Random function:
ExpandConstant('{app}\Myfile.dll.' + IntToStr(Random(1000)))
Though, it does not prevent you from generating an already existing name. You should at least test, if the generate name exists. And if it does, then try a new random name. But then it makes no sense to use a random name. You can use incremental numbers instead, as those have better semantics.
See How to find an unique name to rename/archive old directories in Inno Setup.

In IDL, how can I access a variable given its name?

I would like to convert a string to a variablename, so it can be read as a already restored variable.
So, I look through a file, and look at all the files. I use RESTORE to use the file in IDL, restore names this object as something slightly different. It names it as an object which we'll call map_1 (in the code it's called filerestore_name). This is related to the file name and I can recreate this variable name - however, its saved as a string.
Now, I pass this onto the make_cool_video procedure. However, althoughthis string now is exactly the same as the varialbe name, its still a string!.
Thus, as its a string, the procedure can't work.
filenames=FILE_SEARCH('rxrt*')
filenames_withoutextension = STREGEX(filenames,'rxrt_[0-9]+[a-zA-Z_]+',/EXTRACT,/FOLD_CASE)
restore, '/home/tomi/Documents/actualwork/'+filenames_withoutextension(18)+'.idl_sav',
filerestore_name = STRJOIN(STRSPLIT(filenameswithout(18),'_[0-9]+',/EXTRACT,/REGEX),'')
PRINT, filerestorename
make_cool_video, EXECUTE(filerestore_name),filename=filerestorenames, outdir='/path/to.file/'
retall
What I tried: using the RESTORE function and the associated RESTORED_OBJECTS to store pointers in an array, and then referring to the array. But I couldn't get the restore function to form an array.
Using EXECUTE(filerestore_name) however, this doesn't convert it as I was expecting.
I would recommend using SCOPE_VARFETCH() instead (it isn't as limited as EXECUTE() and is probably more efficient). You can do something like:
make_cool_video, (SCOPE_VARFETCH(filerestore_name)), filename=filerestorenames, outdir='/path/to.file/'
I wrote this, then immediately thought of the answer.
So,
Convert everything to a string:
string1 = "makecooljes, "+ filerestore_name, outdir='file/to/path/'"
result= EXECUTE(string1)

Invalid Parameter Name

I am having a problem with saving of data because of an incorrectly generated parameter name.
The table has a field "E-mail", and when the class wrapper is generated, the InsertCmd uses "#E-mail" as one of the parameters. In SQL Server, this is illegal and generated an exception.
I have hunted all over SubSonic for a way to modify the parameter name to simply "#Email" but the ParameterName property is read only.
I am using SubSonic 2.2 and don't have the source for it to make an internal modification.
Any ideas?
TIA
I got a mate of mine that uses SVN to pull the source code, and as expected, found a bug in the SS source.
When the column name is set in the class wrapper, the setter for the ColumnName property sets the ParamaterName property for you correctly using
"parameterName = Utility.PrefixParameter(Utility.StripNonAlphaNumeric(columnName), Table.Provider);". This removes any illegal characters like the hyphen in my E-mail column.
BUT... The property ParameterName is NOT used when the SQL commands are created. Here is the code in SQLDataProvider.GetInsertSQL, line 1462.
pars.Append(Utility.PrefixParameter( colName, this));
I changed this to
pars.Append(col.ParameterName);
and the problem is now sorted.
Thanks to you that came up with possible solutions.
You can modify the templates if you can't change the column name. See this blog post for details of how:
http://johnnycoder.com/blog/2008/06/09/custom-templates-with-subsonic/

Resources