Thursday, March 21, 2024

c_c++ - How to check DLL architecture (x86 vs x64)

From VS terminal run this command:
dumpbin /headers clib.dll
Output:
Dump of file clib.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
            8664 machine (x64)
               A number of sections
        65FA9AE8 time date stamp Wed Mar 20 09:14:32 2024
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
            2022 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   DLL

c_c++ - How to check entry points of the DLL

From VS terminal run this command:
dumpbin /exports clib.dll
Output, you can see two entry points:
Dump of file clib.dll

File Type: DLL

  Section contains the following exports for CLib.dll

    00000000 characteristics
    FFFFFFFF time date stamp
        0.00 version
           1 ordinal base
           2 number of functions
           2 number of names

    ordinal hint RVA      name

          1    0 00011249 add = @ILT+580(add)
          2    1 000110BE subtract = @ILT+185(subtract)

  Summary

        1000 .00cfg
        1000 .data
        1000 .idata
        1000 .msvcjmc
        3000 .pdata
        3000 .rdata
        1000 .reloc
        1000 .rsrc
        8000 .text
       10000 .textbss

Tuesday, January 16, 2024

c# - How to use LINQ aggregate() function

This calling performs SUM on Population (with starting value = 0.)
    
public List<Country> Countries = new();
...
this.Countries.Add( new Country( "Czech", Country.ContinentEnum.EUROPE, 10 ) );
this.Countries.Add( new Country( "Poland", Country.ContinentEnum.EUROPE, 40 ) );
this.Countries.Add( new Country( "China", Country.ContinentEnum.ASIA, 1100 ) );
this.Countries.Add( new Country( "USA", Country.ContinentEnum.AMERICA, 340 ) );
...
int total = this.Countries.Aggregate( 0, (total,b) => total + b.Population );

MessageBox.Show( total.ToString() );  // -> 1490