Edited by wap2k, 20 October 2014 - 07:52 PM.

This function is called to start a Win32 thread. Its purpose is to call the thread start address.
If the thread returns it will terminate the thread and delete it's stack.

Arguments:

  • DWORD LdrReserved - Should always be 0 for user threads
  • LPTHREAD_START_ROUTINE lpStartAddress - Supplies the starting address of the new thread. The address is a function that never returns and that accepts a single DWORD pointer argument.
  • LPVOID lpParameter - Supplies a single parameter value passed to the thread.

Return value is nothing.

Before Vista:

VOID
BaseThreadStart(IN LPTHREAD_START_ROUTINE lpStartAddress,
IN LPVOID lpParameter
)

Vista+

VOID BaseThreadInitThunk(IN DWORD LdrReserved, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter);

The use of the LdrReserved is used by the system in several places by NTDLL referred to as

Kernel32ThreadInitThunkFunction)(1, 0, 0) as you can see this allows the lpStartAddress and lpParameter to be NULL.

I can only guess that this is for use only by the windows loader functions it checks if this parameter is null and then calls BasepInitializeTermsrvFpns() if a flag is set in an unknown variable.

Before Windows Vista the function looked like this:

VOID
BaseThreadStart(
IN LPTHREAD_START_ROUTINE lpStartAddress,
IN LPVOID lpParameter
){
try { //
// test for fiber start or new thread
// if ( NtCurrentTeb()->NtTib.Version == OS2_VERSION ) {
if ( !BaseRunningInServerProcess ) {
CsrNewThread();
}
}
ExitThread((lpStartAddress)(lpParameter));
}
except(UnhandledExceptionFilter( GetExceptionInformation() )) {
if ( !BaseRunningInServerProcess ) {
ExitProcess(GetExceptionCode());
}
else {
ExitThread(GetExceptionCode());
}
}
}

After Vista similar to this:

VOID BaseThreadInitThunk(DWORD LdrReserved, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter)
{
int tUserThread; if ( !LdrReserved )
{
tUserThread = (lpStartAddress)(lpParameter);
RtlExitUserThread(tUserThread);
}
if(Flag_v7FFE02D0 & 0x10) BasepInitializeTermsrvFpns();
}

[ 转载 ] kernel32.BaseThreadInitThunk的更多相关文章

  1. 深入Windows APC

      本篇原文为 Depths of Windows APC ,如果有良好的英文基础,可以点击该链接进行阅读.本文为我个人:寂静的羽夏(wingsummer) 中文翻译,非机翻,著作权归原作者 Rbmm ...

  2. Response.Redirect引起的性能问题分析

    现象: 最近做的一个系统通过单点登录(SSO) 技术验证用户登录.用户在SSO 系统上通过验证后,跳转到该系统的不同模块.而跳转的时间一直维持子啊几分钟左右. 分析步骤: 在问题复现时抓取Hang d ...

  3. 一个由Response.Redirect 引起的性能问题的分析

    现象: 某系统通过单点登录(SSO) 技术验证用户登录.用户在SSO 系统上通过验证后,跳转到某系统的主页上面.而跳转的时间很长,约1分钟以上. 分析步骤: 在问题复现时抓取Hang dump 进行分 ...

  4. Windbg跟踪临界区的BUG

    最近跟踪了一个程序的界面卡死问题,该卡死偶尔出现,在抓到一次dump后用windbg载入分析,打印出函数调用堆栈后,一眼可以看出是临界区死锁了. 代码: 0:000:x86> kb ChildE ...

  5. Windows进程崩溃问题定位方法

    Linux上进程崩溃通常会生成core文件,用gdb打开后执行bt命令即可查看堆栈.而在Windows平台上,我们通常会采用MiniDumpWriteDump来进行堆栈转储,而这需要对系统Api有一定 ...

  6. 调试SQLSERVER (三)使用Windbg调试SQLSERVER的一些命令

    调试SQLSERVER (三)使用Windbg调试SQLSERVER的一些命令 调试SQLSERVER (一)生成dump文件的方法调试SQLSERVER (二)使用Windbg调试SQLSERVER ...

  7. 调试SQLSERVER (二)使用Windbg调试SQLSERVER的环境设置

    调试SQLSERVER (二)使用Windbg调试SQLSERVER的环境设置 调试SQLSERVER (一)生成dump文件的方法调试SQLSERVER (三)使用Windbg调试SQLSERVER ...

  8. 从点击Button到弹出一个MessageBox, 背后发生了什么

    思考一个最简单的程序行为:我们的Dialog上有一个Button, 当用户用鼠标点击这个Button时, 我们弹出一个MessageBox. 这个看似简单的行为, 谁能说清楚它是如何运行起来的,背后究 ...

  9. debug实战:COM组件GetToSTA导致高内存+GC被阻塞

    最近花了好几周解决一个WPF高内存的问题,问题的表象是内存不断增加.未被回收,根源是GC的FinalizeThread被阻塞,导致整个GC挂掉.从以下几步来分析这个问题: 1.用ANTS Memory ...

随机推荐

  1. 导出excel表格。

    导出也做了很多遍了,还是发现好记性不如烂笔头,还是记下来. public void exportLog(HttpServletRequest request,HttpServletResponse r ...

  2. linux挂着U盘和光盘

    挂载光盘 mkdir /mnt/cdrom/ (建立挂载点) mount -t iso9660 /dev/cdrom /mnt/cdrom (挂载光盘) mount /dev/sr0 /mnt/cdr ...

  3. redis入门笔记(1)

    redis入门笔记(1) 1. Redis 简介 •Redis是一款开源的.高性能的键-值存储(key-value store).它常被称作是一款数据结构服务器(data structure serv ...

  4. java中的程序流程控制

    一.布尔逻辑1.布尔运算符:①短路和——&&:判断两个表达式,如果第一个为真,继续判断第二个表达式,如果第一个为假,就不需要判断第二个变大时②和——&:判断两个表达式,如果第一 ...

  5. XJOI‘s story (不定期连载)

    王城双基的力量.... 我也不知道写写这种东西会不会被查大表..尴尬  . 我为什么要写这东西: 为了蛤鸡 为了红太阳 xj 人物列传 2017   1,6   Friday 得到大新闻 机房后面的监 ...

  6. 合并果子 2004年NOIP全国联赛普及组

    时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆 ...

  7. js模块化AMD/CMD

    JavaSript模块化 在了解AMD,CMD规范前,还是需要先来简单地了解下什么是模块化,模块化开发?     模块化是指在解决某一个复杂问题或者一系列的杂糅问题时,依照一种分类的思维把问题进行系统 ...

  8. 激!GSS系列

    #include <cstdio> ; ; inline int max(int, int); inline int getint(); inline void putint(int); ...

  9. ubuntu下安装rpm 文件

      正想着如何把rpm package 安装到ubuntu上, 发现了这篇文章,转载一下 Ubuntu的软件包格式是deb,如果要安装rpm的包,则要先用alien把rpm转换成deb. sudo a ...

  10. 利用SPM工具运行自己创建的小组件(使用common-model向后台接口请求数据)

    步骤如下: 1.安装依赖:spm install -e 2.编译:spm build (编译好的东西会放在trunk-dist里面) 3.发布:spm app -d (会出来一个export端口,一般 ...