- 积分
- 94
- 最后登录
- 2016-10-26
- 阅读权限
- 20
- 积分
- 94
- 帖子
- 163
- 精华
- 4
TA的每日心情 | 衰 2016-10-26 03:39 |
|---|
签到天数: 90 天 连续签到: 1 天 [LV.6]常住居民II 菜鸟入门

- UID
- 5415
- 小七币
- 292
- 贡献
- 6
- 在线时间
- 95 小时
- 注册时间
- 2012-3-7
|
废话:
还是那句话使用GetCurrentDirectory来获取当前工作路径是不可靠的
这个是随时可以改变的而且是全局影响的,早期360可以用这招来进行
DLL欺骗现在倒是不可以了,但是用bat配合的话到也还是可以运作.
还是比较猥琐的.
Delphi版本
- program Sdk12;
- uses
- Windows;
- var
- szPath: Array[0..MAX_PATH] Of Char;
- begin
- ZeroMemory(@szPath, SizeOf(szPath)); // 清零
- // 获取当前路径
- GetCurrentDirectory(SizeOf(szPath), szPath);
- MessageBox(0, szPath, 'xqmsyk.com', 0);
- // 设置当前路径
- SetCurrentDirectory('c:\');
- GetCurrentDirectory(SizeOf(szPath), szPath);
- MessageBox(0, szPath, 'xqmsyk.com', 0);
- end.
复制代码 汇编版本
- .686
- .model flat, stdcall
- option casemap:none
- include \masm32\include\windows.inc
- include \masm32\include\kernel32.inc
- include \masm32\include\user32.inc
- includelib \masm32\lib\kernel32.lib
- includelib \masm32\lib\user32.lib
- INVALID_FILE_ATTRIBUTES equ -1
- .data
- szFile db "c:\1", 0
- szCaption db "xqmsyk.com", 0
- .code
- WinMain proc
- LOCAL @szPath[MAX_PATH]: BYTE
-
- invoke RtlZeroMemory, addr @szPath, sizeof @szPath
-
- ; 获取当前路径
- invoke GetCurrentDirectory, sizeof @szPath, addr @szPath
- invoke MessageBox, 0, addr @szPath, offset szCaption, 0
- ; 设置当前路径
- invoke SetCurrentDirectory, offset szFile
-
- invoke GetCurrentDirectory, sizeof @szPath, addr @szPath
- invoke MessageBox, 0, addr @szPath, offset szCaption, 0
- ret
- WinMain endp
- start:
- invoke WinMain
- ret
- end start
复制代码 |
|