Shuffling function addresses in C/C++ with MSVC

The Microsoft C/C++ compiler allows you to specify link order of functions or variables. Using the #pragma directive with either code_seg or data_seg and specifying the segment name and its sorting key, you can tell the linker how to place the object code in the final executable.

Let’s start with a simple example:

#pragma code_seg(push, ".text$EB009")
__declspec(noinline) void f1()
{
    printf("this is f1()\n");
}
#pragma code_seg(pop)


#pragma code_seg(push, ".text$EB005")
__declspec(noinline) void f2()
{
    printf("this is f2()\n");
}
#pragma code_seg(pop)


#pragma code_seg(push, ".text$EB001")
__declspec(noinline) void f3()
{
    printf("this is f3()\n");
}
#pragma code_seg(pop)

int main()
{
    f1();
    f2();
    f3();
    return 0;
}

When the code_seg pragma is used, we can specify where the subsequent code should lie (in which section in the PE file). When the section name contains the “$” sign, then the subsequent text is not part of the section name (the string prior to the “$”) and instead is used as a sorting key. Continue reading “Shuffling function addresses in C/C++ with MSVC”

Klara with Guitar

During my short visit to Brussels, Belgium this year, I met another street performer: her name is Klara and she had a lovely voice. Unlike other public performers though, she was not friendly so I could not interview her and share with you part of her story. We will have to contend with just a short video I captured:

You can visit her Facebook page here: https://www.facebook.com/klarawinterain/

You might also like:

When man got afraid

  • When man got afraid
  • When he got afraid from darkness, he invented electricity
  • When he got afraid from cold, he invented clothing
  • When he got afraid from thirst, he dug wells
  • When he got afraid from disease, he invented medicine
  • When he got afraid of fire, he invented the fire extinguisher
  • When he got afraid from loneliness, he invented the television
  • When he got very bored, he invented social media

You might also like:

Meet Roger, the man who lives in the Amsterdam Airport Schiphol


I was traveling from the US to Europe and I had a layover in Amsterdam. In the men’s room, I met an interesting character called Roger. Roger, in his mid forties, was neat and dressed like a backpack traveler. He started a conversation with me, talking about random stuff. At one point, out of the blue he mentions that he lives in the airport. I was not sure what he meant but he explained that he literally lives in the airport. I asked him if he showers, sleeps and gets his basic needs met in the airport and he said yes. In fact, he uses the handicap toilet to wash himself at nights then he goes to sleep in the airport pretending to be an early morning passenger. In the morning, he also uses to toilets to get himself ready and then leaves the airport for the day.

What an interesting encounter. I had no idea that some people, out of necessity do that. I have walked in the streets of popular European cities and I have met many homeless people. Panhandling and sleeping on the street is a second nature to them unfortunately. Roger at least, gets a warm place and washes himself instead of sleeping out in the freezing cold in the winter.

You might also like:

Learn from…

  • From the mountains, learn highness and glory
  • From rivers and fountains, learn generosity
  • From rocks, learn to be strong
  • From the absent and not manifest, learn silence and reverence
  • From ants, learn hard work
  • From pigeons, learn serenity
  • From the fox, learn intelligence
  • From the rooster, learn early rising
  • From the lion, learn courage

You might also like:

Excerpts and notes from the “Soft Skills” book

A couple of years ago, I was reading the book entitled “Soft Skills” by John Sonmez. The book was super useful to me especially that I was exploring ways to improve my soft skills and learn all the tricks I can regarding how to start my own business, organize my time, etc.

In this blog post, I share with you some of the takeaways and excerpts from that book.

Continue reading “Excerpts and notes from the “Soft Skills” book”

The benefits of Onions (Arabic edition)

:اشتروا البصل وكلوه مهما أرتفع ثمنه

<

p style=”text-align: right;”>-
حتى لوكنتم في شهرالعسل كلوه يقول الدكتور داود الربيعي صاحب الموسوعة العربية للعلاج بالاعشاب الطبية
كتبت عدة مقالات عن البصل وفوائده الغذائية والعلاجية 
وكلما قرأت تقريراً جديدا 
تحمست لكتابة المزيد عنه . 
ولما كان الحديث عنه يطول كثيرا فقد أرتأيت كتابته تحت عنوان هل تعلم : –
هل تعلم أن البصل من أغنى الخضار والفاكهة بمادة طبية مهمة تسمى الكوريسيتين ولا ينافسه بذلك سوى براعم نبات القبار .
وهل تعلم بأن مضاد الأكسدة (الكوريسيتن) في البصل تقاوم الالتهابات Inflammations حيثما وجدت وخاصة في الجيوب الأنفية والرئتين .
هل تعلم بأن تناول البصل يمنع تطور مرض السكري من النمط (2) الذي يعالج بالأقراص إلى النمط (1) الذي يتطلب حقن الإنسولين .
هل تعلم بأن البصل يحول بإذن الله تعالى دون الإصابة بسرطان الثدي ، البروستات ، الرحم والمبايض وكما يمنع نمو وزيادة عدد البقع ما قبل سرطانية precancerous lesions
هل تعلم بأن البصل يقاوم هجمات الربو .
هل تعلم بأن البصل يحمي الخلايا العصبية من التلف وما ينتج عن ذلك من أمراض مرتبطة بالجهاز العصبي .
هل تعلم بأن البصل يحول دون تلف الأوعية الدموية وإصابتها بالتصلب ويمنع حدوث الكثير من امراض القلب .
هل تعلم بأن البصل يعزز وجود وتكاثر البكتيريا الطبيعية في الأمعاء مما يحسن امتصاص العناصر المغذية، يعزز جهاز المناعة ويمنع انفلات زيادة الوزن المفرطة
هل تعلم بأن البصل يقتل كثير من انواع الجراثيم في الحلق والرئتين .
هل تعلم بأن البصل يميع الدم ويمنع حدوث الجلطات وخاصة عندما يكون مشوياً وأنه يحذر من تناول مميعات الدم الصيدلانية مثل الأسبرين والورافين مع البصل المشوي أو المقلي وذلك لأنه يسبب زيادة مفرطة في ميوعة الدم .
هل تعلم بأن البصل يخفض الضغط الشرياني لدى مرضى الضغط .
هل تعلم بأن البصل يجلب النعاس .
هل تعلم بأن البصل يمنع نمو جرثوم القرحة المعدية H. Pylori ويقضي عليها .
هل تعلم بأن البصل يخفض الكولستيرول والدهون الثلاثية .
هل تعلم بأن البصل يحول دون حدوث الأمراض المترافقة مع مرض السكري .
هل تعلم بأن البصل يمنع تكاثر فيروس الإيدز .
هل تعلم بأن البصل يمنع حدوث هشاشة العظام .
 هل تعلم بأن البصل يحتوي على كميات وافرة من المركبات الكبريتية التي تحافظ على نضارة البشرة وقوة وجمال الشعر والأظافر.
ملحوظات : -
يقول المثل الشعبي :-
 ( كل بصل وأنسى ما حصل )
 فعلا يعمل البصل على تحسين المزاج ويريح القلب ..
القشور الخارجية للبصل هي الأغنى بمضاد الأكسدة الكوريسيتين ..
لا يفقد البصل خصائصة الطبية في درجة الغليان .
وشوربة البصل نموذجية للحصول على جميع ميزات البصل .
جميع ما ذكر أعلاه هو خلاصة مئات الأبحاث العلمية التجريبية .
اللهم بارك
.. إن أمكن نشرها لتعم الفائدة للجميع .. جعلها الله في ميزان حسناتكم ..

 

You might also like:

Cryptocurrency acronyms

If you are in cryptocurrency, then you might have encountered one or more of the following acronyms and wondered what they meant. Here you go:

  • WTC: Welcome to Crypto
  • FUD: Fear, uncertainty and doubt. A propaganda to lower prices.
  • FOMO: Fear out of missing. This is when you invest out of fear and not of educated decisions.
  • HODL: Misspelling for “hold”. People say HODL so that you don’t sell your BTC and hang on unto them.
  • Mooning: Price going up extremely high.
  • FIAT: Government-issued currency, such as the US dollar.
  • Whale: Someone who owns lots of cryptos. They might sells them to manipulate the prices.
  • Bullish: An expectation that the price is going to increase.
  • Bearish: An expectation that the price is going to decrease.
  • ATH: All time high. The highest price a coin has ever been
  • Market Cap: Total supply x Current price
  • ICO: Initial Coin Offering. Like IPO for the stock market
  • ROI: Return on investment
  • Cold storage: Storing the crypto coins offline. Be it on a paper wallet or a hardware wallet.
  • BTFD: Buy the F*king dip
  • NADDIC: Never A Dull Day In Crypto
  • DYOR: Do Your Own Research

Note: This is a live post and will be updated with new acronyms in the future.

You might also like:

The frugal business man and the sailor

One time, a frugal business man was almost drowning when the cruise ship started sinking. A young sailor throws himself in the water and saves the men. After they arrived to the shore, the frugal business man reached out to his pocket to give the sailor a reward for saving his life. The business man handed him 10$ and said “Thank you”. All the people around the business man, witnessing the situation got disgusted at how cheap the business man and how feeble is the payback for the sailor who saved his life. The sailor then calms the people down and tells them: “He knows more than any of us how much his life is worth”.

You might also like:

A universal grace prayer

Back in 2007, I went to India to do Dyan Yatra (a spiritual trek/pilgrimage to the foothills of the Himalayas to visit ancient temples). We were a group of 120 people traveling in 4 buses containing 30 people each. We would drive to the foothills of a mountain range, then hike up around 8 to 10 km to reach a small village and the temple we wanted to visit. We would sleep in the village and hike back down the next day and resume our pilgrimage.

One day, we got stuck in a village because of a landslide blocking the road. We stayed an extra day in the village and this is when I befriended an Indian who’s both a homeopathic doctor and a Yogi. I had an extensive chat with him and he ended up teaching me a few handy spiritual practices. One of the things that I still remember and practice to this day was the prayer he taught me to say before eating. It is akin to the Christians’ grace prayer that is recited before food is consumed.

If you follow my blog, you may have noticed that I love two things: Prayers and Stories. Anyway, his version of the prayer goes something like this:

Oh my creator and God, thank you for this food. May this food nourish my body, may it be converted into blood and energy that I can use to help and serve others.

This is a very short prayer and is almost devoid of any religious affiliations. It is not a Christian prayer, it is not a Muslim prayer and it surely not a Buddhist or Hindu prayer. It is a simple remembrance that we are grateful for the grace we have in our life and how we intended to return this grace by serving others.

You might also like: