Extracting Export Functions From DLL - dll

I am trying to write a function that pulls the names of the export functions from dll files. The interpreter I am using does not have access to winAPI and am restricted to some very basic binary-parsing functions to accomplish this.
So far I have been able to locate the basic components of PE header, PE optional header, and COFF header. By traversing these structures I am able to locate the IMAGE_DIRECTORY_ENTRY_EXPORT within the data_directory of the optional header (QWORD).
Where I am stuck is locating the IMAGE_EXPORT_DIRECTORY from the IMAGE_DIRECTORY_ENTRY_EXPORT? My understanding is that the IMAGE_DIRECTORY_ENTRY_EXPORT contains two relevant pieces of information Name Offset/Integer Id (first DWORD) and Data Entry Offset (second DWORD).
I've tried to follow the data entry offset, but it doesn't seem to be accurate, since (if it were absolute) it would be located before the PE header...which can't be right.
This leads me to think that it is a relative offset, but I have no idea what it would be relative to.
So in summary, is there a relationship between IMAGE_DIRECTORY_ENTRY_EXPORT to IMAGE_EXPORT_DIRECTORY, and if so how do you go from the first to the absolute offset of the second?

Related

How to use atomselect to specify atomNumbers/Index position in a pdb file for MDAnalysis?

After reading through the documentation I still have not been able to figure out a way to select one specific atom in my pdb file with MDAnalysis.
For my project I am essentially pulling a chloride through a membrane channel in an applied electric field. I want to use MDAnalysis to specifically select this one chloride that is being pushed through the channel. Unfortunately this is not the only chloride in the same system or even segment so selecting a resname or segment isn't going to be useful in identifying which chloride I would like to track. Essentially with MDAnalysis I am going to be running a calculation that uses the trajectory of that one specific chloride to calculate the displacement charge function. I am having difficulty writing code to tell MDAnalysis that I want that specific chloride.
The way I have distinguished this in NAMD was by using an index number but I cannot find a way in their documentation to use this number within MDAnalysis and would really appreciate if someone has experience using the pdb index number rather than segnames and ids, or linking the relevant page to the documentation if it exists.
Thanks!
Unfortunately this is not yet documented, but as of 2.0.0dev0 you can also use the id keyword in addition to index and bynum. This might be more straightforward, as id corresponds directly to the number in the "serial" column in the PDB format. For example:
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PDB
u = mda.Universe(PDB)
atom_with_serial_10_in_pdb = u.select_atoms("id 10")[0]
or
atom_with_serial_10_in_pdb = u.atoms[u.atoms.ids == 10][0]
bynum 7:10 which is a 1-based inclusive index
index 7 which is a 0-based index
For example, atomi7 = universe.select_atoms("index 7")
Relevant documentation:

Tabulator - formatting print and PDF output

I am a relatively new user of Tabulator so please forgive me if I am asking anything that, perhaps, should be obvious.
I have a Tabulator report that I am able to print and create as a PDF, but the report's formatting (as shown on the screen) is not used in either output.
For printing I have used printAsHtml and printStyled=true, but this doesn't produce a printout that matches what is on the screen. I have formatted number fields (with comma separators) and these are showing correctly, but the number columns should be right-aligned but all of the columns appear as left-aligned.
I am also using Tree View where the tree rows are coloured differently to the main table, but when I print the report with a tree open it colours the whole table with the tree colours and not just the tree.
For the PDF none of the Tabulator formatting is being used. I've looked for anything similar to the printStyled option, but I can't see anything. I've also looked at the autoTable option, but I am struggling to find what to use.
I want to format the print and PDF outputs so that they look as close to the screen representation as possible.
Is there anywhere I could look that would provide examples of how to achieve the above? The Tabulator documentation is very good, but the provided examples don't appear to explain what I am trying to do.
Perhaps there are there CSS classes that I am missing or even mis-using? I have tried including .tabulator-print-table in my CSS, but I am probably not using it correctly. I also couldn't find anything equivalent for producing PDFs. Some examples would help immensely.
Thank you in advance for any advice or assistance.
Formatting is deliberately not included in these, below i will outline why:
Downloaders
Downloaded files do not contain formatted data, only the raw data, this is because a lot of the formatters create visual elements (progress bar, star formatter etc) that cannot be replicated sensibly in downloaded files.
If you want to change the format of data in the download you will need to use an accessor, the accessorDownload option is the one you want to use in this case. The accessors transform the data as it is leaving the table.
For instance we could create an accessor that prepended "Mr " to the front of every name in a column:
var mrAccessor= function(value, data, type, params, column, row){
return "Mr " + value;
}
Assign it to a columns definition:
{title:"Name", field:"name", accessorDownload:mrAccessor}
Printing
Printing also does not include the formatters, this is because when you print a Tabulator table, the whole table is actually rebuilt as a standard HTML table, which allows the printer to work out how to layout everything across multiple pages with column headers etc. The downside of this is that it is only loosely styled like a Tabulator and so formatted contents generated inside Tabulator cells will likely break when added to a normal td element.
For this reason there is also a accessorPrint option that works in the same way as the download accessor but for printing.
If you want to use the same accessor for both occasions, you can assign the function once to the accessor option and it will be applied in both instances.
Checkout the Accessor Documentation for full details.

Search all programs within a package for a MODIFY statement

I want to search all programs - within a package - that use the statement:
modify itab_xyz from wa_itab_xyz
Preferably, the string should be searched with wild cards like itab*
for a range of itab_(values) like itab_abc, itab_def, itab_ghi
etc..
How do i do this in SAP ABAP?
Below is a screenshot of all programs within a package one can search from.
One possibility would be to use program RS_ABAP_SOURCE_SCAN.
You can restrict the selection by package and you can also enter a specific string to search for in the code.
I use the transaction code_scanner (program is afx_code_scanner).
The biggest problem with this program and the RS_ABAP_SOURCE_SCAN provided above is that they won’t find everything. IMO the most important missing component to them is implicit enhancements. They can be very impactful to system functions, and if you are searching for an error message or hard coded value skipping them could mean not finding something critical.
At the time I looked (about 7 years ago), I was unable to find a delivered tool that would actually scan all the code in the system. I ended up enhancing the code_scanner to look for enhancements, WDA components, BSP code, and forms code.
I don’t know if the open source component above includes those. At first glance it doesn’t seem to, but I don’t have time to really dig into it.
You could use a tool from the Galileo-Open Source library. This program searches ABAP Source, OTR-Texts, Message and Textpools for static Text, wildcard patterns or regex patterns.
ABAP-Coding:
https://github.com/galileo-group/galileo-abap-lib/blob/master/%23gal%23devtools_find_text.prog.abap
Textpool:
https://github.com/galileo-group/galileo-abap-lib/blob/master/%23gal%23devtools_find_text.prog.xml
It refers to some additional classes from the library, so you either need to copy these as well or just use ABAPgit to get the whole library. You can also contact me, so I can send you a transport containing the library.
Additional information (October 1, 2020):
I created a version of the report that you can copy/paste to the ABAP editor. It is too long to include it in the response, but you can find it here.
Do not forget to copy the text elements / selection texts.
Required Text Elements:
-----------------------
B00 Scope
B01 Search pattern
H01 Type
H02 Name
H03 Key
H04 Match
Required Selection Texts:
-------------------------
P_CASE Case-sensitive
P_DEVC Package
P_LANGU Language
P_MESS Messages
P_OTR OTR Texts
P_PATT Pattern
P_REGEX Regular expression
P_SOURCE ABAP sources
P_TPOOL Textpools
P_WILDC Wildcard pattern

Looking for efficient way to index files

I started working on a new home project, I need to index specific files names with there paths.
The program will index files on my local hard-disk with no need to deal with the contents of the files (so I assuming/hoping it would be simple implementation).
At first the user will insert a list of file extensions to get indexed (During setup time).
Then the program will run and create the data structure holding the path for the specific file entered by the user.
Retrieving data from by data structure would look like this:
path of the file on my HDD=function(filename entered by user)
I thought about it for quite a while and wrote a design for the data structure here is my suggestion
(Design Illustration):
I'll use an array with a hash function for mapping extension to a cell (Each cell presents the
first letter of the extension file).
inside each cell there would be a list of extensions starting with the same letter.
for each node in the list there would be a red black tree for searching the filename and then
after we found the filename the program will retrieve the path of the file stored in the tree
node.
Oh by the way usually I program in c (low level) or in c++.
I think you are making a way too elaborate and complicated scheme. If locating a MyFileTree based on extension is what you want then just use SortedDictionary<string, MyFileTree> where string is your extension and you'll get a O(log n) retrieval mechanism out of the box.

Controlling Doxygen's LaTeX output for making PDF documentation

I'm using Doxygen to generate documentation for my code. I need to make a PDF version of this and using Doxygen's LaTeX output appears to be the way to do it.
However I've run into a number of annoying problems, and not knowing anything about LaTeX previously haven't really got much of an idea on how to approach them, and the countless references for LaTeX related things are not much help...
I worked out how to create a custom style thing in a sty file and how to get Doxygen to use it. After a lot of searching I found out how to set the page margins etc. through this, and I'm guessing the perhaps this is the file I want for doing the other things I want, but I cant seem to find any commands for doign what I want :(
The table of contents at the start of the document contains a lot of items Id rather it didn't as it makes the contents very long. Is there some way to limit this contents to just say the first two levels, rather than having entries for every single individual function, variable, etc.? Id quite like to keep all the bookmarks however. I did try the "COMPACT_LATEX" option but as well as removing items on the contents pages, it removed the bookmarks and the member lists at the start of each section, which I do really want to keep.
Is there a way to change the order of things, like putting the full class description at the start of the section, rather than after all the members and attributes?
Wow, that's kind of evil of Doxygen.
Okay, to get around the tocdepth counter problem, add the following line to your .sty file:
\AtBeginDocument{\setcounter{tocdepth}{2}}% or whatever level you want
You can set the PDF bookmarks depth to a separate value:
% requires you \usepackage{hyperref} first
\hypersetup{
bookmarksdepth = section, % of whatever level you want
}
Also note that if you have a list of figures/tables, the tocdepth must be at least 2 for them to show up.
I don't see any way of rearranging those items within the LaTeX files---Doxygen just barfs them out there, so we can't do much. You'll have to poke around the Doxygen documentation to see if there's any way to specify the order I guess. (Here's hoping!)
You're so close.
Googling on "latex contents level" brought me to LaTeX - customizing the depth of the table of contents for different parts of the thesis which suggests
\setcounter{tocdepth}{n}
where n starts at zero for only the highest level division. This is presumable defined in all the default styles, but is worth a try in doxygen.
You could write a Perl/Awk script to simply delete the unwanted lines from the table of contents. For the file burble.tex, Latex will generate the file burble.toc, which will contain lines such as:
\contentsline {subsection}{Class F rewrites}{38}
\contentsline {subsection}{Class M rewrites}{39}
\contentsline {section}{\numberline {7}Definition and properties of the translation}{44}
\contentsline {paragraph}{Well-formedness}{54}
Simple regexes will identify which levels each line belongs to, and you can filter the file based on that. Once you have the table of contents the way you want it, insert \nofiles in the appropriate place (the style sheet?), which means that Latex will read the auxiliary files but not overwrite them.