1. 2009. 4. 25. 20:58 IDE & SDK/Delphi
unit Ntdll;
interface
uses Windows,sysutils,tlhelp32;
const LNtdll: WideString='Ntdll.dll';
type TRtlAdjustPrivilege=function(Privilege: Cardinal; bEnablePrivilege: Cardinal; IsThreadPrivilege: Cardinal; PreviousValue: Cardinal): Cardinal; stdcall;
var
RtlAdjustPrivilege: TRtlAdjustPrivilege;
HNtdll: Cardinal;
implementation
initialization
HNtdll:=LoadLibraryW(PWideChar(LNtdll));
if HNtdll=0 then Raise Exception.Create('Something is really messed up on your computer! You don''t seems to have a ''Ntdll.dll''!');
RtlAdjustPrivilege:=GetProcAddress(HNtdll,'RtlAdjustPrivilege');
finalization
end.

API를 자신이 만든펑션로 대체하는것도 간단하게 구현할 수 있음.
1. DLL 로드
2. 펑션의 주소를 구해온뒤 변수에 담아둠.
3. Type 변수를 바로 Call 해서 사용할 수 있음.
4. 정적 링크
function  RtlAdjustPrivilege(Privilege: ULONG; Enable: LONGBOOL; CurrentThread: LONGBOOL; Enabled: PBOOLEAN): DWORD; stdcall; external 'ntdll';
//C or C++ DLL 사용시 stdcall 대신 cdecl 를 사용 해줍니다.
Posted by Nightly Luna
,
이전 1 ··· 322 323 324 325 326 327 328 ··· 337 다음
® © Tanny Tales
/ rss